WordPress.org

Plugin Directory

Changeset 1810902


Ignore:
Timestamp:
01/28/18 22:46:23 (3 weeks ago)
Author:
coffee2code
Message:

Update to v1.6:

  • Change: Update plugin framework to 046
    • 046:
    • Fix reset_options() to reference instance variable $options.
      • Note compatibility through WP 4.7+.
      • Update copyright date (2017)
    • 045:
    • Ensure reset_options() resets values saved in the database.
    • 044:
    • Add reset_caches() to clear caches and memoized data. Use it in reset_options() and verify_config().
    • Add verify_options() with logic extracted from verify_config() for initializing default option attributes.
    • Add add_option() to add a new option to the plugin's configuration.
    • Add filter 'sanitized_option_names' to allow modifying the list of whitelisted option names.
    • Change: Refactor get_option_names().
    • 043:
    • Disregard invalid lines supplied as part of hash option value.
    • 042:
    • Update disable_update_check() to check for HTTP and HTTPS for plugin update check API URL.
    • Translate "Donate" in footer message.
  • Change: Update unit test bootstrap
    • Default WP_TESTS_DIR to /tmp/wordpress-tests-lib rather than erroring out if not defined via environment variable
    • Enable more error output for unit tests
  • Change: Align config array elements
  • Change: Note compatibility through WP 4.9+
  • Change: Remove support for WordPress older than 4.6
  • Change: Update copyright date (2018)
Location:
add-admin-javascript
Files:
2 added
1 deleted
6 edited
6 copied

Legend:

