get_control() https://developer.wordpress.org/reference/classes/wp_customize_manager/get_control/ * * @param $input * @param $setting * @return sanitized output * */ if ( !function_exists('blog_edge_sanitize_select') ) : function blog_edge_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; /** * Sanitize checkbox field * * @since blog_edge 1.0.0 * * @param $checked * @return Boolean */ if ( !function_exists('blog_edge_sanitize_checkbox') ) : function blog_edge_sanitize_checkbox( $checked ) { // Boolean check. return ( ( isset( $checked ) && true == $checked ) ? true : false ); } endif; /** * Sanitize RGBA color field * * @since blog_edge 1.0.0 * * @param $checked * @return Boolean */ function blog_edge_sanitize_rgba( $color ) { if ( empty( $color ) || is_array( $color ) ) return 'rgba(0,0,0,0)'; // If string does not start with 'rgba', then treat as hex // sanitize the hex color and finally convert hex to rgba if ( false === strpos( $color, 'rgba' ) ) { return sanitize_hex_color( $color ); } // By now we know the string is formatted as an rgba color so we need to further sanitize it. $color = str_replace( ' ', '', $color ); sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha ); return 'rgba('.$red.','.$green.','.$blue.','.$alpha.')'; } /** * Sidebar layout options * * @since blog-edge 1.0.0 * * @param null * @return array $blog_edge_sidebar_layout * */ if ( !function_exists('blog_edge_sidebar_layout') ) : function blog_edge_sidebar_layout() { $blog_edge_sidebar_layout = array( 'right-sidebar' => __( 'Right Sidebar', 'blog-edge'), 'left-sidebar' => __( 'Left Sidebar' , 'blog-edge'), 'no-sidebar' => __( 'No Sidebar', 'blog-edge') ); return apply_filters( 'blog_edge_sidebar_layout', $blog_edge_sidebar_layout ); } endif; /** * Default Theme options * * @since blog-edge 1.0.0 * * @param null * @return array $blog_edge_theme_layout * */ if ( !function_exists('blog_edge_default_theme_options') ) : function blog_edge_default_theme_options() { $default_theme_options = array( /*feature section options*/ 'blog_edge_top_header_section' =>'show', 'blog-edge-feature-cat' => 0, 'blog-edge-promo-cat' => 0, 'blog-edge-footer-copyright' => esc_html__( 'Blog Edge WordPress Theme, Copyright 2018', 'blog-edge'), 'blog-edge-layout' => 'right-sidebar', 'breadcrumb_option' => 'simple', 'blog-edge-realted-post' => 0, 'blog-edge-realted-post-title' => esc_html__( 'Related Posts', 'blog-edge' ), '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( 'blog_edge_default_theme_options', $default_theme_options ); } endif; /** * Get theme options * * @since blog-edge 1.0.0 * * @param null * @return array blog_edge_theme_options * */ if ( !function_exists('blog_edge_get_theme_options') ) : function blog_edge_get_theme_options() { $blog_edge_default_theme_options = blog_edge_default_theme_options(); $blog_edge_get_theme_options = get_theme_mod( 'blog_edge_theme_options'); if( is_array( $blog_edge_get_theme_options )){ return array_merge( $blog_edge_default_theme_options, $blog_edge_get_theme_options ); } else{ return $blog_edge_default_theme_options; } } endif; /** * Load Update to Pro section */ require get_template_directory() . '/inc/customizer-pro/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 blog_edge_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', 'blog-edge' ), 'priority' => 9 ) ); $wp_customize->add_setting( 'upgrade_text', array( 'default' => '', 'sanitize_callback' => '__return_false' ) ); $wp_customize->add_control( new blog_edge_Customize_Static_Text_Control( $wp_customize, 'upgrade_text', array( 'section' => 'theme_detail', 'label' => __( 'Upgrade to PRO', 'blog-edge' ), 'description' => array('') ) ) ); /*defaults options*/ $defaults = blog_edge_get_theme_options(); /** * Load customizer custom-controls */ require get_template_directory() . '/inc/customizer-inc/custom-controls.php'; /** * Load customizer feature section */ require get_template_directory() . '/inc/customizer-inc/blog-edge-theme-options.php'; } add_action( 'customize_register', 'blog_edge_customize_register' ); /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function blog_edge_customize_preview_js() { wp_enqueue_script( 'blog_edge_customizer', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), '20151216', true ); } add_action( 'customize_preview_init', 'blog_edge_customize_preview_js' ); function blog_edge_customizer_script() { wp_enqueue_style( 'blog-edge-customizer-style', get_template_directory_uri() .'/inc/css/customizer-style.css'); wp_enqueue_script( 'blog-edge-alpha-color-picker', get_template_directory_uri() .'/inc/js/alpha-color-picker.js',array( 'jquery', 'wp-color-picker' ), time()); } add_action( 'customize_controls_enqueue_scripts', 'blog_edge_customizer_script' );