=== SMK Sidebar Generator === Contributors: _smartik_ Tags: sidebar, widget, generator, custom, unlimited Requires at least: 3.2 Tested up to: 3.8 Stable tag: 2.3.2 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html This plugin generates as many sidebars as you need. Then allows you to place them on any page you wish. == Description == This plugin generates as many sidebars as you need. Then allows you to place them on any page you wish. **Important info: I'm working for version 3.0 which will support custom sidebars without touching a single line of code. If you want to get acces to first beta, click the following link, subscribe and I will send it to you when it's ready:** http://eepurl.com/QeMOf **Demo video:** https://www.youtube.com/watch?v=fluNdMnSCKA * Author : Smartik - http://smartik.ws/ * License : GPLv2 * Project page and usage instructions: https://github.com/Smartik89/Wordpress-Sidebar-Generator ####Features: * Full AJAX (add, remove, save, validation, etc.) * Drag to sort sidebar position. * Name validation(characters and duplicate). * Display sidebars using WP built-in function, a custom function or a shortcode. * Get registered sidebars anywhere you need them.(theme options, metaboxes, widgets, etc.) ####How to install this plugin? Like any other Wordpress plugin.
Drop `smk-sidebar-generator` to `wp-content/plugins/`.
More info here: http://codex.wordpress.org/Managing_Plugins#Installing_Plugins **Get all sidebars in an array:** Add this function in your theme `functions.php`:
if(! function_exists('smk_get_all_sidebars') ) {
	function smk_get_all_sidebars(){
		global $wp_registered_sidebars;
		$all_sidebars = array();
		if ( $wp_registered_sidebars && ! is_wp_error( $wp_registered_sidebars ) ) {
			
			foreach ( $wp_registered_sidebars as $sidebar ) {
				$all_sidebars[ $sidebar['id'] ] = $sidebar['name'];
			}
			
		}
		return $all_sidebars;
	}
}
Now using this function you can get all sidebars in an array(`[id] => [name]`):
print_r( smk_get_all_sidebars() )
*result of the above code(example)*
array(
  "sidebarID" => "Default Sidebar",
  "anotherID" => "Sidebar Name",
  "smk_sbg_18" => "Sidebar Name 1",
  "smk_sbg_7" => "Sidebar Name Something"
)
*You can output this anywhere in page/post metaboxes, theme options, etc.* *Example with php `foreach`:*
echo '<select>';
  foreach($the_sidebars as $key => $value){
    echo '<option value="'. $key .'">'. $value .'</option>';
  }
echo '</select>';
**Display a sidebar using `smk_sidebar` function:**
if(function_exists('smk_sidebar'){
 smk_sidebar('sidebarID');
}
**Display a sidebar using wp native function:**
if(function_exists('dynamic_sidebar') && dynamic_sidebar('sidebarID')) : 
	endif;
**Display a sidebar using built-in shortcode:**
[smk_sidebar id="sidebarID"]
== Installation == 1. Upload the `smk-sidebar-generator` folder to the `/wp-content/plugins/` directory 2. Activate the SMK Sidebar Generator plugin through the 'Plugins' menu in WordPress 3. Configure the plugin by going to the SMK Sidebars menu that appears in your admin menu == Screenshots == 1. Admin panel == Changelog == = 2.3.2 = * Quick fix UI. When a new sidebar is created, it display an incorect info and it was fixed only after page refresh. * Removed unused files, since version 3.0 is on development `smk_sidebar_metabox.php` was removed, as it was never used and is not required for the next versions. = 2.3.1 = * Quick fix for shortcode smk_sidebar ID. Shortcode did not work because the ID was not set correctly. * Added new tab "How to use?" and links to docs. = 2.3 = * **Added import/export functions.** * Changes to `smk_sidebar` shortcode. Previously to get a sidebar required only an integer number, now you can get any sidebar using the shortcode just giving the id, even if the sidebar is not generated using Sidebar Generator plugin. * Added plugin version to enqueued scripts and style. = 2.2 = * Confirm sidebar remove. * Bug fix: Sidebars could not be added when all previous sidebars were removed. * Bug fix: Fixed ajax name validation. = 2.1.1 = * enqueue styles and scripts only on plugin page, not on all WP dashboard pages. * `admin_enqueue_scripts` make use of `SMK_SBG_URI` constant. = 2.1 = * `smk_get_all_sidebars()` function is included in plugin. Anyways, you must include it in your theme `functions.php`, because if you'll deactivate the plugin it will return a fatal error. = 2.0 = * Initial release