Plugin Directory

Changeset 1927703


Ignore:
Timestamp:
08/21/2018 01:08:29 AM (8 years ago)
Author:
JeffMatson
Message:

releasing version 1.2.5

Location:
heartbeat-control
Files:
7 edited
70 copied

Legend:

Unmodified
Added
Removed
  • heartbeat-control/tags/1.2.5/autoloader.php

    r1740215 r1927703  
    11<?php
    2 if ( ! defined( 'ABSPATH' ) ) { exit; }
     2/**
     3 * Contains the autoloader.
     4 *
     5 * @package Heartbeat_Control
     6 */
    37
    4 function heartbeat_control_autoload( $classname ) {
    5     $class     = str_replace( '\\', DIRECTORY_SEPARATOR, str_replace( '_', '-', strtolower($classname) ) );
    6     $file_path = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $class . '.php';
    7     if ( file_exists( $file_path ) ) {
    8         require_once $file_path;
    9     }
     8if ( ! defined( 'ABSPATH' ) ) {
     9    exit;
    1010}
    1111
    12 spl_autoload_register('heartbeat_control_autoload');
     12/**
     13 * Autoloads files based on class names.
     14 *
     15 * @param string $classname The class name.
     16 *
     17 * @return void
     18 */
     19function heartbeat_control_autoload( $classname ) {
     20    $class     = str_replace( '\\', DIRECTORY_SEPARATOR, str_replace( '_', '-', strtolower( $classname ) ) );
     21    $file_path = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $class . '.php';
     22    if ( file_exists( $file_path ) ) {
     23        require_once $file_path;
     24    }
     25}
     26
     27// Register the autoloader.
     28spl_autoload_register( 'heartbeat_control_autoload' );
  • heartbeat-control/tags/1.2.5/heartbeat-control.php

    r1917302 r1927703  
    44 * Plugin URI: https://jeffmatson.net/heartbeat-control
    55 * Description: Completely controls the WordPress heartbeat.
    6  * Version: 1.2.4
     6 * Version: 1.2.5
    77 * Author: Jeff Matson
    88 * Author URI: http://jeffmatson.net
     
    1010 * Text Domain: heartbeat-control
    1111 * Domain Path: /languages
     12 *
     13 * @package Heartbeat_Control
    1214 */
    1315
     
    1517
    1618/**
    17  * Undocumented class
     19 * The primary Heartbeat Control class.
    1820 */
    1921class Heartbeat_Control {
    2022
    2123    /**
    22      * Undocumented variable
     24     * The current version.
    2325     *
    2426     * @var string
    2527     */
    26     public $version = '1.2.4';
     28    public $version = '1.2.5';
    2729
    2830    /**
    29      * Undocumented function
     31     * Heartbeat_Control Constructor.
    3032     */
    3133    public function __construct() {
     
    3840    }
    3941
     42    /**
     43     * Enqueue additional scrips if needed.
     44     *
     45     * @return void
     46     */
    4047    public function maybe_enqueue_scripts() {
    4148        if ( get_option( 'heartbeat_control_update_notice' ) ) {
     
    4552    }
    4653
     54    /**
     55     * Register additional plugin dependencies.
     56     *
     57     * @return void
     58     */
    4759    public function register_dependencies() {
     60        // Main plugin autoloader.
    4861        require_once dirname( __FILE__ ) . '/autoloader.php';
     62
     63        // Initialize CMB2 for settings pages.
    4964        require_once dirname( __FILE__ ) . '/vendor/webdevstudios/cmb2/init.php';
    5065        add_action( 'cmb2_admin_init', array( new Settings(), 'init_metaboxes' ) );
    5166    }
    5267
     68    /**
     69     * Check the version and update as needed.
     70     *
     71     * @return void
     72     */
    5373    public function maybe_upgrade() {
    54         add_action( 'admin_notices', array( $this, 'heartbeat_control_updated' ) );
     74        if ( ! apply_filters( 'hbc_disable_notice', false ) ) {
     75            add_action( 'admin_notices', array( $this, 'heartbeat_control_updated' ) );
     76        }
     77
    5578        $db_version = get_option( 'heartbeat_control_version', '1.0' );
    5679        if ( version_compare( $db_version, $this->version, '<' ) ) {
     
    6083
    6184    /**
    62      * Undocumented function
     85     * Upgrades the database from older versions.
    6386     *
    64      * @param [type] $version
     87     * @param string $version The current DB version.
    6588     * @return void
    6689     */
     
    81104                    $updated_options['heartbeat_control_location'] = array( '/wp-admin/post.php' );
    82105                } else {
    83                     if ( $old_frequency = get_option('heartbeat_frequency') ) {
    84                         $updated_options['heartbeat_control_behavior'] = 'modify';
    85                         $updated_options['heartbeat_control_location'] = array( 'frontend', 'admin', '/wp-admin/post.php' );
     106                    if ( $old_frequency === get_option( 'heartbeat_frequency' ) ) {
     107                        $updated_options['heartbeat_control_behavior']  = 'modify';
     108                        $updated_options['heartbeat_control_location']  = array( 'frontend', 'admin', '/wp-admin/post.php' );
    86109                        $updated_options['heartbeat_control_frequency'] = $old_frequency;
    87110                    }
     
    101124    }
    102125
     126    /**
     127     * Displays the update notice.
     128     *
     129     * @return void
     130     */
    103131    public function heartbeat_control_updated() {
    104132        if ( get_option( 'heartbeat_control_update_notice' ) ) {
    105         ?>
     133            ?>
    106134            <div id="heartbeat_control_update_notice" class="notice notice-success is-dismissible">
    107                 <p><?php _e( 'Heartbeat Control has updated to a new version!', 'heartbeat-control' ); ?></p>
    108                 <p><?php _e( 'Love it? Does it save you money and valuable server resources? Consider <a href="https://paypal.me/JeffMatson">sending me a donation</a>. The plugin is entirely developed in my spare time and every little bit helps to motivate me to add more features and bug fixes.', 'heartbeat-control' ); ?></p>
     135                <p><?php esc_html_e( 'Heartbeat Control has updated to a new version!', 'heartbeat-control' ); ?></p>
     136                <p><?php esc_html_e( 'Love it? Does it save you money and valuable server resources? Consider <a href="https://paypal.me/JeffMatson">sending me a donation</a>. The plugin is entirely developed in my spare time and every little bit helps to motivate me to add more features and bug fixes.', 'heartbeat-control' ); ?></p>
    109137            </div>
    110         <?php
     138            <?php
    111139        }
    112140    }
    113141
     142    /**
     143     * Dismisses the update notice.
     144     *
     145     * @return void
     146     */
    114147    public function dismiss_update_notice() {
    115148        delete_option( 'heartbeat_control_update_notice' );
     
    118151}
    119152
    120 new Heartbeat_Control;
     153new Heartbeat_Control();
  • heartbeat-control/tags/1.2.5/heartbeat.php

    r1917325 r1927703  
    11<?php
     2/**
     3 * Contains the Heartbeat_Control\Heartbeat class.
     4 *
     5 * @package Heartbeat_Control
     6 */
    27
    38namespace Heartbeat_Control;
    49
     10/**
     11 * Primary Hearbeat class.
     12 */
    513class Heartbeat {
    614
     15    /**
     16     * The current screen being accessed.
     17     *
     18     * @var string
     19     */
    720    public $current_screen;
     21
     22    /**
     23     * The current query string being accessed.
     24     *
     25     * @var string
     26     */
    827    public $current_query_string;
     28
     29    /**
     30     * Stores heartbeat settings across class methods.
     31     *
     32     * @var array
     33     */
    934    public $settings = array();
    1035
     36    /**
     37     * Just a regular ole constructor.
     38     */
    1139    public function __construct() {
    1240
    1341        if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
    1442            $current_url = $_SERVER['REQUEST_URI'] . '?' . $_SERVER['QUERY_STRING'];
    15         }  else {
     43        } else {
    1644            $current_url = $_SERVER['REQUEST_URI'];
    1745        }
     
    3765    }
    3866
     67    /**
     68     * Checks if the current location has a rule.
     69     *
     70     * @param array $locations Locations that have rules.
     71     *
     72     * @return bool
     73     */
    3974    public function check_location( $locations ) {
    4075        if ( ! isset( $locations ) || ! is_array( $locations ) ) {
     
    5388    }
    5489
     90    /**
     91     * Disable the heartbeat, if needed.
     92     *
     93     * @return void
     94     */
    5595    public function maybe_disable() {
    5696        foreach ( $this->settings as $rule ) {
    57             if ( array_key_exists( 'heartbeat_control_behavior', $rule ) && $rule['heartbeat_control_behavior']  === 'disable' ) {
     97            if ( array_key_exists( 'heartbeat_control_behavior', $rule ) && $rule['heartbeat_control_behavior'] === 'disable' ) {
    5898
    5999                if ( ! array_key_exists( 'heartbeat_control_location', $rule ) ) {
     
    70110    }
    71111
     112    /**
     113     * Modify the heartbeat, if needed.
     114     *
     115     * @param array $settings The settings.
     116     *
     117     * @return array
     118     */
    72119    public function maybe_modify( $settings ) {
    73120
  • heartbeat-control/tags/1.2.5/readme.txt

    r1917302 r1927703  
    55Requires at least: 3.6
    66Tested up to: 4.9.7
    7 Stable tag: 1.2.4
     7Stable tag: 1.2.5
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3636
    3737== Changelog ==
     38= 1.2.5 =
     39* Fixed issue caused by previous version deployment.
     40* Added hbc_disable_notice hook to force dismissal of update notices.
     41* Additional documentation added.
     42* Minor standards adjustments.
     43
    3844= 1.2.4 =
    3945* Updated CMB2 to 2.4.2.
  • heartbeat-control/tags/1.2.5/settings.php

    r1823627 r1927703  
    11<?php
     2/**
     3 * Contains the Heartbeat_Control\Settings class.
     4 *
     5 * @package Heartbeat_Control
     6 */
    27
    38namespace Heartbeat_Control;
    49
     10/**
     11 * Primary settings page class.
     12 */
    513class Settings {
    614
     15    /**
     16     * Renders the slider field.
     17     *
     18     * @param [type] $field
     19     * @param [type] $field_escaped_value
     20     * @param [type] $field_object_id
     21     * @param [type] $field_object_type
     22     * @param [type] $field_type_object
     23     *
     24     * @return void
     25     */
    726    public function render_slider_field( $field, $field_escaped_value, $field_object_id, $field_object_type, $field_type_object ) {
    827        echo '<div class="slider-field"></div>';
     28        // phpcs:ignore
    929        echo $field_type_object->input( array(
    1030            'type'       => 'hidden',
     
    1232            'readonly'   => 'readonly',
    1333            'data-start' => absint( $field_escaped_value ),
    14             'data-min'   => $field->min(),
    15             'data-max'   => $field->max(),
    16             'data-step'  => $field->step(),
     34            'data-min'   => intval( $field->min() ),
     35            'data-max'   => intval( $field->max() ),
     36            'data-step'  => intval( $field->step() ),
    1737            'desc'       => '',
    1838        ) );
    19         echo '<span class="slider-field-value-display">'. $field->value_label() .' <span class="slider-field-value-text"></span></span>';
     39        echo '<span class="slider-field-value-display">' . esc_html( $field->value_label() ) . ' <span class="slider-field-value-text"></span></span>';
    2040        $field_type_object->_desc( true, true );
    2141    }
    2242
     43    /**
     44     * Enqueue scripts on settings pages.
     45     *
     46     * @param string $hook The settings page slug.
     47     *
     48     * @return void
     49     */
    2350    public function enqueue_scripts( $hook ) {
    24         if ( $hook != 'settings_page_heartbeat_control_settings' ) {
     51        if ( $hook !== 'settings_page_heartbeat_control_settings' ) {
    2552            return;
    2653        }
    2754
    28         wp_enqueue_script('heartbeat-control-settings', plugins_url( '/assets/js/bundle.js' , __FILE__ ), array('jquery', 'jquery-ui-slider'), '1.0.0', true);
     55        wp_enqueue_script( 'heartbeat-control-settings', plugins_url( '/assets/js/bundle.js', __FILE__ ), array( 'jquery', 'jquery-ui-slider' ), '1.0.0', true );
    2956        wp_localize_script( 'heartbeat-control-settings', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
    3057        wp_register_style( 'slider_ui', '//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.min.css', array(), '1.0' );
     
    3259    }
    3360
     61    /**
     62     * Initialize the meta boxes in CMB2.
     63     *
     64     * @return void
     65     */
    3466    public function init_metaboxes() {
    3567        add_action( 'cmb2_render_slider', array( $this, 'render_slider_field' ), 10, 5 );
     
    4072            'id'           => 'heartbeat_control_settings',
    4173            'title'        => __( 'Heartbeat Control Settings', 'heartbeat-control' ),
    42             'object_types' => array( 'options-page', ), // Post type
     74            'object_types' => array( 'options-page' ),
    4375            'option_key'   => 'heartbeat_control_settings',
    4476            'capability'   => 'manage_options',
     
    5991
    6092        $cmb->add_group_field( $rule_group, array(
    61             'name'       => __( 'Heartbeat Behavior', 'heartbeat-control' ),
    62             'id'         => $prefix . 'behavior',
    63             'type'       => 'select',
    64             'default'          => 'allow',
    65             'classes'    => 'heartbeat_behavior',
    66             'options'          => array(
    67                 'allow' => __( 'Allow Heartbeat', 'heartbeat-control' ),
    68                 'disable'   => __( 'Disable Heartbeat', 'heartbeat-control' ),
    69                 'modify'     => __( 'Modify Heartbeat', 'heartbeat-control' ),
     93            'name'    => __( 'Heartbeat Behavior', 'heartbeat-control' ),
     94            'id'      => $prefix . 'behavior',
     95            'type'    => 'select',
     96            'default' => 'allow',
     97            'classes' => 'heartbeat_behavior',
     98            'options' => array(
     99                'allow'   => __( 'Allow Heartbeat', 'heartbeat-control' ),
     100                'disable' => __( 'Disable Heartbeat', 'heartbeat-control' ),
     101                'modify'  => __( 'Modify Heartbeat', 'heartbeat-control' ),
    70102            ),
    71103        ) );
    72104
    73105        $cmb->add_group_field( $rule_group, array(
    74             'name'       => __( 'Locations', 'heartbeat-control' ),
    75             'id'         => $prefix . 'location',
    76             'type'       => 'multicheck',
    77             'options'          => array(
    78                 'admin' => __( 'WordPress Dashboard', 'heartbeat-control' ),
    79                 'frontend'  => __( 'Frontend', 'heartbeat-control' ),
     106            'name'    => __( 'Locations', 'heartbeat-control' ),
     107            'id'      => $prefix . 'location',
     108            'type'    => 'multicheck',
     109            'options' => array(
     110                'admin'              => __( 'WordPress Dashboard', 'heartbeat-control' ),
     111                'frontend'           => __( 'Frontend', 'heartbeat-control' ),
    80112                '/wp-admin/post.php' => __( 'Post Editor', 'heartbeat-control' ),
    81113            ),
     
    83115
    84116        $cmb->add_group_field( $rule_group, array(
    85             'name'       => __( 'Frequency', 'heartbeat-control' ),
    86             'id'         => $prefix . 'frequency',
    87             'type'       => 'slider',
    88             'min'        => '15',
    89             'step' => '1',
    90             'max'  => '300',
     117            'name'    => __( 'Frequency', 'heartbeat-control' ),
     118            'id'      => $prefix . 'frequency',
     119            'type'    => 'slider',
     120            'min'     => '15',
     121            'step'    => '1',
     122            'max'     => '300',
    91123            'default' => '15',
    92124            'classes' => 'heartbeat_frequency',
  • heartbeat-control/trunk/autoloader.php

    r1740215 r1927703  
    11<?php
    2 if ( ! defined( 'ABSPATH' ) ) { exit; }
     2/**
     3 * Contains the autoloader.
     4 *
     5 * @package Heartbeat_Control
     6 */
    37
    4 function heartbeat_control_autoload( $classname ) {
    5     $class     = str_replace( '\\', DIRECTORY_SEPARATOR, str_replace( '_', '-', strtolower($classname) ) );
    6     $file_path = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $class . '.php';
    7     if ( file_exists( $file_path ) ) {
    8         require_once $file_path;
    9     }
     8if ( ! defined( 'ABSPATH' ) ) {
     9    exit;
    1010}
    1111
    12 spl_autoload_register('heartbeat_control_autoload');
     12/**
     13 * Autoloads files based on class names.
     14 *
     15 * @param string $classname The class name.
     16 *
     17 * @return void
     18 */
     19function heartbeat_control_autoload( $classname ) {
     20    $class     = str_replace( '\\', DIRECTORY_SEPARATOR, str_replace( '_', '-', strtolower( $classname ) ) );
     21    $file_path = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $class . '.php';
     22    if ( file_exists( $file_path ) ) {
     23        require_once $file_path;
     24    }
     25}
     26
     27// Register the autoloader.
     28spl_autoload_register( 'heartbeat_control_autoload' );
  • heartbeat-control/trunk/heartbeat-control.php

    r1917302 r1927703  
    44 * Plugin URI: https://jeffmatson.net/heartbeat-control
    55 * Description: Completely controls the WordPress heartbeat.
    6  * Version: 1.2.4
     6 * Version: 1.2.5
    77 * Author: Jeff Matson
    88 * Author URI: http://jeffmatson.net
     
    1010 * Text Domain: heartbeat-control
    1111 * Domain Path: /languages
     12 *
     13 * @package Heartbeat_Control
    1214 */
    1315
     
    1517
    1618/**
    17  * Undocumented class
     19 * The primary Heartbeat Control class.
    1820 */
    1921class Heartbeat_Control {
    2022
    2123    /**
    22      * Undocumented variable
     24     * The current version.
    2325     *
    2426     * @var string
    2527     */
    26     public $version = '1.2.4';
     28    public $version = '1.2.5';
    2729
    2830    /**
    29      * Undocumented function
     31     * Heartbeat_Control Constructor.
    3032     */
    3133    public function __construct() {
     
    3840    }
    3941
     42    /**
     43     * Enqueue additional scrips if needed.
     44     *
     45     * @return void
     46     */
    4047    public function maybe_enqueue_scripts() {
    4148        if ( get_option( 'heartbeat_control_update_notice' ) ) {
     
    4552    }
    4653
     54    /**
     55     * Register additional plugin dependencies.
     56     *
     57     * @return void
     58     */
    4759    public function register_dependencies() {
     60        // Main plugin autoloader.
    4861        require_once dirname( __FILE__ ) . '/autoloader.php';
     62
     63        // Initialize CMB2 for settings pages.
    4964        require_once dirname( __FILE__ ) . '/vendor/webdevstudios/cmb2/init.php';
    5065        add_action( 'cmb2_admin_init', array( new Settings(), 'init_metaboxes' ) );
    5166    }
    5267
     68    /**
     69     * Check the version and update as needed.
     70     *
     71     * @return void
     72     */
    5373    public function maybe_upgrade() {
    54         add_action( 'admin_notices', array( $this, 'heartbeat_control_updated' ) );
     74        if ( ! apply_filters( 'hbc_disable_notice', false ) ) {
     75            add_action( 'admin_notices', array( $this, 'heartbeat_control_updated' ) );
     76        }
     77
    5578        $db_version = get_option( 'heartbeat_control_version', '1.0' );
    5679        if ( version_compare( $db_version, $this->version, '<' ) ) {
     
    6083
    6184    /**
    62      * Undocumented function
     85     * Upgrades the database from older versions.
    6386     *
    64      * @param [type] $version
     87     * @param string $version The current DB version.
    6588     * @return void
    6689     */
     
    81104                    $updated_options['heartbeat_control_location'] = array( '/wp-admin/post.php' );
    82105                } else {
    83                     if ( $old_frequency = get_option('heartbeat_frequency') ) {
    84                         $updated_options['heartbeat_control_behavior'] = 'modify';
    85                         $updated_options['heartbeat_control_location'] = array( 'frontend', 'admin', '/wp-admin/post.php' );
     106                    if ( $old_frequency === get_option( 'heartbeat_frequency' ) ) {
     107                        $updated_options['heartbeat_control_behavior']  = 'modify';
     108                        $updated_options['heartbeat_control_location']  = array( 'frontend', 'admin', '/wp-admin/post.php' );
    86109                        $updated_options['heartbeat_control_frequency'] = $old_frequency;
    87110                    }
     
    101124    }
    102125
     126    /**
     127     * Displays the update notice.
     128     *
     129     * @return void
     130     */
    103131    public function heartbeat_control_updated() {
    104132        if ( get_option( 'heartbeat_control_update_notice' ) ) {
    105         ?>
     133            ?>
    106134            <div id="heartbeat_control_update_notice" class="notice notice-success is-dismissible">
    107                 <p><?php _e( 'Heartbeat Control has updated to a new version!', 'heartbeat-control' ); ?></p>
    108                 <p><?php _e( 'Love it? Does it save you money and valuable server resources? Consider <a href="https://paypal.me/JeffMatson">sending me a donation</a>. The plugin is entirely developed in my spare time and every little bit helps to motivate me to add more features and bug fixes.', 'heartbeat-control' ); ?></p>
     135                <p><?php esc_html_e( 'Heartbeat Control has updated to a new version!', 'heartbeat-control' ); ?></p>
     136                <p><?php esc_html_e( 'Love it? Does it save you money and valuable server resources? Consider <a href="https://paypal.me/JeffMatson">sending me a donation</a>. The plugin is entirely developed in my spare time and every little bit helps to motivate me to add more features and bug fixes.', 'heartbeat-control' ); ?></p>
    109137            </div>
    110         <?php
     138            <?php
    111139        }
    112140    }
    113141
     142    /**
     143     * Dismisses the update notice.
     144     *
     145     * @return void
     146     */
    114147    public function dismiss_update_notice() {
    115148        delete_option( 'heartbeat_control_update_notice' );
     
    118151}
    119152
    120 new Heartbeat_Control;
     153new Heartbeat_Control();
  • heartbeat-control/trunk/heartbeat.php

    r1917325 r1927703  
    11<?php
     2/**
     3 * Contains the Heartbeat_Control\Heartbeat class.
     4 *
     5 * @package Heartbeat_Control
     6 */
    27
    38namespace Heartbeat_Control;
    49
     10/**
     11 * Primary Hearbeat class.
     12 */
    513class Heartbeat {
    614
     15    /**
     16     * The current screen being accessed.
     17     *
     18     * @var string
     19     */
    720    public $current_screen;
     21
     22    /**
     23     * The current query string being accessed.
     24     *
     25     * @var string
     26     */
    827    public $current_query_string;
     28
     29    /**
     30     * Stores heartbeat settings across class methods.
     31     *
     32     * @var array
     33     */
    934    public $settings = array();
    1035
     36    /**
     37     * Just a regular ole constructor.
     38     */
    1139    public function __construct() {
    1240
    1341        if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
    1442            $current_url = $_SERVER['REQUEST_URI'] . '?' . $_SERVER['QUERY_STRING'];
    15         }  else {
     43        } else {
    1644            $current_url = $_SERVER['REQUEST_URI'];
    1745        }
     
    3765    }
    3866
     67    /**
     68     * Checks if the current location has a rule.
     69     *
     70     * @param array $locations Locations that have rules.
     71     *
     72     * @return bool
     73     */
    3974    public function check_location( $locations ) {
    4075        if ( ! isset( $locations ) || ! is_array( $locations ) ) {
     
    5388    }
    5489
     90    /**
     91     * Disable the heartbeat, if needed.
     92     *
     93     * @return void
     94     */
    5595    public function maybe_disable() {
    5696        foreach ( $this->settings as $rule ) {
    57             if ( array_key_exists( 'heartbeat_control_behavior', $rule ) && $rule['heartbeat_control_behavior']  === 'disable' ) {
     97            if ( array_key_exists( 'heartbeat_control_behavior', $rule ) && $rule['heartbeat_control_behavior'] === 'disable' ) {
    5898
    5999                if ( ! array_key_exists( 'heartbeat_control_location', $rule ) ) {
     
    70110    }
    71111
     112    /**
     113     * Modify the heartbeat, if needed.
     114     *
     115     * @param array $settings The settings.
     116     *
     117     * @return array
     118     */
    72119    public function maybe_modify( $settings ) {
    73120
  • heartbeat-control/trunk/readme.txt

    r1917302 r1927703  
    55Requires at least: 3.6
    66Tested up to: 4.9.7
    7 Stable tag: 1.2.4
     7Stable tag: 1.2.5
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3636
    3737== Changelog ==
     38= 1.2.5 =
     39* Fixed issue caused by previous version deployment.
     40* Added hbc_disable_notice hook to force dismissal of update notices.
     41* Additional documentation added.
     42* Minor standards adjustments.
     43
    3844= 1.2.4 =
    3945* Updated CMB2 to 2.4.2.
  • heartbeat-control/trunk/settings.php

    r1823627 r1927703  
    11<?php
     2/**
     3 * Contains the Heartbeat_Control\Settings class.
     4 *
     5 * @package Heartbeat_Control
     6 */
    27
    38namespace Heartbeat_Control;
    49
     10/**
     11 * Primary settings page class.
     12 */
    513class Settings {
    614
     15    /**
     16     * Renders the slider field.
     17     *
     18     * @param [type] $field
     19     * @param [type] $field_escaped_value
     20     * @param [type] $field_object_id
     21     * @param [type] $field_object_type
     22     * @param [type] $field_type_object
     23     *
     24     * @return void
     25     */
    726    public function render_slider_field( $field, $field_escaped_value, $field_object_id, $field_object_type, $field_type_object ) {
    827        echo '<div class="slider-field"></div>';
     28        // phpcs:ignore
    929        echo $field_type_object->input( array(
    1030            'type'       => 'hidden',
     
    1232            'readonly'   => 'readonly',
    1333            'data-start' => absint( $field_escaped_value ),
    14             'data-min'   => $field->min(),
    15             'data-max'   => $field->max(),
    16             'data-step'  => $field->step(),
     34            'data-min'   => intval( $field->min() ),
     35            'data-max'   => intval( $field->max() ),
     36            'data-step'  => intval( $field->step() ),
    1737            'desc'       => '',
    1838        ) );
    19         echo '<span class="slider-field-value-display">'. $field->value_label() .' <span class="slider-field-value-text"></span></span>';
     39        echo '<span class="slider-field-value-display">' . esc_html( $field->value_label() ) . ' <span class="slider-field-value-text"></span></span>';
    2040        $field_type_object->_desc( true, true );
    2141    }
    2242
     43    /**
     44     * Enqueue scripts on settings pages.
     45     *
     46     * @param string $hook The settings page slug.
     47     *
     48     * @return void
     49     */
    2350    public function enqueue_scripts( $hook ) {
    24         if ( $hook != 'settings_page_heartbeat_control_settings' ) {
     51        if ( $hook !== 'settings_page_heartbeat_control_settings' ) {
    2552            return;
    2653        }
    2754
    28         wp_enqueue_script('heartbeat-control-settings', plugins_url( '/assets/js/bundle.js' , __FILE__ ), array('jquery', 'jquery-ui-slider'), '1.0.0', true);
     55        wp_enqueue_script( 'heartbeat-control-settings', plugins_url( '/assets/js/bundle.js', __FILE__ ), array( 'jquery', 'jquery-ui-slider' ), '1.0.0', true );
    2956        wp_localize_script( 'heartbeat-control-settings', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
    3057        wp_register_style( 'slider_ui', '//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.min.css', array(), '1.0' );
     
    3259    }
    3360
     61    /**
     62     * Initialize the meta boxes in CMB2.
     63     *
     64     * @return void
     65     */
    3466    public function init_metaboxes() {
    3567        add_action( 'cmb2_render_slider', array( $this, 'render_slider_field' ), 10, 5 );
     
    4072            'id'           => 'heartbeat_control_settings',
    4173            'title'        => __( 'Heartbeat Control Settings', 'heartbeat-control' ),
    42             'object_types' => array( 'options-page', ), // Post type
     74            'object_types' => array( 'options-page' ),
    4375            'option_key'   => 'heartbeat_control_settings',
    4476            'capability'   => 'manage_options',
     
    5991
    6092        $cmb->add_group_field( $rule_group, array(
    61             'name'       => __( 'Heartbeat Behavior', 'heartbeat-control' ),
    62             'id'         => $prefix . 'behavior',
    63             'type'       => 'select',
    64             'default'          => 'allow',
    65             'classes'    => 'heartbeat_behavior',
    66             'options'          => array(
    67                 'allow' => __( 'Allow Heartbeat', 'heartbeat-control' ),
    68                 'disable'   => __( 'Disable Heartbeat', 'heartbeat-control' ),
    69                 'modify'     => __( 'Modify Heartbeat', 'heartbeat-control' ),
     93            'name'    => __( 'Heartbeat Behavior', 'heartbeat-control' ),
     94            'id'      => $prefix . 'behavior',
     95            'type'    => 'select',
     96            'default' => 'allow',
     97            'classes' => 'heartbeat_behavior',
     98            'options' => array(
     99                'allow'   => __( 'Allow Heartbeat', 'heartbeat-control' ),
     100                'disable' => __( 'Disable Heartbeat', 'heartbeat-control' ),
     101                'modify'  => __( 'Modify Heartbeat', 'heartbeat-control' ),
    70102            ),
    71103        ) );
    72104
    73105        $cmb->add_group_field( $rule_group, array(
    74             'name'       => __( 'Locations', 'heartbeat-control' ),
    75             'id'         => $prefix . 'location',
    76             'type'       => 'multicheck',
    77             'options'          => array(
    78                 'admin' => __( 'WordPress Dashboard', 'heartbeat-control' ),
    79                 'frontend'  => __( 'Frontend', 'heartbeat-control' ),
     106            'name'    => __( 'Locations', 'heartbeat-control' ),
     107            'id'      => $prefix . 'location',
     108            'type'    => 'multicheck',
     109            'options' => array(
     110                'admin'              => __( 'WordPress Dashboard', 'heartbeat-control' ),
     111                'frontend'           => __( 'Frontend', 'heartbeat-control' ),
    80112                '/wp-admin/post.php' => __( 'Post Editor', 'heartbeat-control' ),
    81113            ),
     
    83115
    84116        $cmb->add_group_field( $rule_group, array(
    85             'name'       => __( 'Frequency', 'heartbeat-control' ),
    86             'id'         => $prefix . 'frequency',
    87             'type'       => 'slider',
    88             'min'        => '15',
    89             'step' => '1',
    90             'max'  => '300',
     117            'name'    => __( 'Frequency', 'heartbeat-control' ),
     118            'id'      => $prefix . 'frequency',
     119            'type'    => 'slider',
     120            'min'     => '15',
     121            'step'    => '1',
     122            'max'     => '300',
    91123            'default' => '15',
    92124            'classes' => 'heartbeat_frequency',
Note: See TracChangeset for help on using the changeset viewer.