function options() { global $zn_framework; $sidebars = array('default_sidebar' => 'Default Sidebar'); // Add the unlimited sidebars $unlimited_sidebars_op = zget_option('unlimited_sidebars', 'unlimited_sidebars'); if (is_array($unlimited_sidebars_op)) { foreach ($unlimited_sidebars_op as $key => $value) { $sidebars[zn_sanitize_widget_id($value['sidebar_name'])] = $value['sidebar_name']; } } $options = array(array('id' => 'sidebar', 'name' => 'Select sidebar', 'description' => 'Select which sidebar you wish to use', 'type' => 'select', 'std' => 'default_sidebar', 'options' => $sidebars)); return $options; }
<?php global $zn_framework; $zn_meta_locations = array(array('title' => 'Page Options', 'slug' => 'post_options', 'page' => array('post'), 'context' => 'side', 'priority' => 'default'), array('title' => 'Page Options', 'slug' => 'page_options', 'page' => array('page'), 'context' => 'side', 'priority' => 'default'), array('title' => 'Page Options', 'slug' => 'portfolio_options', 'page' => array('portfolio'), 'context' => 'side', 'priority' => 'default')); // Page description $zn_meta_elements[] = array("slug" => array('page_options'), "name" => "Page description", "description" => "Please enter a description for your page/post", "id" => "zn_page_subtitle", "std" => "", "type" => "text", "class" => 'zn_full'); // Wich sidebar position $zn_meta_elements[] = array("slug" => array('page_options', 'portfolio_options', 'post_options'), "name" => "Sidebar Layout", "description" => "Please select the sidebar layout you want to use.", "id" => "zn_page_sidebar_layout", "std" => "defaut", "type" => "select", "options" => array('default' => 'Set in theme options', 'sidebar_left' => 'Left sidebar', 'sidebar_right' => 'Right sidebar', 'no_sidebar' => 'No sidebar'), "class" => 'zn_full'); // Which sidebar to display $sidebars = array('' => 'Set in theme options', 'default_sidebar' => 'Default Sidebar'); // Add the unlimited sidebars $unlimited_sidebars = zget_option('unlimited_sidebars', 'unlimited_sidebars'); if (is_array($unlimited_sidebars)) { foreach ($unlimited_sidebars as $key => $value) { $sidebars[zn_sanitize_widget_id($value['sidebar_name'])] = $value['sidebar_name']; } } $zn_meta_elements[] = array("slug" => array('page_options', 'portfolio_options', 'post_options'), "name" => "Sidebar to use?", "description" => "Please select the sidebar that you want to use. You can create unlimited sidebars from the admin panel.", "id" => "zn_page_sidebar_select", "std" => "defaut", "type" => "select", "options" => $sidebars, "class" => 'zn_full'); $zn_meta_elements[] = array("slug" => array('page_options', 'portfolio_options', 'post_options'), "name" => "Header image", "description" => "Select an image that will be used as the header image. If no image is selected, the default image will be used.", "id" => "header_media_image", "std" => "", "type" => "media", "class" => 'zn_full'); /* PORTFOLIO MEDIA */ $zn_meta_elements[] = array("slug" => array('page_options'), 'id' => 'page_icon', 'name' => 'Select the icon for this page', 'description' => 'This icon will show after the header.', 'type' => 'icon_list', 'modal' => true, 'std' => array('unicode' => 'ue871', 'family' => 'eleganticons')); $zn_meta_elements[] = array("slug" => array('page_options', 'portfolio_options', 'post_options'), 'id' => 'show_footer', 'name' => 'Show footer', 'description' => 'Choose if you want to show the main footer or not on this page. ', 'type' => 'toggle2', 'std' => 'show_footer', 'value' => 'show_footer', "class" => 'zn_full'); // Show oblique cut on footer ? $zn_meta_elements[] = array("slug" => array('page_options', 'portfolio_options', 'post_options'), "name" => "Use oblique style on footer?", "description" => "Select yes if you want to use the oblique style on footer on this page.", "id" => "zn_page_oblique_footer", "std" => '', "type" => "select", "options" => array('' => 'Set in theme options', 'yes' => 'Yes', 'no' => 'No'), "class" => 'zn_full', 'dependency' => array('element' => 'show_footer', 'value' => array('show_footer'))); // Use dark footer style? $newStyles = array('' => 'Set in theme options', 'defaultStyle' => 'Default Style'); $old = $zn_framework->unlimited_styles; unset($old['']); $newStyles = array_merge($newStyles, $old); $zn_meta_elements[] = array("slug" => array('page_options', 'portfolio_options', 'post_options'), "name" => "Override footer style", "description" => "You can choose to override the footer color style set in theme options.", "id" => "zn_page_footer_style", "std" => "sto", "type" => "select", "options" => $newStyles, "class" => 'zn_full', 'dependency' => array('element' => 'show_footer', 'value' => array('show_footer'))); //** Show footer widgets
/** * Register theme sidebars * @hooked to widgets_init * @since 4.0.0 */ function wpkRegisterSidebars() { if (function_exists('register_sidebar')) { /** * Default sidebar */ register_sidebar(array('name' => 'Default Sidebar', 'id' => 'defaultsidebar', 'description' => esc_html__("This is the default sidebar. You can choose from the theme's options page where\n the widgets from this sidebar will be shown.", 'zn_framework'), 'before_widget' => '<div id="%1$s" class="widget zn-sidebar-widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widgettitle zn-sidebar-widget-title title">', 'after_title' => '</h3>')); /** * Hidden Panel sidebar */ register_sidebar(array('name' => 'Hidden Panel Sidebar', 'id' => 'hiddenpannelsidebar', 'description' => esc_html__("This is the sidebar for the hidden panel in the header. You can choose from the\n theme's options page where the widgets from this sidebar will be shown.", 'zn_framework'), 'before_widget' => '<div id="%1$s" class="widget support-panel-widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widgettitle title support-panel-widgettitle">', 'after_title' => '</h3>')); // Footer sidebar 1 $footer_row1_widget_positions = zget_option('footer_row1_widget_positions', 'general_options', false, '{"3":[["4","4","4"]]}'); $f_row1 = key(json_decode(stripslashes($footer_row1_widget_positions))); if ($f_row1 > 1) { register_sidebars($f_row1, array('name' => 'Footer row 1 - widget %d', 'id' => "znfooter", 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widgettitle title m_title m_title_ext text-custom">', 'after_title' => '</h3>')); } else { register_sidebars(1, array('name' => 'Footer row 1 - widget 1', 'id' => "znfooter", 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widgettitle title m_title m_title_ext text-custom">', 'after_title' => '</h3>')); } // Footer sidebar 2 $footer_row2_widget_positions = zget_option('footer_row2_widget_positions', 'general_options', false, '{"3":[["4","4","4"]]}'); $f_row1 = key(json_decode(stripslashes($footer_row2_widget_positions))); if ($f_row1 > 1) { register_sidebars($f_row1, array('name' => 'Footer row 2 - widget %d', 'id' => "znfooter", 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widgettitle title m_title m_title_ext text-custom">', 'after_title' => '</h3>')); } else { register_sidebars(1, array('name' => 'Footer row 2 - widget 1', 'id' => "znfooter", 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widgettitle title m_title m_title_ext text-custom">', 'after_title' => '</h3>')); } // global $wp_registered_sidebars; // Dynamic sidebars if ($unlimited_sidebars = zget_option('unlimited_sidebars', 'unlimited_sidebars')) { foreach ($unlimited_sidebars as $sidebar) { if ($sidebar['sidebar_name']) { // $i = count($wp_registered_sidebars) + 1; register_sidebar(array('name' => $sidebar['sidebar_name'], 'id' => zn_sanitize_widget_id($sidebar['sidebar_name']), 'before_widget' => '<div id="%1$s" class="widget zn-sidebar-widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widgettitle zn-sidebar-widget-title title">', 'after_title' => '</h3>')); } } } } }
function zn_register_sidebars() { // Register the default sidebar register_sidebar(array('name' => 'Default Sidebar', 'id' => zn_sanitize_widget_id('Default Sidebar'), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title underline">', 'after_title' => '</h3>')); // Register unlimited sidebars if ($sidebars = zget_option('unlimited_sidebars', 'unlimited_sidebars')) { if (is_array($sidebars)) { foreach ($sidebars as $sidebar) { if ($sidebarname = $sidebar['sidebar_name']) { register_sidebar(array('name' => $sidebarname, 'id' => zn_sanitize_widget_id($sidebarname), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title underline">', 'after_title' => '</h3>')); } } } } //Register Footer Columns if ($footer_columns = zget_option('footer_columns', 'general_options')) { if ($footer_columns > 1) { $args = array('name' => 'Footer - widget %d', 'id' => 'znfooter', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'); register_sidebars($footer_columns, $args); } else { $args = array('name' => 'Footer - widget 1', 'id' => "znfooter", 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'); register_sidebars(1, $args); } } }
function sidebar($value) { // Get unlimited sidebars only once if (empty($this->sidebars)) { $sidebars = array(); // Add the unlimited sidebars $unlimited_sidebars = zget_option('unlimited_sidebars', 'unlimited_sidebars'); if (is_array($unlimited_sidebars)) { foreach ($unlimited_sidebars as $key => $sidebar) { $sidebars[zn_sanitize_widget_id($sidebar['sidebar_name'])] = $sidebar['sidebar_name']; } } $this->sidebars = $sidebars; } if (!empty($value['supports']['default_sidebar'])) { $sidebars = array($value['supports']['default_sidebar'] => 'Default Sidebar'); } else { $sidebars = array('default_sidebar' => 'Default Sidebar'); } if (is_array($this->sidebars)) { $sidebars = array_merge($sidebars, $this->sidebars); } // Override default sidebar options if (!empty($value['supports']['sidebar_options'])) { $sidebar_options = $value['supports']['sidebar_options']; } else { $sidebar_options = array('sidebar_right' => 'Right sidebar', 'sidebar_left' => 'Left sidebar', 'no_sidebar' => 'No sidebar'); } if (!is_array($value['std'])) { $value['std'] = array(); } if (!isset($value['std']['layout'])) { $value['std']['layout'] = ''; } if (!isset($value['std']['sidebar']) || empty($value['std']['sidebar'])) { $value['std']['sidebar'] = ''; } // Sidebar layout $output = '<label for="' . $value['id'] . '_layout">Sidebar layout</label><select class="select zn_input" name="' . $value['id'] . '[layout]" id="' . $value['id'] . '_layout">'; foreach ($sidebar_options as $select_ID => $option) { $output .= '<option id="' . $select_ID . '" value="' . $select_ID . '" ' . selected($value['std']['layout'], $select_ID, false) . ' >' . $option . '</option>'; } $output .= '</select>'; // Sidebar select $output .= '<label for="' . $value['id'] . '_sidebar">Sidebar select</label><select class="select zn_input" name="' . $value['id'] . '[sidebar]" id="' . $value['id'] . '_sidebar">'; foreach ($sidebars as $select_ID => $option) { $output .= '<option id="' . $select_ID . '" value="' . $select_ID . '" ' . selected($value['std']['sidebar'], $select_ID, false) . ' >' . $option . '</option>'; } $output .= '</select>'; return $output; }
function zn_cnv_repare_sidebars() { global $wp_registered_sidebars; $our_sidebars = false; $old_sidebar_config = wp_get_sidebars_widgets(); $sidebars_mapping = array(); $unlimited_sidebars = zget_option('unlimited_sidebars', 'unlimited_sidebars'); $unlimited_sidebars_num = count($unlimited_sidebars); $i = 1; // Check to see if we actually need to convert the sidebars id's if ($unlimited_sidebars_num == 0 || empty($old_sidebar_config) || empty($unlimited_sidebars)) { return false; } foreach ($old_sidebar_config as $key => $value) { if ($key == 'hiddenpannelsidebar') { $our_sidebars = true; continue; } // We reached our sidebars, now we need to see if we have footer sidebars if (strpos($key, 'znfooter') === 0) { $our_sidebars = true; continue; } // We've reached the unlimited sidebars if ($our_sidebars && strpos($key, 'sidebar-') == 0 && $i <= $unlimited_sidebars_num) { if (!empty($unlimited_sidebars[$i - 1])) { $new_id = zn_sanitize_widget_id($unlimited_sidebars[$i - 1]['sidebar_name']); $old_sidebar_config[$new_id] = $value; $sidebars_mapping[$key] = $new_id; // unset( $unlimited_sidebars[ $sidebar_id ] ); unset($old_sidebar_config[$key]); } $i++; } else { // we converted all our sidebars continue; } } // Save the new config wp_set_sidebars_widgets($old_sidebar_config); // Fix theme mod $master_theme_config = get_option('theme_mods_kallyas'); $new_sidebar_config = array(); if (!empty($master_theme_config['sidebars_widgets']['data'])) { $master_theme_config['sidebars_widgets']['data'] = $old_sidebar_config; } update_option('theme_mods_kallyas', $master_theme_config); // Fix for child themes $old_sidebars_widgets = get_theme_mod('sidebars_widgets'); if (!empty($child_sidebar_config['data'])) { set_theme_mod('sidebars_widgets', $old_sidebar_config); } }