add_panel( 'theme_option', array( 'priority' => 10, 'capability' => 'edit_theme_options', 'title' => 'Theme Settings', ) ); foreach ($sections as $key => $section) { $title = explode('', $section['title'])[1]; $wp_customize->add_section( $section['id'], array( 'priority' => $key, 'capability' => 'edit_theme_options', 'title' => $title, 'panel' => 'theme_option', )); foreach ($settings as $key2 => $setting) { if($setting['section'] == $section['id'] && isset($options[$setting['id']])){ $wp_customize->add_setting( $option_name.'['.$setting['id'].']', array( 'default' => $options[$setting['id']], 'capability' => 'edit_theme_options', 'type' => 'option', 'sanitize_callback' => array($this, 'sv_sanitize_callback') ) ); // var_dump($setting['label']); switch ($setting['type']) { case 'upload': $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, $option_name.'['.$setting['id'].']', array( 'label' => $setting['label'], 'section' => $setting['section'], 'settings' => $option_name.'['.$setting['id'].']', 'priority' => $key.$key2 ) ) ); break; case 'textarea-simple': $wp_customize->add_control( new WP_Customize_Control( $wp_customize, $option_name.'['.$setting['id'].']', array( 'label' => $setting['label'], 'section' => $setting['section'], 'settings' => $option_name.'['.$setting['id'].']', 'type' => 'textarea' ) ) ); break; case 'page-select': $wp_customize->add_control( new WP_Customize_Control( $wp_customize, $option_name.'['.$setting['id'].']', array( 'label' => $setting['label'], 'section' => $setting['section'], 'settings' => $option_name.'['.$setting['id'].']', 'type' => 'dropdown-pages' ) ) ); break; case 'background': $wp_customize->add_control( new SV_Customize_Bg( $wp_customize, $option_name.'['.$setting['id'].']', array( 'label' => $setting['label'], 'section' => $setting['section'], 'settings1' => $option_name.'['.$setting['id'].']', ) ) ); break; case 'typography': $wp_customize->add_control( new SV_Customize_Typography( $wp_customize, $option_name.'['.$setting['id'].']', array( 'label' => $setting['label'], 'section' => $setting['section'], 'settings1' => $option_name.'['.$setting['id'].']', 'key_id' => $setting['id'], ) ) ); break; case 'colorpicker': $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $option_name.'['.$setting['id'].']', array( 'label' => $setting['label'], 'section' => $setting['section'], 'settings' => $option_name.'['.$setting['id'].']' ) ) ); break; case 'select': $choices = $setting['choices']; $customize_choices = array(); foreach ($choices as $choice) { $customize_choices[$choice['value']] = $choice['label']; } $wp_customize->add_control( new WP_Customize_Control( $wp_customize, $option_name.'['.$setting['id'].']', array( 'label' => $setting['label'], 'section' => $setting['section'], 'settings' => $option_name.'['.$setting['id'].']', 'type' => 'select', 'class' => 'select-sidebar', 'choices' => $customize_choices ) ) ); unset($customize_choices); break; case 'sidebar-select': global $wp_registered_sidebars; $customize_choices = array('' => '-- Choose Sidebar --'); foreach ($wp_registered_sidebars as $choice) { $customize_choices[$choice['id']] = $choice['name']; } $wp_customize->add_control( new WP_Customize_Control( $wp_customize, $option_name.'['.$setting['id'].']', array( 'label' => $setting['label'], 'section' => $setting['section'], 'settings' => $option_name.'['.$setting['id'].']', 'type' => 'select', 'choices' => $customize_choices ) ) ); unset($customize_choices); break; case 'on-off': $wp_customize->add_control( new WP_Customize_Control( $wp_customize, $option_name.'['.$setting['id'].']', array( 'label' => $setting['label'], 'section' => $setting['section'], 'settings' => $option_name.'['.$setting['id'].']', 'type' => 'radio', 'choices' => array( 'on' => 'On', 'off' => 'Off' ) ) ) ); break; default: # code... break; } // $wp_customize->get_setting( $option_name.'['.$setting['id'].']' )->transport = 'postMessage'; } } } } } new SV_CustomizeConfig; } if(class_exists('WP_Customize_Control')){ class SV_Customize_Bg extends WP_Customize_Control{ public $label; public $settings1; public function render_content() { if(!is_array($this->value())) $values = json_decode(urldecode($this->value()),true); else $values = $this->value(); // var_dump($this->value()); // ot_type_background($this->data); $setting_id = str_replace('[', '-', $this->settings1); $setting_id = str_replace(']', '', $setting_id); ?>