slug; $i++; } $cats[$category->slug] = $category->name; } //General Section $wp_customize->add_section( 'general_section', array( 'title' => esc_html__( 'General Options','rhymes' ), 'description' => esc_html__( 'Here you can customize Your theme\'s general Settings','rhymes' ), 'capability'=>'edit_theme_options', 'priority' => 20, ) ); $wp_customize->add_setting( 'rhymes_options[site_bg_color]', array( 'default'=>'#f9f9f9', 'sanitize_callback'=>'sanitize_hex_color', 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'site_bg_color', array( 'label' => esc_html__( 'Body Background Color', 'rhymes' ), 'description' => esc_html__( 'Choose your Background color here.', 'rhymes' ), 'section' => 'general_section', 'settings' => 'rhymes_options[site_bg_color]', ) ) ); $wp_customize->add_setting( 'rhymes_options[site_color]', array( 'default'=>'#008df9', 'sanitize_callback'=>'sanitize_hex_color', 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'site_color', array( 'label' => esc_html__( 'Site Color', 'rhymes' ), 'description' => esc_html__( 'Choose your theme color here.', 'rhymes' ), 'section' => 'general_section', 'settings' => 'rhymes_options[site_color]', ) ) ); $wp_customize->add_setting( 'rhymes_options[breadcrump_bg]', array( 'default'=> get_template_directory_uri().'/images/bread_pg.png', 'sanitize_callback'=>'esc_url_raw', 'capability' => 'edit_theme_options', ) ); //Front Page Section $wp_customize->add_section( 'home_section', array( 'title' => esc_html__( 'Home Page Options','rhymes' ), 'description' => esc_html__( 'Here you can customize Your theme\'s Home Page','rhymes' ), 'capability'=>'edit_theme_options', 'priority' => 20, ) ); $wp_customize->add_setting( 'rhymes_options[show_slider]', array( 'default'=> 'on', 'sanitize_callback'=>'rhymes_checkbox_sanitize', 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( 'show_slider', array( 'label' => esc_html__( 'Show Slider', 'rhymes' ), 'description' => esc_html__( 'Checked to enable Slider On Front Page.', 'rhymes' ), 'type'=>'checkbox', 'section' => 'home_section', 'settings' => 'rhymes_options[show_slider]', ) ); $wp_customize->add_setting('rhymes_options[category_slider]', array( 'default' => '', 'sanitize_callback' => 'rhymes_sanitize_category', )); $wp_customize->add_control('rhymes_slider_control', array( 'settings' => 'rhymes_options[category_slider]', 'type' => 'select', 'label' => esc_html__('Select Category:','rhymes'), 'section' => 'home_section', 'choices' => $cats, )); $wp_customize->add_setting( 'rhymes_options[blog_heading]', array( 'default'=> '', 'sanitize_callback'=>'rhymes_text_sanitize', 'capability' => 'edit_theme_options', ) ); //Social Settings $wp_customize->add_section( 'social_section', array( 'title' => esc_html__( 'Social Settings','rhymes' ), 'description' => 'Here you can customize Social Icon Settings', 'capability'=>'edit_theme_options', 'priority' => 25, ) ); $wp_customize->add_setting( 'rhymes_options[footer_social]', array( 'default'=> 'off', 'sanitize_callback'=>'rhymes_checkbox_sanitize', 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( 'footer_social', array( 'label' => esc_html__( 'Show Social Icons On Footer', 'rhymes' ), 'description' => esc_html__( 'Checked to enable social icon on footer.', 'rhymes' ), 'type'=>'checkbox', 'section' => 'social_section', 'settings' => 'rhymes_options[footer_social]', ) ); for($i=1; $i<=5; $i++){ $wp_customize->add_setting( 'rhymes_options[social_icon_'.$i.']', array( 'default'=> '', 'sanitize_callback'=>'rhymes_text_sanitize', 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( 'social_icon_'.$i, array( 'label' => esc_html__( 'Social Icon ', 'rhymes' ).$i, 'description' => esc_html__( 'Please add FontAwesome Class of respective social. Like "fa fa-facebook"', 'rhymes' ), 'section' => 'social_section', 'settings' => 'rhymes_options[social_icon_'.$i.']', ) ); $wp_customize->add_setting( 'rhymes_options[social_icon_link_'.$i.']', array( 'default'=> '', 'sanitize_callback'=>'esc_url_raw', 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( 'social_link_'.$i, array( 'label' => esc_html__( 'Social Link ', 'rhymes' ).$i, 'description' => esc_html__( 'Provide Social link here.', 'rhymes' ), 'section' => 'social_section', 'settings' => 'rhymes_options[social_icon_link_'.$i.']', ) ); $wp_customize->add_setting( 'rhymes_options[icon_color_'.$i.']', array( 'default'=> '', 'sanitize_callback'=>'rhymes_text_sanitize', 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'icon_color_'.$i, array( 'label' => esc_html__( 'Social Icon Color ', 'rhymes' ).$i, 'description' => esc_html__( 'Choose your social icon`s color here.', 'rhymes' ), 'section' => 'social_section', 'settings' => 'rhymes_options[icon_color_'.$i.']', ) ) ); } $wp_customize->add_section( 'footer_section', array( 'title' => esc_html__( 'Footer Settings','rhymes' ), 'description' => esc_html__( 'Here you can customize Footer Settings','rhymes'), 'capability'=>'edit_theme_options', 'priority' => 30, ) ); $wp_customize->add_setting( 'rhymes_options[footer_credit]', array( 'default'=> '', 'sanitize_callback'=>'rhymes_text_sanitize', 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( 'footer_credit', array( 'label' => esc_html__( 'Footer Credit ', 'rhymes' ), 'description' => esc_html__( 'Add your footer Credit text here.','rhymes'), 'section' => 'footer_section', 'settings' => 'rhymes_options[footer_credit]', ) ); $wp_customize->add_setting( 'rhymes_options[footer_company]', array( 'default'=> '', 'sanitize_callback'=>'rhymes_text_sanitize', 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( 'footer_company', array( 'label' => esc_html__( 'Footer Credit Name ', 'rhymes' ), 'description' => esc_html__( 'Add your company name here.','rhymes'), 'section' => 'footer_section', 'settings' => 'rhymes_options[footer_company]', ) ); $wp_customize->add_setting( 'rhymes_options[footer_company_link]', array( 'default'=> '', 'sanitize_callback'=>'esc_url_raw', 'capability' => 'edit_theme_options', ) ); $wp_customize->add_control( 'footer_company_link', array( 'label' => esc_html__( 'Footer Credit Link ', 'rhymes' ), 'description' => esc_html__( 'Add your company link here.','rhymes'), 'section' => 'footer_section', 'settings' => 'rhymes_options[footer_company_link]', ) ); } function rhymes_text_sanitize( $input ) { return wp_kses_post( force_balance_tags( $input ) ); } function rhymes_checkbox_sanitize( $input ) { if($input==1){ return 'on'; }else{ return 'off'; } } function rhymes_integer_sanitize( $input ) { return (int)($input); } if ( ! function_exists( 'rhymes_sanitize_category' ) ){ function rhymes_sanitize_category( $input ) { $categories = get_categories(); $cats = array(); $i = 0; foreach($categories as $category){ if($i==0){ $default = $category->slug; $i++; } $cats[$category->slug] = $category->name; } $valid = $cats; if ( array_key_exists( $input, $valid ) ) { return $input; } else { return ''; } } }