WordPress.org

Plugin Directory

Changeset 1810901


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

Update to v1.6:

  • New: Add support for CodeMirror (as packaged with WP 4.9)
    • Adds code highlighting, syntax checking, and other features
  • Fix: Show admin notifications for settings page
  • 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: Note compatibility through WP 4.9+
  • Change: Remove support for WordPress older than 4.6
  • Change: Update copyright date (2018)
Location:
add-admin-css
Files:
2 added
8 edited
3 copied

Legend:

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

    r1395944 r1810901  
    22/** 
    33 * Plugin Name: Add Admin CSS 
    4  * Version:     1.4 
     4 * Version:     1.6 
    55 * Plugin URI:  http://coffee2code.com/wp-plugins/add-admin-css/ 
    66 * Author:      Scott Reilly 
    77 * Author URI:  http://coffee2code.com/ 
    88 * Text Domain: add-admin-css 
    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 CSS (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.9+ 
    1514 * 
    1615 * =>> Read the accompanying readme.txt file for instructions and documentation. 
     
    2019 * @package Add_Admin_CSS 
    2120 * @author  Scott Reilly 
    22  * @version 1.4 
     21 * @version 1.6 
    2322 **/ 
    2423 
    2524/* 
    2625 * TODO: 
    27  * - Show admin notifications for settings page (they don't appear since the 
    28  *   settings page isn't under Settings). 
    2926 */ 
    3027 
    3128/* 
    32     Copyright (c) 2010-2016 by Scott Reilly (aka coffee2code) 
     29    Copyright (c) 2010-2018 by Scott Reilly (aka coffee2code) 
    3330 
    3431    This program is free software; you can redistribute it and/or 
     
    5350require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'c2c-plugin.php' ); 
    5451 
    55 class c2c_AddAdminCSS extends c2c_AddAdminCSS_Plugin_040 { 
     52final class c2c_AddAdminCSS extends c2c_AddAdminCSS_Plugin_046 { 
    5653 
    5754    /** 
     
    9592     */ 
    9693    protected function __construct() { 
    97         parent::__construct( '1.4', 'add-admin-css', 'c2c', __FILE__, array( 'settings_page' => 'themes' ) ); 
     94        parent::__construct( '1.6', 'add-admin-css', 'c2c', __FILE__, array( 'settings_page' => 'themes' ) ); 
    9895        register_activation_hook( __FILE__, array( __CLASS__, 'activation' ) ); 
    9996 
     
    129126 
    130127        $this->config = array( 
    131             'files' => array( 'input' => 'inline_textarea', 'default' => '', 'datatype' => 'array', 
    132                     'label' => __( 'Admin CSS Files', 'add-admin-css' ), 
    133                     'help'  => __( 'List one file per line.  The reference can be relative to the root of your active theme, relative to the root of your site (by prepending file or path with "/"), or a full, absolute URL.  These will be listed in the order listed, and appear before the CSS defined below.', 'add-admin-css' ), 
    134                     'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="4" cols="40"' 
     128            'files' => array( 
     129                'input'            => 'inline_textarea', 
     130                'default'          => '', 
     131                'datatype'         => 'array', 
     132                'label'            => __( 'Admin CSS Files', 'add-admin-css' ), 
     133                'help'             => __( 'List one file per line.  The reference can be relative to the root of your active theme, relative to the root of your site (by prepending file or path with "/"), or a full, absolute URL.  These will be listed in the order listed, and appear before the CSS defined below.', 'add-admin-css' ), 
     134                'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="4" cols="40"', 
    135135            ), 
    136             'css' => array( 'input' => 'inline_textarea', 'default' => '', 'datatype' => 'text', 
    137                     'label' => __( 'Admin CSS', 'add-admin-css' ), 
    138                     'help'  => __( 'Note that the above CSS will be added to all admin pages and apply for all users able to view those pages.', 'add-admin-css' ), 
    139                     'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="10" cols="40"' 
     136            'css' => array( 
     137                'input'            => 'inline_textarea', 
     138                'default'          => '', 
     139                'datatype'         => 'text', 
     140                'label'            => __( 'Admin CSS', 'add-admin-css' ), 
     141                'help'             => __( 'Note that the above CSS will be added to all admin pages and apply for all users able to view those pages.', 'add-admin-css' ), 
     142                'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="10" cols="40"', 
    140143            ), 
    141144        ); 
     
    148151        add_action( 'admin_init', array( $this, 'register_css_files' ) ); 
    149152        add_action( 'admin_head', array( $this, 'add_css' ) ); 
     153        add_action( 'admin_notices', array( $this, 'show_admin_notices' ) ); 
     154        add_action( 'admin_enqueue_scripts', array( $this, 'add_codemirror' ) ); 
    150155    } 
    151156 
     
    223228 
    224229        return $help; 
     230    } 
     231 
     232    /** 
     233     * Shows settings admin notices. 
     234     * 
     235     * Settings notices are only shown for admin pages listed under Settings. 
     236     * This plugin has its settings page under Appearance. 
     237     * 
     238     * @since 1.6 
     239     */ 
     240    public function show_admin_notices() { 
     241        // Bail if not on the plugin setting page. 
     242        if ( $this->options_page !== get_current_screen()->id ) { 
     243            return; 
     244        } 
     245 
     246        settings_errors(); 
    225247    } 
    226248 
     
    293315    } 
    294316 
     317    /** 
     318     * Initializes CodeMirror for the CSS textarea. 
     319     * 
     320     * @since 1.6 
     321     */ 
     322    public function add_codemirror() { 
     323        // Bail if not on the plugin setting page. 
     324        if ( $this->options_page !== get_current_screen()->id ) { 
     325            return; 
     326        } 
     327 
     328        // Bail if the code editor script hasn't been registered. 
     329        if ( ! wp_script_is( 'code-editor', 'registered' ) ) { 
     330            return; 
     331        } 
     332 
     333        // Enqueue code editor and settings for manipulating CSS. 
     334        $settings = wp_enqueue_code_editor( array( 'type' => 'text/css' ) ); 
     335 
     336        // Bail if user disabled CodeMirror. 
     337        if ( false === $settings ) { 
     338            return; 
     339        } 
     340 
     341        // Inline the CodeMirror code. 
     342        wp_add_inline_script( 
     343            'code-editor', 
     344            sprintf( 
     345                'jQuery( function() { wp.codeEditor.initialize( "css", %s ); } );', 
     346                wp_json_encode( $settings ) 
     347            ) 
     348        ); 
     349    } 
     350 
    295351} // end c2c_AddAdminCSS 
    296352 
  • add-admin-css/tags/1.6/c2c-plugin.php

    r1327230 r1810901  
    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_AddAdminCSS_Plugin_040' ) ) : 
    35  
    36 abstract class c2c_AddAdminCSS_Plugin_040 { 
     34if ( ! class_exists( 'c2c_AddAdminCSS_Plugin_046' ) ) : 
     35 
     36abstract class c2c_AddAdminCSS_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-css' ), $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-css' ), $this->name ) ); 
    634714            $title         = __( 'Coffee fuels my coding.', 'add-admin-css' ); 
    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-css' ) . '</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-css' ) . "' /><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-css' ) . '">' . 
    9241008        __( 'Did you find this plugin useful?', 'add-admin-css' ) . '</a></span>'; 
    925         echo '</div></div>' . "\n"; 
     1009        echo '</div>' . "\n"; 
     1010 
     1011        echo '</div>' . "\n"; 
    9261012    } 
    9271013 
  • add-admin-css/tags/1.6/readme.txt

    r1395944 r1810901  
    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 CSS (inline and/or by URL) to be added to all administration pages. 
     
    4747 
    4848You can hook the 'c2c_add_admin_css' and 'c2c_add_admin_css_files' filters and determine the current user to decide whether the respective hook argument should be returned (and thus output) for the user or not. 
     49 
     50= How do I disable syntax highlighting? = 
     51 
     52The plugin's syntax highlighting of CSS (available on WP 4.9+) honors the built-in setting for whether syntax highlighting should be enabled or not. 
     53 
     54To disable syntax highlighting, go to your profile page. Next to "Syntax Highlighting", click the checkbox labeled "Disable syntax highlighting when editing code". Note that this checkbox disables syntax highlighting throughout the admin interface and not just specifically for the plugin's settings page. 
    4955 
    5056= Does this plugin include unit tests? = 
     
    97103 
    98104== Changelog == 
     105 
     106= 1.6 (2017-11-03) = 
     107* New: Add support for CodeMirror (as packaged with WP 4.9) 
     108    * Adds code highlighting, syntax checking, and other features 
     109* Fix: Show admin notifications for settings page 
     110* Change: Update plugin framework to 046 
     111    * 046: 
     112    * Fix `reset_options()` to reference instance variable `$options`. 
     113    * Note compatibility through WP 4.7+. 
     114    * Update copyright date (2017) 
     115    * 045: 
     116    * Ensure `reset_options()` resets values saved in the database. 
     117    * 044: 
     118    * Add `reset_caches()` to clear caches and memoized data. Use it in `reset_options()` and `verify_config()`. 
     119    * Add `verify_options()` with logic extracted from `verify_config()` for initializing default option attributes. 
     120    * Add `add_option()` to add a new option to the plugin's configuration. 
     121    * Add filter 'sanitized_option_names' to allow modifying the list of whitelisted option names. 
     122    * Change: Refactor `get_option_names()`. 
     123    * 043: 
     124    * Disregard invalid lines supplied as part of hash option value. 
     125    * 042: 
     126    * Update `disable_update_check()` to check for HTTP and HTTPS for plugin update check API URL. 
     127    * Translate "Donate" in footer message. 
     128* Change: Update unit test bootstrap 
     129    * Default `WP_TESTS_DIR` to `/tmp/wordpress-tests-lib` rather than erroring out if not defined via environment variable 
     130    * Enable more error output for unit tests 
     131* Change: Note compatibility through WP 4.9+ 
     132* Change: Remove support for WordPress older than 4.6 
     133* Change: Update copyright date (2018) 
     134 
     135= 1.5 (2016-04-21) = 
     136* Change: Declare class as final. 
     137* Change: Update plugin framework to 041: 
     138    * For a setting that is of datatype array, ensure its default value is an array. 
     139    * Make `verify_config()` public. 
     140    * Use `<p class="description">` for input field help text instead of custom styled span. 
     141    * Remove output of markup for adding icon to setting page header. 
     142    * Remove styling for .c2c-input-help. 
     143    * Add braces around the few remaining single line conditionals. 
     144* Change: Note compatibility through WP 4.5+. 
     145* Change: Remove 'Domain Path' from plugin header. 
     146* New: Add LICENSE file. 
    99147 
    100148= 1.4 (2016-01-10) = 
     
    220268== Upgrade Notice == 
    221269 
     270= 1.6 = 
     271Recommended update: added code highlighting, syntax checking, etc as introduced elsewhere in WP 4.9; show admin notifications for settings page; updated 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). 
     272 
     273= 1.5 = 
     274Minor update: updated plugin framework to version 041; verified compatibility through WP 4.5. 
     275 
    222276= 1.4 = 
    223277Recommended 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-css/tags/1.6/tests/bootstrap.php

    r832111 r1810901  
    11<?php 
     2/** 
     3 * PHPUnit bootstrap file 
     4 * 
     5 * @package Add_Admin_CSS 
     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-css.php'; 
     23    require dirname( dirname( __FILE__ ) ) . '/add-admin-css.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-css/tags/1.6/tests/test-add-admin-css.php

    r1327230 r1810901  
    125125            define( 'WP_ADMIN', true ); 
    126126        } 
    127         require( dirname( __FILE__ ) . '/../add-admin-css.php' ); 
     127        require( dirname( dirname( __FILE__ ) ) . '/add-admin-css.php' ); 
    128128        c2c_AddAdminCSS::instance()->init(); 
    129129        c2c_AddAdminCSS::instance()->register_css_files(); 
     
    139139 
    140140    public function test_plugin_framework_class_name() { 
    141         $this->assertTrue( class_exists( 'c2c_AddAdminCSS_Plugin_040' ) ); 
     141        $this->assertTrue( class_exists( 'c2c_AddAdminCSS_Plugin_046' ) ); 
    142142    } 
    143143 
    144144    public function test_plugin_framework_version() { 
    145         $this->assertEquals( '040', c2c_AddAdminCSS::instance()->c2c_plugin_version() ); 
     145        $this->assertEquals( '046', c2c_AddAdminCSS::instance()->c2c_plugin_version() ); 
    146146    } 
    147147 
    148148    public function test_version() { 
    149         $this->assertEquals( '1.4', c2c_AddAdminCSS::instance()->version() ); 
     149        $this->assertEquals( '1.6', c2c_AddAdminCSS::instance()->version() ); 
    150150    } 
    151151 
  • add-admin-css/trunk/add-admin-css.php

    r1395944 r1810901  
    22/** 
    33 * Plugin Name: Add Admin CSS 
    4  * Version:     1.4 
     4 * Version:     1.6 
    55 * Plugin URI:  http://coffee2code.com/wp-plugins/add-admin-css/ 
    66 * Author:      Scott Reilly 
    77 * Author URI:  http://coffee2code.com/ 
    88 * Text Domain: add-admin-css 
    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 CSS (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.9+ 
    1514 * 
    1615 * =>> Read the accompanying readme.txt file for instructions and documentation. 
     
    2019 * @package Add_Admin_CSS 
    2120 * @author  Scott Reilly 
    22  * @version 1.4 
     21 * @version 1.6 
    2322 **/ 
    2423 
    2524/* 
    2625 * TODO: 
    27  * - Show admin notifications for settings page (they don't appear since the 
    28  *   settings page isn't under Settings). 
    2926 */ 
    3027 
    3128/* 
    32     Copyright (c) 2010-2016 by Scott Reilly (aka coffee2code) 
     29    Copyright (c) 2010-2018 by Scott Reilly (aka coffee2code) 
    3330 
    3431    This program is free software; you can redistribute it and/or 
     
    5350require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'c2c-plugin.php' ); 
    5451 
    55 class c2c_AddAdminCSS extends c2c_AddAdminCSS_Plugin_040 { 
     52final class c2c_AddAdminCSS extends c2c_AddAdminCSS_Plugin_046 { 
    5653 
    5754    /** 
     
    9592     */ 
    9693    protected function __construct() { 
    97         parent::__construct( '1.4', 'add-admin-css', 'c2c', __FILE__, array( 'settings_page' => 'themes' ) ); 
     94        parent::__construct( '1.6', 'add-admin-css', 'c2c', __FILE__, array( 'settings_page' => 'themes' ) ); 
    9895        register_activation_hook( __FILE__, array( __CLASS__, 'activation' ) ); 
    9996 
     
    129126 
    130127        $this->config = array( 
    131             'files' => array( 'input' => 'inline_textarea', 'default' => '', 'datatype' => 'array', 
    132                     'label' => __( 'Admin CSS Files', 'add-admin-css' ), 
    133                     'help'  => __( 'List one file per line.  The reference can be relative to the root of your active theme, relative to the root of your site (by prepending file or path with "/"), or a full, absolute URL.  These will be listed in the order listed, and appear before the CSS defined below.', 'add-admin-css' ), 
    134                     'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="4" cols="40"' 
     128            'files' => array( 
     129                'input'            => 'inline_textarea', 
     130                'default'          => '', 
     131                'datatype'         => 'array', 
     132                'label'            => __( 'Admin CSS Files', 'add-admin-css' ), 
     133                'help'             => __( 'List one file per line.  The reference can be relative to the root of your active theme, relative to the root of your site (by prepending file or path with "/"), or a full, absolute URL.  These will be listed in the order listed, and appear before the CSS defined below.', 'add-admin-css' ), 
     134                'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="4" cols="40"', 
    135135            ), 
    136             'css' => array( 'input' => 'inline_textarea', 'default' => '', 'datatype' => 'text', 
    137                     'label' => __( 'Admin CSS', 'add-admin-css' ), 
    138                     'help'  => __( 'Note that the above CSS will be added to all admin pages and apply for all users able to view those pages.', 'add-admin-css' ), 
    139                     'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="10" cols="40"' 
     136            'css' => array( 
     137                'input'            => 'inline_textarea', 
     138                'default'          => '', 
     139                'datatype'         => 'text', 
     140                'label'            => __( 'Admin CSS', 'add-admin-css' ), 
     141                'help'             => __( 'Note that the above CSS will be added to all admin pages and apply for all users able to view those pages.', 'add-admin-css' ), 
     142                'input_attributes' => 'style="width: 98%; white-space: pre; word-wrap: normal; overflow-x: scroll;" rows="10" cols="40"', 
    140143            ), 
    141144        ); 
     
    148151        add_action( 'admin_init', array( $this, 'register_css_files' ) ); 
    149152        add_action( 'admin_head', array( $this, 'add_css' ) ); 
     153        add_action( 'admin_notices', array( $this, 'show_admin_notices' ) ); 
     154        add_action( 'admin_enqueue_scripts', array( $this, 'add_codemirror' ) ); 
    150155    } 
    151156 
     
    223228 
    224229        return $help; 
     230    } 
     231 
     232    /** 
     233     * Shows settings admin notices. 
     234     * 
     235     * Settings notices are only shown for admin pages listed under Settings. 
     236     * This plugin has its settings page under Appearance. 
     237     * 
     238     * @since 1.6 
     239     */ 
     240    public function show_admin_notices() { 
     241        // Bail if not on the plugin setting page. 
     242        if ( $this->options_page !== get_current_screen()->id ) { 
     243            return; 
     244        } 
     245 
     246        settings_errors(); 
    225247    } 
    226248 
     
    293315    } 
    294316 
     317    /** 
     318     * Initializes CodeMirror for the CSS textarea. 
     319     * 
     320     * @since 1.6 
     321     */ 
     322    public function add_codemirror() { 
     323        // Bail if not on the plugin setting page. 
     324        if ( $this->options_page !== get_current_screen()->id ) { 
     325            return; 
     326        } 
     327 
     328        // Bail if the code editor script hasn't been registered. 
     329        if ( ! wp_script_is( 'code-editor', 'registered' ) ) { 
     330            return; 
     331        } 
     332 
     333        // Enqueue code editor and settings for manipulating CSS. 
     334        $settings = wp_enqueue_code_editor( array( 'type' => 'text/css' ) ); 
     335 
     336        // Bail if user disabled CodeMirror. 
     337        if ( false === $settings ) { 
     338            return; 
     339        } 
     340 
     341        // Inline the CodeMirror code. 
     342        wp_add_inline_script( 
     343            'code-editor', 
     344            sprintf( 
     345                'jQuery( function() { wp.codeEditor.initialize( "css", %s ); } );', 
     346                wp_json_encode( $settings ) 
     347            ) 
     348        ); 
     349    } 
     350 
    295351} // end c2c_AddAdminCSS 
    296352 
  • add-admin-css/trunk/c2c-plugin.php

    r1327230 r1810901  
    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_AddAdminCSS_Plugin_040' ) ) : 
    35  
    36 abstract class c2c_AddAdminCSS_Plugin_040 { 
     34if ( ! class_exists( 'c2c_AddAdminCSS_Plugin_046' ) ) : 
     35 
     36abstract class c2c_AddAdminCSS_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-css' ), $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-css' ), $this->name ) ); 
    634714            $title         = __( 'Coffee fuels my coding.', 'add-admin-css' ); 
    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-css' ) . '</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-css' ) . "' /><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-css' ) . '">' . 
    9241008        __( 'Did you find this plugin useful?', 'add-admin-css' ) . '</a></span>'; 
    925         echo '</div></div>' . "\n"; 
     1009        echo '</div>' . "\n"; 
     1010 
     1011        echo '</div>' . "\n"; 
    9261012    } 
    9271013 
  • add-admin-css/trunk/readme.txt

    r1395944 r1810901  
    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 CSS (inline and/or by URL) to be added to all administration pages. 
     
    4747 
    4848You can hook the 'c2c_add_admin_css' and 'c2c_add_admin_css_files' filters and determine the current user to decide whether the respective hook argument should be returned (and thus output) for the user or not. 
     49 
     50= How do I disable syntax highlighting? = 
     51 
     52The plugin's syntax highlighting of CSS (available on WP 4.9+) honors the built-in setting for whether syntax highlighting should be enabled or not. 
     53 
     54To disable syntax highlighting, go to your profile page. Next to "Syntax Highlighting", click the checkbox labeled "Disable syntax highlighting when editing code". Note that this checkbox disables syntax highlighting throughout the admin interface and not just specifically for the plugin's settings page. 
    4955 
    5056= Does this plugin include unit tests? = 
     
    97103 
    98104== Changelog == 
     105 
     106= 1.6 (2017-11-03) = 
     107* New: Add support for CodeMirror (as packaged with WP 4.9) 
     108    * Adds code highlighting, syntax checking, and other features 
     109* Fix: Show admin notifications for settings page 
     110* Change: Update plugin framework to 046 
     111    * 046: 
     112    * Fix `reset_options()` to reference instance variable `$options`. 
     113    * Note compatibility through WP 4.7+. 
     114    * Update copyright date (2017) 
     115    * 045: 
     116    * Ensure `reset_options()` resets values saved in the database. 
     117    * 044: 
     118    * Add `reset_caches()` to clear caches and memoized data. Use it in `reset_options()` and `verify_config()`. 
     119    * Add `verify_options()` with logic extracted from `verify_config()` for initializing default option attributes. 
     120    * Add `add_option()` to add a new option to the plugin's configuration. 
     121    * Add filter 'sanitized_option_names' to allow modifying the list of whitelisted option names. 
     122    * Change: Refactor `get_option_names()`. 
     123    * 043: 
     124    * Disregard invalid lines supplied as part of hash option value. 
     125    * 042: 
     126    * Update `disable_update_check()` to check for HTTP and HTTPS for plugin update check API URL. 
     127    * Translate "Donate" in footer message. 
     128* Change: Update unit test bootstrap 
     129    * Default `WP_TESTS_DIR` to `/tmp/wordpress-tests-lib` rather than erroring out if not defined via environment variable 
     130    * Enable more error output for unit tests 
     131* Change: Note compatibility through WP 4.9+ 
     132* Change: Remove support for WordPress older than 4.6 
     133* Change: Update copyright date (2018) 
     134 
     135= 1.5 (2016-04-21) = 
     136* Change: Declare class as final. 
     137* Change: Update plugin framework to 041: 
     138    * For a setting that is of datatype array, ensure its default value is an array. 
     139    * Make `verify_config()` public. 
     140    * Use `<p class="description">` for input field help text instead of custom styled span. 
     141    * Remove output of markup for adding icon to setting page header. 
     142    * Remove styling for .c2c-input-help. 
     143    * Add braces around the few remaining single line conditionals. 
     144* Change: Note compatibility through WP 4.5+. 
     145* Change: Remove 'Domain Path' from plugin header. 
     146* New: Add LICENSE file. 
    99147 
    100148= 1.4 (2016-01-10) = 
     
    220268== Upgrade Notice == 
    221269 
     270= 1.6 = 
     271Recommended update: added code highlighting, syntax checking, etc as introduced elsewhere in WP 4.9; show admin notifications for settings page; updated 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). 
     272 
     273= 1.5 = 
     274Minor update: updated plugin framework to version 041; verified compatibility through WP 4.5. 
     275 
    222276= 1.4 = 
    223277Recommended 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-css/trunk/tests/bootstrap.php

    r832111 r1810901  
    11<?php 
     2/** 
     3 * PHPUnit bootstrap file 
     4 * 
     5 * @package Add_Admin_CSS 
     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-css.php'; 
     23    require dirname( dirname( __FILE__ ) ) . '/add-admin-css.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-css/trunk/tests/test-add-admin-css.php

    r1327230 r1810901  
    125125            define( 'WP_ADMIN', true ); 
    126126        } 
    127         require( dirname( __FILE__ ) . '/../add-admin-css.php' ); 
     127        require( dirname( dirname( __FILE__ ) ) . '/add-admin-css.php' ); 
    128128        c2c_AddAdminCSS::instance()->init(); 
    129129        c2c_AddAdminCSS::instance()->register_css_files(); 
     
    139139 
    140140    public function test_plugin_framework_class_name() { 
    141         $this->assertTrue( class_exists( 'c2c_AddAdminCSS_Plugin_040' ) ); 
     141        $this->assertTrue( class_exists( 'c2c_AddAdminCSS_Plugin_046' ) ); 
    142142    } 
    143143 
    144144    public function test_plugin_framework_version() { 
    145         $this->assertEquals( '040', c2c_AddAdminCSS::instance()->c2c_plugin_version() ); 
     145        $this->assertEquals( '046', c2c_AddAdminCSS::instance()->c2c_plugin_version() ); 
    146146    } 
    147147 
    148148    public function test_version() { 
    149         $this->assertEquals( '1.4', c2c_AddAdminCSS::instance()->version() ); 
     149        $this->assertEquals( '1.6', c2c_AddAdminCSS::instance()->version() ); 
    150150    } 
    151151 
Note: See TracChangeset for help on using the changeset viewer.