/** * Theme Customizer Controls Implementation * * Implement the Theme Customizer for the Theme Settings * in this theme. * * @link http://ottopress.com/2012/how-to-leverage-the-theme-customizer-in-your-own-themes/ Otto * * @see final class WP_Customize_Manager defined in \{root}\wp-includes\class-wp-customize-manager.php * * @param object $wp_customize Object that holds the customizer data * * @since 1.3 * @version 1.3.6 * */ public function register_controls($wp_customize) { if (!isset($wp_customize)) { return; } $tt_font_options = EGF_Register_Options::get_options(false); // Get the array of option parameters $option_parameters = EGF_Register_Options::get_option_parameters(); // Get customizer panels $panels = EGF_Register_Options::get_panels(); // Get list of tabs $tabs = EGF_Register_Options::get_setting_tabs(); /** * 1. Add Panels * * Add the panels to the customizer: * Add panels to the customizer based on each $panel * from EGF_Register_Options::get_panels() using the * new panels API in the customizer. * */ if (method_exists($wp_customize, 'add_panel')) { foreach ($panels as $panel) { $wp_customize->add_panel($panel['name'], array('priority' => $panel['priority'], 'capability' => $panel['capability'], 'title' => $panel['title'], 'description' => $panel['description'])); } } /** * 2. Register Sections * * Add Each Customizer Section: * Add each customizer section based on each $tab section * from EGF_Register_Options::get_setting_tabs() * */ foreach ($tabs as $tab) { // Add $tab section $wp_customize->add_section('tt_font_' . $tab['name'], array('title' => $tab['title'], 'description' => $tab['description'], 'panel' => $tab['panel'])); } /** * 3. Add Settings to Sections * 4. Register Control for Each Setting * */ $priority = 0; foreach ($option_parameters as $option_parameter) { /** * Set Transport Method: * * Default is to reload the iframe when the option is * modified in the customizer. * * DEVELOPER NOTE: To change the transport type for each * option modify the 'transport' value for the appropriate * option in the $options array found in: * tt_font_get_option_parameters() * */ $transport = empty($option_parameter['transport']) ? 'refresh' : $option_parameter['transport']; /** * Add Setting To Customizer: * * Adds $option_parameter setting to customizer * further properties are registered below. * */ $wp_customize->add_setting('tt_font_theme_options[' . $option_parameter['name'] . ']', array('default' => $option_parameter['default'], 'type' => 'option', 'transport' => $transport)); /** * Section Prefix: * * Add the 'tt_font_' prefix to prevent namespace * collisions. Removes the prefix if we are adding * this option to a default WordPress section. * */ $prefix = empty($option_parameter['wp_section']) ? 'tt_font_' : ''; // Set control $priority $priority += 20; switch ($option_parameter['type']) { case 'font': $wp_customize->add_control(new EGF_Font_Control($wp_customize, $option_parameter['name'], array('id' => '', 'label' => $option_parameter['title'], 'section' => 'tt_font_' . $option_parameter['tab'], 'settings' => 'tt_font_theme_options[' . $option_parameter['name'] . ']', 'priority' => $priority, 'option' => $option_parameter))); break; // Here in case we decide to implement // an additional lightweight control. // Here in case we decide to implement // an additional lightweight control. case 'font_basic': break; } } }