Title: Plugin doesn&#8217;t respect admin_enqueue_scripts
Last modified: December 18, 2024

---

# Plugin doesn’t respect admin_enqueue_scripts

 *  Resolved [bluedogranch](https://wordpress.org/support/users/bluedogranch/)
 * (@bluedogranch)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/plugin-doesnt-respect-admin_enqueue_scripts/)
 * For some reason, Mailpoet doesn’t respect `admin_enqueue_scripts`.
 * In my theme, I load a custom CSS style sheet for WordPress admin, and it loads
   for all admin pages except the Mailpoet admin pages. How do I load custom CSS
   for Mailpoet admin pages?
 * I use this:
 *     ```wp-block-code
       //Add Custom Admin CSS add_action( 'admin_enqueue_scripts', 'load_admin_style' ); function load_admin_style() {	wp_enqueue_style( 'admin_css', get_stylesheet_directory_uri() . '/css/custom-admin.css', null, '1.0' ); }
       ```
   

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Ján Mikláš](https://wordpress.org/support/users/neosinner/)
 * (@neosinner)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/plugin-doesnt-respect-admin_enqueue_scripts/#post-18207938)
 * Hi [@bluedogranch](https://wordpress.org/support/users/bluedogranch/),
 * This is because of MailPoet’s [no-conflict system](https://kb.mailpoet.com/article/365-how-to-solve-3rd-party-css-menu-conflict).
   You can use [filters](https://kb.mailpoet.com/article/365-how-to-solve-3rd-party-css-menu-conflict)
   to allow your styles to be loaded on MailPoet pages.
 *  Thread Starter [bluedogranch](https://wordpress.org/support/users/bluedogranch/)
 * (@bluedogranch)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/plugin-doesnt-respect-admin_enqueue_scripts/#post-18209195)
 * Thanks but I’m not using a plugin; I’m using the function above in functions.
   php. Changing the “plugin name” admin_css doesn’t work.
 *  Thread Starter [bluedogranch](https://wordpress.org/support/users/bluedogranch/)
 * (@bluedogranch)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/plugin-doesnt-respect-admin_enqueue_scripts/#post-18209300)
 * Changing the “plugin name” in the function to admin_css doesn’t work.
 *  Plugin Author [Ján Mikláš](https://wordpress.org/support/users/neosinner/)
 * (@neosinner)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/plugin-doesnt-respect-admin_enqueue_scripts/#post-18209626)
 * [@bluedogranch](https://wordpress.org/support/users/bluedogranch/) just to confirm,
   this is the code you’ve tried?
 *     ```wp-block-code
       add_filter( 'mailpoet_conflict_resolver_whitelist_style' , function ( $whitelistedStyles ) {  $whitelistedStyles[] = 'admin_css';  return $whitelistedStyles;} );
       ```
   
 * If that doesn’t work, can you try lowering the priority to 5 (or maybe even 1,
   if that doesn’t help)? MailPoet scripts may be executed before your filter, which
   would still dequeue your custom styles.
 *     ```wp-block-code
       add_filter( 'mailpoet_conflict_resolver_whitelist_style' , function ( $whitelistedStyles ) {  $whitelistedStyles[] = 'admin_css';  return $whitelistedStyles;}, 5 );
       ```
   
 *  Thread Starter [bluedogranch](https://wordpress.org/support/users/bluedogranch/)
 * (@bluedogranch)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/plugin-doesnt-respect-admin_enqueue_scripts/#post-18209846)
 * Thanks, but nope, doesn’t work. I’m using this:
 *     ```wp-block-code
       //Add Custom Admin CSS add_action( 'admin_enqueue_scripts', 'load_admin_style' ); function load_admin_style() {	wp_enqueue_style( 'admin_css', get_stylesheet_directory_uri() . '/css/custom-admin.css', null, '1.0' ); }add_filter( 'mailpoet_conflict_resolver_whitelist_style' , function ( $whitelistedStyles ) {  $whitelistedStyles[] = 'admin_css';  return $whitelistedStyles;}, 5 );
       ```
   
 *  Plugin Support [Lynn J.a11n](https://wordpress.org/support/users/lynnjat7/)
 * (@lynnjat7)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/plugin-doesnt-respect-admin_enqueue_scripts/#post-18219953)
 * Hi there [@bluedogranch](https://wordpress.org/support/users/bluedogranch/),
 * Thanks for reaching back out and confirming that the code didn’t quite work as
   expected.
 * Can you please try changing the ‘admin_css’ string in the MailPoet hook to the
   directory of your theme? For example, if your theme files are under /wp-content/
   themes/mycustomtheme, then use ‘mycustomtheme’ instead, like this:
 *     ```wp-block-code
       add_filter( 'mailpoet_conflict_resolver_whitelist_style' , function ( $whitelistedStyles ) {  $whitelistedStyles[] = 'mycustomtheme';  return $whitelistedStyles;}, 5 );
       ```
   
 * Please let us know how that goes.
 *  Thread Starter [bluedogranch](https://wordpress.org/support/users/bluedogranch/)
 * (@bluedogranch)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/plugin-doesnt-respect-admin_enqueue_scripts/#post-18220022)
 * Thanks, that works!
 * What is the difference and why does that now work?
 *  Plugin Support [Lynn J.a11n](https://wordpress.org/support/users/lynnjat7/)
 * (@lynnjat7)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/plugin-doesnt-respect-admin_enqueue_scripts/#post-18222569)
 * Hi there [@bluedogranch](https://wordpress.org/support/users/bluedogranch/),
 * The code that allows the MailPoet hook to work – i.e. that enqueues specific 
   CSS files that otherwise would be surpressed – triggers based on the *directory
   that the CSS file is in*.
 * Usually if the issue was a conflict with another plugin, you’d use the plugin
   directory in your WordPress installation.
 * In your case, as you are loading your CSS file directly into the admin, you were
   originally using “admin_css” as if it was the name of the plugin or the location
   of a plugin. However, it is not; the actual location of the CSS file is in your
   theme. You can see that as you load it in, you’re using “get_stylesheet_directory_uri()”
   in your own code to grab the full URL of the theme + CSS directory + CSS file.
 * This is the URL we want to use to help ID the CSS file that is allowed, but rather
   than the entire URL (that the function call would use) we just want the actual
   name of the theme file directory. This works along the same lines as the plugin
   directory name to allow the CSS to pass.
 * Hope that helps!
 *  Thread Starter [bluedogranch](https://wordpress.org/support/users/bluedogranch/)
 * (@bluedogranch)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/plugin-doesnt-respect-admin_enqueue_scripts/#post-18239705)
 * Thanks, that makes sense 🙂

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Plugin doesn’t respect admin_enqueue_scripts’ is closed to new replies.

 * ![](https://ps.w.org/mailpoet/assets/icon-256x256.png?rev=3284564)
 * [MailPoet - Newsletters, Email Marketing, and Automation](https://wordpress.org/plugins/mailpoet/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mailpoet/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mailpoet/)
 * [Active Topics](https://wordpress.org/support/plugin/mailpoet/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mailpoet/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mailpoet/reviews/)

 * 14 replies
 * 3 participants
 * Last reply from: [bluedogranch](https://wordpress.org/support/users/bluedogranch/)
 * Last activity: [1 year, 3 months ago](https://wordpress.org/support/topic/plugin-doesnt-respect-admin_enqueue_scripts/#post-18239705)
 * Status: resolved