Plugin Directory

Changeset 1850069


Ignore:
Timestamp:
03/30/2018 03:07:13 PM (8 years ago)
Author:
bjorsq
Message:

Some minor changes to script and CSS inclusion - using admin_enqueue_scripts now. Added icon

Location:
rich-text-excerpts/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • rich-text-excerpts/trunk/readme.txt

    r1307423 r1850069  
    44Tags: excerpt, editor, TinyMCE, formatting
    55Requires at least: 3.3
    6 Tested up to: 4.4
    7 Stable tag: 1.3.3
     6Tested up to: 4.9.4
     7Stable tag: 1.3.4
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl.html
     
    7777== Changelog ==
    7878
     79= 1.3.4 =
     80* started using admin_enqueue_scripts to enqueue all scripts and styles.
     81* Added icon
     82* Bumped "Tested up to" value to 4.9.4
     83
    7984= 1.3.3 =
    8085* Incorporated *some* of the suggestions in [this forum post](https://wordpress.org/support/topic/css-to-remove-space) about the padding around the editor
  • rich-text-excerpts/trunk/rich-text-excerpts.php

    r1307423 r1850069  
    66Author: Peter Edwards <pete@bjorsq.net>
    77Author URI: https://github.com/bjorsq/rich-text-excerpts
    8 Version: 1.3.3
     8Version: 1.3.4
    99Text Domain: rich-text-excerpts
    1010License: GPLv3
     
    6464        add_filter( 'teeny_mce_buttons', array( __CLASS__, 'teeny_mce_buttons' ), 10, 2 );
    6565        /**
    66          * register plugin admin options
     66         * create admin page, register plugin admin options and enqueue scripts/CSS
    6767         */
    6868        add_action( 'admin_menu', array( __CLASS__, 'add_plugin_admin_menu' ) );
    6969        add_action( 'admin_init', array( __CLASS__, 'register_plugin_options' ) );
     70        add_action( 'admin_enqueue_scripts', array( __CLASS__, 'add_plugin_scripts_styles' ) );
    7071
    7172         /**
     
    260261    {
    261262        /* Plugin Options page */
    262         $options_page = add_submenu_page( 'options-general.php', __( 'Rich Text Excerpts', 'rich-text-excerpts' ), __( 'Rich Text Excerpts', 'rich-text-excerpts' ), "manage_options", "rich_text_excerpts_options", array( __CLASS__, "plugin_options_page" ) );
    263         /**
    264          * Use the admin_print_scripts action to add scripts.
    265          * Admin script is only needed on plugin admin page, but editor script is needed on all pages
    266          * which include the editor
    267          */
    268         add_action( 'admin_print_scripts-' . $options_page, array( __CLASS__, 'plugin_admin_scripts' ) );
    269         add_action( 'admin_print_scripts', array( __CLASS__, 'plugin_editor_scripts' ) );
    270         /**
    271          * Use the admin_print_styles action to add CSS.
    272          * CSS is needed for the post/page editor only
    273          */
    274         add_action( 'admin_print_styles', array( __CLASS__, 'plugin_admin_styles' ) );
     263        add_submenu_page( 'options-general.php', __( 'Rich Text Excerpts', 'rich-text-excerpts' ), __( 'Rich Text Excerpts', 'rich-text-excerpts' ), "manage_options", "rich_text_excerpts_options", array( __CLASS__, "plugin_options_page" ) );
    275264    }
    276265
    277266    /**
    278267     * add script to admin for plugin options
    279      */
    280     public static function plugin_admin_scripts()
    281     {
    282         wp_enqueue_script('RichTextExcerptsAdminScript', plugins_url('rich-text-excerpts.js', __FILE__), array('jquery'));
    283     }
    284    
    285     /**
    286      * add script to admin for plugin options
    287      */
    288     public static function plugin_editor_scripts()
    289     {
     268     * called using admin_enqueue_scripts hook
     269     */
     270    public static function add_plugin_scripts_styles( $hook )
     271    {
     272        /**
     273         * check $hook to queue script for options page
     274         */
     275        if ( $hook === 'settings_page_rich_text_excerpts_options' ) {
     276            wp_enqueue_script(
     277                'RichTextExcerptsAdminScript',
     278                plugins_url('rich-text-excerpts.js', __FILE__),
     279                array('jquery')
     280            );
     281        }
     282        /**
     283         * check post type to queue script and style for editor
     284         */
    290285        $screen = get_current_screen();
    291286        if ( self::post_type_supported( $screen->post_type ) ) {
    292             wp_enqueue_script('RichTextExcerptsEditorScript', plugins_url('rich-text-excerpts-editor.js', __FILE__), array('jquery'));
    293         }
    294     }
    295 
    296     /**
    297      * add css to admin for editor formatting
    298      */
    299     public static function plugin_admin_styles()
    300     {
    301         $screen = get_current_screen();
    302         if ( self::post_type_supported( $screen->post_type ) ) {
    303             wp_enqueue_style('RichTextExcerptsAdminCSS', plugins_url('rich-text-excerpts.css', __FILE__));
    304         }
    305     }
    306 
     287            wp_enqueue_script(
     288                'RichTextExcerptsEditorScript',
     289                plugins_url('rich-text-excerpts-editor.js', __FILE__),
     290                array('jquery')
     291            );
     292            wp_enqueue_style(
     293                'RichTextExcerptsAdminCSS',
     294                plugins_url('rich-text-excerpts.css', __FILE__)
     295            );
     296        }
     297    }
     298   
    307299    /**
    308300     * creates the options page
     
    310302    public static function plugin_options_page()
    311303    {
    312         printf('<div class="wrap"><div class="icon32" id="icon-options-general"><br /></div><h2>%s</h2>', __('Rich Text Excerpts Options', 'rich-text-excerpts'));
     304        printf('<div class="wrap"><h2>%s</h2>', __('Rich Text Excerpts Options', 'rich-text-excerpts'));
    313305        settings_errors('rich_text_excerpts_options');
    314306        print('<form method="post" action="options.php" id="rich_text_excerpts_options_form">');
    315307        settings_fields('rich_text_excerpts_options');
    316308        do_settings_sections('rte');
    317         printf('<p class="submit"><input type="submit" class="button-primary" name="Submit" value="%s" /></p>', __('Save Changes', 'rich-text-excerpts'));
     309        submit_button();
    318310        print('</form></div>');
    319311    }
Note: See TracChangeset for help on using the changeset viewer.