get_control() https://developer.wordpress.org/reference/classes/wp_customize_manager/get_control/ * * @param $input * @param $setting * @return sanitized output * */ if ( !function_exists('blogyard_sanitize_select') ) : function blogyard_sanitize_select( $input, $setting ) { // Ensure input is a slug. $input = sanitize_key( $input ); // Get list of choices from the control associated with the setting. $choices = $setting->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 ); } endif; /** * Sidebar layout options * * @since 1.0.0 * * @param null * @return array $blogyard_sidebar_layout * */ if ( !function_exists('blogyard_sidebar_layout') ) : function blogyard_sidebar_layout() { $blogyard_sidebar_layout = array( 'right-sidebar' => __( 'Right Sidebar', 'blogyard'), 'left-sidebar' => __( 'Left Sidebar' , 'blogyard'), 'no-sidebar' => __( 'No Sidebar', 'blogyard') ); return apply_filters( 'blogyard_sidebar_layout', $blogyard_sidebar_layout ); } endif; /** * Default Theme options * * @since 1.0.0 * * @param null * @return array $blogyard_theme_layout * */ if ( !function_exists('blogyard_default_theme_options') ) : function blogyard_default_theme_options() { $default_theme_options = array( /*feature section options*/ 'blogyard-feature-cat' => 0, 'blogyard-promo-cat' => 0, 'blogyard-footer-copyright' => esc_html__( 'Copyright 2017, All rights reserved.', 'blogyard'), 'blogyard-layout' => 'right-sidebar', 'breadcrumb_option' => 'enable', 'blogyard-realted-post' => 0, 'blogyard-realted-post-title' => esc_html__( 'Related Posts', 'blogyard' ), 'hide-breadcrumb-at-home' => 1 , 'primary_color' => '#222222', 'slider_caption_bg_color' => 'rgba(249,244,242,0.64)', 'hide-slider-post-at-category' => 1, ); return apply_filters( 'blogyard_default_theme_options', $default_theme_options ); } endif; /** * Get theme options * * @since 1.0.0 * * @param null * @return array blogyard_theme_options * */ if ( !function_exists('blogyard_get_theme_options') ) : function blogyard_get_theme_options() { $blogyard_default_theme_options = blogyard_default_theme_options(); $blogyard_get_theme_options = get_theme_mod( 'blogyard_theme_options'); if( is_array( $blogyard_get_theme_options )){ return array_merge( $blogyard_default_theme_options, $blogyard_get_theme_options ); } else{ return $blogyard_default_theme_options; } } endif; /** * Load Update to Pro section */ require get_template_directory() . '/inc/upgrade/class-customize.php'; /** * Add postMessage support for site title and description for the Theme Customizer. * * @param WP_Customize_Manager $wp_customize Theme Customizer object. */ function blogyard_customize_register( $wp_customize ) { $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; $wp_customize->add_section( 'theme_detail', array( 'title' => __( 'About Theme', 'blogyard' ), 'priority' => 9 ) ); $wp_customize->add_setting( 'upgrade_text', array( 'default' => '', 'sanitize_callback' => '__return_false' ) ); $wp_customize->add_control( new Blogyard_cstmz_Static_Text_Control( $wp_customize, 'upgrade_text', array( 'section' => 'theme_detail', 'label' => __( 'Upgrade to PRO', 'blogyard' ), 'description' => array('') ) ) ); /*defaults options*/ $defaults = blogyard_get_theme_options(); /** * Load customizer custom-controls */ require get_template_directory() . '/inc/customizer/custom-controls.php'; /** * Load customizer feature section */ require get_template_directory() . '/inc/customizer/theme-options.php'; } add_action( 'customize_register', 'blogyard_customize_register' ); /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function blogyard_customize_preview_js() { wp_enqueue_script( 'blogyard_customizer', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), '20151216', true ); } add_action( 'customize_preview_init', 'blogyard_customize_preview_js' );