/** * Format Configuration Array. * * Get an array of all default values as set in * options.php. The 'id','std' and 'type' keys need * to be defined in the configuration array. In the * event that these keys are not present the option * will not be included in this function's output. * * @return array Rey-keyed options configuration array. * * @access private */ function of_get_default_values() { $output = array(); $config = combined_option_array(); foreach ( (array) $config as $option ) { if ( ! isset( $option['id'] ) ) { continue; } if ( ! isset( $option['std'] ) ) { continue; } if ( ! isset( $option['type'] ) ) { continue; } if ( has_filter( 'of_sanitize_' . $option['type'] ) ) { $output[$option['id']] = apply_filters( 'of_sanitize_' . $option['type'], $option['std'], $option ); } } do_action( 'optionsframework_after_validate' ); return $output; }
/** * Generates the options fields that are used in the form. */ function optionsframework_fields() { global $allowedtags; $optionsframework_settings = get_option('optionsframework'); // Gets the unique option id if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'optionsframework'; } $settings = get_option($option_name); $options = combined_option_array(); $counter = 0; $menu = ''; foreach ($options as $value) { $counter++; $val = ''; $select_value = ''; $checked = ''; $output = ''; // Wrap all options if ($value['type'] != "heading" && $value['type'] != "info") { // Keep all ids lowercase with no spaces $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['id'])); $id = 'section-' . $value['id']; $class = 'section '; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n"; if (isset($value['name'])) { $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; } if ($value['type'] != 'editor') { $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n"; } else { $output .= '<div class="option">' . "\n" . '<div>' . "\n"; } } // Set default value to $val if (isset($value['std'])) { $val = $value['std']; } // If the option is already saved, ovveride $val if ($value['type'] != 'heading' && $value['type'] != 'info') { if (isset($settings[$value['id']])) { $val = $settings[$value['id']]; // Striping slashes of non-array options if (!is_array($val)) { $val = stripslashes($val); } } } // If there is a description save it for labels $explain_value = ''; if (isset($value['desc'])) { $explain_value = $value['desc']; } switch ($value['type']) { // Basic text input case 'text': $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '" />'; break; // Textarea // Textarea case 'textarea': $rows = '8'; if (isset($value['settings']['rows'])) { $custom_rows = $value['settings']['rows']; if (is_numeric($custom_rows)) { $rows = $custom_rows; } } $val = stripslashes($val); $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" rows="' . $rows . '">' . $val . '</textarea>'; break; // Select Box // Select Box case $value['type'] == 'select': $output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">'; foreach ($value['options'] as $key => $option) { $selected = ''; if ($val != '') { if ($val == $key) { $selected = ' selected="selected"'; } } $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>'; } $output .= '</select>'; break; // Radio Box // Radio Box case "radio": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $id = $option_name . '-' . $value['id'] . '-' . $key; $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_attr($key) . '" ' . checked($val, $key, false) . ' /><label for="' . esc_attr($id) . '">' . esc_html($option) . '</label>'; } break; // Image Selectors // Image Selectors case "images": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $selected = ''; $checked = ''; if ($val != '') { if ($val == $key) { $selected = ' of-radio-img-selected'; $checked = ' checked="checked"'; } } $output .= '<div class="img_wrapper">'; $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . $checked . ' />'; $output .= '<div class="of-radio-img-label">' . esc_html($key) . '</div>'; $output .= '<img src="' . esc_url($option) . '" alt="' . $option . '" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;" />'; if (array_key_exists('title', $value)) { $output .= '<div class="img_title">' . $value['title'][$key] . '</div>'; } $output .= '</div>'; } break; // Checkbox // Checkbox case "checkbox": $output .= '<input id="' . esc_attr($value['id']) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' />'; $output .= '<label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>'; break; // Multicheck // Multicheck case "multicheck": foreach ($value['options'] as $key => $option) { $checked = ''; $label = $option; $option = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($key)); $id = $option_name . '-' . $value['id'] . '-' . $option; $name = $option_name . '[' . $value['id'] . '][' . $option . ']'; if (isset($val[$option])) { $checked = checked($val[$option], 1, false); } if ($label == "") { $label = theme_locals('no_lable'); } $output .= '<input id="' . esc_attr($id) . '" class="checkbox of-input" type="checkbox" value="' . $option . '" name="' . esc_attr($name) . '" ' . $checked . ' /><label for="' . esc_attr($id) . '">' . esc_html($label) . '</label>'; } break; // Color picker // Color picker case "color": $output .= '<div id="' . esc_attr($value['id'] . '_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $val) . '"></div></div>'; $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" type="text" value="' . esc_attr($val) . '" />'; break; // Uploader // Uploader case "upload": $output .= optionsframework_medialibrary_uploader($value['id'], $val, null); break; // Typography // Typography case 'typography': unset($font_size, $font_lineheight, $font_style, $font_face, $font_character, $font_color); $typography_defaults = array('size' => '', 'face' => '', 'character' => '', 'style' => '', 'lineheight' => '', 'color' => ''); $typography_stored = wp_parse_args($val, $typography_defaults); $typography_options = array('sizes' => of_recognized_font_sizes(), 'faces' => of_recognized_font_faces(), 'characters' => of_recognized_font_characters(), 'styles' => of_recognized_font_styles(), 'lineheight' => of_recognized_font_sizes(), 'color' => true); if (isset($value['options'])) { $typography_options = wp_parse_args($value['options'], $typography_options); } // Font Size if ($typography_options['sizes']) { $font_size = '<div class="field"><label for="of-typography-size">' . theme_locals('font_size') . '</label>'; $font_size .= '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">'; $sizes = $typography_options['sizes']; foreach ($sizes as $i) { $size = $i . 'px'; $font_size .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>'; } $font_size .= '</select></div>'; } // Lineheights if ($typography_options['lineheight']) { $font_lineheight = '<div class="field"><label for="of-typography-lineheight">' . theme_locals('lineheight') . '</label>'; $font_lineheight .= '<select class="of-typography of-typography-lineheight" name="' . $option_name . '[' . $value['id'] . '][lineheight]" id="' . $value['id'] . '_style">'; $lineheights = $typography_options['lineheight']; foreach ($lineheights as $i) { $lineheight = $i . 'px'; $font_lineheight .= '<option value="' . esc_attr($lineheight) . '" ' . selected($typography_stored['lineheight'], $lineheight, false) . '>' . esc_html($lineheight) . '</option>'; } $font_lineheight .= '</select></div>'; } // Font Face if ($typography_options['faces']) { $font_face = '<div class="field"><label for="of-typography-face">' . theme_locals('font_face') . '</label>'; $font_face .= '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">'; $faces = $typography_options['faces']; foreach ($faces as $key => $face) { $font_face .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>'; } $font_face .= '</select></div>'; } // Font Character Sets if ($typography_options['characters']) { $font_character = '<div class="field"><label for="of-typography-character">' . theme_locals('character_sets') . '</label>'; $font_character .= '<select class="of-typography of-typography-character" name="' . $option_name . '[' . $value['id'] . '][character]" id="' . $value['id'] . '_character">'; $characters = $typography_options['characters']; foreach ($characters as $key => $character) { $font_character .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['character'], $key, false) . '>' . $character . '</option>'; } $font_character .= '</select></div>'; } // Font Styles if ($typography_options['styles']) { $font_style = '<div class="field"><label for="of-typography-style">' . theme_locals('font_style') . '</label>'; $font_style .= '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">'; $styles = $typography_options['styles']; foreach ($styles as $key => $style) { $font_style .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['style'], $key, false) . '>' . $style . '</option>'; } $font_style .= '</select></div>'; } // Font Color if ($typography_options['color']) { $font_color = '<div class="field"><label for="of-typography-color">' . theme_locals('color') . '</label>'; $font_color .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $typography_stored['color']) . '"></div></div>'; $font_color .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($typography_stored['color']) . '" /></div>'; } // Allow modification/injection of typography fields $typography_fields = compact('font_size', 'font_lineheight', 'font_face', 'font_style', 'font_character', 'font_color'); $typography_fields = apply_filters('of_typography_fields', $typography_fields, $typography_stored, $option_name, $value); $output .= implode('', $typography_fields); break; // Background // Background case 'background': $background = $val; // Background Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>'; $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />'; // Background Image - New AJAX Uploader using Media Library if (!isset($background['image'])) { $background['image'] = ''; } $output .= optionsframework_medialibrary_uploader($value['id'], $background['image'], null, '', 0, 'image'); $class = 'of-background-properties'; if ('' == $background['image']) { $class .= ' hide'; } $output .= '<div class="' . esc_attr($class) . '">'; // Background Repeat $output .= '<select class="of-background of-background-repeat" name="' . esc_attr($option_name . '[' . $value['id'] . '][repeat]') . '" id="' . esc_attr($value['id'] . '_repeat') . '">'; $repeats = of_recognized_background_repeat(); foreach ($repeats as $key => $repeat) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>'; } $output .= '</select>'; // Background Position $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position]') . '" id="' . esc_attr($value['id'] . '_position') . '">'; $positions = of_recognized_background_position(); foreach ($positions as $key => $position) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>'; } $output .= '</select>'; // Background Attachment $output .= '<select class="of-background of-background-attachment" name="' . esc_attr($option_name . '[' . $value['id'] . '][attachment]') . '" id="' . esc_attr($value['id'] . '_attachment') . '">'; $attachments = of_recognized_background_attachment(); foreach ($attachments as $key => $attachment) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>'; } $output .= '</select>'; $output .= '</div>'; break; // Editor // Editor case 'editor': $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; echo $output; $textarea_name = esc_attr($option_name . '[' . $value['id'] . ']'); $default_editor_settings = array('textarea_name' => $textarea_name, 'media_buttons' => false, 'tinymce' => array('plugins' => 'wordpress')); $editor_settings = array(); if (isset($value['settings'])) { $editor_settings = $value['settings']; } $editor_settings = array_merge($editor_settings, $default_editor_settings); wp_editor($val, $value['id'], $editor_settings); $output = ''; break; // Info // Info case "info": $id = ''; $class = 'section'; if (isset($value['id'])) { $id = 'id="' . esc_attr($value['id']) . '" '; } if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div ' . $id . 'class="' . esc_attr($class) . '">' . "\n"; if (isset($value['name'])) { $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; } if ($value['desc']) { $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n"; } $output .= '</div>' . "\n"; break; // Heading for Navigation // Heading for Navigation case "heading": if ($counter >= 2) { $output .= '</div>' . "\n"; } $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name'])); $jquery_click_hook = "of-option-" . $counter; $menu .= '<a class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>'; $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">'; $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n"; break; } if ($value['type'] != "heading" && $value['type'] != "info") { $output .= '</div>'; if ($value['type'] != "checkbox" && $value['type'] != "editor") { $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; } $output .= '</div></div>' . "\n"; } echo $output; } echo '</div>'; }
function cherry_register($wp_customize) { $themename = CURRENT_THEME; $options = combined_option_array(); // remove default sections $wp_customize->remove_section('static_front_page'); // change transport $wp_customize->get_setting('blogname')->transport = 'postMessage'; $wp_customize->get_setting('blogdescription')->transport = 'postMessage'; // ------------------------------------------------------------ // General // ------------------------------------------------------------ $wp_customize->add_section($themename . '_general', array('title' => theme_locals('general'), 'priority' => 1)); if (isset($options['body_background'])) { /* Body Background Color */ $wp_customize->add_setting($themename . '[body_background][color]', array('default' => $options['body_background']['std']['color'], 'type' => 'option', 'transport' => 'postMessage')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $themename . '_body_background_color', array('label' => theme_locals('background_color'), 'section' => $themename . '_general', 'settings' => $themename . '[body_background][color]', 'priority' => 10))); /* Body Background Image */ $wp_customize->add_setting($themename . '[body_background][image]', array('default' => $options['body_background']['std']['image'], 'type' => 'option')); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, $themename . '_body_background_image', array('label' => theme_locals('background_image'), 'section' => $themename . '_general', 'settings' => $themename . '[body_background][image]', 'priority' => 11))); } /* Main Background Color */ if (isset($options['main_background'])) { $wp_customize->add_setting($themename . '[main_background]', array('default' => $options['main_background']['std'], 'type' => 'option', 'transport' => 'postMessage')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $themename . '_main_background', array('label' => $options['main_background']['name'], 'section' => $themename . '_general', 'settings' => $themename . '[main_background]', 'priority' => 13))); } if (isset($options['header_background'])) { /* Header Background Color */ $wp_customize->add_setting($themename . '[header_background][color]', array('default' => $options['header_background']['std']['color'], 'type' => 'option', 'transport' => 'postMessage')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $themename . '_header_background_color', array('label' => theme_locals('header_color'), 'section' => $themename . '_general', 'settings' => $themename . '[header_background][color]', 'priority' => 14))); /* Header Background Image */ $wp_customize->add_setting($themename . '[header_background][image]', array('default' => $options['header_background']['std']['image'], 'type' => 'option')); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, $themename . '_header_background_image', array('label' => theme_locals('header_image'), 'section' => $themename . '_general', 'settings' => $themename . '[header_background][image]', 'priority' => 15))); } /* Links Color */ if (isset($options['links_color'])) { $wp_customize->add_setting($themename . '[links_color]', array('default' => $options['links_color']['std'], 'type' => 'option', 'transport' => 'postMessage')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $themename . '_links_color', array('label' => $options['links_color']['name'], 'section' => $themename . '_general', 'settings' => $themename . '[links_color]', 'priority' => 16))); } /* H1 Heading font face */ if (isset($options['h1_heading'])) { $wp_customize->add_setting($themename . '[h1_heading][face]', array('default' => $options['h1_heading']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_h1_heading', array('label' => $options['h1_heading']['name'], 'section' => $themename . '_general', 'settings' => $themename . '[h1_heading][face]', 'type' => 'select', 'choices' => $options['h1_heading']['options']['faces'], 'priority' => 18)); } /* H2 Heading font face */ if (isset($options['h2_heading'])) { $wp_customize->add_setting($themename . '[h2_heading][face]', array('default' => $options['h2_heading']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_h2_heading', array('label' => $options['h2_heading']['name'], 'section' => $themename . '_general', 'settings' => $themename . '[h2_heading][face]', 'type' => 'select', 'choices' => $options['h2_heading']['options']['faces'], 'priority' => 19)); } /* H3 Heading font face */ if (isset($options['h3_heading'])) { $wp_customize->add_setting($themename . '[h3_heading][face]', array('default' => $options['h3_heading']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_h3_heading', array('label' => $options['h3_heading']['name'], 'section' => $themename . '_general', 'settings' => $themename . '[h3_heading][face]', 'type' => 'select', 'choices' => $options['h3_heading']['options']['faces'], 'priority' => 20)); } /* H4 Heading font face */ if (isset($options['h4_heading'])) { $wp_customize->add_setting($themename . '[h4_heading][face]', array('default' => $options['h4_heading']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_h4_heading', array('label' => $options['h4_heading']['name'], 'section' => $themename . '_general', 'settings' => $themename . '[h4_heading][face]', 'type' => 'select', 'choices' => $options['h4_heading']['options']['faces'], 'priority' => 21)); } /* H5 Heading font face */ if (isset($options['h5_heading'])) { $wp_customize->add_setting($themename . '[h5_heading][face]', array('default' => $options['h5_heading']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_h5_heading', array('label' => $options['h5_heading']['name'], 'section' => $themename . '_general', 'settings' => $themename . '[h5_heading][face]', 'type' => 'select', 'choices' => $options['h5_heading']['options']['faces'], 'priority' => 22)); } /* H6 Heading font face */ if (isset($options['h6_heading'])) { $wp_customize->add_setting($themename . '[h6_heading][face]', array('default' => $options['h6_heading']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_h6_heading', array('label' => $options['h6_heading']['name'], 'section' => $themename . '_general', 'settings' => $themename . '[h6_heading][face]', 'type' => 'select', 'choices' => $options['h6_heading']['options']['faces'], 'priority' => 23)); } /* Breadcrumbs */ if (isset($options['g_breadcrumbs_id'])) { $wp_customize->add_setting($themename . '[g_breadcrumbs_id]', array('default' => $options['g_breadcrumbs_id']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_g_breadcrumbs_id', array('label' => $options['g_breadcrumbs_id']['name'], 'section' => $themename . '_general', 'settings' => $themename . '[g_breadcrumbs_id]', 'type' => 'radio', 'choices' => $options['g_breadcrumbs_id']['options'], 'priority' => 24)); } /* Search Box */ if (isset($options['g_search_box_id'])) { $wp_customize->add_setting($themename . '[g_search_box_id]', array('default' => $options['g_search_box_id']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_g_search_box_id', array('label' => $options['g_search_box_id']['name'], 'section' => $themename . '_general', 'settings' => $themename . '[g_search_box_id]', 'type' => 'radio', 'choices' => $options['g_search_box_id']['options'], 'priority' => 25)); } // --------------------------------------------------------- // Logo // --------------------------------------------------------- /* Logo Type */ if (isset($options['logo_type'])) { $wp_customize->add_setting($themename . '[logo_type]', array('default' => $options['logo_type']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_logo_type', array('label' => $options['logo_type']['name'], 'section' => 'title_tagline', 'settings' => $themename . '[logo_type]', 'type' => $options['logo_type']['type'], 'choices' => $options['logo_type']['options'], 'priority' => 1)); } /* Logo Path */ if (isset($options['logo_url'])) { $wp_customize->add_setting($themename . '[logo_url]', array('type' => 'option')); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, $themename . '_logo_url', array('label' => $options['logo_url']['name'], 'section' => 'title_tagline', 'settings' => $themename . '[logo_url]', 'priority' => 2))); } /* Logo-text font */ if (isset($options['logo_typography'])) { $wp_customize->add_setting($themename . '[logo_typography][face]', array('default' => $options['logo_typography']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_logo_typography_face', array('label' => $options['logo_typography']['name'], 'section' => 'title_tagline', 'settings' => $themename . '[logo_typography][face]', 'type' => 'select', 'choices' => $options['logo_typography']['options']['faces'], 'priority' => 3)); /* Logo Text Color */ $wp_customize->add_setting($themename . '[logo_typography][color]', array('default' => $options['logo_typography']['std']['color'], 'type' => 'option', 'transport' => 'postMessage')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $themename . '_logo_typography_color', array('label' => theme_locals('logo_color'), 'section' => 'title_tagline', 'settings' => $themename . '[logo_typography][color]', 'priority' => 4))); } // --------------------------------------------------------- // Navigation // --------------------------------------------------------- /* Header Navigation font */ if (isset($options['menu_typography'])) { $wp_customize->add_setting($themename . '[menu_typography][face]', array('default' => $options['menu_typography']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_menu_typography_face', array('label' => theme_locals('header_menu_face'), 'section' => 'nav', 'settings' => $themename . '[menu_typography][face]', 'type' => 'select', 'choices' => $options['menu_typography']['options']['faces'], 'priority' => 11)); /* Header Navigation Color */ $wp_customize->add_setting($themename . '[menu_typography][color]', array('default' => $options['menu_typography']['std']['color'], 'type' => 'option', 'transport' => 'postMessage')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $themename . '_menu_typography_color', array('label' => theme_locals('header_menu_color'), 'section' => 'nav', 'settings' => $themename . '[menu_typography][color]', 'priority' => 12))); } /* Footer Navigation font */ if (isset($options['footer_menu_typography'])) { $wp_customize->add_setting($themename . '[footer_menu_typography][face]', array('default' => $options['footer_menu_typography']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_footer_menu_typography_face', array('label' => theme_locals('footer_menu_face'), 'section' => 'nav', 'settings' => $themename . '[footer_menu_typography][face]', 'type' => 'select', 'choices' => $options['footer_menu_typography']['options']['faces'], 'priority' => 13)); /* Footer Navigation Color */ $wp_customize->add_setting($themename . '[footer_menu_typography][color]', array('default' => $options['footer_menu_typography']['std']['color'], 'type' => 'option', 'transport' => 'postMessage')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $themename . '_footer_menu_typography_color', array('label' => theme_locals('footer_menu_color'), 'section' => 'nav', 'settings' => $themename . '[footer_menu_typography][color]', 'priority' => 14))); } // --------------------------------------------------------- // Slider // --------------------------------------------------------- $wp_customize->add_section($themename . '_slider', array('title' => theme_locals('slider'), 'priority' => 200)); /* Slider Type */ // Custom control - Layout Picker if (isset($options['slider_type'])) { $wp_customize->add_setting($themename . '[slider_type]', array('default' => $options['slider_type']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_slider_type', array('label' => $options['slider_type']['name'], 'section' => $themename . '_slider', 'settings' => $themename . '[slider_type]', 'choices' => $options['slider_type']['title'], 'type' => 'radio')); } // --------------------------------------------------------- // Blog // --------------------------------------------------------- $wp_customize->add_section($themename . '_blog', array('title' => theme_locals('blog'), 'priority' => 203)); /* Blog title */ if (isset($options['blog_text'])) { $wp_customize->add_setting($themename . '[blog_text]', array('default' => $options['blog_text']['std'], 'type' => 'option', 'transport' => 'postMessage')); $wp_customize->add_control($themename . '_blog_text', array('label' => $options['blog_text']['name'], 'section' => $themename . '_blog', 'settings' => $themename . '[blog_text]', 'type' => 'text', 'priority' => 1)); } /* Related posts title */ if (isset($options['blog_related'])) { $wp_customize->add_setting($themename . '[blog_related]', array('default' => $options['blog_related']['std'], 'type' => 'option', 'transport' => 'postMessage')); $wp_customize->add_control($themename . '_blog_related', array('label' => $options['blog_related']['name'], 'section' => $themename . '_blog', 'settings' => $themename . '[blog_related]', 'type' => 'text', 'priority' => 2)); } /* Blog layout */ // Custom control - Layout Picker if (isset($options['blog_sidebar_pos'])) { $wp_customize->add_setting($themename . '[blog_sidebar_pos]', array('default' => $options['blog_sidebar_pos']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_blog_sidebar_pos', array('label' => $options['blog_sidebar_pos']['name'], 'section' => $themename . '_blog', 'settings' => $themename . '[blog_sidebar_pos]', 'choices' => array('left' => theme_locals('sidebar_left'), 'right' => theme_locals('sidebar_right'), 'none' => theme_locals('sidebar_hide'), 'masonry' => theme_locals('blog_masonry')), 'type' => 'radio', 'priority' => 3)); } /* Blog image size */ if (isset($options['post_image_size'])) { $wp_customize->add_setting($themename . '[post_image_size]', array('default' => $options['post_image_size']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_post_image_size', array('label' => $options['post_image_size']['name'], 'section' => $themename . '_blog', 'settings' => $themename . '[post_image_size]', 'type' => $options['post_image_size']['type'], 'choices' => $options['post_image_size']['options'], 'priority' => 4)); } /* Single post image size */ if (isset($options['single_image_size'])) { $wp_customize->add_setting($themename . '[single_image_size]', array('default' => $options['single_image_size']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_single_image_size', array('label' => $options['single_image_size']['name'], 'section' => $themename . '_blog', 'settings' => $themename . '[single_image_size]', 'type' => $options['single_image_size']['type'], 'choices' => $options['single_image_size']['options'], 'priority' => 6)); } /* Post Meta */ if (isset($options['post_meta'])) { $wp_customize->add_setting($themename . '[post_meta]', array('default' => $options['post_meta']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_post_meta', array('label' => $options['post_meta']['name'], 'section' => $themename . '_blog', 'settings' => $themename . '[post_meta]', 'type' => $options['post_meta']['type'], 'choices' => $options['post_meta']['options'], 'priority' => 7)); } /* Post Excerpt */ if (isset($options['post_excerpt'])) { $wp_customize->add_setting($themename . '[post_excerpt]', array('default' => $options['post_excerpt']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_post_excerpt', array('label' => $options['post_excerpt']['name'], 'section' => $themename . '_blog', 'settings' => $themename . '[post_excerpt]', 'type' => $options['post_excerpt']['type'], 'choices' => $options['post_excerpt']['options'], 'priority' => 8)); } /* Button text */ if (isset($options['blog_button_text'])) { $wp_customize->add_setting($themename . '[blog_button_text]', array('default' => $options['blog_button_text']['std'], 'type' => 'option', 'transport' => 'postMessage')); $wp_customize->add_control($themename . '_blog_button_text', array('label' => $options['blog_button_text']['name'], 'section' => $themename . '_blog', 'settings' => $themename . '[blog_button_text]', 'type' => 'text', 'priority' => 9)); } // --------------------------------------------------------- // Portfolio // --------------------------------------------------------- $wp_customize->add_section($themename . '_portfolio', array('title' => theme_locals('portfolio'), 'priority' => 204)); /* Portfolio filter */ if (isset($options['folio_filter'])) { $wp_customize->add_setting($themename . '[folio_filter]', array('default' => $options['folio_filter']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_folio_filter', array('label' => $options['folio_filter']['name'], 'section' => $themename . '_portfolio', 'settings' => $themename . '[folio_filter]', 'type' => $options['folio_filter']['type'], 'choices' => $options['folio_filter']['options'], 'priority' => 1)); } /* Show Portfolio posts title? */ if (isset($options['folio_title'])) { $wp_customize->add_setting($themename . '[folio_title]', array('default' => $options['folio_title']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_folio_title', array('label' => $options['folio_title']['name'], 'section' => $themename . '_portfolio', 'settings' => $themename . '[folio_title]', 'type' => $options['folio_title']['type'], 'choices' => $options['folio_title']['options'], 'priority' => 2)); } /* Show Portfolio posts excerpt? */ if (isset($options['folio_excerpt'])) { $wp_customize->add_setting($themename . '[folio_excerpt]', array('default' => $options['folio_excerpt']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_folio_excerpt', array('label' => $options['folio_excerpt']['name'], 'section' => $themename . '_portfolio', 'settings' => $themename . '[folio_excerpt]', 'type' => $options['folio_excerpt']['type'], 'choices' => $options['folio_excerpt']['options'], 'priority' => 3)); } /* Show Portfolio posts button? */ if (isset($options['folio_btn'])) { $wp_customize->add_setting($themename . '[folio_btn]', array('default' => $options['folio_btn']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_folio_btn', array('label' => $options['folio_btn']['name'], 'section' => $themename . '_portfolio', 'settings' => $themename . '[folio_btn]', 'type' => $options['folio_btn']['type'], 'choices' => $options['folio_btn']['options'], 'priority' => 4)); } /* Button text */ if (isset($options['folio_button_text'])) { $wp_customize->add_setting($themename . '[folio_button_text]', array('default' => $options['folio_button_text']['std'], 'type' => 'option', 'transport' => 'postMessage')); $wp_customize->add_control($themename . '_folio_button_text', array('label' => $options['folio_button_text']['name'], 'section' => $themename . '_portfolio', 'settings' => $themename . '[folio_button_text]', 'type' => 'text', 'priority' => 5)); } // --------------------------------------------------------- // Footer // --------------------------------------------------------- $wp_customize->add_section($themename . '_footer', array('title' => theme_locals('footer'), 'priority' => 205)); /* Footer Copyright Text */ if (isset($options['footer_text'])) { $wp_customize->add_setting($themename . '[footer_text]', array('default' => $options['footer_text']['std'], 'type' => 'option', 'transport' => 'postMessage')); $wp_customize->add_control($themename . '_footer_text', array('label' => $options['footer_text']['name'], 'section' => $themename . '_footer', 'settings' => $themename . '[footer_text]', 'type' => 'text')); } }
function cherry_register($wp_customize) { $themename = CURRENT_THEME; $options = combined_option_array(); // ------------------------------------------------------------ // General // ------------------------------------------------------------ $wp_customize->add_section($themename . '_header', array('title' => theme_locals('general'), 'priority' => 200)); // Background Image $wp_customize->add_setting($themename . '[body_background][image]', array('default' => $options['body_background']['std']['image'], 'type' => 'option')); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'body_background_image', array('label' => theme_locals('background_image'), 'section' => $themename . '_header', 'settings' => $themename . '[body_background][image]'))); // Background Color $wp_customize->add_setting($themename . '[body_background][color]', array('default' => $options['body_background']['std']['color'], 'type' => 'option')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'body_background', array('label' => theme_locals('background_color'), 'section' => $themename . '_header', 'settings' => $themename . '[body_background][color]'))); // Header Color $wp_customize->add_setting($themename . '[header_color]', array('default' => $options['header_color']['std'], 'type' => 'option')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'header_color', array('label' => $options['header_color']['name'], 'section' => $themename . '_header', 'settings' => $themename . '[header_color]'))); // Body Font Face $wp_customize->add_setting($themename . '[google_mixed_3][face]', array('default' => $options['google_mixed_3']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_google_mixed_3', array('label' => $options['google_mixed_3']['name'], 'section' => $themename . '_header', 'settings' => $themename . '[google_mixed_3][face]', 'type' => 'select', 'choices' => $options['google_mixed_3']['options']['faces'])); // Buttons and Links Color $wp_customize->add_setting($themename . '[links_color]', array('default' => $options['links_color']['std'], 'type' => 'option')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'links_color', array('label' => $options['links_color']['name'], 'section' => $themename . '_header', 'settings' => $themename . '[links_color]'))); // breadcrumbs $wp_customize->add_setting($themename . '[g_breadcrumbs_id]', array('default' => $options['g_breadcrumbs_id']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_g_breadcrumbs_id', array('label' => $options['g_breadcrumbs_id']['name'], 'section' => $themename . '_header', 'settings' => $themename . '[g_breadcrumbs_id]', 'type' => $options['g_breadcrumbs_id']['type'], 'choices' => $options['g_breadcrumbs_id']['options'])); // Search Box $wp_customize->add_setting($themename . '[g_search_box_id]', array('default' => $options['g_search_box_id']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_g_search_box_id', array('label' => $options['g_search_box_id']['name'], 'section' => $themename . '_header', 'settings' => $themename . '[g_search_box_id]', 'type' => $options['g_search_box_id']['type'], 'choices' => $options['g_search_box_id']['options'])); // H4 Heading font face $wp_customize->add_setting($themename . '[h4_heading][face]', array('default' => $options['h4_heading']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_h4_heading', array('label' => $options['h4_heading']['name'], 'section' => $themename . '_header', 'settings' => $themename . '[h4_heading][face]', 'type' => 'select', 'choices' => $options['h4_heading']['options']['faces'])); // H3 Heading font face $wp_customize->add_setting($themename . '[h3_heading][face]', array('default' => $options['h3_heading']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_h3_heading', array('label' => $options['h3_heading']['name'], 'section' => $themename . '_header', 'settings' => $themename . '[h3_heading][face]', 'type' => 'select', 'choices' => $options['h3_heading']['options']['faces'])); // H2 Heading font face $wp_customize->add_setting($themename . '[h2_heading][face]', array('default' => $options['h2_heading']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_h2_heading', array('label' => $options['h2_heading']['name'], 'section' => $themename . '_header', 'settings' => $themename . '[h2_heading][face]', 'type' => 'select', 'choices' => $options['h2_heading']['options']['faces'])); // H1 Heading font face $wp_customize->add_setting($themename . '[h1_heading][face]', array('default' => $options['h1_heading']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_h1_heading', array('label' => $options['h1_heading']['name'], 'section' => $themename . '_header', 'settings' => $themename . '[h1_heading][face]', 'type' => 'select', 'choices' => $options['h1_heading']['options']['faces'])); // H6 Heading font face $wp_customize->add_setting($themename . '[h6_heading][face]', array('default' => $options['h6_heading']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_h6_heading', array('label' => $options['h6_heading']['name'], 'section' => $themename . '_header', 'settings' => $themename . '[h6_heading][face]', 'type' => 'select', 'choices' => $options['h6_heading']['options']['faces'])); // H5 Heading font face $wp_customize->add_setting($themename . '[h5_heading][face]', array('default' => $options['h5_heading']['std']['face'], 'type' => 'option')); $wp_customize->add_control($themename . '_h5_heading', array('label' => $options['h5_heading']['name'], 'section' => $themename . '_header', 'settings' => $themename . '[h5_heading][face]', 'type' => 'select', 'choices' => $options['h5_heading']['options']['faces'])); // --------------------------------------------------------- // Logo // --------------------------------------------------------- $wp_customize->add_section($themename . '_logo', array('title' => theme_locals('logo'), 'priority' => 201)); /* Logo Type */ $wp_customize->add_setting($themename . '[logo_type]', array('default' => $options['logo_type']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_logo_type', array('label' => $options['logo_type']['name'], 'section' => $themename . '_logo', 'settings' => $themename . '[logo_type]', 'type' => $options['logo_type']['type'], 'choices' => $options['logo_type']['options'])); /* Logo Path */ $wp_customize->add_setting($themename . '[logo_url]', array('type' => 'option')); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'logo_url', array('label' => $options['logo_url']['name'], 'section' => $themename . '_logo', 'settings' => $themename . '[logo_url]'))); // --------------------------------------------------------- // Slider // --------------------------------------------------------- $wp_customize->add_section($themename . '_slider', array('title' => theme_locals('slider_name'), 'priority' => 202)); /* Slider Effect */ $wp_customize->add_setting($themename . '[sl_effect]', array('default' => $options['sl_effect']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_sl_effect', array('label' => $options['sl_effect']['name'], 'section' => $themename . '_slider', 'settings' => $themename . '[sl_effect]', 'type' => $options['sl_effect']['type'], 'choices' => $options['sl_effect']['options'])); /* Pause time */ $wp_customize->add_setting($themename . '[sl_pausetime]', array('default' => $options['sl_pausetime']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_sl_pausetime', array('label' => $options['sl_pausetime']['name'], 'section' => $themename . '_slider', 'settings' => $themename . '[sl_pausetime]', 'type' => $options['sl_pausetime']['type'])); /* Animation speed */ $wp_customize->add_setting($themename . '[sl_animation_speed]', array('default' => $options['sl_animation_speed']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_sl_animation_speed', array('label' => $options['sl_animation_speed']['name'], 'section' => $themename . '_slider', 'settings' => $themename . '[sl_animation_speed]', 'type' => $options['sl_animation_speed']['type'])); /* Auto slideshow */ $wp_customize->add_setting($themename . '[sl_slideshow]', array('default' => $options['sl_slideshow']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_sl_slideshow', array('label' => $options['sl_slideshow']['name'], 'section' => $themename . '_slider', 'settings' => $themename . '[sl_slideshow]', 'type' => $options['sl_slideshow']['type'], 'choices' => $options['sl_slideshow']['options'])); /* Slide thumbnails */ $wp_customize->add_setting($themename . '[sl_thumbnails]', array('default' => $options['sl_thumbnails']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_sl_thumbnails', array('label' => $options['sl_thumbnails']['name'], 'section' => $themename . '_slider', 'settings' => $themename . '[sl_thumbnails]', 'type' => $options['sl_thumbnails']['type'], 'choices' => $options['sl_thumbnails']['options'])); /* Show pagination? */ $wp_customize->add_setting($themename . '[sl_control_nav]', array('default' => $options['sl_control_nav']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_sl_control_nav', array('label' => $options['sl_control_nav']['name'], 'section' => $themename . '_slider', 'settings' => $themename . '[sl_control_nav]', 'type' => $options['sl_control_nav']['type'], 'choices' => $options['sl_control_nav']['options'])); /* Display next & prev navigation? */ $wp_customize->add_setting($themename . '[sl_dir_nav]', array('default' => $options['sl_dir_nav']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_sl_dir_nav', array('label' => $options['sl_dir_nav']['name'], 'section' => $themename . '_slider', 'settings' => $themename . '[sl_dir_nav]', 'type' => $options['sl_dir_nav']['type'], 'choices' => $options['sl_dir_nav']['options'])); /* Play/Pause button */ $wp_customize->add_setting($themename . '[sl_play_pause_button]', array('default' => $options['sl_play_pause_button']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_sl_play_pause_button', array('label' => $options['sl_play_pause_button']['name'], 'section' => $themename . '_slider', 'settings' => $themename . '[sl_play_pause_button]', 'type' => $options['sl_play_pause_button']['type'], 'choices' => $options['sl_play_pause_button']['options'])); /* Loader */ $wp_customize->add_setting($themename . '[sl_loader]', array('default' => $options['sl_loader']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_sl_loader', array('label' => $options['sl_loader']['name'], 'section' => $themename . '_slider', 'settings' => $themename . '[sl_loader]', 'type' => $options['sl_loader']['type'], 'choices' => $options['sl_loader']['options'])); // --------------------------------------------------------- // Blog // --------------------------------------------------------- $wp_customize->add_section($themename . '_blog', array('title' => theme_locals('blog'), 'priority' => 203)); /* Blog image size */ $wp_customize->add_setting($themename . '[post_image_size]', array('default' => $options['post_image_size']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_post_image_size', array('label' => $options['post_image_size']['name'], 'section' => $themename . '_blog', 'settings' => $themename . '[post_image_size]', 'type' => $options['post_image_size']['type'], 'choices' => $options['post_image_size']['options'])); /* Single post image size */ $wp_customize->add_setting($themename . '[single_image_size]', array('default' => $options['single_image_size']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_single_image_size', array('label' => $options['single_image_size']['name'], 'section' => $themename . '_blog', 'settings' => $themename . '[single_image_size]', 'type' => $options['single_image_size']['type'], 'choices' => $options['single_image_size']['options'])); /* Post Meta */ $wp_customize->add_setting($themename . '[post_meta]', array('default' => $options['post_meta']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_post_meta', array('label' => $options['post_meta']['name'], 'section' => $themename . '_blog', 'settings' => $themename . '[post_meta]', 'type' => $options['post_meta']['type'], 'choices' => $options['post_meta']['options'])); /* Post Excerpt */ $wp_customize->add_setting($themename . '[post_excerpt]', array('default' => $options['post_excerpt']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_post_excerpt', array('label' => $options['post_excerpt']['name'], 'section' => $themename . '_blog', 'settings' => $themename . '[post_excerpt]', 'type' => $options['post_excerpt']['type'], 'choices' => $options['post_excerpt']['options'])); // --------------------------------------------------------- // Footer // --------------------------------------------------------- $wp_customize->add_section($themename . '_footer', array('title' => theme_locals('footer'), 'priority' => 204)); /* Footer Copyright Text */ $wp_customize->add_setting($themename . '[footer_text]', array('default' => $options['footer_text']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_footer_text', array('label' => $options['footer_text']['name'], 'section' => $themename . '_footer', 'settings' => $themename . '[footer_text]', 'type' => 'text')); /* Display Footer Menu */ $wp_customize->add_setting($themename . '[footer_menu]', array('default' => $options['footer_menu']['std'], 'type' => 'option')); $wp_customize->add_control($themename . '_footer_menu', array('label' => $options['footer_menu']['name'], 'section' => $themename . '_footer', 'settings' => $themename . '[footer_menu]', 'type' => $options['footer_menu']['type'], 'choices' => $options['footer_menu']['options'])); }