Ready to get started?Download WordPress


How Do You Load jQuery UI Plugin Only In My WP Plugins Menu Page? (4 posts)

  1. mtpultz
    Posted 2 years ago #

    I've tried a bunch of things to get it to load, this seemed to make the most sense, but it doesn't load the file either. I'm down to dropping the wp_enqueue throughout my plugin trying to see if that loads the files. Don't ever see it in the resources but the wp_enqueue call works in the theme so I know that I'm loading jQuery ui and accordion correctly. Any idea why or how to do this? Seems to be a lot of answers out there but none have worked.

    add_action('admin_menu', 'myplugin_add_menu_page');
    function myplugin_add_menu_page()
            // Add plugin submenu page
    	$subpage = add_submenu_page('parent_slug'
    		,'Page Title'
    		,'Menu Title'
    	add_action( "admin_print_scripts-$subpage", 'myplugin' );
    function myplugin()
            // NOTE: it makes it here but this doesn't load the plugins
    	wp_enqueue_script( 'jquery-ui-core' );
    	wp_enqueue_script( 'jquery-ui-accordion' );
  2. mtpultz
    Posted 2 years ago #

    I also downloaded the plugin example that invokes this exact same sequence as above to load scripts in a plugin and it works, but ONLY for custom scripts it doesn't work for wp_enqueue_script( 'jquery-ui-core' ); or wp_enqueue_script( 'jquery-ui-accordion' );

    Does anyone know how to do this?
    Any help would be awesome.

  3. Digital Raindrops
    Posted 2 years ago #

    I have a child theme that uses the Default Scripts Included in WordPress 'farbtastic' and 'dashboard', plus a custom script and stylesheet.

    Here is a snippet of code that loads the scripts.

    It uses a different action 'admin_print_styles-appearance_page_{pagename}'
    Where {pagename} is the page slug, it looks like it loads on page appearance.

    So for my page with the slug 'theme_colors' we get this call!

    // load page scripts
    add_action( 'admin_print_styles-appearance_page_theme_colors', 'drtc_admin_enqueue_scripts' );

    This I know works in this theme download, but have not tried it in a plugin, but it is a page action to load scripts, so it should work.



  4. mtpultz
    Posted 2 years ago #

    Thanks for the response :) That is pretty much similar to what I've done. I do that in my themes too and it works no problem, not sure why it does this in plugin pages. I made it work by just downloading my own version of jquery ui and doing it like the plugin example I found did it. Pretty lame that's what had to be done it simply won't enqueue jquery-ui in the plugin page. I flipped through some well made plugins like NextGEN Gallery and they all do it with their own library the same way *shrug*

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.