* @license http://www.gnu.org/licenses/gpl-2.0.html * @link https://github.com/maddisondesigns */ class bluestreet_Image_Radio_Button_Custom_Control extends WP_Customize_Control { /** * The type of control being rendered */ public $type = 'image_radio_button'; public function enqueue() { add_action('customize_controls_print_styles', array($this, 'print_styles')); } public function print_styles() { ?>
label)) { ?> label); ?> description)) { ?> description); ?> choices as $key => $value) { ?>
add_panel('header_options', array( 'priority' => 450, 'capability' => 'edit_theme_options', 'title' => esc_html__('Header settings', 'bluestreet'), )); $wp_customize->add_section('header_center_layout_setting', array( 'title' => esc_html__('Header Layout', 'bluestreet'), 'panel' => 'header_options' )); // Header Layout settings if (get_option('wallstreet_user', 'new')=='old' || $bluestreet_current_options['upload_image_logo'] != '' || $bluestreet_current_options['webrit_custom_css'] == 'nomorenow') { $wp_customize->add_setting('wallstreet_pro_options[header_center_layout_setting]', array( 'default' => 'default', 'sanitize_callback' => 'bluestreet_sanitize_radio', 'type' => 'option' )); } else { $wp_customize->add_setting('wallstreet_pro_options[header_center_layout_setting]', array( 'default' => 'center', 'sanitize_callback' => 'bluestreet_sanitize_radio', 'type' => 'option' )); } $wp_customize->add_control(new bluestreet_Image_Radio_Button_Custom_Control($wp_customize, 'wallstreet_pro_options[header_center_layout_setting]', array( 'label' => esc_html__('Header Layout Setting', 'bluestreet'), 'section' => 'header_center_layout_setting', 'choices' => array( 'default' => array( 'image' => get_stylesheet_directory_uri() . '/images/bluestreet-header-default.png', 'name' => esc_html__('Standard Layout', 'bluestreet') ), 'center' => array( 'image' => get_stylesheet_directory_uri() . '/images/bluestreet-header-center.png', 'name' => esc_html__('Center Layout', 'bluestreet') ) ) ) )); } add_action('customize_register', 'bluestreet_header_layout_customizer'); //radio box sanitization function function bluestreet_sanitize_radio($input, $setting) { $input = sanitize_key($input); $choices = $setting->manager->get_control($setting->id)->choices; //return if valid return ( array_key_exists($input, $choices) ? $input : $setting->default ); }