/** * 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; } }
* 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']) { $wp_customize->add_setting($optiondb, array('default' => $option['default'], 'type' => 'option', 'capabilities' => 'manage_theme_options', 'transport' => 'postMessage'));
/** * Separate settings by tab * * Returns an array of tabs, each of * which is an indexed array of settings * included with the specified tab. * * @uses gpp_get_option_parameters() defined in \functions\options.php * * @return array $settingsbytab array of arrays of settings by tab */ function gpp_get_settings_by_tab() { global $gpp_tabs; // Initialize an array to hold // an indexed array of tabnames $settingsbytab = array(); // Loop through the array of tabs foreach ($gpp_tabs as $tab) { $tabname = $tab['name']; // Add an indexed array key // to the settings-by-tab // array for each tab name $tabs[] = $tabname; } // Get the array of option parameters $option_parameters = gpp_get_option_parameters(); // Loop through the option parameters // array foreach ($option_parameters as $option_parameter) { // Ignore "internal" type options if (in_array($option_parameter['tab'], $tabs)) { $optiontab = $option_parameter['tab']; $optionname = $option_parameter['name']; // Add an indexed array key to the // settings-by-tab array for each // setting associated with each tab $settingsbytab[$optiontab][] = $optionname; } } // Return the settings-by-tab // array return $settingsbytab; }