• Resolved Mad Max

    (@mad_max)


    I’ve noticed that the plugin injects its JS on every back-end pages. It should enqueue its scripts only where is needed, to avoid conflicts with other plugins in other areas than the post/page edit screen.

    I’ve added a check in your plugin_admin_scripts function, on line 277 of rich-text-excerpt.php, like this:

    public static function plugin_admin_scripts()
    	{
    		$screen = get_current_screen();
    		if ( $screen->base == 'post' )
    			wp_enqueue_script('RichTextExcerptsAdminScript', plugins_url('rich-text-excerpts.js', __FILE__), array('jquery'));
    	}

    and it seems to work well.

    Hope it can be useful

    https://www.ads-software.com/plugins/rich-text-excerpts/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author bjorsq

    (@bjorsq)

    The scripts currently used by the plugin are required both on the plugin admin page and on the post editor screens for the post types supported by the plugin. I will split the scripts in the next version of the plugin so they are only included on the relevant pages, but this is not as simple as your solution seems to indicate. Including a script only on the plugin admin page is simple, but you would have to hook into screens with a base of edit and check against the plugin’s supported post types to add the script on the editor screens…

    Plugin Author bjorsq

    (@bjorsq)

    I think I’ve found a compromise here – the CSS and JS which is used to fix and format the editor is only included where the current screen object relates to a post type defined in the “supported post types” setting of the plugin. I’ve separated the JS for the Plugin options page and included that for this page only. Changes will be in the next release.

    Thread Starter Mad Max

    (@mad_max)

    Great! thanks bjorsq

    Thread Starter Mad Max

    (@mad_max)

    Just updated and it seems to work great. Marking as resolved.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘js injection in back-end’ is closed to new replies.