Plugin Directory

Changeset 2185939


Ignore:
Timestamp:
11/05/2019 06:30:24 AM (6 years ago)
Author:
ranss
Message:

New version of Comment Limiter plugin

Location:
comment-limiter/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • comment-limiter/trunk/README.md

    r1645992 r2185939  
    2323## Changelog
    2424
     25#### 1.3
     26* Minimum characters number by default changed
     27* Standarized code improved
     28* Spelling issue resolved
     29* GPL plugin version updated
     30
     31#### 1.2
     32* New Update
     33
     34#### 1.1
     35* Moved menu under top-level Comments dashboard menu
     36* Tested on WordPress 4.9 for compatibility
     37
    2538#### 1.0
    2639* Plugin released
  • comment-limiter/trunk/comment-limiter.php

    r1762330 r2185939  
    33Plugin Name: Comment Limiter
    44Description: A simple plugin that limit the maximum and minimum of characters allowed in a post comment
    5 Version:     1.2
     5Version:     1.3
    66Author:      Anass Rahou
    77Author URI:  https://wpbody.com/
    8 License:     GPL2
     8License:     GPL v2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010Text Domain: comment-limiter
     
    1212*/
    1313
    14 if ( ! defined( 'ABSPATH' ) ) {
    15     exit;
     14defined( 'ABSPATH' ) || exit;
     15
     16if( ! defined( 'CL_VERSION' ) ) {
     17  define( 'CL_VERSION', '1.3' );
    1618}
    1719
    18 define( 'CL_VERSION', '1.2' );
     20if ( ! defined( 'CL_PLUGIN_PATH' ) ) {
     21  define( 'CL_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
     22}
    1923
    20 require_once plugin_dir_path( __FILE__ ) . '/includes/class-comment-limiter-i18n.php';
    21 require_once plugin_dir_path( __FILE__ ) . '/includes/class-comment-limiter-config.php';
    22 require_once plugin_dir_path( __FILE__ ) . '/includes/class-comment-limiter-settings.php';
    23 require_once plugin_dir_path( __FILE__ ) . '/includes/class-comment-limiter-deactivator.php';
     24require_once CL_PLUGIN_PATH . 'includes/class-comment-limiter-i18n.php';
     25require_once CL_PLUGIN_PATH . 'includes/class-comment-limiter-config.php';
     26require_once CL_PLUGIN_PATH . 'includes/class-comment-limiter-settings.php';
     27require_once CL_PLUGIN_PATH . 'includes/class-comment-limiter-deactivator.php';
    2428
    2529
     
    3943 */
    4044function cl_filter_plugin_action_links( $plugin_actions, $plugin_file ) {
    41    
     45
    4246    $new_actions = array();
    43    
    44     if ( basename( dirname( __FILE__ ) ) . '/comment-limiter.php' === $plugin_file ) {
     47
     48    if ( basename( CL_PLUGIN_PATH ) . 'comment-limiter.php' === $plugin_file ) {
    4549        $new_actions['cl_settings'] = sprintf( __( '<a href="%s">Settings</a>', 'comment-limiter' ), esc_url( admin_url( 'options-general.php?page=comment-limiter' ) ) );
    4650    }
    47    
     51
    4852    return array_merge( $new_actions, $plugin_actions );
    4953}
  • comment-limiter/trunk/includes/class-comment-limiter-config.php

    r1762296 r2185939  
    33 * If accessed directly, then exit.
    44 */
    5 if ( ! defined( 'ABSPATH' ) ) {
    6     exit;
    7 }
     5defined( 'ABSPATH' ) || exit;
     6
    87
    98/**
     
    1110 */
    1211if ( ! class_exists( 'Comment_Limiter_Config' ) ) {
    13    
     12
    1413    /**
    1514     * Configuration class.
     
    2019        /**
    2120         * Property instance.
    22          * 
     21         *
    2322         * @var object
    2423         */
     
    2726        /**
    2827         * Handles default values.
    29          * 
     28         *
    3029         * @var array
    3130         */
     
    4241                ),
    4342                'minimum_characters' => array(
    44                     'default' => 320,
     43                    'default' => 10,
    4544                ),
    4645                'enable_admin_feature' => array(
     
    5251        /**
    5352         * Return only default values.
    54          * 
     53         *
    5554         * @return array default values
    5655         */
     
    5857
    5958            $defaults = array();
    60             foreach ($this->defaults as $key => $default) {
    61                 $defaults[ $key ] = $default['default'];
     59            foreach ( $this->defaults as $key => $default ) {
     60                $defaults[ $key ] = $default[ 'default' ];
    6261            }
    6362
     
    6766        /**
    6867         * Parse default values.
    69          * 
     68         *
    7069         * @return array default values parsed
    7170         */
     
    7978        /**
    8079         * Instance class object.
    81          * 
     80         *
    8281         * @return object
    8382         */
  • comment-limiter/trunk/includes/class-comment-limiter-deactivator.php

    r1645992 r2185939  
    33 * If accessed directly, then exit
    44 */
    5 if ( ! defined( 'ABSPATH' ) ) {
    6     exit;
    7 }
     5defined( 'ABSPATH' ) || exit;
    86
    97/**
     
    2018        /**
    2119         * Property instance
    22          * 
     20         *
    2321         * @var object
    2422         */
     
    5755        /**
    5856         * Unregister setting method.
    59          * 
     57         *
    6058         * @since   1.0
    6159         * @return void
    6260         */
    6361        public function deactivate_comment_limiter() {
    64            
     62
    6563            unregister_setting(
    6664                'comment_limiter_group',
     
    7674         */
    7775        public static function factory() {
    78            
     76
    7977            if ( ! self::$_instance ) {
    8078                self::$_instance = new self();
  • comment-limiter/trunk/includes/class-comment-limiter-settings.php

    r1762296 r2185939  
    33 * If accessed directly, then exit
    44 */
    5 if ( ! defined( 'ABSPATH' ) ) {
    6     exit;
    7 }
     5defined( 'ABSPATH' ) || exit;
     6
    87
    98/**
     
    1110 */
    1211if ( ! class_exists( 'Comment_Limiter' ) ) {
    13    
     12
    1413    /**
    1514     * Class that holds Comment Limiter settings
     
    1918        /**
    2019         * Property instance
    21          * 
     20         *
    2221         * @since 1.0
    2322         * @var object
     
    4039         */
    4140        public $defaults = array();
    42        
     41
    4342        /**
    4443         * Constructor
     
    126125                </form>
    127126            </div>
    128             <?php 
     127            <?php
    129128        }
    130129
     
    175174
    176175            add_settings_field(
    177                 'enable_admin_feature', 
    178                 __( 'Apply Settings to Admins', 'comment-limiter' ), 
    179                 array( $this, 'comment_limiter_dropdown' ), 
     176                'enable_admin_feature',
     177                __( 'Apply Settings to Admins', 'comment-limiter' ),
     178                array( $this, 'comment_limiter_dropdown' ),
    180179                'comment-limiter-admin',
    181180                'comment_limiter_section' ,
     
    200199            if ( $input['maximum_characters'] <= $input['minimum_characters'] ) {
    201200                add_settings_error( 'comment-limiter-messages', 'invalid-values', __( 'Invalid lengths. Please insert logical values.', 'comment-limiter' ) );
    202                
     201
    203202                return $output;
    204203            }
    205            
     204
    206205            if ( isset( $input['maximum_characters'] ) ) {
    207206                $output['maximum_characters'] = sanitize_text_field( absint( $input['maximum_characters'] ) );
     
    288287            <input type="number" name="comment_limiter_settings[maximum_characters]" id="maximum_characters" class="regular-text" value="<?php esc_html_e( $config['maximum_characters'], 'comment-limiter' ); ?>" />
    289288            <span class="description"><?php esc_html_e( 'Accepts only numbers', 'comment-limiter' ); ?></span>
    290             <p class="description"><?php esc_html_e( 'If the user inserts a comment that is fewer than the number selected above, then, it will receives an advice message to extend his comment.', 'comment-limiter' ); ?></p>
     289            <p class="description"><?php esc_html_e( 'If the user inserts a comment that is lower than the number selected above, then, he will receives an advice message to extend his comment.', 'comment-limiter' ); ?></p>
    291290            <?php
    292291        }
     
    299298         */
    300299        public function minimum_characters_callback() {
    301            
     300
    302301            $config = Comment_Limiter_Config::factory()->get();
    303302
     
    305304            <input type="number" name="comment_limiter_settings[minimum_characters]" id="minimum_characters" class="regular-text" value="<?php esc_html_e( $config['minimum_characters'], 'comment-limiter' ); ?>" />
    306305            <span class="description"><?php esc_html_e( 'Accepts only numbers', 'comment-limiter' ); ?></span>
    307             <p class="description"><?php esc_html_e( 'If the user inserts a comment that is larger than the number selected above, then, it will receives an advice message to minimize his comment.', 'comment-limiter' ); ?></p>
     306            <p class="description"><?php esc_html_e( 'If the user inserts a comment that is greater than the number selected above, then, he will receives an advice message to abbreviate his comment.', 'comment-limiter' ); ?></p>
    308307            <?php
    309308        }
  • comment-limiter/trunk/readme.txt

    r1762330 r2185939  
    33Tags: comment, length, limit, maximum, comment length, minimum comment, comment characters
    44Requires at least: 4.0
    5 Tested up to: 4.9
    6 Stable tag: 1.2
     5Tested up to: 5.2.4
     6Stable tag: 1.3
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3232== Changelog ==
    3333
     34= 1.3 =
     35* Standarized code improved
     36* Spelling issue resolved
     37* GPL plugin version updated
     38
    3439= 1.2 =
    3540* New Update
Note: See TracChangeset for help on using the changeset viewer.