Note that there are some explanatory texts on larger screens.

plurals
  1. POWordpress Plugin not loading CSS on the plugin's option page in the admin menu
    primarykey
    data
    text
    <p>I'm building a WordPress plugin, but I'm having trouble loading the css on the plugin's options page in the admin menu. I consulted the codex at <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_style" rel="nofollow">http://codex.wordpress.org/Function_Reference/wp_enqueue_style</a></p> <p>And here's what I got (I simplified the code by taking out all the parts irrelevant to my question and changing the plugin name):</p> <pre><code>&lt;?php if (!class_exists('My_Plugin')){ class My_Plugin{ public function __construct(){ //add admin page add_action('admin_menu', array($this, 'my_plugin_menu')); add_action('admin_init', array($this, 'my_admin_init')); } //adds a page in the admin menu under posts public function my_admin(){ //ensure user is admin if ( !current_user_can( 'manage_options' ) ) { wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); } ?&gt; &lt;div class="wrap"&gt; &lt;?php screen_icon(); ?&gt; &lt;h1&gt;My Plugin&lt;/h1&gt; &lt;/div&gt; &lt;?php } //admin initialization function public function my_admin_init(){ //register admin page's css wp_register_style('my_style', plugins_url('my_style.css', __FILE__)); } //add css files for admin menu() public function my_admin_enqueue_styles(){ wp_enqueue_style('my_style'); } //add menu page under posts public function my_plugin_menu(){ $page = add_submenu_page('edit.php', 'My Plugin', 'My Plugin', 'manage_options', 'my-plugin', array($this, 'my_admin')); //add css add_action('admin_print_styles-'.$page, 'my_admin_enqueue_styles'); } } //instantiate the class $mp = new My_Plugin(); } </code></pre> <p>In the my_style.css file I just stuck <code>h1{color:red;}</code> in order to test it out. The options page loads fine, but firebug isn't showing the css as being loaded at all. I'm stumped. What do I need to do?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload