Enqueue files to a specific admin page

 * Add admin files to a specific page
 * @hooks into admin_enqueue_scripts
 * @author Ethan Allen
function wpsnippit_add_files_to_adminPage() {
    //get current screen
    $screen_page = get_current_screen();

    //dump the variable to display the value for your plugin settings page

    //compare current page to the value of our settings page
    if( 'value_of-$screen_page' == $screen_page->id ){
        wp_enqueue_style( 'plugin-styles', plugins_url( 'css/plugin-styles.css', __FILE__ ),'20140605', false );
add_action( 'admin_enqueue_scripts', 'wpsnippit_add_files_to_adminPage' );

Instead of enqueueing files on every page load, you can use this wpsnipp.it to load files on specific admin pages ONLY.


Leave a Reply