How can I add scripts/styles for specific plugin page in Admin?
-
So I currently register my plugin settings page as such:
// this function adds the settings page to the Appearance tab add_action('admin_menu', 'add_wp_accordion_menu'); function add_wp_accordion_menu() { add_submenu_page('upload.php', 'WP Accordion Settings', 'WP Accordion', 'upload_files', 'wp-accordion', 'wp_accordion_admin_page'); }
When I use these actions, everything works fine:
add_action( 'admin_print_scripts' , 'wp_accordion_jquery' ); add_action( 'admin_print_scripts' , 'wp_accordion_scripts' ); add_action( 'admin_print_styles' , 'wp_accordion_styles' ); add_action( 'admin_head', 'wp_accordion_style' ); add_action( 'admin_head', 'wp_accordion_args' );
However, I’d rather only call the scripts/styles only when my plugin page is called, so I tried:
add_action( 'admin_print_scripts-wp-accordion' , 'wp_accordion_jquery' ); add_action( 'admin_print_scripts-wp-accordion' , 'wp_accordion_scripts' ); add_action( 'admin_print_styles-wp-accordion' , 'wp_accordion_styles' ); add_action( 'admin_head-wp-accordion', 'wp_accordion_style' ); add_action( 'admin_head-wp-accordion', 'wp_accordion_args' );
However, it is not working. So what am I doing wrong?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘How can I add scripts/styles for specific plugin page in Admin?’ is closed to new replies.