. */ class sidebar_generator { function sidebar_generator(){ add_action('init',array('sidebar_generator','init')); add_action('admin_menu',array('sidebar_generator','admin_menu')); add_action('admin_print_scripts', array('sidebar_generator','admin_print_scripts')); add_action('wp_ajax_add_sidebar', array('sidebar_generator','add_sidebar') ); add_action('wp_ajax_remove_sidebar', array('sidebar_generator','remove_sidebar') ); } function init(){ //go through each sidebar and register it $sidebars = sidebar_generator::get_sidebars(); if(is_array($sidebars)){ foreach($sidebars as $sidebar){ $sidebar_class = sidebar_generator::name_to_class($sidebar); register_sidebar(array( 'name'=>$sidebar, 'before_widget' => '', 'before_title' => '
', )); } } } function admin_print_scripts(){ wp_print_scripts( array( 'sack' )); ?> Remove]'); //cellLeft.appendChild(textNode) var cellLeft = row.insertCell(2); removeLink = document.createElement('a'); linkText = document.createTextNode('remove'); removeLink.setAttribute('onclick', 'remove_sidebar_link(\'$name\')'); removeLink.setAttribute('href', 'javacript:void(0)'); removeLink.appendChild(linkText); cellLeft.appendChild(removeLink); "; die( "$js"); } function remove_sidebar(){ $sidebars = sidebar_generator::get_sidebars(); $name = str_replace(array("\n","\r","\t"),'',$_POST['sidebar_name']); $id = sidebar_generator::name_to_class($name); if(!isset($sidebars[$id])){ die("alert('Sidebar does not exist.')"); } $row_number = $_POST['row_number']; unset($sidebars[$id]); sidebar_generator::update_sidebars($sidebars); $js = " var tbl = document.getElementById('sbg_table'); tbl.deleteRow($row_number) "; die($js); } function admin_menu(){ add_theme_page('Sidebars', 'Sidebars', 'manage_options', 'multiple_sidebars', array('sidebar_generator','admin_page')); } function admin_page(){ ?>The sidebar name is for your use only. It will not be visible to any of your visitors. A CSS class is assigned to each of your sidebar, use this styling to customize the sidebars.
Name | CSS class | Remove |
---|---|---|
remove | ||
No Sidebars defined |