Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // STEP 1. Add a admin-sidebar-selector.js file inside your "js" theme folder
- jQuery(document).ready(function($){
- // fetch all sidebars
- var allNames='';
- $('#widgets-right .sidebar-name h3').each(function(){
- allNames+= '<option value="'+$(this).text()+'">'+$(this).text()+'</option>';
- });
- // hide them all but the first one
- $('#widgets-right .widgets-holder-wrap').hide().filter(':eq(0)').show();
- $('#widgets-right').prepend('<div id="sidebar_selector_menu" style="padding:1em;border:1px solid #CCC;margin:1em 0;"><label for="sidebar_selector">Select the sidebar you want to modify:</label><select id="sidebar_selector" name="sidebar_selector">'+allNames+'</select></div');
- $('#sidebar_selector').change(function(){
- var val = $(this).val();
- $('#widgets-right .widgets-holder-wrap').hide();
- var result = $('#widgets-right .widgets-holder-wrap h3:contains("'+val+'")');
- var parent = result.eq(0).parents('.widgets-holder-wrap:first').show();
- });
- });
- // STEP 2. Put this In your Theme functions.php:
- function sidebar_selector_dropdown_menu() {
- wp_enqueue_script('sidebar-selector-js', get_stylesheet_directory_uri().'/js/admin-sidebar-selector.js', array('jquery'));
- }
- add_action('admin_print_scripts-widgets.php', 'sidebar_selector_dropdown_menu');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement