/** * Set some default theme options when theme is switched to this theme */ function gpp_theme_options_activation_func() { $defaults = (array) gpp_get_options(); if (!get_option(gpp_get_current_theme_id() . "_options")) { update_option(gpp_get_current_theme_id() . "_options", $defaults); } }
/** * Globalize the variable that holds * the Settings Page tab definitions * * @global array Settings Page Tab definitions */ /** * Register Theme Opitons tab section in the Theme Customizer * * @todo Add description. * */ $sectionname = "theme_options"; $sectiontitle = __('Theme Options', 'gpp'); $wp_customize->add_section($sectionname, array('title' => $sectiontitle, 'priority' => 35)); $gpp_options = (array) gpp_get_options(); $gpp_option_parameters = gpp_get_option_parameters(); foreach ($gpp_option_parameters as $option) { $optionname = $option['name']; $optiondb = gpp_get_current_theme_id() . "_options[{$optionname}]"; $option_section_name = $option['section']; if ($option['name'] == 'css') { $wp_customize->add_setting($optiondb, array('default' => $option['default'], 'type' => 'option', 'capabilities' => 'manage_theme_options', 'transport' => 'postMessage')); // intercept the theme option and control it $wp_customize->add_control(new gpp_CSS_Control($wp_customize, $option['name'], array('label' => $option['title'], 'section' => $sectionname, 'settings' => $optiondb, 'type' => 'textarea'))); } if ('font' == $option['name'] || 'font_alt' == $option['name'] || 'color' == $option['name']) { $wp_customize->add_setting($optiondb, array('default' => $option['default'], 'type' => 'option', 'capabilities' => 'manage_theme_options', 'transport' => 'postMessage')); $wp_customize->add_control($option['name'], array('label' => $option['title'], 'section' => $sectionname, 'settings' => $optiondb, 'type' => $option['type'], 'choices' => gpp_extract_valid_options($option['valid_options']))); } if ('logo' == $option['name']) {
/** * Callback for get_settings_field() */ function gpp_setting_callback($option) { $gpp_options = (array) gpp_get_options(); $option_parameters = gpp_get_option_parameters(); $optionname = $option['name']; $optiontitle = $option['title']; $fieldtype = $option['type']; $attr = $option_parameters[$option['name']]; $value = $gpp_options[$optionname]; //Determine the type of input field switch ($fieldtype) { //Render Text Input case 'text': gpp_field_text($value, $attr); echo '<span class="option-description">' . $option['description'] . '</span>'; break; //Render Hidden Input //Render Hidden Input case 'hidden': gpp_field_hidden($value, $attr); break; //Render textarea options //Render textarea options case 'textarea': gpp_field_textarea($value, $attr); echo '<span class="option-description">' . $option['description'] . '</span>'; break; //Render select dropdowns //Render select dropdowns case 'select': gpp_field_select($value, $attr); echo '<span class="option-description">' . $option['description'] . '</span>'; break; //Render radio dropdowns //Render radio dropdowns case 'radio': gpp_field_radio($value, $attr); echo '<span class="option-description">' . $option['description'] . '</span>'; break; //Render radio image dropdowns //Render radio image dropdowns case 'radio_image': gpp_field_radio_image($value, $attr); echo '<span class="option-description">' . $option['description'] . '</span>'; break; //Render checkboxes //Render checkboxes case 'checkbox': gpp_field_checkbox($value, $attr); echo '<span class="option-description">' . $option['description'] . '</span>'; break; //Render color picker //Render color picker case 'color': gpp_field_color($value, $attr); echo '<span class="option-description">' . $option['description'] . '</span>'; break; //Render uploaded image //Render uploaded image case 'image': gpp_field_image($value, $attr); echo '<span class="option-description">' . $option['description'] . '</span>'; break; //Render uploaded gallery //Render uploaded gallery case 'gallery': gpp_field_gallery($value, $attr); echo '<span class="option-description">' . $option['description'] . '</span>'; break; default: break; } }