Hi @bluedogranch,
This is because of MailPoet’s no-conflict system. You can use filters to allow your styles to be loaded on MailPoet pages.
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.
Changing the “plugin name” in the function to admin_css doesn’t work.
@bluedogranch just to confirm, this is the code you’ve tried?
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.
add_filter( 'mailpoet_conflict_resolver_whitelist_style' , function ( $whitelistedStyles ) {
$whitelistedStyles[] = 'admin_css';
return $whitelistedStyles;
}, 5 );
Thanks, but nope, doesn’t work. I’m using this:
//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 );
Hi there @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:
add_filter( 'mailpoet_conflict_resolver_whitelist_style' , function ( $whitelistedStyles ) {
$whitelistedStyles[] = 'mycustomtheme';
return $whitelistedStyles;
}, 5 );
Please let us know how that goes.
Thanks, that works!
What is the difference and why does that now work?
Hi there @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!
Thanks, that makes sense 🙂