function enlightenment_sidebars_settings()
{
    remove_filter('enlightenment_text_input_args', 'enlightenment_theme_settings_override_value');
    remove_filter('enlightenment_select_box_args', 'enlightenment_theme_settings_override_value');
    add_settings_section('dynamic_sidebars', __('Dynamic Sidebars', 'enlightenment'), '__return_false', 'enlightenment_theme_options');
    $sidebar_options = enlightenment_theme_option('sidebars');
    $sidebars = array();
    if (!empty($sidebar_options)) {
        foreach ($sidebar_options as $sidebar => $atts) {
            $sidebars[] = array('name' => 'sidebars[' . $sidebar . ']', 'atts' => $atts);
        }
    }
    if (!empty($sidebars)) {
        add_settings_field('edit_dynamic_sidebars', __('Edit Dynamic Sidebars', 'enlightenment'), 'enlightenment_edit_dynamic_sidebars', 'enlightenment_theme_options', 'dynamic_sidebars', array('sidebars' => $sidebars));
    }
    global $wp_registered_sidebars;
    $i = count($wp_registered_sidebars);
    // + 1;
    do {
        $i++;
    } while (array_key_exists('sidebar-' . $i, $wp_registered_sidebars));
    add_settings_field('add_dynamic_sidebar', __('Add Dynamic Sidebar', 'enlightenment'), 'enlightenment_add_dynamic_sidebar', 'enlightenment_theme_options', 'dynamic_sidebars', array('name' => 'sidebars[sidebar-' . $i . ']'));
    add_settings_section('sidebar_locations', __('Sidebar Locations', 'enlightenment'), '__return_false', 'enlightenment_theme_options');
    add_settings_field('select_template', __('Select Template to Edit', 'enlightenment'), 'enlightenment_unlimited_sidebars_select_template', 'enlightenment_theme_options', 'sidebar_locations', array('name' => 'select_template', 'class' => 'select-template', 'value' => enlightenment_unlimited_sidebars_current_template()));
    $locations = enlightenment_sidebar_locations();
    $template = enlightenment_unlimited_sidebars_current_template();
    foreach ($locations[$template] as $location => $sidebar) {
        add_settings_field('edit_sidebar_location_' . $location, $sidebar['name'], 'enlightenment_edit_sidebar_location', 'enlightenment_theme_options', 'sidebar_locations', array('name' => 'sidebar_locations[' . $template . '][' . $location . ']', 'value' => $sidebar['sidebar'], 'description' => ''));
    }
}
Exemplo n.º 2
0
function enlightenment_sidebars_settings()
{
    remove_filter('enlightenment_text_input_args', 'enlightenment_theme_settings_override_value');
    remove_filter('enlightenment_select_box_args', 'enlightenment_theme_settings_override_value');
    if (!isset($_GET['template'])) {
        if (!isset($_GET['sidebar'])) {
            $sidebar_options = enlightenment_theme_option('sidebars');
            $sidebars = array();
            if (!empty($sidebar_options)) {
                add_settings_section('edit_dynamic_sidebars', __('Edit Dynamic Sidebars', 'enlightenment'), '__return_false', 'enlightenment_theme_options');
                foreach ($sidebar_options as $sidebar => $atts) {
                    add_settings_field('edit_dynamic_' . $sidebar, $atts['name'], 'enlightenment_edit_dynamic_sidebar_buttons', 'enlightenment_theme_options', 'edit_dynamic_sidebars', array('name' => $sidebar, 'atts' => $atts));
                }
            }
        }
        if (isset($_GET['sidebar'])) {
            $sidebar = esc_attr($_GET['sidebar']);
            $sidebar_options = enlightenment_theme_option('sidebars');
            $atts = array_merge(enlightenment_registered_sidebars_default_atts(), $sidebar_options[$sidebar]);
        } else {
            global $wp_registered_sidebars;
            $i = count($wp_registered_sidebars);
            // + 1;
            do {
                $i++;
            } while (array_key_exists('sidebar-' . $i, $wp_registered_sidebars));
            $sidebar = 'sidebar-' . $i;
            $atts = enlightenment_registered_sidebars_default_atts();
            $atts['name'] = '';
        }
        add_settings_section('add_dynamic_sidebar', isset($_GET['sidebar']) ? __('Edit Dynamic Sidebar', 'enlightenment') : __('Add Dynamic Sidebar', 'enlightenment'), '__return_false', 'enlightenment_theme_options');
        add_settings_field('sidebar_name', __('Sidebar Title', 'enlightenment'), 'enlightenment_text_input', 'enlightenment_theme_options', 'add_dynamic_sidebar', array('name' => 'sidebars[' . $sidebar . '][name]', 'value' => $atts['name']));
        add_settings_field('display_title', __('Display Sidebar Title', 'enlightenment'), 'enlightenment_checkbox', 'enlightenment_theme_options', 'add_dynamic_sidebar', array('name' => 'sidebars[' . $sidebar . '][display_title]', 'label' => __('Show Title in Sidebar', 'enlightenment'), 'checked' => $atts['display_title']));
        add_settings_field('sidebar_description', __('Sidebar Description', 'enlightenment'), 'enlightenment_textarea', 'enlightenment_theme_options', 'add_dynamic_sidebar', array('name' => 'sidebars[' . $sidebar . '][description]', 'value' => $atts['description']));
        add_settings_field('display_description', __('Display Sidebar Description', 'enlightenment'), 'enlightenment_checkbox', 'enlightenment_theme_options', 'add_dynamic_sidebar', array('name' => 'sidebars[' . $sidebar . '][display_description]', 'label' => __('Show Description in Sidebar', 'enlightenment'), 'checked' => $atts['display_description']));
        if (current_theme_supports('enlightenment-grid-loop')) {
            add_settings_field('grid', __('Sidebar Grid', 'enlightenment'), 'enlightenment_dynamic_sidebar_grid', 'enlightenment_theme_options', 'add_dynamic_sidebar', array('name' => 'sidebars[' . $sidebar . '][grid]', 'value' => $atts['grid']));
        }
        if (current_theme_supports('enlightenment-bootstrap')) {
            add_settings_field('contain_widgets', __('Contain Widgets', 'enlightenment'), 'enlightenment_checkbox', 'enlightenment_theme_options', 'add_dynamic_sidebar', array('name' => 'sidebars[' . $sidebar . '][contain_widgets]', 'label' => __('Center widgets in a fixed-width wrapper', 'enlightenment'), 'checked' => $atts['contain_widgets']));
        }
        add_settings_field('sidebar_background', __('Sidebar Background', 'enlightenment'), 'enlightenment_background_options', 'enlightenment_theme_options', 'add_dynamic_sidebar', array('name' => 'sidebars[' . $sidebar . '][background]', 'value' => $atts['background'], 'description' => __('When Transparent is checked, the value passed to background color will be ignored.', 'enlightenment')));
        add_settings_field('sidebar_title_color', __('Sidebar Title Color', 'enlightenment'), 'enlightenment_color_picker', 'enlightenment_theme_options', 'add_dynamic_sidebar', array('name' => 'sidebars[' . $sidebar . '][sidebar_title_color]', 'value' => $atts['sidebar_title_color'], 'description' => __('For sidebars with a background image it is recommended to set the title color to white.', 'enlightenment')));
        add_settings_field('sidebar_text_color', __('Sidebar Text Color', 'enlightenment'), 'enlightenment_color_picker', 'enlightenment_theme_options', 'add_dynamic_sidebar', array('name' => 'sidebars[' . $sidebar . '][sidebar_text_color]', 'value' => $atts['sidebar_text_color'], 'description' => __('For sidebars with a background image it is recommended to set the text color to white.', 'enlightenment')));
        add_settings_field('widgets_background_color', __('Widgets Background Color', 'enlightenment'), 'enlightenment_color_picker', 'enlightenment_theme_options', 'add_dynamic_sidebar', array('name' => 'sidebars[' . $sidebar . '][widgets_background_color]', 'value' => $atts['widgets_background_color'], 'transparent' => true, 'description' => __('When Transparent is checked, the value passed to background color will be ignored.', 'enlightenment')));
        add_settings_field('widgets_title_color', __('Widgets Headings Color', 'enlightenment'), 'enlightenment_color_picker', 'enlightenment_theme_options', 'add_dynamic_sidebar', array('name' => 'sidebars[' . $sidebar . '][widgets_title_color]', 'value' => $atts['widgets_title_color']));
        add_settings_field('widgets_text_color', __('Widgets Text Color', 'enlightenment'), 'enlightenment_color_picker', 'enlightenment_theme_options', 'add_dynamic_sidebar', array('name' => 'sidebars[' . $sidebar . '][widgets_text_color]', 'value' => $atts['widgets_text_color']));
        add_settings_field('widgets_link_color', __('Widgets Link Color', 'enlightenment'), 'enlightenment_color_picker', 'enlightenment_theme_options', 'add_dynamic_sidebar', array('name' => 'sidebars[' . $sidebar . '][widgets_link_color]', 'value' => $atts['widgets_link_color']));
    }
    if (!isset($_GET['sidebar'])) {
        add_settings_section('sidebar_locations', __('Sidebar Locations', 'enlightenment'), '__return_false', 'enlightenment_theme_options');
        add_settings_field('select_template', __('Select Template to Edit', 'enlightenment'), 'enlightenment_unlimited_sidebars_select_template', 'enlightenment_theme_options', 'sidebar_locations', array('name' => 'select_template', 'class' => 'select-template', 'value' => enlightenment_unlimited_sidebars_current_template()));
        $locations = enlightenment_sidebar_locations();
        $template = enlightenment_unlimited_sidebars_current_template();
        foreach ($locations[$template] as $location => $sidebar) {
            add_settings_field('edit_sidebar_location_' . $location, $sidebar['name'], 'enlightenment_edit_sidebar_location', 'enlightenment_theme_options', 'sidebar_locations', array('name' => 'sidebar_locations[' . $template . '][' . $location . ']', 'value' => $sidebar['sidebar'], 'description' => ''));
        }
    }
}