get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'background_color' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; /** * Theme Options Panel */ $wp_customize->add_panel( 'canyon_theme_options', array( 'title' => esc_html__( 'Theme Options', 'canyon' ), 'priority' => 1, ) ); /** * General Options Section */ $wp_customize->add_section( 'canyon_general_options', array ( 'title' => esc_html__( 'General Options', 'canyon' ), 'panel' => 'canyon_theme_options', 'priority' => 10, 'description' => esc_html__( 'Personalize the settings of your theme.', 'canyon' ), ) ); // Theme Layout $wp_customize->add_setting ( 'canyon_theme_layout', array( 'default' => canyon_default( 'canyon_theme_layout' ), 'sanitize_callback' => 'canyon_sanitize_select', ) ); $wp_customize->add_control ( 'canyon_theme_layout', array( 'label' => esc_html__( 'Theme Layout', 'canyon' ), 'description' => esc_html__( 'Box layout will be visible at minimum 1200px display', 'canyon' ), 'section' => 'canyon_general_options', 'priority' => 1, 'type' => 'select', 'choices' => array( 'wide' => esc_html__( 'Wide', 'canyon' ), 'box' => esc_html__( 'Box', 'canyon' ), ), ) ); // Featured Image Size $wp_customize->add_setting ( 'canyon_featured_image_size', array ( 'default' => canyon_default( 'canyon_featured_image_size' ), 'sanitize_callback' => 'canyon_sanitize_select', ) ); $wp_customize->add_control ( 'canyon_featured_image_size', array ( 'label' => esc_html__( 'Featured Image Size', 'canyon' ), 'section' => 'canyon_general_options', 'priority' => 2, 'type' => 'select', 'choices' => array( 'landscape' => esc_html__( 'Landscape', 'canyon'), 'landscape-half' => esc_html__( 'Landscape Small', 'canyon'), 'landscape-quarter' => esc_html__( 'Landscape Tiny', 'canyon'), ), ) ); // Main Sidebar Position $wp_customize->add_setting ( 'canyon_sidebar_position', array ( 'default' => canyon_default( 'canyon_sidebar_position' ), 'sanitize_callback' => 'canyon_sanitize_select', ) ); $wp_customize->add_control ( 'canyon_sidebar_position', array ( 'label' => esc_html__( 'Main Sidebar Position (if active)', 'canyon' ), 'section' => 'canyon_general_options', 'priority' => 3, 'type' => 'select', 'choices' => array( 'right' => esc_html__( 'Right', 'canyon'), 'left' => esc_html__( 'Left', 'canyon'), ), ) ); /** * Footer Section */ $wp_customize->add_section( 'canyon_footer_options', array ( 'title' => esc_html__( 'Footer Options', 'canyon' ), 'panel' => 'canyon_theme_options', 'priority' => 20, 'description' => esc_html__( 'Personalize the footer settings of your theme.', 'canyon' ), ) ); // Copyright Control $wp_customize->add_setting ( 'canyon_copyright', array ( 'default' => canyon_default( 'canyon_copyright' ), 'transport' => 'postMessage', 'sanitize_callback' => 'wp_kses_post', ) ); $wp_customize->add_control ( 'canyon_copyright', array ( 'label' => esc_html__( 'Copyright', 'canyon' ), 'section' => 'canyon_footer_options', 'priority' => 1, 'type' => 'textarea', ) ); // Credit Control $wp_customize->add_setting ( 'canyon_credit', array ( 'default' => canyon_default( 'canyon_credit' ), 'transport' => 'postMessage', 'sanitize_callback' => 'canyon_sanitize_checkbox', ) ); $wp_customize->add_control ( 'canyon_credit', array ( 'label' => esc_html__( 'Display Designer Credit', 'canyon' ), 'section' => 'canyon_footer_options', 'priority' => 2, 'type' => 'checkbox', ) ); // Support Section $wp_customize->add_section( 'canyon_support_options', array( 'title' => esc_html__( 'Support Options', 'canyon' ), 'description' => esc_html__( 'Thanks for your interest in Canyon! If you have any questions or run into any trouble, please visit us the following links. We will get you fixed up!', 'canyon' ), 'panel' => 'canyon_theme_options', 'priority' => 30, ) ); // Theme Support $wp_customize->add_setting ( 'canyon_theme_support', array( 'default' => '', ) ); $wp_customize->add_control( new Canyon_Button_Control( $wp_customize, 'canyon_theme_support', array( 'label' => esc_html__( 'Canyon Support', 'canyon' ), 'section' => 'canyon_support_options', 'priority' => 1, 'type' => 'canyon-button', 'button_tag' => 'a', 'button_class' => 'button button-primary', 'button_href' => 'https://designcanyon.com/contact/', 'button_target' => '_blank', ) ) ); // Theme Review Section $wp_customize->add_section( 'canyon_review_options', array( 'title' => esc_html__( 'Enjoying the theme?', 'canyon' ), 'description' => esc_html__( 'Why not leave us a review on WordPress.org? We\'d really appreciate it!', 'canyon' ), 'panel' => 'canyon_theme_options', 'priority' => 40, ) ); // Theme $wp_customize->add_setting ( 'canyon_theme_review', array( 'default' => '', ) ); $wp_customize->add_control( new Canyon_Button_Control( $wp_customize, 'canyon_theme_review', array( 'label' => esc_html__( 'Review on WordPress.org', 'canyon' ), 'section' => 'canyon_review_options', 'type' => 'canyon-button', 'button_tag' => 'a', 'button_class' => 'button button-primary', 'button_href' => 'https://wordpress.org/support/theme/canyon/reviews', 'button_target' => '_blank', ) ) ); } add_action( 'customize_register', 'canyon_customize_register' ); /** * Button Control Class */ if ( class_exists( 'WP_Customize_Control' ) ) { class Canyon_Button_Control extends WP_Customize_Control { /** * @access public * @var string */ public $type = 'canyon-button'; /** * HTML tag to render button object. * * @var string */ protected $button_tag = 'button'; /** * Class to render button object. * * @var string */ protected $button_class = 'button button-primary'; /** * Link for based button. * * @var string */ protected $button_href = 'javascript:void(0)'; /** * Target for based button. * * @var string */ protected $button_target = ''; /** * Click event handler. * * @var string */ protected $button_onclick = ''; /** * ID attribute for HTML tab. * * @var string */ protected $button_tag_id = ''; /** * Render the control's content. */ public function render_content() { ?> button_tag ); // button class if ( ! empty( $this->button_class ) ) { echo ' class="' . esc_attr( $this->button_class ) . '"'; } // button or href if ( 'button' == $this->button_tag ) { echo ' type="button"'; } else { echo ' href="' . esc_url( $this->button_href ) . '"' . ( empty( $this->button_tag ) ? '' : ' target="' . esc_attr( $this->button_target ) . '"' ); } // onClick Event if ( ! empty( $this->button_onclick ) ) { echo ' onclick="' . esc_js( $this->button_onclick ) . '"'; } // ID if ( ! empty( $this->button_tag_id ) ) { echo ' id="' . esc_attr( $this->button_tag_id ) . '"'; } echo '>'; // Print text inside tag echo esc_html( $this->label ); // Print close tag echo 'button_tag ) . '>'; ?> manager->get_control( $setting->id )->choices; // If the input is a valid key, return it; otherwise, return the default. return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } /** * Sanitize the checkbox. * * @param bool $checked Whether the checkbox is checked. * @return bool Whether the checkbox is checked. */ function canyon_sanitize_checkbox( $checked ) { return ( ( isset( $checked ) && true === $checked ) ? true : false ); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function canyon_customize_preview_js() { wp_enqueue_script( 'canyon_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20140120', true ); } add_action( 'customize_preview_init', 'canyon_customize_preview_js' );