Unmodified
Added
Removed
  • add-admin-javascript/tags/1.6/add-admin-javascript.php

    r1395946 r1810902  
    22/** 
    33 * Plugin Name: Add Admin JavaScript 
    4  * Version:     1.4 
     4 * Version:     1.6 
    55 * Plugin URI:  http://coffee2code.com/wp-plugins/add-admin-javascript/ 
    66 * Author:      Scott Reilly 
    77 * Author URI:  http://coffee2code.com/ 
    88 * Text Domain: add-admin-javascript 
    9  * Domain Path: /lang/ 
    109 * License:     GPLv2 or later 
    1110 * License URI: http://www.gnu.org/licenses/gpl-2.0.html 
    1211 * Description: Interface for easily defining additional JavaScript (inline and/or by URL) to be added to all administration pages. 
    1312 * 
    14  * Compatible with WordPress 4.1+ through 4.5+. 
     13 * Compatible with WordPress 4.6+ through 4.8+. 
    1514 * 
    1615 * =>> Read the accompanying readme.txt file for instructions and documentation. 
     
    2019 * @package Add_Admin_JavaScript 
    2120 * @author  Scott Reilly 
    22  * @version 1.4 
     21 * @version 1.6 
    2322*/ 
    2423 
     
    2928 
    3029/* 
    31     Copyright (c) 2010-2016 by Scott Reilly (aka coffee2code) 
     30    Copyright (c) 2010-2018 by Scott Reilly (aka coffee2code) 
    3231 
    3332    This program is free software; you can redistribute it and/or 
     
    4847defined( 'ABSPATH' ) or die(); 
    4948 
    50 if ( is_admin() && ! class_exists( 'c2c_AddAdminJavaScript' ) ) : 
     49if ( is_admin() && ! class_exists( 'c2c_AddAdminJavaScript_Plugin_046' ) ) : 
    5150 
    5251require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'c2c-plugin.php' ); 
    5352 
    54 class c2c_AddAdminJavaScript extends c2c_AddAdminJavaScript_Plugin_040 { 
     53final class c2c_AddAdminJavaScript extends c2c_AddAdminJavaScript_Plugin_046 { 
    5554 
    5655    /** 
     
    8584     */ 
    8685    protected function __construct() { 
    87         parent::__construct( '1.4', 'add-admin-javascript', 'c2c', __FILE__, array() ); 
     86        parent::__construct( '1.6', 'add-admin-javascript', 'c2c', __FILE__, array() ); 
    8887        register_activation_hook( __FILE__, array( __CLASS__, 'activation' ) ); 
    8988 
     
    128127 
    129128        $this->config = array( 
    130             'files' => array( 'input' => 'inline_textarea', 'default' => '', 'datatype' => 'array', 
    131                     'label' => __( 'Admin JavaScript Files', 'add-admin-javascript' ), 
    132                     'help' => __( 'List one URL per line.  The reference can be relative to the root of your site, or a full, absolute URL.  These will be listed in the order listed, and appear in the <head> before the JS defined below.', 'add-admin-javascript' ), 
    133                     'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
     129            'files' => array( 
     130                'input'            => 'inline_textarea', 
     131                'default'          => '', 
     132                'datatype'         => 'array', 
     133                'label'            => __( 'Admin JavaScript Files', 'add-admin-javascript' ), 
     134                'help'             => __( 'List one URL per line.  The reference can be relative to the root of your site, or a full, absolute URL.  These will be listed in the order listed, and appear in the <head> before the JS defined below.', 'add-admin-javascript' ), 
     135                'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
    134136            ), 
    135             'js_head' => array( 'input' => 'inline_textarea', 'default' => '', 'datatype' => 'text', 
    136                     'label' => __( 'Admin JavaScript (in head)', 'add-admin-javascript' ), 
    137                     'help' => __( 'Note that the above JavaScript will be added to all admin pages and apply for all admin users. <em>To speed up page load, it is recommended that inline JavaScript be added to the footer instead of the head.</em>', 'add-admin-javascript' ), 
    138                     'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
     137            'js_head' => array( 
     138                'input'            => 'inline_textarea', 
     139                'default'          => '', 
     140                'datatype'         => 'text', 
     141                'label'            => __( 'Admin JavaScript (in head)', 'add-admin-javascript' ), 
     142                'help'             => __( 'Note that the above JavaScript will be added to all admin pages and apply for all admin users. <em>To speed up page load, it is recommended that inline JavaScript be added to the footer instead of the head.</em>', 'add-admin-javascript' ), 
     143                'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
    139144            ), 
    140             'js_foot' => array( 'input' => 'inline_textarea', 'default' => '', 'datatype' => 'text', 
    141                     'label' => __( 'Admin JavaScript (in footer)', 'add-admin-javascript' ), 
    142                     'help' => __( 'Note that the above JavaScript will be added to all admin pages and apply for all admin users. <em>To speed up page load, it is recommended that inline JavaScript be added to the footer instead of the head.</em>', 'add-admin-javascript' ), 
    143                     'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
     145            'js_foot' => array( 
     146                'input'            => 'inline_textarea', 
     147                'default'          => '', 
     148                'datatype'         => 'text', 
     149                'label'            => __( 'Admin JavaScript (in footer)', 'add-admin-javascript' ), 
     150                'help'             => __( 'Note that the above JavaScript will be added to all admin pages and apply for all admin users. <em>To speed up page load, it is recommended that inline JavaScript be added to the footer instead of the head.</em>', 'add-admin-javascript' ), 
     151                'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
    144152            ), 
    145             'js_jq' => array( 'input' => 'inline_textarea', 'default' => '', 'datatype' => 'text', 
    146                     'label' => __( 'Admin jQuery JavaScript', 'add-admin-javascript' ), 
    147                     'help' => __( 'This will be put in a <code>jQuery(document).ready(function($)) {}</code> in the footer. Note that the above JavaScript will be added to all admin pages and apply for all admin users.', 'add-admin-javascript' ), 
    148                     'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
     153            'js_jq' => array( 
     154                'input'            => 'inline_textarea', 
     155                'default'          => '', 
     156                'datatype'         => 'text', 
     157                'label'            => __( 'Admin jQuery JavaScript', 'add-admin-javascript' ), 
     158                'help'             => __( 'This will be put in a <code>jQuery(document).ready(function($)) {}</code> in the footer. Note that the above JavaScript will be added to all admin pages and apply for all admin users.', 'add-admin-javascript' ), 
     159                'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
    149160            ) 
    150161        ); 
  • add-admin-javascript/tags/1.6/c2c-plugin.php

    r1327238 r1810902  
    33 * @package C2C_Plugins 
    44 * @author  Scott Reilly 
    5  * @version 040 
     5 * @version 046 
    66 */ 
    77/* 
    88Basis for other plugins. 
    99 
    10 Compatible with WordPress 3.6+ through 4.4+. 
     10Compatible with WordPress 3.6+ through 4.7+. 
    1111 
    1212*/ 
    1313 
    1414/* 
    15     Copyright (c) 2010-2016 by Scott Reilly (aka coffee2code) 
     15    Copyright (c) 2010-2017 by Scott Reilly (aka coffee2code) 
    1616 
    1717    This program is free software; you can redistribute it and/or 
     
    3232defined( 'ABSPATH' ) or die(); 
    3333 
    34 if ( ! class_exists( 'c2c_AddAdminJavaScript_Plugin_040' ) ) : 
    35  
    36 abstract class c2c_AddAdminJavaScript_Plugin_040 { 
     34if ( ! class_exists( 'c2c_AddAdminJavaScript_Plugin_046' ) ) : 
     35 
     36abstract class c2c_AddAdminJavaScript_Plugin_046 { 
    3737    protected $plugin_css_version = '009'; 
    3838    protected $options            = array(); 
     
    6666     */ 
    6767    public function c2c_plugin_version() { 
    68         return '040'; 
     68        return '046'; 
    6969    } 
    7070 
     
    8080    protected function __construct( $version, $id_base, $author_prefix, $file, $plugin_options = array() ) { 
    8181        $id_base = sanitize_title( $id_base ); 
    82         if ( ! file_exists( $file ) ) 
     82        if ( ! file_exists( $file ) ) { 
    8383            die( sprintf( __( 'Invalid file specified for C2C_Plugin: %s', 'add-admin-javascript' ), $file ) ); 
     84        } 
    8485 
    8586        $u_id_base = str_replace( '-', '_', $id_base ); 
     
    269270     */ 
    270271    public function disable_update_check( $r, $url ) { 
    271         if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) ) { 
    272             return $r; // Not a plugin update request. Bail immediately. 
    273         } 
     272        // Bail immediately if not a plugin update request. 
     273        $plugin_update_check_strpos = strpos( $url, '://api.wordpress.org/plugins/update-check' ); 
     274        if ( 4 !== $plugin_update_check_strpos && 5 !== $plugin_update_check_strpos ) { 
     275            return $r; 
     276        } 
     277 
    274278        $plugins = unserialize( $r['body']['plugins'] ); 
    275279        unset( $plugins->plugins[ $this->plugin_basename ] ); 
     
    348352     */ 
    349353    public function reset_options() { 
     354        $this->reset_caches(); 
     355 
     356        // If a setting has been saved to the database. 
     357        if ( $option = get_option( $this->admin_options_name ) ) { 
     358            // Unset the options (so that in get_options() the defaults are used). 
     359            foreach ( $this->get_option_names() as $opt ) { 
     360                unset( $this->options[ $opt ] ); 
     361            } 
     362            update_option( $this->admin_options_name, $this->options ); 
     363        } 
     364 
    350365        $this->options = $this->get_options( false ); 
     366 
    351367        return $this->options; 
     368    } 
     369 
     370    /** 
     371     * Resets caches and data memoization. 
     372     * 
     373     * @since 044 
     374     */ 
     375    public function reset_caches() { 
     376        $this->options         = array(); 
     377        $this->option_names    = array(); 
     378        $this->options_from_db = ''; 
    352379    } 
    353380 
     
    365392            $options = $this->get_options(); 
    366393            $option_names = $this->get_option_names(); 
     394            $option_names = (array) apply_filters( $this->get_hook( 'sanitized_option_names' ), $option_names, $inputs ); 
    367395            foreach ( $option_names as $opt ) { 
    368396                if ( !isset( $inputs[ $opt ] ) ) { 
     
    406434                                    $new_values = array(); 
    407435                                    foreach ( explode( "\n", $val ) AS $line ) { 
     436                                        // TODO: It's possible to allow multi-line replacement text, in which case 
     437                                        // instead of skipping invalid looking lines, simply append them to the 
     438                                        // previous line, joined with "\n". 
     439                                        if ( false === strpos( $line, '=>' ) ) { 
     440                                            continue; 
     441                                        } 
    408442                                        list( $shortcut, $text ) = array_map( 'trim', explode( "=>", $line, 2 ) ); 
    409                                         if ( ! empty( $shortcut ) ) { 
     443                                        if ( $shortcut && $text ) { 
    410444                                            $new_values[str_replace( '\\', '', $shortcut )] = str_replace( '\\', '', $text ); 
    411445                                        } 
     
    434468 
    435469    /** 
     470     * Adds a new option to the plugin's configuration. 
     471     * 
     472     * Intended to be used for dynamically adding a new option after the config 
     473     * is initially created via load_config(), but it can be called earlier. 
     474     * 
     475     * @since 044 
     476     * 
     477     * @param string $option_name The option name. 
     478     * @param array  $args        The configuration for the setting. 
     479     * @return array The fully initialized option. 
     480     */ 
     481    public function add_option( $option_name, $args ) { 
     482        $this->config[ $option_name ] = $args; 
     483 
     484        // This function may be running after the config array has already been 
     485        // processed by the plugin, thus this new option won't be automatically 
     486        // verified, which includes setting defaults for setting attributes that 
     487        // weren't explicitly specified. 
     488        $this->verify_options( array( $option_name ) ); 
     489 
     490        return $this->config[ $option_name ]; 
     491    } 
     492 
     493    /** 
    436494     * Verify that the necessary configuration files were set in the inheriting class. 
    437495     */ 
    438     protected function verify_config() { 
     496    public function verify_config() { 
    439497        // Ensure required configuration options have been configured via the sub-class. Die if any aren't. 
    440498        foreach ( $this->required_config as $config ) { 
     
    448506            $this->show_admin = false; 
    449507        } else { 
    450             // Initialize any option attributes that weren't specified by the plugin 
    451             foreach ( $this->get_option_names( true ) as $opt ) { 
    452                 foreach ( $this->config_attributes as $attrib => $default) { 
    453                     if ( ! isset( $this->config[ $opt ][ $attrib ] ) ) { 
    454                         $this->config[ $opt ][ $attrib ] = $default; 
    455                     } 
     508            $this->verify_options(); 
     509        } 
     510    } 
     511 
     512    /** 
     513     * Initializes any option attributes that weren't specified by the plugin. 
     514     * 
     515     * @since 044 
     516     * 
     517     * @param array $options Array of all the option names to verify. Leave empty 
     518     *                       to verify them all. Default empty array. 
     519     */ 
     520    public function verify_options( $options = array() ) { 
     521        // If no options specified, assume them all. 
     522        if ( ! $options ) { 
     523            $options = $this->get_option_names( true ); 
     524        } 
     525 
     526        foreach ( $options as $opt ) { 
     527            foreach ( $this->config_attributes as $attrib => $default) { 
     528                if ( ! isset( $this->config[ $opt ][ $attrib ] ) ) { 
     529                    $this->config[ $opt ][ $attrib ] = $default; 
    456530                } 
    457531            } 
    458         } 
     532            if ( 'array' === $this->config[ $opt ]['datatype'] && ! is_array( $this->config[ $opt ]['default'] ) ) { 
     533                $this->config[ $opt ]['default'] = $this->config[ $opt ]['default'] ? 
     534                    array( $this->config[ $opt ]['default'] ) : 
     535                    array(); 
     536            } 
     537        } 
     538        $this->reset_caches(); 
    459539    } 
    460540 
     
    529609            border-color:#dadada; 
    530610            border-width:1px 0; 
    531         } 
    532         #c2c div { 
     611            overflow: auto; 
     612        } 
     613        #c2c div:first-child { 
    533614            margin:0 auto; 
    534615            padding:5px 40px 0 0; 
     
    546627        .wrap {margin-bottom:30px !important;} 
    547628        .c2c-form .hr, .c2c-hr {border-bottom:1px solid #ccc;padding:0 2px;margin-bottom:6px;} 
    548         .c2c-input-help {color:#777;font-size:x-small;} 
    549629        .c2c-fieldset {border:1px solid #ccc; padding:2px 8px;} 
    550630        .c2c-textarea, .c2c-inline_textarea {width:98%;font-family:"Courier New", Courier, mono;} 
     
    633713            $donation_url .= urlencode( sprintf( __( 'Donation for coffee2code plugin: %s', 'add-admin-javascript' ), $this->name ) ); 
    634714            $title         = __( 'Coffee fuels my coding.', 'add-admin-javascript' ); 
    635             $links[] = '<a href="' . esc_url( $donation_url ) . '" title="' . esc_attr( $title ) . '">Donate</a>'; 
     715            $links[] = '<a href="' . esc_url( $donation_url ) . '" title="' . esc_attr( $title ) . '">' . __( 'Donate', 'add-admin-javascript' ) . '</a>'; 
    636716        } 
    637717        return $links; 
     
    670750     */ 
    671751    protected function get_option_names( $include_non_options = false ) { 
    672         if ( ! $include_non_options && ! empty( $this->option_names ) ) { 
    673             return $this->option_names; 
    674         } 
     752        $option_names = array(); 
     753 
    675754        if ( $include_non_options ) { 
    676             return array_keys( $this->config ); 
    677         } 
    678         $this->option_names = array(); 
    679         foreach ( array_keys( $this->config ) as $opt ) { 
    680             if ( isset( $this->config[ $opt ]['input'] ) && $this->config[ $opt ]['input'] != '' && $this->config[ $opt ]['input'] != 'none' && $this->is_option_valid( $opt ) ) { 
    681                 $this->option_names[] = $opt; 
    682             } 
    683         } 
    684         return $this->option_names; 
     755            $option_names = array_keys( $this->config ); 
     756        } else { 
     757            if ( ! $this->option_names ) { 
     758                $this->option_names = array(); 
     759                foreach ( array_keys( $this->config ) as $opt ) { 
     760                    if ( isset( $this->config[ $opt ]['input'] ) && $this->config[ $opt ]['input'] != '' && $this->config[ $opt ]['input'] != 'none' && $this->is_option_valid( $opt ) ) { 
     761                        $this->option_names[] = $opt; 
     762                    } 
     763                } 
     764            } 
     765            $option_names = $this->option_names; 
     766        } 
     767 
     768        return $option_names; 
    685769    } 
    686770 
     
    694778     */ 
    695779    public function get_options( $with_current_values = true ) { 
    696         if ( $with_current_values && ! empty( $this->options ) ) { 
     780        if ( $with_current_values && $this->options ) { 
    697781            return $this->options; 
    698782        } 
    699783        // Derive options from the config 
    700784        $options = array(); 
    701         $option_names = $this->get_option_names( !$with_current_values ); 
     785        $option_names = $this->get_option_names( ! $with_current_values ); 
    702786        foreach ( $option_names as $opt ) { 
    703787            $options[ $opt ] = $this->config[ $opt ]['default']; 
     
    720804                        $new_val = wp_specialchars_decode( $val, ENT_QUOTES ); 
    721805                        $this->options[ $opt ][ $new_key ] = $new_val; 
    722                         if ( $key != $new_key ) 
     806                        if ( $key != $new_key ) { 
    723807                            unset( $this->options[ $opt ][ $key ] ); 
     808                        } 
    724809                    } 
    725810                } else { 
     
    883968        } 
    884969        if ( $help = apply_filters( $this->get_hook( 'option_help'), $this->config[ $opt ]['help'], $opt ) ) { 
    885             echo "<br /><span class='c2c-input-help'>{$help}</span>\n"; 
     970            echo "<p class='description'>{$help}</p>\n"; 
    886971        } 
    887972 
     
    903988 
    904989        echo "<div class='wrap'>\n"; 
    905         echo "<div class='icon32' style='width:44px;'><img src='{$logo}' alt='" . esc_attr__( 'A plugin by coffee2code', 'add-admin-javascript' ) . "' /><br /></div>\n"; 
    906990 
    907991        do_action( $this->get_hook( 'before_settings_form' ), $this ); 
     
    9231007        echo '<span><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6ARCFJ9TX3522" title="' . esc_attr__( 'Please consider a donation', 'add-admin-javascript' ) . '">' . 
    9241008        __( 'Did you find this plugin useful?', 'add-admin-javascript' ) . '</a></span>'; 
    925         echo '</div></div>' . "\n"; 
     1009        echo '</div>' . "\n"; 
     1010 
     1011        echo '</div>' . "\n"; 
    9261012    } 
    9271013 
  • add-admin-javascript/tags/1.6/readme.txt

    r1395946 r1810902  
    55License: GPLv2 or later 
    66License URI: http://www.gnu.org/licenses/gpl-2.0.html 
    7 Requires at least: 4.1 
    8 Tested up to: 4.5 
    9 Stable tag: 1.4 
     7Requires at least: 4.6 
     8Tested up to: 4.9 
     9Stable tag: 1.6 
    1010 
    1111Interface for easily defining additional JavaScript (inline and/or by URL) to be added to all administration pages. 
     
    144144 
    145145== Changelog == 
     146 
     147= 1.6 (2017-11-03) = 
     148* Change: Update plugin framework to 046 
     149    * 046: 
     150    * Fix `reset_options()` to reference instance variable `$options`. 
     151    * Note compatibility through WP 4.7+. 
     152    * Update copyright date (2017) 
     153    * 045: 
     154    * Ensure `reset_options()` resets values saved in the database. 
     155    * 044: 
     156    * Add `reset_caches()` to clear caches and memoized data. Use it in `reset_options()` and `verify_config()`. 
     157    * Add `verify_options()` with logic extracted from `verify_config()` for initializing default option attributes. 
     158    * Add `add_option()` to add a new option to the plugin's configuration. 
     159    * Add filter 'sanitized_option_names' to allow modifying the list of whitelisted option names. 
     160    * Change: Refactor `get_option_names()`. 
     161    * 043: 
     162    * Disregard invalid lines supplied as part of hash option value. 
     163    * 042: 
     164    * Update `disable_update_check()` to check for HTTP and HTTPS for plugin update check API URL. 
     165    * Translate "Donate" in footer message. 
     166* Change: Update unit test bootstrap 
     167    * Default `WP_TESTS_DIR` to `/tmp/wordpress-tests-lib` rather than erroring out if not defined via environment variable 
     168    * Enable more error output for unit tests 
     169* Change: Align config array elements 
     170* Change: Note compatibility through WP 4.9+ 
     171* Change: Remove support for WordPress older than 4.6 
     172* Change: Update copyright date (2018) 
     173 
     174= 1.5 (2016-04-22) = 
     175* Change: Declare class as final. 
     176* Change: Update plugin framework to 041: 
     177    * For a setting that is of datatype array, ensure its default value is an array. 
     178    * Make `verify_config()` public. 
     179    * Use `<p class="description">` for input field help text instead of custom styled span. 
     180    * Remove output of markup for adding icon to setting page header. 
     181    * Remove styling for .c2c-input-help. 
     182    * Add braces around the few remaining single line conditionals. 
     183* Change: Note compatibility through WP 4.5+. 
     184* Change: Remove 'Domain Path' from plugin header. 
     185* New: Add LICENSE file. 
    146186 
    147187= 1.4 (2016-01-12) = 
     
    273313== Upgrade Notice == 
    274314 
     315= 1.6 = 
     316Minor update: update plugin framework to version 046; verified compatibility through WP 4.9; dropped compatibility with versions of WordPress older than 4.6; updated copyright date (2018). 
     317 
     318= 1.5 = 
     319Minor update: update plugin framework to version 041; verified compatibility through WP 4.5. 
     320 
    275321= 1.4 = 
    276322Recommended update: bugfixes for CSS file links containing query arguments; improved support for localization; verified compatibility through WP 4.4; removed compatibility with WP earlier than 4.1; updated copyright date (2016) 
  • add-admin-javascript/tags/1.6/tests/bootstrap.php

    r832122 r1810902  
    11<?php 
     2/** 
     3 * PHPUnit bootstrap file 
     4 * 
     5 * @package Add_Admin_JavaScript 
     6 */ 
    27 
    3 require_once getenv( 'WP_TESTS_DIR' ) . '/includes/functions.php'; 
     8ini_set( 'display_errors', 'on' ); 
     9error_reporting( E_ALL ); 
    410 
     11$_tests_dir = getenv( 'WP_TESTS_DIR' ); 
     12if ( ! $_tests_dir ) { 
     13    $_tests_dir = '/tmp/wordpress-tests-lib'; 
     14} 
     15 
     16// Give access to tests_add_filter() function. 
     17require_once $_tests_dir . '/includes/functions.php'; 
     18 
     19/** 
     20 * Manually load the plugin being tested. 
     21 */ 
    522function _manually_load_plugin() { 
    6     require dirname( __FILE__ ) . '/../add-admin-javascript.php'; 
     23    require dirname( dirname( __FILE__ ) ) . '/add-admin-javascript.php'; 
    724} 
    825tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); 
    926 
    10 require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php'; 
     27// Start up the WP testing environment. 
     28require $_tests_dir . '/includes/bootstrap.php'; 
  • add-admin-javascript/tags/1.6/tests/test-add-admin-javascript.php

    r1327238 r1810902  
    155155 
    156156    public function test_plugin_framework_class_name() { 
    157         $this->assertTrue( class_exists( 'c2c_AddAdminJavaScript_Plugin_040' ) ); 
     157        $this->assertTrue( class_exists( 'c2c_AddAdminJavaScript_Plugin_046' ) ); 
    158158    } 
    159159 
    160160    public function test_plugin_framework_version() { 
    161         $this->assertEquals( '040', c2c_AddAdminJavaScript::instance()->c2c_plugin_version() ); 
     161        $this->assertEquals( '046', c2c_AddAdminJavaScript::instance()->c2c_plugin_version() ); 
    162162    } 
    163163 
    164164    public function test_version() { 
    165         $this->assertEquals( '1.4', c2c_AddAdminJavaScript::instance()->version() ); 
     165        $this->assertEquals( '1.6', c2c_AddAdminJavaScript::instance()->version() ); 
    166166    } 
    167167 
  • add-admin-javascript/trunk/add-admin-javascript.php

    r1395946 r1810902  
    22/** 
    33 * Plugin Name: Add Admin JavaScript 
    4  * Version:     1.4 
     4 * Version:     1.6 
    55 * Plugin URI:  http://coffee2code.com/wp-plugins/add-admin-javascript/ 
    66 * Author:      Scott Reilly 
    77 * Author URI:  http://coffee2code.com/ 
    88 * Text Domain: add-admin-javascript 
    9  * Domain Path: /lang/ 
    109 * License:     GPLv2 or later 
    1110 * License URI: http://www.gnu.org/licenses/gpl-2.0.html 
    1211 * Description: Interface for easily defining additional JavaScript (inline and/or by URL) to be added to all administration pages. 
    1312 * 
    14  * Compatible with WordPress 4.1+ through 4.5+. 
     13 * Compatible with WordPress 4.6+ through 4.8+. 
    1514 * 
    1615 * =>> Read the accompanying readme.txt file for instructions and documentation. 
     
    2019 * @package Add_Admin_JavaScript 
    2120 * @author  Scott Reilly 
    22  * @version 1.4 
     21 * @version 1.6 
    2322*/ 
    2423 
     
    2928 
    3029/* 
    31     Copyright (c) 2010-2016 by Scott Reilly (aka coffee2code) 
     30    Copyright (c) 2010-2018 by Scott Reilly (aka coffee2code) 
    3231 
    3332    This program is free software; you can redistribute it and/or 
     
    4847defined( 'ABSPATH' ) or die(); 
    4948 
    50 if ( is_admin() && ! class_exists( 'c2c_AddAdminJavaScript' ) ) : 
     49if ( is_admin() && ! class_exists( 'c2c_AddAdminJavaScript_Plugin_046' ) ) : 
    5150 
    5251require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'c2c-plugin.php' ); 
    5352 
    54 class c2c_AddAdminJavaScript extends c2c_AddAdminJavaScript_Plugin_040 { 
     53final class c2c_AddAdminJavaScript extends c2c_AddAdminJavaScript_Plugin_046 { 
    5554 
    5655    /** 
     
    8584     */ 
    8685    protected function __construct() { 
    87         parent::__construct( '1.4', 'add-admin-javascript', 'c2c', __FILE__, array() ); 
     86        parent::__construct( '1.6', 'add-admin-javascript', 'c2c', __FILE__, array() ); 
    8887        register_activation_hook( __FILE__, array( __CLASS__, 'activation' ) ); 
    8988 
     
    128127 
    129128        $this->config = array( 
    130             'files' => array( 'input' => 'inline_textarea', 'default' => '', 'datatype' => 'array', 
    131                     'label' => __( 'Admin JavaScript Files', 'add-admin-javascript' ), 
    132                     'help' => __( 'List one URL per line.  The reference can be relative to the root of your site, or a full, absolute URL.  These will be listed in the order listed, and appear in the &lt;head&gt; before the JS defined below.', 'add-admin-javascript' ), 
    133                     'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
     129            'files' => array( 
     130                'input'            => 'inline_textarea', 
     131                'default'          => '', 
     132                'datatype'         => 'array', 
     133                'label'            => __( 'Admin JavaScript Files', 'add-admin-javascript' ), 
     134                'help'             => __( 'List one URL per line.  The reference can be relative to the root of your site, or a full, absolute URL.  These will be listed in the order listed, and appear in the &lt;head&gt; before the JS defined below.', 'add-admin-javascript' ), 
     135                'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
    134136            ), 
    135             'js_head' => array( 'input' => 'inline_textarea', 'default' => '', 'datatype' => 'text', 
    136                     'label' => __( 'Admin JavaScript (in head)', 'add-admin-javascript' ), 
    137                     'help' => __( 'Note that the above JavaScript will be added to all admin pages and apply for all admin users. <em>To speed up page load, it is recommended that inline JavaScript be added to the footer instead of the head.</em>', 'add-admin-javascript' ), 
    138                     'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
     137            'js_head' => array( 
     138                'input'            => 'inline_textarea', 
     139                'default'          => '', 
     140                'datatype'         => 'text', 
     141                'label'            => __( 'Admin JavaScript (in head)', 'add-admin-javascript' ), 
     142                'help'             => __( 'Note that the above JavaScript will be added to all admin pages and apply for all admin users. <em>To speed up page load, it is recommended that inline JavaScript be added to the footer instead of the head.</em>', 'add-admin-javascript' ), 
     143                'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
    139144            ), 
    140             'js_foot' => array( 'input' => 'inline_textarea', 'default' => '', 'datatype' => 'text', 
    141                     'label' => __( 'Admin JavaScript (in footer)', 'add-admin-javascript' ), 
    142                     'help' => __( 'Note that the above JavaScript will be added to all admin pages and apply for all admin users. <em>To speed up page load, it is recommended that inline JavaScript be added to the footer instead of the head.</em>', 'add-admin-javascript' ), 
    143                     'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
     145            'js_foot' => array( 
     146                'input'            => 'inline_textarea', 
     147                'default'          => '', 
     148                'datatype'         => 'text', 
     149                'label'            => __( 'Admin JavaScript (in footer)', 'add-admin-javascript' ), 
     150                'help'             => __( 'Note that the above JavaScript will be added to all admin pages and apply for all admin users. <em>To speed up page load, it is recommended that inline JavaScript be added to the footer instead of the head.</em>', 'add-admin-javascript' ), 
     151                'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
    144152            ), 
    145             'js_jq' => array( 'input' => 'inline_textarea', 'default' => '', 'datatype' => 'text', 
    146                     'label' => __( 'Admin jQuery JavaScript', 'add-admin-javascript' ), 
    147                     'help' => __( 'This will be put in a <code>jQuery(document).ready(function($)) {}</code> in the footer. Note that the above JavaScript will be added to all admin pages and apply for all admin users.', 'add-admin-javascript' ), 
    148                     'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
     153            'js_jq' => array( 
     154                'input'            => 'inline_textarea', 
     155                'default'          => '', 
     156                'datatype'         => 'text', 
     157                'label'            => __( 'Admin jQuery JavaScript', 'add-admin-javascript' ), 
     158                'help'             => __( 'This will be put in a <code>jQuery(document).ready(function($)) {}</code> in the footer. Note that the above JavaScript will be added to all admin pages and apply for all admin users.', 'add-admin-javascript' ), 
     159                'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="8" cols="40"' 
    149160            ) 
    150161        ); 
  • add-admin-javascript/trunk/c2c-plugin.php

    r1327238 r1810902  
    33 * @package C2C_Plugins 
    44 * @author  Scott Reilly 
    5  * @version 040 
     5 * @version 046 
    66 */ 
    77/* 
    88Basis for other plugins. 
    99 
    10 Compatible with WordPress 3.6+ through 4.4+. 
     10Compatible with WordPress 3.6+ through 4.7+. 
    1111 
    1212*/ 
    1313 
    1414/* 
    15     Copyright (c) 2010-2016 by Scott Reilly (aka coffee2code) 
     15    Copyright (c) 2010-2017 by Scott Reilly (aka coffee2code) 
    1616 
    1717    This program is free software; you can redistribute it and/or 
     
    3232defined( 'ABSPATH' ) or die(); 
    3333 
    34 if ( ! class_exists( 'c2c_AddAdminJavaScript_Plugin_040' ) ) : 
    35  
    36 abstract class c2c_AddAdminJavaScript_Plugin_040 { 
     34if ( ! class_exists( 'c2c_AddAdminJavaScript_Plugin_046' ) ) : 
     35 
     36abstract class c2c_AddAdminJavaScript_Plugin_046 { 
    3737    protected $plugin_css_version = '009'; 
    3838    protected $options            = array(); 
     
    6666     */ 
    6767    public function c2c_plugin_version() { 
    68         return '040'; 
     68        return '046'; 
    6969    } 
    7070 
     
    8080    protected function __construct( $version, $id_base, $author_prefix, $file, $plugin_options = array() ) { 
    8181        $id_base = sanitize_title( $id_base ); 
    82         if ( ! file_exists( $file ) ) 
     82        if ( ! file_exists( $file ) ) { 
    8383            die( sprintf( __( 'Invalid file specified for C2C_Plugin: %s', 'add-admin-javascript' ), $file ) ); 
     84        } 
    8485 
    8586        $u_id_base = str_replace( '-', '_', $id_base ); 
     
    269270     */ 
    270271    public function disable_update_check( $r, $url ) { 
    271         if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) ) { 
    272             return $r; // Not a plugin update request. Bail immediately. 
    273         } 
     272        // Bail immediately if not a plugin update request. 
     273        $plugin_update_check_strpos = strpos( $url, '://api.wordpress.org/plugins/update-check' ); 
     274        if ( 4 !== $plugin_update_check_strpos && 5 !== $plugin_update_check_strpos ) { 
     275            return $r; 
     276        } 
     277 
    274278        $plugins = unserialize( $r['body']['plugins'] ); 
    275279        unset( $plugins->plugins[ $this->plugin_basename ] ); 
     
    348352     */ 
    349353    public function reset_options() { 
     354        $this->reset_caches(); 
     355 
     356        // If a setting has been saved to the database. 
     357        if ( $option = get_option( $this->admin_options_name ) ) { 
     358            // Unset the options (so that in get_options() the defaults are used). 
     359            foreach ( $this->get_option_names() as $opt ) { 
     360                unset( $this->options[ $opt ] ); 
     361            } 
     362            update_option( $this->admin_options_name, $this->options ); 
     363        } 
     364 
    350365        $this->options = $this->get_options( false ); 
     366 
    351367        return $this->options; 
     368    } 
     369 
     370    /** 
     371     * Resets caches and data memoization. 
     372     * 
     373     * @since 044 
     374     */ 
     375    public function reset_caches() { 
     376        $this->options         = array(); 
     377        $this->option_names    = array(); 
     378        $this->options_from_db = ''; 
    352379    } 
    353380 
     
    365392            $options = $this->get_options(); 
    366393            $option_names = $this->get_option_names(); 
     394            $option_names = (array) apply_filters( $this->get_hook( 'sanitized_option_names' ), $option_names, $inputs ); 
    367395            foreach ( $option_names as $opt ) { 
    368396                if ( !isset( $inputs[ $opt ] ) ) { 
     
    406434                                    $new_values = array(); 
    407435                                    foreach ( explode( "\n", $val ) AS $line ) { 
     436                                        // TODO: It's possible to allow multi-line replacement text, in which case 
     437                                        // instead of skipping invalid looking lines, simply append them to the 
     438                                        // previous line, joined with "\n". 
     439                                        if ( false === strpos( $line, '=>' ) ) { 
     440                                            continue; 
     441                                        } 
    408442                                        list( $shortcut, $text ) = array_map( 'trim', explode( "=>", $line, 2 ) ); 
    409                                         if ( ! empty( $shortcut ) ) { 
     443                                        if ( $shortcut && $text ) { 
    410444                                            $new_values[str_replace( '\\', '', $shortcut )] = str_replace( '\\', '', $text ); 
    411445                                        } 
     
    434468 
    435469    /** 
     470     * Adds a new option to the plugin's configuration. 
     471     * 
     472     * Intended to be used for dynamically adding a new option after the config 
     473     * is initially created via load_config(), but it can be called earlier. 
     474     * 
     475     * @since 044 
     476     * 
     477     * @param string $option_name The option name. 
     478     * @param array  $args        The configuration for the setting. 
     479     * @return array The fully initialized option. 
     480     */ 
     481    public function add_option( $option_name, $args ) { 
     482        $this->config[ $option_name ] = $args; 
     483 
     484        // This function may be running after the config array has already been 
     485        // processed by the plugin, thus this new option won't be automatically 
     486        // verified, which includes setting defaults for setting attributes that 
     487        // weren't explicitly specified. 
     488        $this->verify_options( array( $option_name ) ); 
     489 
     490        return $this->config[ $option_name ]; 
     491    } 
     492 
     493    /** 
    436494     * Verify that the necessary configuration files were set in the inheriting class. 
    437495     */ 
    438     protected function verify_config() { 
     496    public function verify_config() { 
    439497        // Ensure required configuration options have been configured via the sub-class. Die if any aren't. 
    440498        foreach ( $this->required_config as $config ) { 
     
    448506            $this->show_admin = false; 
    449507        } else { 
    450             // Initialize any option attributes that weren't specified by the plugin 
    451             foreach ( $this->get_option_names( true ) as $opt ) { 
    452                 foreach ( $this->config_attributes as $attrib => $default) { 
    453                     if ( ! isset( $this->config[ $opt ][ $attrib ] ) ) { 
    454                         $this->config[ $opt ][ $attrib ] = $default; 
    455                     } 
     508            $this->verify_options(); 
     509        } 
     510    } 
     511 
     512    /** 
     513     * Initializes any option attributes that weren't specified by the plugin. 
     514     * 
     515     * @since 044 
     516     * 
     517     * @param array $options Array of all the option names to verify. Leave empty 
     518     *                       to verify them all. Default empty array. 
     519     */ 
     520    public function verify_options( $options = array() ) { 
     521        // If no options specified, assume them all. 
     522        if ( ! $options ) { 
     523            $options = $this->get_option_names( true ); 
     524        } 
     525 
     526        foreach ( $options as $opt ) { 
     527            foreach ( $this->config_attributes as $attrib => $default) { 
     528                if ( ! isset( $this->config[ $opt ][ $attrib ] ) ) { 
     529                    $this->config[ $opt ][ $attrib ] = $default; 
    456530                } 
    457531            } 
    458         } 
     532            if ( 'array' === $this->config[ $opt ]['datatype'] && ! is_array( $this->config[ $opt ]['default'] ) ) { 
     533                $this->config[ $opt ]['default'] = $this->config[ $opt ]['default'] ? 
     534                    array( $this->config[ $opt ]['default'] ) : 
     535                    array(); 
     536            } 
     537        } 
     538        $this->reset_caches(); 
    459539    } 
    460540 
     
    529609            border-color:#dadada; 
    530610            border-width:1px 0; 
    531         } 
    532         #c2c div { 
     611            overflow: auto; 
     612        } 
     613        #c2c div:first-child { 
    533614            margin:0 auto; 
    534615            padding:5px 40px 0 0; 
     
    546627        .wrap {margin-bottom:30px !important;} 
    547628        .c2c-form .hr, .c2c-hr {border-bottom:1px solid #ccc;padding:0 2px;margin-bottom:6px;} 
    548         .c2c-input-help {color:#777;font-size:x-small;} 
    549629        .c2c-fieldset {border:1px solid #ccc; padding:2px 8px;} 
    550630        .c2c-textarea, .c2c-inline_textarea {width:98%;font-family:"Courier New", Courier, mono;} 
     
    633713            $donation_url .= urlencode( sprintf( __( 'Donation for coffee2code plugin: %s', 'add-admin-javascript' ), $this->name ) ); 
    634714            $title         = __( 'Coffee fuels my coding.', 'add-admin-javascript' ); 
    635             $links[] = '<a href="' . esc_url( $donation_url ) . '" title="' . esc_attr( $title ) . '">Donate</a>'; 
     715            $links[] = '<a href="' . esc_url( $donation_url ) . '" title="' . esc_attr( $title ) . '">' . __( 'Donate', 'add-admin-javascript' ) . '</a>'; 
    636716        } 
    637717        return $links; 
     
    670750     */ 
    671751    protected function get_option_names( $include_non_options = false ) { 
    672         if ( ! $include_non_options && ! empty( $this->option_names ) ) { 
    673             return $this->option_names; 
    674         } 
     752        $option_names = array(); 
     753 
    675754        if ( $include_non_options ) { 
    676             return array_keys( $this->config ); 
    677         } 
    678         $this->option_names = array(); 
    679         foreach ( array_keys( $this->config ) as $opt ) { 
    680             if ( isset( $this->config[ $opt ]['input'] ) && $this->config[ $opt ]['input'] != '' && $this->config[ $opt ]['input'] != 'none' && $this->is_option_valid( $opt ) ) { 
    681                 $this->option_names[] = $opt; 
    682             } 
    683         } 
    684         return $this->option_names; 
     755            $option_names = array_keys( $this->config ); 
     756        } else { 
     757            if ( ! $this->option_names ) { 
     758                $this->option_names = array(); 
     759                foreach ( array_keys( $this->config ) as $opt ) { 
     760                    if ( isset( $this->config[ $opt ]['input'] ) && $this->config[ $opt ]['input'] != '' && $this->config[ $opt ]['input'] != 'none' && $this->is_option_valid( $opt ) ) { 
     761                        $this->option_names[] = $opt; 
     762                    } 
     763                } 
     764            } 
     765            $option_names = $this->option_names; 
     766        } 
     767 
     768        return $option_names; 
    685769    } 
    686770 
     
    694778     */ 
    695779    public function get_options( $with_current_values = true ) { 
    696         if ( $with_current_values && ! empty( $this->options ) ) { 
     780        if ( $with_current_values && $this->options ) { 
    697781            return $this->options; 
    698782        } 
    699783        // Derive options from the config 
    700784        $options = array(); 
    701         $option_names = $this->get_option_names( !$with_current_values ); 
     785        $option_names = $this->get_option_names( ! $with_current_values ); 
    702786        foreach ( $option_names as $opt ) { 
    703787            $options[ $opt ] = $this->config[ $opt ]['default']; 
     
    720804                        $new_val = wp_specialchars_decode( $val, ENT_QUOTES ); 
    721805                        $this->options[ $opt ][ $new_key ] = $new_val; 
    722                         if ( $key != $new_key ) 
     806                        if ( $key != $new_key ) { 
    723807                            unset( $this->options[ $opt ][ $key ] ); 
     808                        } 
    724809                    } 
    725810                } else { 
     
    883968        } 
    884969        if ( $help = apply_filters( $this->get_hook( 'option_help'), $this->config[ $opt ]['help'], $opt ) ) { 
    885             echo "<br /><span class='c2c-input-help'>{$help}</span>\n"; 
     970            echo "<p class='description'>{$help}</p>\n"; 
    886971        } 
    887972 
     
    903988 
    904989        echo "<div class='wrap'>\n"; 
    905         echo "<div class='icon32' style='width:44px;'><img src='{$logo}' alt='" . esc_attr__( 'A plugin by coffee2code', 'add-admin-javascript' ) . "' /><br /></div>\n"; 
    906990 
    907991        do_action( $this->get_hook( 'before_settings_form' ), $this ); 
     
    9231007        echo '<span><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6ARCFJ9TX3522" title="' . esc_attr__( 'Please consider a donation', 'add-admin-javascript' ) . '">' . 
    9241008        __( 'Did you find this plugin useful?', 'add-admin-javascript' ) . '</a></span>'; 
    925         echo '</div></div>' . "\n"; 
     1009        echo '</div>' . "\n"; 
     1010 
     1011        echo '</div>' . "\n"; 
    9261012    } 
    9271013 
  • add-admin-javascript/trunk/readme.txt

    r1395946 r1810902  
    55License: GPLv2 or later 
    66License URI: http://www.gnu.org/licenses/gpl-2.0.html 
    7 Requires at least: 4.1 
    8 Tested up to: 4.5 
    9 Stable tag: 1.4 
     7Requires at least: 4.6 
     8Tested up to: 4.9 
     9Stable tag: 1.6 
    1010 
    1111Interface for easily defining additional JavaScript (inline and/or by URL) to be added to all administration pages. 
     
    144144 
    145145== Changelog == 
     146 
     147= 1.6 (2017-11-03) = 
     148* Change: Update plugin framework to 046 
     149    * 046: 
     150    * Fix `reset_options()` to reference instance variable `$options`. 
     151    * Note compatibility through WP 4.7+. 
     152    * Update copyright date (2017) 
     153    * 045: 
     154    * Ensure `reset_options()` resets values saved in the database. 
     155    * 044: 
     156    * Add `reset_caches()` to clear caches and memoized data. Use it in `reset_options()` and `verify_config()`. 
     157    * Add `verify_options()` with logic extracted from `verify_config()` for initializing default option attributes. 
     158    * Add `add_option()` to add a new option to the plugin's configuration. 
     159    * Add filter 'sanitized_option_names' to allow modifying the list of whitelisted option names. 
     160    * Change: Refactor `get_option_names()`. 
     161    * 043: 
     162    * Disregard invalid lines supplied as part of hash option value. 
     163    * 042: 
     164    * Update `disable_update_check()` to check for HTTP and HTTPS for plugin update check API URL. 
     165    * Translate "Donate" in footer message. 
     166* Change: Update unit test bootstrap 
     167    * Default `WP_TESTS_DIR` to `/tmp/wordpress-tests-lib` rather than erroring out if not defined via environment variable 
     168    * Enable more error output for unit tests 
     169* Change: Align config array elements 
     170* Change: Note compatibility through WP 4.9+ 
     171* Change: Remove support for WordPress older than 4.6 
     172* Change: Update copyright date (2018) 
     173 
     174= 1.5 (2016-04-22) = 
     175* Change: Declare class as final. 
     176* Change: Update plugin framework to 041: 
     177    * For a setting that is of datatype array, ensure its default value is an array. 
     178    * Make `verify_config()` public. 
     179    * Use `<p class="description">` for input field help text instead of custom styled span. 
     180    * Remove output of markup for adding icon to setting page header. 
     181    * Remove styling for .c2c-input-help. 
     182    * Add braces around the few remaining single line conditionals. 
     183* Change: Note compatibility through WP 4.5+. 
     184* Change: Remove 'Domain Path' from plugin header. 
     185* New: Add LICENSE file. 
    146186 
    147187= 1.4 (2016-01-12) = 
     
    273313== Upgrade Notice == 
    274314 
     315= 1.6 = 
     316Minor update: update plugin framework to version 046; verified compatibility through WP 4.9; dropped compatibility with versions of WordPress older than 4.6; updated copyright date (2018). 
     317 
     318= 1.5 = 
     319Minor update: update plugin framework to version 041; verified compatibility through WP 4.5. 
     320 
    275321= 1.4 = 
    276322Recommended update: bugfixes for CSS file links containing query arguments; improved support for localization; verified compatibility through WP 4.4; removed compatibility with WP earlier than 4.1; updated copyright date (2016) 
  • add-admin-javascript/trunk/tests/bootstrap.php

    r832122 r1810902  
    11<?php 
     2/** 
     3 * PHPUnit bootstrap file 
     4 * 
     5 * @package Add_Admin_JavaScript 
     6 */ 
    27 
    3 require_once getenv( 'WP_TESTS_DIR' ) . '/includes/functions.php'; 
     8ini_set( 'display_errors', 'on' ); 
     9error_reporting( E_ALL ); 
    410 
     11$_tests_dir = getenv( 'WP_TESTS_DIR' ); 
     12if ( ! $_tests_dir ) { 
     13    $_tests_dir = '/tmp/wordpress-tests-lib'; 
     14} 
     15 
     16// Give access to tests_add_filter() function. 
     17require_once $_tests_dir . '/includes/functions.php'; 
     18 
     19/** 
     20 * Manually load the plugin being tested. 
     21 */ 
    522function _manually_load_plugin() { 
    6     require dirname( __FILE__ ) . '/../add-admin-javascript.php'; 
     23    require dirname( dirname( __FILE__ ) ) . '/add-admin-javascript.php'; 
    724} 
    825tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); 
    926 
    10 require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php'; 
     27// Start up the WP testing environment. 
     28require $_tests_dir . '/includes/bootstrap.php'; 
  • add-admin-javascript/trunk/tests/test-add-admin-javascript.php

    r1327238 r1810902  
    155155 
    156156    public function test_plugin_framework_class_name() { 
    157         $this->assertTrue( class_exists( 'c2c_AddAdminJavaScript_Plugin_040' ) ); 
     157        $this->assertTrue( class_exists( 'c2c_AddAdminJavaScript_Plugin_046' ) ); 
    158158    } 
    159159 
    160160    public function test_plugin_framework_version() { 
    161         $this->assertEquals( '040', c2c_AddAdminJavaScript::instance()->c2c_plugin_version() ); 
     161        $this->assertEquals( '046', c2c_AddAdminJavaScript::instance()->c2c_plugin_version() ); 
    162162    } 
    163163 
    164164    public function test_version() { 
    165         $this->assertEquals( '1.4', c2c_AddAdminJavaScript::instance()->version() ); 
     165        $this->assertEquals( '1.6', c2c_AddAdminJavaScript::instance()->version() ); 
    166166    } 
    167167 
Note: See TracChangeset for help on using the changeset viewer.