Last active
December 1, 2015 11:51
-
-
Save Firestorm-Graphics/2911578 to your computer and use it in GitHub Desktop.
Dynamic sidebars for use with ( custom metaboxes & fields for wordpress, https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress) along with smof options panel or options far,work by devin - Allows you to select how many automatically generated sidebars you want & select the sidebar of your choice per page from a metabox (cmb meta…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Author: Dan Beaven | |
* Company: Firestorm Graphics | |
* Web: http://firestorm-graphics.com | |
*/ | |
* Released under the GPL license | |
* http://www.opensource.org/licenses/gpl-license.php | |
* | |
* This is an add-on for WordPress | |
* http://wordpress.org/ | |
* | |
* ********************************************************************** | |
* This program is free software; you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation; either version 2 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
* ********************************************************************** | |
*/ | |
// Add this to the top near the declaration for categories | |
$of_sidebars = array(); | |
$of_sidebars_obj = $GLOBALS['wp_registered_sidebars']; | |
foreach ($of_sidebars_obj as $option) | |
{ | |
$of_sidebars[$option['id']] = $option['name']; | |
} | |
$sidebars_tmp = array_unshift($of_sidebars, "Select a sidebar:"); | |
// Then add this to your field types and change id to your preference | |
$of_options[] = array( "name" => __("Sidebar", THEMENAME), | |
"desc" => "Select your sidebar of choice.", | |
"id" => "alt-sidebar", | |
"std" => "", | |
"type" => "select", | |
"options" => "$of_sidebars); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Author: Dan Beaven | |
* Company: Firestorm Graphics | |
* Web: http://firestorm-graphics.com | |
*/ | |
* Released under the GPL license | |
* http://www.opensource.org/licenses/gpl-license.php | |
* | |
* This is an add-on for WordPress | |
* http://wordpress.org/ | |
* | |
* ********************************************************************** | |
* This program is free software; you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation; either version 2 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
* ********************************************************************** | |
*/ | |
//:: This is for use with optionsframework by devin - place in your functions.php file. | |
//:: This registers a default sidebar and then pulls the set amount of sidebars set in the theme options. | |
//:: Dont forget to change widget class's to suit your theme. | |
//:: Credit to us appreciated | |
global $wpdb; | |
// Default Sidebar | |
if ( function_exists('register_sidebar') ) { | |
$default_sidebar = array('Default Sidebar'); | |
foreach ($default_sidebar as $side) { | |
register_sidebar(array( | |
'name' => $side, | |
'id' => 'sidebar', | |
'description' => __('Widgets in this area will be shown in the default Sidebar', FIRE_THEMENAME ), | |
'before_widget' => '<aside id="%1$s" class="widget %2$s well col-md-12">', | |
'after_widget' => '</aside>', | |
'before_title' => '<h4 class="widget-title">', | |
'after_title' => '</h4><hr>', | |
)); | |
} | |
} | |
$sidebar_default = ( get_option( 'fire_sidebars_num' ) != '' ) ? get_option( 'fire_sidebars_num' ) : '2'; | |
$sidebars_num = ( of_get_option('fire_sidebars_num') !='' ) ? of_get_option('fire_sidebars_num') : $sidebar_default; | |
// Custom Sidebar Columns | |
$i=1; | |
while( $i <= $sidebars_num ) | |
{ | |
if ( function_exists('register_sidebar') ) | |
{ | |
register_sidebar( | |
array( | |
'name' => __('Sidebar '.$i, 'YOURTHEME'), | |
'id' => 'sidebar'.$i, | |
'description' => __('Widgets in this area will be shown in Sidebar '.$i.'.', 'YOURTHEME' ), | |
'before_widget' => '<aside id="%1$s" class="widget %2$s well col-md-12">', | |
'after_widget' => '</aside>', | |
'before_title' => '<h4 class="widget-title">', | |
'after_title' => '</h4><hr>', | |
)); | |
} | |
$i++; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Author: Dan Beaven | |
* Company: Firestorm Graphics | |
* Web: http://firestorm-graphics.com | |
*/ | |
* Released under the GPL license | |
* http://www.opensource.org/licenses/gpl-license.php | |
* | |
* This is an add-on for WordPress | |
* http://wordpress.org/ | |
* | |
* ********************************************************************** | |
* This program is free software; you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation; either version 2 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
* ********************************************************************** | |
*/ | |
global $data, $num_sidebars; | |
$get_sidebar_num = $data['sidebar_num']; // pull sidebar qty from smof field with id "sidebar_num" | |
if($get_sidebar_num !="") { | |
$num_sidebars = $data['sidebar_num']; // Check if number of Sidebars is defined. | |
} | |
else { | |
$num_sidebars="2"; // If not then generate default of 2 | |
} | |
$i=1; | |
while($i<=$num_sidebars) | |
{ | |
if ( function_exists('register_sidebar')) { | |
register_sidebar(array('name'=>'sidebar-'.$i, // sidebar- name is sidebar plus a number | |
'before_widget' => '<article id="%1$s" class="row widget %2$s"><div class="sidebar-section eleven columns centered">', | |
'after_widget' => '</div></article><div class="clearfix"></div>', | |
'before_title' => '<h3><div class="sidebar-title"><strong>', | |
'after_title' => '</strong></div></h3>', | |
)); | |
}// end if statement | |
$i++; | |
} // end while |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Author: Dan Beaven | |
* Company: Firestorm Graphics | |
* Web: http://firestorm-graphics.com | |
*/ | |
* Released under the GPL license | |
* http://www.opensource.org/licenses/gpl-license.php | |
* | |
* This is an add-on for WordPress | |
* http://wordpress.org/ | |
* | |
* ********************************************************************** | |
* This program is free software; you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation; either version 2 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
* ********************************************************************** | |
*/ | |
// this is the select field for the custom metabox see for the script i refer to as cmb (https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress) | |
array( | |
'name' => 'Select Sidebar', | |
'desc' => 'Select your prefered widgetized sidebar to display.', | |
'id' => $prefix . '_sidebar_select', | |
'type' => 'sidebar_select', | |
'std' => '', | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Author: Dan Beaven | |
* Company: Firestorm Graphics | |
* Web: http://firestorm-graphics.com | |
*/ | |
* Released under the GPL license | |
* http://www.opensource.org/licenses/gpl-license.php | |
* | |
* This is an add-on for WordPress | |
* http://wordpress.org/ | |
* | |
* ********************************************************************** | |
* This program is free software; you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation; either version 2 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
* ********************************************************************** | |
*/ | |
// PLace this in the options.php file in options framework | |
//:: Sidebars | |
$options[] = array( | |
'name' => __('Number of Sidebars', 'options_framework_theme'), | |
"desc" => __('Select qty sidebars', 'options_framework_theme'), | |
'plac' => __('Default is 2 sidebars', 'options_framework_theme'), | |
'tooltip' => __('Slide to your desired option.','options_framework_theme'), | |
'id' => $shortname.'_sidebars_num', | |
'std' => '', | |
'type' => 'text' | |
); |
- i think there is something missing
nothing missing, and working well for me in several themes, used it with cmb metaboxes along with both smof and options framework
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how it will working
if we select sidebar in both side (smof and cmb) so where we add our sidebar i think where is something missing