add_section( 'actify_theme_general_settings', array( 'title' => __( 'Theme Options', 'actify' ), 'priority' => 30, ) ); // Logo hight setting $wp_customize->add_setting( 'actify_logo_height', array( 'default' => 60, 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'actify_logo_height', array( 'label' => __( 'Enter logo height (in px)', 'actify' ), 'type' => 'number', 'section' => 'title_tagline', 'setting' => 'actify_logo_height', 'priority' => '9', ) ); // Sidebar Setting $wp_customize->add_setting( 'actify_sidebar_position', array( 'default' => 'hide', 'sanitize_callback' => 'actify_sanitize_select', ) ); $wp_customize->add_control( 'actify_sidebar_position', array( 'label' => __( 'Sidebar Position', 'actify' ), 'type' => 'select', 'section' => 'actify_theme_general_settings', 'setting' => 'actify_sidebar_position', 'choices' => array( 'hide' => __( 'Hide Sidebar (Default)', 'actify' ), 'right' => __( 'Right', 'actify' ), 'left' => __( 'Left', 'actify' ), ) ) ); // Display full blog post $wp_customize->add_setting( 'actify_display_full_blog', array( 'default' => false, 'sanitize_callback' => 'actify_sanitize_checkbox', ) ); $wp_customize->add_control( 'actify_display_full_blog', array( 'label' => __( 'Display full posts on the Homepage', 'actify' ), 'type' => 'checkbox', 'section' => 'actify_theme_general_settings', 'setting' => 'actify_display_full_blog', 'description' => esc_html__( 'By default, excerpt is displayed on the blog homepage.', 'actify' ), ) ); // Display header image on all pages $wp_customize->add_setting( 'actify_display_header_img_only_on_home', array( 'default' => true, 'sanitize_callback' => 'actify_sanitize_checkbox', ) ); $wp_customize->add_control( 'actify_display_header_img_only_on_home', array( 'label' => __( 'Display header image only on the Homepage', 'actify' ), 'type' => 'checkbox', 'section' => 'actify_theme_general_settings', 'setting' => 'actify_display_header_img_only_on_home', 'description' => esc_html__( 'By default, header image is displayed on all pages.', 'actify' ), 'active_callback' => 'actify_is_custom_header_active', ) ); // Hide goto top button $wp_customize->add_setting( 'actify_hide_goto_top', array( 'default' => false, 'sanitize_callback' => 'actify_sanitize_checkbox', ) ); $wp_customize->add_control( 'actify_hide_goto_top', array( 'label' => __( 'Hide "Goto Top" button from footer', 'actify' ), 'type' => 'checkbox', 'section' => 'actify_theme_general_settings', 'setting' => 'actify_hide_goto_top', 'description' => esc_html__( 'By default, it will be displayed when user scrolls down more than 700 px.', 'actify' ), ) ); // Display cover section on homepage $wp_customize->add_setting( 'actify_display_cover_section', array( 'default' => false, 'sanitize_callback' => 'actify_sanitize_checkbox', ) ); $wp_customize->add_control( 'actify_display_cover_section', array( 'label' => __( 'Display cover section on Homepage', 'actify' ), 'type' => 'checkbox', 'section' => 'actify_theme_general_settings', 'setting' => 'actify_display_cover_section', 'description' => esc_html__( 'Uncheck this setting if you want to hide cover section from the blog homepage.', 'actify' ), ) ); // Cover Image $wp_customize->add_setting('actify_cover_img', array( 'default' => get_template_directory_uri() . '/assets/images/cover-img.jpg', 'sanitize_callback' => 'actify_sanitize_image', )); $wp_customize->add_control( new WP_Customize_Image_Control($wp_customize, 'actify_cover_img', array( 'label' => __('Cover Section Image', 'actify'), 'section' => 'actify_theme_general_settings', 'setting' => 'actify_cover_img', 'active_callback' => 'actify_is_cover_active', ))); // Cover Title $wp_customize->add_setting( 'actify_cover_title', array( 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'actify_cover_title', array( 'label' => __( 'Title on Cover Section', 'actify' ), 'type' => 'text', 'section' => 'actify_theme_general_settings', 'setting' => 'actify_cover_title', 'active_callback' => 'actify_is_cover_active', ) ); $wp_customize->get_setting( 'actify_cover_title' )->transport = 'postMessage'; // Cover subtitle $wp_customize->add_setting( 'actify_cover_subtitle', array( 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'actify_cover_subtitle', array( 'label' => __( 'Sub-title on Cover Section', 'actify' ), 'type' => 'textarea', 'section' => 'actify_theme_general_settings', 'setting' => 'actify_cover_subtitle', 'active_callback' => 'actify_is_cover_active', ) ); $wp_customize->get_setting( 'actify_cover_subtitle' )->transport = 'postMessage'; function actify_sanitize_select( $input, $setting ){ //input must be a slug: lowercase alphanumeric characters, dashes and underscores are allowed only $input = sanitize_key($input); //get the list of possible select options $choices = $setting->manager->get_control( $setting->id )->choices; //return input if valid or return default option return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } function actify_sanitize_checkbox( $checked ){ //returns true if checkbox is checked return ( ( isset( $checked ) && true == $checked ) ? true : false ); }