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' => ''));
        }
    }
}
Beispiel #2
0
function enlightenment_unlimited_sidebars_print_theme_css($output)
{
    $sidebars = enlightenment_registered_sidebars();
    $defaults = enlightenment_registered_sidebars_default_atts();
    $default_bg = $defaults['widgets_background_color'];
    foreach ($sidebars as $sidebar => $atts) {
        if ($default_bg != $atts['widgets_background_color']) {
            $output .= sprintf(".custom-%s .widget {\n", $sidebar);
            $output .= "\tpadding-left: 20px;\n";
            $output .= "\tpadding-right: 20px;\n";
            $output .= "\tmargin-top: 15px;\n";
            $output .= "\tmargin-bottom: 15px;\n";
            $output .= "\tborder-radius: 2px;\n";
            $output .= "}\n";
        }
        if ('parallax' == $atts['background']['scroll']) {
            $output .= sprintf(".custom-%s {\n", $sidebar);
            $output .= "\tposition: relative;\n";
            $output .= "\toverflow: hidden;\n";
            $output .= "}\n";
        }
    }
    return $output;
}
function enlightenment_unlimited_sidebars_print_background_color_option_settings_defaults($color, $selector, $option)
{
    $default_options = enlightenment_default_theme_options();
    $default_sidebars = isset($default_options['sidebars']) ? $default_options['sidebars'] : array();
    if (array_key_exists($option, $default_sidebars)) {
        $color = $default_sidebars[$option]['widgets_background_color'];
    } else {
        $defaults = enlightenment_registered_sidebars_default_atts();
        $color = $defaults['widgets_background_color'];
    }
    return $color;
}