theme_fields = $fields; add_action ('customize_register' , array( &$this, 'customize_panel' ) ); add_action ('customize_controls_enqueue_scripts' , array( &$this, 'customize_scripts' ) ); } public function customize_scripts() { wp_enqueue_style ( 'alhena-lite_panel', get_template_directory_uri() . '/core/admin/assets/css/customize.css', array(), '' ); } public function customize_panel ( $wp_customize ) { $theme_panel = $this->theme_fields ; foreach ( $theme_panel as $element ) { switch ( $element['type'] ) { case 'panel' : $wp_customize->add_panel( $element['id'], array( 'title' => $element['title'], 'priority' => $element['priority'], 'description' => $element['description'], 'capability' => 'edit_theme_options', ) ); break; case 'section' : $wp_customize->add_section( $element['id'], array( 'title' => $element['title'], 'panel' => $element['panel'], 'priority' => $element['priority'], 'capability' => 'edit_theme_options', ) ); break; case 'text' : $wp_customize->add_setting( $element['id'], array( 'sanitize_callback' => 'sanitize_text_field', 'default' => $element['std'], 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( $element['id'] , array( 'type' => $element['type'], 'section' => $element['section'], 'label' => $element['label'], 'description' => $element['description'], ) ); break; case 'url' : $wp_customize->add_setting( $element['id'], array( 'sanitize_callback' => 'esc_url_raw', 'default' => $element['std'], 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( $element['id'] , array( 'type' => $element['type'], 'section' => $element['section'], 'label' => $element['label'], 'description' => $element['description'], ) ); break; case 'upload' : $wp_customize->add_setting( $element['id'], array( 'default' => $element['std'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw', 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( new WP_Customize_Image_Control($wp_customize, $element['id'], array( 'label' => $element['label'], 'description' => $element['description'], 'section' => $element['section'], 'settings' => $element['id'], ))); break; case 'color' : $wp_customize->add_setting( $element['id'], array( 'sanitize_callback' => 'sanitize_hex_color', 'default' => $element['std'], 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( $element['id'] , array( 'type' => $element['type'], 'section' => $element['section'], 'label' => $element['label'], 'description' => $element['description'], ) ); break; case 'button' : $wp_customize->add_setting( $element['id'], array( 'sanitize_callback' => array( &$this, 'customize_button_sanize' ), 'default' => $element['std'], 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( $element['id'] , array( 'type' => 'url', 'section' => $element['section'], 'label' => $element['label'], 'description' => $element['description'], ) ); break; case 'textarea' : $wp_customize->add_setting( $element['id'], array( 'sanitize_callback' => 'esc_textarea', 'default' => $element['std'], 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( $element['id'] , array( 'type' => $element['type'], 'section' => $element['section'], 'label' => $element['label'], 'description' => $element['description'], ) ); break; case 'select' : $wp_customize->add_setting( $element['id'], array( 'sanitize_callback' => array( &$this, 'customize_select_sanize' ), 'default' => $element['std'], 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( $element['id'] , array( 'type' => $element['type'], 'section' => $element['section'], 'label' => $element['label'], 'description' => $element['description'], 'choices' => $element['options'], ) ); break; case 'alhena-lite-customize-info' : $wp_customize->add_section( $element['id'], array( 'title' => $element['title'], 'priority' => $element['priority'], 'capability' => 'edit_theme_options', ) ); $wp_customize->add_setting( $element['id'], array( 'sanitize_callback' => 'esc_url_raw' ) ); $wp_customize->add_control( new Alhenalite_Customize_Info_Control( $wp_customize, $element['id'] , array( 'section' => $element['section'], ) ) ); break; } } if ( alhenalite_is_woocommerce_active() ) : $wp_customize->remove_control( 'woocommerce_catalog_rows'); $wp_customize->remove_control( 'woocommerce_catalog_columns'); endif; } public function customize_select_sanize ($value, $setting) { global $wp_customize; $control = $wp_customize->get_control( $setting->id ); if ( array_key_exists( $value, $control->choices ) ) { return $value; } else { return $setting->default; } } public function customize_button_sanize ( $value, $setting ) { $sanize = array ( 'wip_footer_email_button' => 'mailto:', 'wip_footer_skype_button' => 'skype:', 'wip_footer_whatsapp_button' => 'tel:', ); if (!isset($value) || $value == '' || $value == $sanize[$setting->id]) { return ''; } elseif (!strstr($value, $sanize[$setting->id])) { return $sanize[$setting->id] . $value; } else { return esc_url_raw($value, array('mailto', 'skype', 'tel')); } } } if ( class_exists( 'WP_Customize_Control' ) ) { class Alhenalite_Customize_Info_Control extends WP_Customize_Control { public $type = "alhenalite-customize-info"; public function render_content() { ?>