add_section( 'popular_section', array( 'title' => __( 'Popular Posts', 'blossom-floral-pro' ), 'priority' => 57, 'panel' => 'frontpage_settings', ) ); /** Enable Popular Area */ $wp_customize->add_setting( 'ed_popular', array( 'default' => true, 'sanitize_callback' => 'blossom_floral_pro_sanitize_checkbox' ) ); $wp_customize->add_control( new Blossom_Floral_Pro_Toggle_Control( $wp_customize, 'ed_popular', array( 'section' => 'popular_section', 'label' => __( 'Enable Popular Section', 'blossom-floral-pro' ), 'description' => __( 'Enable to show popular section in home page.', 'blossom-floral-pro' ), ) ) ); $wp_customize->add_setting( 'popular_bg', array( 'default' => get_template_directory_uri() . '/images/popularpost-flower.png', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'popular_bg', array( 'label' => esc_html__( 'Popular Background Image', 'blossom-floral-pro' ), 'description' => esc_html__( 'Choose background Image of your choice. The recommended size for image is 1920px by 493px in PNG format.', 'blossom-floral-pro' ), 'section' => 'popular_section', 'type' => 'image', ) ) ); $wp_customize->add_setting( 'popular_bg_two', array( 'default' => get_template_directory_uri() . '/images/popular-post-right-flower.png', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'popular_bg_two', array( 'label' => esc_html__( 'Secondary Background Image', 'blossom-floral-pro' ), 'description' => esc_html__( 'This will appear at the top right corner of popular section. The recommended size for image is 133px by 140px in PNG format.', 'blossom-floral-pro' ), 'section' => 'popular_section', 'type' => 'image', ) ) ); /** Popular Section Title */ $wp_customize->add_setting( 'popular_title', array( 'default' => __( 'Popular Now', 'blossom-floral-pro' ), 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage' ) ); $wp_customize->add_control( 'popular_title', array( 'type' => 'text', 'section' => 'popular_section', 'label' => __( 'Section Title', 'blossom-floral-pro' ), ) ); $wp_customize->selective_refresh->add_partial( 'popular_title', array( 'selector' => '.popular-post .section-header h2.section-title', 'render_callback' => 'blossom_floral_pro_get_popular_title_cb', ) ); /** Popular Section SubTitle */ $wp_customize->add_setting( 'popular_subtitle', array( 'default' => '', 'sanitize_callback' => 'sanitize_textarea_field', 'transport' => 'postMessage' ) ); $wp_customize->add_control( 'popular_subtitle', array( 'type' => 'textarea', 'section' => 'popular_section', 'label' => __( 'Section Subtitle', 'blossom-floral-pro' ), ) ); $wp_customize->selective_refresh->add_partial( 'popular_subtitle', array( 'selector' => '.popular-post .section-desc', 'render_callback' => 'blossom_floral_pro_get_popular_subtitle', ) ); $wp_customize->add_setting( 'popular_type', array( 'default' => 'category', 'sanitize_callback' => 'blossom_floral_pro_sanitize_select' ) ); $wp_customize->add_control( new Blossom_Floral_Pro_Select_Control( $wp_customize, 'popular_type', array( 'label' => __( 'Popular posts based on:', 'blossom-floral-pro' ), 'section' => 'popular_section', 'choices' => array( 'category' => __( 'Select Category', 'blossom-floral-pro' ), 'popular' => __( 'Popular Posts', 'blossom-floral-pro' ), 'custom' => __( 'Custom Select', 'blossom-floral-pro' ), ) ) ) ); /** Popular Length */ $wp_customize->add_setting( 'popular_length', array( 'default' => 6, 'sanitize_callback' => 'blossom_floral_pro_sanitize_number_absint' ) ); $wp_customize->add_control( new Blossom_Floral_Pro_Slider_Control( $wp_customize, 'popular_length', array( 'section' => 'popular_section', 'label' => __( 'Popular posts length', 'blossom-floral-pro' ), 'description' => __( 'Total number of popular posts to show', 'blossom-floral-pro' ), 'choices' => array( 'min' => 3, 'max' => 20, 'step' => 1, ), 'active_callback' => 'blossom_floral_pro_popular_section_ac' ) ) ); /** Popular Post Category */ $wp_customize->add_setting( 'popular_cat', array( 'default' => '', 'sanitize_callback' => 'blossom_floral_pro_sanitize_select' ) ); $wp_customize->add_control( new Blossom_Floral_Pro_Select_Control( $wp_customize, 'popular_cat', array( 'label' => __( 'Select Post Category', 'blossom-floral-pro' ), 'section' => 'popular_section', 'choices' => blossom_floral_pro_get_categories(), 'active_callback' => 'blossom_floral_pro_popular_section_ac' ) ) ); $wp_customize->add_setting( new Blossom_Floral_Pro_Repeater_Setting( $wp_customize, 'custom_posts_repeater', array( 'default' => '', 'sanitize_callback' => array( 'Blossom_Floral_Pro_Repeater_Setting', 'sanitize_repeater_setting' ), ) ) ); $wp_customize->add_control( new Blossom_Floral_Pro_Control_Repeater( $wp_customize, 'custom_posts_repeater', array( 'section' => 'popular_section', 'label' => esc_html__( 'Select Posts', 'blossom-floral-pro' ), 'fields' => array( 'post' => array( 'type' => 'select', 'label' => esc_html__( 'Select posts to display as popular posts', 'blossom-floral-pro' ), 'choices' => blossom_floral_pro_get_posts( 'post', true ) ) ), 'row_label' => array( 'type' => 'field', 'value' => esc_html__( 'posts', 'blossom-floral-pro' ), 'field' => 'post' ), 'active_callback' => 'blossom_floral_pro_popular_section_ac' ) ) ); } add_action( 'customize_register', 'blossom_floral_pro_customize_register_frontpage_popular' );