get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; // Load sanitize functions. include get_template_directory() . '/inc/customizer-button/sanitize.php'; include get_template_directory() . '/inc/customizer-button/upsell-section.php'; if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'render_callback' => 'ca_simplex_blog_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'ca_simplex_blog_customize_partial_blogdescription', ) ); } $wp_customize->register_section_type( 'ca_simplex_blog_Customize_Upsell_Section' ); // Register section. $wp_customize->add_section( new ca_simplex_blog_Customize_Upsell_Section( $wp_customize, 'theme_upsell', array( 'title' => esc_html__( 'CA Simplex blog Pro', 'ca-simplex-blog' ), 'pro_text' => esc_html__( 'Upgrade To Pro', 'ca-simplex-blog' ), 'pro_url' => 'https://wpthemes.chitrarchana.com/ca-simplex-blog-premuim-theme/', 'priority' => 1, ) ) ); } add_action( 'customize_register', 'ca_simplex_blog_customize_register_btn' ); /** * Render the site title for the selective refresh partial. * * @return void */ function ca_simplex_blog_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function ca_simplex_blog_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function ca_simplex_blog_customize_preview_js() { wp_enqueue_script( 'ca-simplex-blog-customizer', get_template_directory_uri() . '/inc/customizer-button/customizer.js', array( 'customize-preview' ), '20151215', true ); } add_action( 'customize_preview_init', 'ca_simplex_blog_customize_preview_js' ); /** * Customizer control scripts and styles. * * @since 1.0.0 */ function ca_simplex_blog_customizer_control_scripts() { wp_enqueue_style( 'ca-simplex-blog-customize-controls', get_template_directory_uri() . '/inc/customizer-button/customize-controls.css', '', '1.0.0' ); wp_enqueue_script( 'ca-simplex-blog-customize-controls', get_template_directory_uri() . '/inc/customizer-button/customize-controls.js', array( 'customize-controls' ), '1.0.0', true ); } add_action( 'customize_controls_enqueue_scripts', 'ca_simplex_blog_customizer_control_scripts', 0 ); //---------------------Code to add the Upgrade to Pro button in the Customizer End---------- //------------------Theme Information-------------------- function ca_simplex_blog_customize_register( $wp_customize ) { // Add a custom setting for the primary color $wp_customize->add_setting( 'ca_simplex_blog_primary_color', array( 'default' => '#0073aa', 'sanitize_callback' => 'sanitize_hex_color', ) ); // Add a custom control for the primary color $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ca_simplex_blog_primary_color', array( 'label' => __( 'Primary Color', 'ca-simplex-blog' ), 'section' => 'colors', 'settings' => 'ca_simplex_blog_primary_color', ) ) ); //-----------------------------------Home Front Page------------------------------- $wp_customize->add_panel( 'ca_simplex_blog_panel', array( 'title' => __( 'Front Page Settings', 'ca-simplex-blog' ), 'priority' => 100, ) ); //-----------------------------------------------------------------Section One (Featured Post)------------------------------------------ $wp_customize->add_section( 'ca_simplex_blog_section1', array( 'title' => __( 'Featured Post (Section One)', 'ca-simplex-blog' ), 'priority' => 10, 'panel' => 'ca_simplex_blog_panel', ) ); //-----------------Enable Option Section One------------- $wp_customize->add_setting('ca_simplex_blog_section1_enable',array( 'default' => 'Enable', 'sanitize_callback' => 'ca_simplex_blog_sanitize_choices' )); $wp_customize->add_control('ca_simplex_blog_section1_enable',array( 'type' => 'radio', 'label' => __('Do you want this section', 'ca-simplex-blog'), 'section' => 'ca_simplex_blog_section1', 'choices' => array( 'Enable' => __('Enable', 'ca-simplex-blog'), 'Disable' => __('Disable', 'ca-simplex-blog') ))); //--------------Section One Title----------------------- $wp_customize->add_setting('ca_simplex_blog_section1_title',array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field' ) ); $wp_customize->add_control('ca_simplex_blog_section1_title',array( 'label' => __('Section Title','ca-simplex-blog'), 'section' => 'ca_simplex_blog_section1', 'setting' => 'ca_simplex_blog_section1_title', 'type' => 'text' ) ); //-----------Category------------ $categories = get_categories(); $cats = array(); $i = 0; foreach($categories as $category){ if($i==0){ $default = $category->name; $i++; } $cats[$category->name] = $category->name; } $wp_customize->add_setting('ca_simplex_blog_section1_category',array( 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('ca_simplex_blog_section1_category',array( 'type' => 'select', 'choices' => $cats, 'label' => __('Select Category to Display Post','ca-simplex-blog'), 'section' => 'ca_simplex_blog_section1', )); //-----------------------------------------------------------------Section Two (Latest Post)------------------------------------------ $wp_customize->add_section( 'ca_simplex_blog_section2', array( 'title' => __( 'Latest Post (Section Two)', 'ca-simplex-blog' ), 'priority' => 10, 'panel' => 'ca_simplex_blog_panel', ) ); //-----------------Enable Option Section Two------------- $wp_customize->add_setting('ca_simplex_blog_section2_enable',array( 'default' => 'Enable', 'sanitize_callback' => 'ca_simplex_blog_sanitize_choices' )); $wp_customize->add_control('ca_simplex_blog_section2_enable',array( 'type' => 'radio', 'label' => __('Do you want this section', 'ca-simplex-blog'), 'section' => 'ca_simplex_blog_section2', 'choices' => array( 'Enable' => __('Enable', 'ca-simplex-blog'), 'Disable' => __('Disable', 'ca-simplex-blog') ))); //--------------Section Two Title----------------------- $wp_customize->add_setting('ca_simplex_blog_section2_title',array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field' ) ); $wp_customize->add_control('ca_simplex_blog_section2_title',array( 'label' => __('Section Title','ca-simplex-blog'), 'section' => 'ca_simplex_blog_section2', 'setting' => 'ca_simplex_blog_section2_title', 'type' => 'text' ) ); $categories = get_categories(); $cats = array(); $i = 0; foreach($categories as $category){ if($i==0){ $default = $category->name; $i++; } $cats[$category->name] = $category->name; } $wp_customize->add_setting('ca_simplex_blog_section2_category',array( 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('ca_simplex_blog_section2_category',array( 'type' => 'select', 'choices' => $cats, 'label' => __('Select Category to Display Post','ca-simplex-blog'), 'section' => 'ca_simplex_blog_section2', )); //-----------------------------------------------------------------Section Three ( News)------------------------------------------ $wp_customize->add_section( 'ca_simplex_blog_section3', array( 'title' => __( 'Latest News (Section Three)', 'ca-simplex-blog' ), 'priority' => 10, 'panel' => 'ca_simplex_blog_panel', ) ); //-----------------Enable Option Section Two------------- $wp_customize->add_setting('ca_simplex_blog_section3_enable',array( 'default' => 'Enable', 'sanitize_callback' => 'ca_simplex_blog_sanitize_choices' )); $wp_customize->add_control('ca_simplex_blog_section3_enable',array( 'type' => 'radio', 'label' => __('Do you want this section', 'ca-simplex-blog'), 'section' => 'ca_simplex_blog_section3', 'choices' => array( 'Enable' => __('Enable', 'ca-simplex-blog'), 'Disable' => __('Disable', 'ca-simplex-blog') ))); //--------------Section Two Title----------------------- $wp_customize->add_setting('ca_simplex_blog_section3_title',array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field' ) ); $wp_customize->add_control('ca_simplex_blog_section3_title',array( 'label' => __('Section Title','ca-simplex-blog'), 'section' => 'ca_simplex_blog_section3', 'setting' => 'ca_simplex_blog_section3_title', 'type' => 'text' ) ); $categories = get_categories(); $cats = array(); $i = 0; foreach($categories as $category){ if($i==0){ $default = $category->name; $i++; } $cats[$category->name] = $category->name; } $wp_customize->add_setting('ca_simplex_blog_section3_category',array( 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('ca_simplex_blog_section3_category',array( 'type' => 'select', 'choices' => $cats, 'label' => __('Select Category to Display Post','ca-simplex-blog'), 'section' => 'ca_simplex_blog_section3', )); //-------------------------Footer Settings------------------------------ $wp_customize->add_section( 'ca_simplex_blog_footer', array( 'title' => __( 'Footer Settings', 'ca-simplex-blog' ), 'priority' => 10, 'panel' => 'ca_simplex_blog_panel', ) ); // Add a custom setting for the footer text $wp_customize->add_setting( 'ca_simplex_blog_footer_text', array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); // Add a custom control for the footer text $wp_customize->add_control( 'ca_simplex_blog_footer_text', array( 'label' => __( 'Footer Text', 'ca-simplex-blog' ), 'section' => 'ca_simplex_blog_footer', 'type' => 'text', ) ); } add_action( 'customize_register', 'ca_simplex_blog_customize_register' );