• Hello,

    The CSS asset wp-content/plugins/ap-custom-testimonial/css/jquery-ui.css?ver=4.9.5 is enqueued all over the admin area, which breaks many other plugin’s style.

    Could you please refactor to enqueue only to the plugin’s own page? Currently you have

    add_action('admin_enqueue_scripts', array($this, 'apct_register_admin_assets'));

    You just need to delete the line and modify apct_add_plugin_menu like this.

            /** On New Plugin Menu */
            function apct_add_plugin_menu() {
    			// Store the page references in an array
    			$pages = [];
                $pages[] = add_menu_page('AP Custom Testimonial', 'AP Custom<br/>Testimonial', 'manage_options', 'apct-admin', array($this, 'apct_main_page'), 'dashicons-id');
                $pages[] = add_submenu_page('apct-admin', 'Testimonial Setting', 'Settings', 'manage_options', 'apct-admin', array($this, 'apct_main_page'));
                $pages[] = add_submenu_page('null', 'Create Testimonial', 'Create Testimonial', 'manage_options', 'apct_testimonial_create', array($this, 'apct_testimonial_create'));
                $pages[] = add_submenu_page('null', 'Edit Testimonial', 'Edit Testimonial', 'manage_options', 'apct_testimonial_edit', array($this, 'apct_testimonial_edit'));
    			$pages[] = add_submenu_page('null', 'View Testimonial', 'View Testimonial', 'manage_options', 'apct_testimonial_view', array($this, 'apct_testimonial_view'));
    			// Loop over the array and enqueue the scripts
    			foreach ( $pages as $page ) {
    				add_action( 'admin_print_styles-' . $page, array( $this, 'apct_register_admin_assets' ) );
    			}
            }
    

    If you are on GitHub, I can send a PR.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Don’t Inject jQuery UI CSS all over admin’ is closed to new replies.