Skip to main content
added 6 characters in body
Source Link

I'm writing a plugin using WPPB, and can't seem to get my CSS to enqueue just on my plugin's admin page.

I've got a function in my class-{plugin}-admin.php file, inside the define_admin_hooks function, that should enqueue the script. And I can see that it's running with the right file path for the css file, but the script doesn't get enqueued for some reason, and I can't find an error. I put error_logs to confirm that the jo_page_enqueue_styles function is in fact only running on the correct pages, but still no stylesheet.

public function jo_page_enqueue_styles() {

    error_log('jo_page_enqueue_styles ran');
    
    error_log('style path is: ' . plugin_dir_url( __FILE__ ) . 'css/jumpoff-admin-page.css');

    wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/jumpoff-admin-page.css', array(), $this->version, 'all' );

}

This function is run by this hook in class-{plugin}.php inside inside the define_admin_hooks function,

$this->loader->add_action( 'admin_print_styles-'.'toplevel_page_jumpoff' , $plugin_admin, 'jo_page_enqueue_styles' );

Any ideas? Am I going about this all wrong? Thanks.

I'm writing a plugin using WPPB, and can't seem to get my CSS to enqueue just on my plugin's admin page.

I've got a function in my class-{plugin}-admin.php file, inside the define_admin_hooks function, that should enqueue the script. And I can see that it's running with the right file path for the css file, but the script doesn't get enqueued for some reason, and I can't find an error. I put error_logs to confirm that the jo_page_enqueue_styles function is in fact only running on the correct pages, but still no stylesheet.

public function jo_page_enqueue_styles() {

    error_log('jo_page_enqueue_styles ran');
    
    error_log('style path is: ' . plugin_dir_url( __FILE__ ) . 'css/jumpoff-admin-page.css');

    wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/jumpoff-admin-page.css', array(), $this->version, 'all' );

}

This function is run by this hook in class-{plugin}.php

$this->loader->add_action( 'admin_print_styles-'.'toplevel_page_jumpoff' , $plugin_admin, 'jo_page_enqueue_styles' );

Any ideas? Am I going about this all wrong? Thanks.

I'm writing a plugin using WPPB, and can't seem to get my CSS to enqueue just on my plugin's admin page.

I've got a function in my class-{plugin}-admin.php file that should enqueue the script. And I can see that it's running with the right file path for the css file, but the script doesn't get enqueued for some reason, and I can't find an error. I put error_logs to confirm that the jo_page_enqueue_styles function is in fact only running on the correct pages, but still no stylesheet.

public function jo_page_enqueue_styles() {

    error_log('jo_page_enqueue_styles ran');
    
    error_log('style path is: ' . plugin_dir_url( __FILE__ ) . 'css/jumpoff-admin-page.css');

    wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/jumpoff-admin-page.css', array(), $this->version, 'all' );

}

This function is run by this hook in class-{plugin}.php inside inside the define_admin_hooks function,

$this->loader->add_action( 'admin_print_styles-'.'toplevel_page_jumpoff' , $plugin_admin, 'jo_page_enqueue_styles' );

Any ideas? Am I going about this all wrong? Thanks.

Source Link

Enqueueing stylesheets on particular plugin admin pages using WordPress Plugin Boilerplate

I'm writing a plugin using WPPB, and can't seem to get my CSS to enqueue just on my plugin's admin page.

I've got a function in my class-{plugin}-admin.php file, inside the define_admin_hooks function, that should enqueue the script. And I can see that it's running with the right file path for the css file, but the script doesn't get enqueued for some reason, and I can't find an error. I put error_logs to confirm that the jo_page_enqueue_styles function is in fact only running on the correct pages, but still no stylesheet.

public function jo_page_enqueue_styles() {

    error_log('jo_page_enqueue_styles ran');
    
    error_log('style path is: ' . plugin_dir_url( __FILE__ ) . 'css/jumpoff-admin-page.css');

    wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/jumpoff-admin-page.css', array(), $this->version, 'all' );

}

This function is run by this hook in class-{plugin}.php

$this->loader->add_action( 'admin_print_styles-'.'toplevel_page_jumpoff' , $plugin_admin, 'jo_page_enqueue_styles' );

Any ideas? Am I going about this all wrong? Thanks.