add_panel( // $id 'broadwell_panel_general', // $args array( 'priority' => 10, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => sprintf(__( '%s General Settings', 'broadwell' ), C_NAME ), 'description' => __( 'Manage general settings for the theme', 'broadwell' ), ) ); /** * Add Panel for Front Page * */ $wp_customize->add_panel( // $id 'broadwell_panel_front', // $args array( 'priority' => 11, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => sprintf(__( '%s Front Page Settings', 'broadwell' ), C_NAME ), 'description' => __( 'Manage content for the front page', 'broadwell' ), ) ); } // Settings API options initilization and validation add_action( 'customize_register', 'broadwell_register_customizer_panels' ); /** * ADD SECTIONS */ function broadwell_register_customizer_sections( $wp_customize ){ /* * Failsafe is safe */ if ( ! isset( $wp_customize ) ) { return; } /** * General > Custom Logo * */ $wp_customize->add_section( // $id 'broadwell_section_logo', // $args array( 'title' => __( 'Custom Logo', 'broadwell' ), 'description' => __( 'Maximum size: 300 x 60', 'broadwell' ), 'panel' => 'broadwell_panel_general' ) ); /** * General > Colors * */ $wp_customize->add_section( // $id 'broadwell_section_colors', // $args array( 'title' => __( 'Colors', 'broadwell' ), 'description' => '', 'panel' => 'broadwell_panel_general' ) ); /** * General > Footer * */ $wp_customize->add_section( // $id 'broadwell_section_footer', // $args array( 'title' => __( 'Footer Settings', 'broadwell' ), 'description' => '', 'panel' => 'broadwell_panel_general' ) ); /** * General > Custom CSS * */ $wp_customize->add_section( // $id 'broadwell_section_css', // $args array( 'title' => __( 'Custom CSS', 'broadwell' ), 'description' => __( 'Add custom CSS to override default theme styles.', 'broadwell' ), 'panel' => 'broadwell_panel_general' ) ); /** * General > Blog * */ $wp_customize->add_section( // $id 'broadwell_section_blog', // $args array( 'title' => __( 'Enable Blog', 'broadwell' ), 'description' => sprintf(__( 'If checked, a menu link will be displayed that points to the blog home page. Leave unchecked if you do not plan to use the blog feature.

Keep in mind that %s is intended to be a single page theme and adding a blog will take visitors away from that single page.', 'broadwell' ), C_NAME ), 'panel' => 'broadwell_panel_general' ) ); /** * Section for Area 1 * */ $wp_customize->add_section( // $id 'broadwell_section_area1', // $args array( 'title' => __( 'Front Page - Area 1', 'broadwell' ), 'description' => __( '
This section appears at the top of the page and effectively serves as the home page.
', 'broadwell' ), 'panel' => 'broadwell_panel_front' ) ); /** * Section for Area 2 * */ $wp_customize->add_section( // $id 'broadwell_section_area2', // $args array( 'title' => __( 'Front Page - Area 2', 'broadwell' ), 'description' => '', 'panel' => 'broadwell_panel_front' ) ); /** * Section for Area 3 * */ $wp_customize->add_section( // $id 'broadwell_section_area3', // $args array( 'title' => __( 'Front Page - Area 3', 'broadwell' ), 'description' => '', 'panel' => 'broadwell_panel_front' ) ); /** * Section for Area 4 * */ $wp_customize->add_section( // $id 'broadwell_section_area4', // $args array( 'title' => __( 'Front Page - Area 4', 'broadwell' ), 'description' => '', 'panel' => 'broadwell_panel_front' ) ); /** * Section for Area 5 * */ $wp_customize->add_section( // $id 'broadwell_section_area5', // $args array( 'title' => __( 'Front Page - Area 5', 'broadwell' ), 'description' => '', 'panel' => 'broadwell_panel_front' ) ); /** * Section for Contact Area * */ $wp_customize->add_section( // $id 'broadwell_section_contact', // $args array( 'title' => __( 'Front Page - Contact Area', 'broadwell' ), 'description' => __( '
This optional section is intended to be used with any contact form plugin that generates a shortcode.
', 'broadwell' ), 'panel' => 'broadwell_panel_front' ) ); /** * Remove default panels that do not apply to this theme */ /*++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++*/ $wp_customize->remove_section('static_front_page'); $wp_customize->remove_section("colors"); $wp_customize->remove_section("background_image"); $wp_customize->remove_control("header_image"); /*++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++*/ } // Settings API options initilization and validation. add_action( 'customize_register', 'broadwell_register_customizer_sections' ); /** * ADD SETTINGS */ function broadwell_register_customizer_settings( $wp_customize ){ /* * Failsafe is safe */ if ( ! isset( $wp_customize ) ) { return; } /** * Custom Logo */ $wp_customize->add_setting( // $id 'setting_custom_logo', // $args array( 'default' => C_DEFAULT_LOGO, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_image' ) ); /** * Enable/Disable Blog */ $wp_customize->add_setting( // $id 'setting_flag_blog', // $args array( 'default' => C_DEFAULT_ENABLE_BLOG, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_checkbox' ) ); /** * Primary Color */ $wp_customize->add_setting( // $id 'setting_primary_color', // $args array( 'default' => C_DEFAULT_PRIMARY_COLOR, // leading hex tag required 'sanitize_callback' => 'broadwell_sanitize_text_field' ) ); /** * Secondary Color */ $wp_customize->add_setting( // $id 'setting_secondary_color', // $args array( 'default' => C_DEFAULT_SECONDARY_COLOR, // leading hex tag required 'sanitize_callback' => 'broadwell_sanitize_text_field' ) ); /** * Footer Credit */ $wp_customize->add_setting( // $id 'setting_footer_credit', // $args array( 'default' => C_DEFAULT_FOOTER_CREDIT, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_checkbox' ) ); /** * Footer Text */ $wp_customize->add_setting( // $id 'setting_footer_text', // $args array( 'default' => C_DEFAULT_FOOTER_TEXT, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_html' ) ); /** * Custom CSS */ $wp_customize->add_setting( // $id 'setting_custom_css', // $args array( 'default' => C_DEFAULT_CUSTOM_CSS, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_css' ) ); /** * Show Recent Posts Flag - Area 1 */ $wp_customize->add_setting( // $id 'setting_show_recent_area1', // $args array( 'default' => C_DEFAULT_RECENT_AREA1, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_checkbox' ) ); /** * Overlay text for Area 1 */ $wp_customize->add_setting( // $id 'setting_overlay_area1', // $args array( 'default' => C_DEFAULT_OVERLAY_AREA1, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_html' ) ); /** * Image for Area 1 */ $wp_customize->add_setting( // $id 'setting_image_area1', // $args array( 'default' => C_DEFAULT_IMAGE_AREA1, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_image' ) ); /** * Content for Area 1 */ $wp_customize->add_setting( // $id 'setting_content_area1', // $args array( 'default' => C_DEFAULT_CONTENT_AREA1, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_html_with_video' ) ); /** * Show Recent Posts Flag - Area 2 */ $wp_customize->add_setting( // $id 'setting_show_recent_area2', // $args array( 'default' => C_DEFAULT_RECENT_AREA2, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_checkbox' ) ); /** * Menu label for for Area 2. */ $wp_customize->add_setting( // $id 'setting_menu_area2', // $args array( 'default' => C_DEFAULT_MENU_AREA2, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_html' ) ); /** * Overlay text for Area 2. */ $wp_customize->add_setting( // $id 'setting_overlay_area2', // $args array( 'default' => C_DEFAULT_OVERLAY_AREA2, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_html' ) ); /** * Image for Area 2. */ $wp_customize->add_setting( // $id 'setting_image_area2', // $args array( 'default' => C_DEFAULT_IMAGE_AREA2, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_image' ) ); /** * Content for Area 2. */ $wp_customize->add_setting( // $id 'setting_content_area2', // $args array( 'default' => C_DEFAULT_CONTENT_AREA2, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_html_with_video' ) ); /** * Show Recent Posts Flag - Area 3 */ $wp_customize->add_setting( // $id 'setting_show_recent_area3', // $args array( 'default' => C_DEFAULT_RECENT_AREA3, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_checkbox' ) ); /** * Menu label for for Area 3. */ $wp_customize->add_setting( // $id 'setting_menu_area3', // $args array( 'default' => C_DEFAULT_MENU_AREA3, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_html' ) ); /** * Overlay text for Area 3. */ $wp_customize->add_setting( // $id 'setting_overlay_area3', // $args array( 'default' => C_DEFAULT_OVERLAY_AREA3, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_html' ) ); /** * Image for Area 3 */ $wp_customize->add_setting( // $id 'setting_image_area3', // $args array( 'default' => C_DEFAULT_IMAGE_AREA3, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_image' ) ); /** * Content for Area 3. */ $wp_customize->add_setting( // $id 'setting_content_area3', // $args array( 'default' => C_DEFAULT_CONTENT_AREA3, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_html_with_video' ) ); /** * Enable/Disable Flag for Area 4. */ $wp_customize->add_setting( // $id 'setting_flag_area4', // $args array( 'default' => C_DEFAULT_FLAG_AREA4, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_html' ) ); /** * Show Recent Posts Flag - Area 4 */ $wp_customize->add_setting( // $id 'setting_show_recent_area4', // $args array( 'default' => C_DEFAULT_RECENT_AREA4, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_checkbox' ) ); /** * Menu label for for Area 4. */ $wp_customize->add_setting( // $id 'setting_menu_area4', // $args array( 'default' => C_DEFAULT_MENU_AREA4, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_html' ) ); /** * Overlay text for Area 4. */ $wp_customize->add_setting( // $id 'setting_overlay_area4', // $args array( 'default' => C_DEFAULT_OVERLAY_AREA4, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_html' ) ); /** * Image for Area 4 */ $wp_customize->add_setting( // $id 'setting_image_area4', // $args array( 'default' => C_DEFAULT_IMAGE_AREA4, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_image' ) ); /** * Content for Area 4. */ $wp_customize->add_setting( // $id 'setting_content_area4', // $args array( 'default' => C_DEFAULT_CONTENT_AREA4, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_html_with_video' ) ); /** * Enable/Disable Flag for Area 5 */ $wp_customize->add_setting( // $id 'setting_flag_area5', // $args array( 'default' => C_DEFAULT_FLAG_AREA5, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_html' ) ); /** * Show Recent Posts Flag - Area 5 */ $wp_customize->add_setting( // $id 'setting_show_recent_area5', // $args array( 'default' => C_DEFAULT_RECENT_AREA5, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_checkbox' ) ); /** * Menu label for for Area 5 */ $wp_customize->add_setting( // $id 'setting_menu_area5', // $args array( 'default' => C_DEFAULT_MENU_AREA5, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_html' ) ); /** * Overlay text for Area 5 */ $wp_customize->add_setting( // $id 'setting_overlay_area5', // $args array( 'default' => C_DEFAULT_OVERLAY_AREA5, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_html' ) ); /** * Image for Area 5 */ $wp_customize->add_setting( // $id 'setting_image_area5', // $args array( 'default' => C_DEFAULT_IMAGE_AREA5, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_image' ) ); /** * Content for Area 5 */ $wp_customize->add_setting( // $id 'setting_content_area5', // $args array( 'default' => C_DEFAULT_CONTENT_AREA5, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_html_with_video' ) ); /** * Enable/Disable Flag for Contact Area. */ $wp_customize->add_setting( // $id 'setting_flag_contact', // $args array( 'default' => C_DEFAULT_FLAG_CONTACT, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_html' ) ); /** * Shortcode for Contact Area. */ $wp_customize->add_setting( // $id 'setting_shortcode_contact', // $args array( 'default' => C_DEFAULT_SHORTCODE_CONTACT, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', //Essential so shortcode quotes don't get escaped ) ); /** * Additional Content for Contact Area. */ $wp_customize->add_setting( // $id 'setting_additional_contact', // $args array( 'default' => C_DEFAULT_ADDITIONAL_CONTACT, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'broadwell_sanitize_html' ) ); } // Settings API options initilization and validation. add_action( 'customize_register', 'broadwell_register_customizer_settings' ); /** * ADD CONTROLS */ function broadwell_register_customizer_controls_basic( $wp_customize ){ /** * Failsafe is safe */ if ( ! isset( $wp_customize ) ) { return; } /** * Custom Logo * */ $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'setting_custom_logo', array( 'label' => 'Custom Header Logo', 'section' => 'broadwell_section_logo', 'settings' => 'setting_custom_logo', ) ) ); /** * Primary Color * */ $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'setting_primary_color', array( 'label' => __( 'Primary Color', 'broadwell' ), 'section' => 'broadwell_section_colors', 'settings' => 'setting_primary_color', ) ) ); /** * Secondary Color * */ $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'setting_secondary_color', array( 'label' => __( 'Secondary Color', 'broadwell' ), 'section' => 'broadwell_section_colors', 'settings' => 'setting_secondary_color', ) ) ); /** * Footer Text * */ $wp_customize->add_control( // $id 'control_footer_text', // $args array( 'settings' => 'setting_footer_text', 'section' => 'broadwell_section_footer', 'type' => 'textarea', 'label' => __( 'Footer Copyright Text', 'broadwell' ), 'description' => __( 'Copyright or other text to be displayed in the site footer. HTML allowed.', 'broadwell' ) ) ); /** * Footer Credit * */ $wp_customize->add_control( // $id 'control_footer_credit', // $args array( 'settings' => 'setting_footer_credit', 'section' => 'broadwell_section_footer', 'type' => 'checkbox', 'label' => __( 'Show Theme Credit in the Footer?', 'broadwell' ), 'description' => '' ) ); /** * Enable/Disable Blog * */ $wp_customize->add_control( // $id 'control_flag_blog', // $args array( 'settings' => 'setting_flag_blog', 'section' => 'broadwell_section_blog', 'type' => 'checkbox', 'label' => __( 'Enable Blog?', 'broadwell' ), 'description' => '' ) ); /** * Custom CSS * */ $wp_customize->add_control( // $id 'control_custom_css', // $args array( 'settings' => 'setting_custom_css', 'section' => 'broadwell_section_css', 'type' => 'textarea', 'label' => __( 'Custom CSS', 'broadwell' ), 'description' => __( 'Enter custom css code without the style tags', 'broadwell' ) ) ); /** * Overlay Text for Area 1 * */ $wp_customize->add_control( // $id 'control_overlay_area1', // $args array( 'settings' => 'setting_overlay_area1', 'section' => 'broadwell_section_area1', 'type' => 'text', 'label' => __( 'Optional Overlay Text', 'broadwell' ), 'description' => '' ) ); /** * Image for Area 1 * */ $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'setting_image_area1', array( 'label' => 'Background Image', 'section' => 'broadwell_section_area1', 'settings' => 'setting_image_area1', ) ) ); /** * Show Posts Flag for Area 1 * */ $wp_customize->add_control( // $id 'control_recent_flag_area1', // $args array( 'settings' => 'setting_show_recent_area1', 'section' => 'broadwell_section_area1', 'type' => 'checkbox', 'label' => __( 'Display Recent Blog Posts in this section?', 'broadwell' ), 'description' => __( 'If checked, this section will display the title and an excerpt of your three most recent blog posts instead of the content below.', 'broadwell' ) ) ); /** * Content for Area 1 * */ $wp_customize->add_control( // $id 'control_content_area1', // $args array( 'settings' => 'setting_content_area1', 'section' => 'broadwell_section_area1', 'type' => 'textarea', 'label' => __( 'Content for Area 1', 'broadwell' ), 'description' => __( 'HTML allowed.', 'broadwell' ) ) ); /** * Menu Label for Area 2 * */ $wp_customize->add_control( // $id 'control_menu_area2', // $args array( 'settings' => 'setting_menu_area2', 'section' => 'broadwell_section_area2', 'type' => 'text', 'label' => __( 'Menu Label', 'broadwell' ), 'description' => '', ) ); /** * Overlay Text for Area 2 * */ $wp_customize->add_control( // $id 'control_overlay_area2', // $args array( 'settings' => 'setting_overlay_area2', 'section' => 'broadwell_section_area2', 'type' => 'text', 'label' => __( 'Optional Overlay Text', 'broadwell' ), 'description' => '', ) ); /** * Image for Area 2 * */ $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'setting_image_area2', array( 'label' => 'Background Image', 'section' => 'broadwell_section_area2', 'settings' => 'setting_image_area2', ) ) ); /** * Show Posts Flag for Area 2 * */ $wp_customize->add_control( // $id 'control_recent_flag_area2', // $args array( 'settings' => 'setting_show_recent_area2', 'section' => 'broadwell_section_area2', 'type' => 'checkbox', 'label' => __( 'Display Recent Blog Posts in this section?', 'broadwell' ), 'description' => __( 'If checked, this section will display the title and an excerpt of your three most recent blog posts instead of the content below.', 'broadwell' ) ) ); /** * Content for Area 2 * */ $wp_customize->add_control( // $id 'control_content_area2', // $args array( 'settings' => 'setting_content_area2', 'section' => 'broadwell_section_area2', 'type' => 'textarea', 'label' => __( 'Content', 'broadwell' ), 'description' => __( 'HTML allowed.', 'broadwell' ) ) ); /** * Menu Label for Area 3 * */ $wp_customize->add_control( // $id 'control_menu_area3', // $args array( 'settings' => 'setting_menu_area3', 'section' => 'broadwell_section_area3', 'type' => 'text', 'label' => __( 'Menu Label', 'broadwell' ), 'description' => '', ) ); /** * Overlay Text for Area 3 * */ $wp_customize->add_control( // $id 'control_overlay_area3', // $args array( 'settings' => 'setting_overlay_area3', 'section' => 'broadwell_section_area3', 'type' => 'text', 'label' => __( 'Optional Overlay Text', 'broadwell' ), 'description' => '', ) ); /** * Image for Area 3 * */ $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'setting_image_area3', array( 'label' => 'Background Image', 'section' => 'broadwell_section_area3', 'settings' => 'setting_image_area3', ) ) ); /** * Show Posts Flag for Area 3 * */ $wp_customize->add_control( // $id 'control_recent_flag_area3', // $args array( 'settings' => 'setting_show_recent_area3', 'section' => 'broadwell_section_area3', 'type' => 'checkbox', 'label' => __( 'Display Recent Blog Posts in this section?', 'broadwell' ), 'description' => __( 'If checked, this section will display the title and an excerpt of your three most recent blog posts instead of the content below.', 'broadwell' ) ) ); /** * Content for Area 3 * */ $wp_customize->add_control( // $id 'control_content_area3', // $args array( 'settings' => 'setting_content_area3', 'section' => 'broadwell_section_area3', 'type' => 'textarea', 'label' => __( 'Content', 'broadwell' ), 'description' => __( 'HTML allowed.', 'broadwell' ) ) ); /** * Flag for Area 4 * */ $wp_customize->add_control( // $id 'control_flag_area4', // $args array( 'settings' => 'setting_flag_area4', 'section' => 'broadwell_section_area4', 'type' => 'checkbox', 'label' => __( 'Enable Area 4?', 'broadwell' ), 'description' => __( 'This section is optional. Check to enable it. Leave unchecked to hide it.', 'broadwell' ) ) ); /** * Menu Label for Area 4 * */ $wp_customize->add_control( // $id 'control_menu_area4', // $args array( 'settings' => 'setting_menu_area4', 'section' => 'broadwell_section_area4', 'type' => 'text', 'label' => __( 'Menu Label', 'broadwell' ), 'description' => '', ) ); /** * Overlay Text for Area 4 * */ $wp_customize->add_control( // $id 'control_overlay_area4', // $args array( 'settings' => 'setting_overlay_area4', 'section' => 'broadwell_section_area4', 'type' => 'text', 'label' => __( 'Optional Overlay Text', 'broadwell' ), 'description' => '', ) ); /** * Image for Area 4 * */ $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'setting_image_area4', array( 'label' => 'Background Image', 'section' => 'broadwell_section_area4', 'settings' => 'setting_image_area4', ) ) ); /** * Show Posts Flag for Area 4 * */ $wp_customize->add_control( // $id 'control_recent_flag_area4', // $args array( 'settings' => 'setting_show_recent_area4', 'section' => 'broadwell_section_area4', 'type' => 'checkbox', 'label' => __( 'Display Recent Blog Posts in this section?', 'broadwell' ), 'description' => __( 'If checked, this section will display the title and an excerpt of your three most recent blog posts instead of the content below.', 'broadwell' ) ) ); /** * Content for Area 4 * */ $wp_customize->add_control( // $id 'control_content_area4', // $args array( 'settings' => 'setting_content_area4', 'section' => 'broadwell_section_area4', 'type' => 'textarea', 'label' => __( 'Content', 'broadwell' ), 'description' => __( 'HTML allowed.', 'broadwell' ) ) ); /** * Flag for Area 5 * */ $wp_customize->add_control( // $id 'control_flag_area5', // $args array( 'settings' => 'setting_flag_area5', 'section' => 'broadwell_section_area5', 'type' => 'checkbox', 'label' => __( 'Enable Area 5?', 'broadwell' ), 'description' => __( 'This section is optional. Check to enable it. Leave unchecked to hide it.', 'broadwell' ) ) ); /** * Menu Label for Area 5 * */ $wp_customize->add_control( // $id 'control_menu_area5', // $args array( 'settings' => 'setting_menu_area5', 'section' => 'broadwell_section_area5', 'type' => 'text', 'label' => __( 'Menu Label', 'broadwell' ), 'description' => '', ) ); /** * Overlay Text for Area 5 * */ $wp_customize->add_control( // $id 'control_overlay_area5', // $args array( 'settings' => 'setting_overlay_area5', 'section' => 'broadwell_section_area5', 'type' => 'text', 'label' => __( 'Optional Overlay Text', 'broadwell' ), 'description' => '', ) ); /** * Image for Area 5 * */ $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'setting_image_area5', array( 'label' => 'Background Image', 'section' => 'broadwell_section_area5', 'settings' => 'setting_image_area5', ) ) ); /** * Show Posts Flag for Area 5 * */ $wp_customize->add_control( // $id 'control_recent_flag_area5', // $args array( 'settings' => 'setting_show_recent_area5', 'section' => 'broadwell_section_area5', 'type' => 'checkbox', 'label' => __( 'Display Recent Blog Posts in this section?', 'broadwell' ), 'description' => __( 'If checked, this section will display the title and an excerpt of your three most recent blog posts instead of the content below.', 'broadwell' ) ) ); /** * Content for Area 5 * */ $wp_customize->add_control( // $id 'control_content_area5', // $args array( 'settings' => 'setting_content_area5', 'section' => 'broadwell_section_area5', 'type' => 'textarea', 'label' => __( 'Content', 'broadwell' ), 'description' => __( 'HTML allowed.', 'broadwell' ) ) ); /** * Flag for Contact Area * */ $wp_customize->add_control( // $id 'control_flag_contact', // $args array( 'settings' => 'setting_flag_contact', 'section' => 'broadwell_section_contact', 'type' => 'checkbox', 'label' => __( 'Enable Contact Area?', 'broadwell' ), 'description' => __( 'This section is optional. Check to enable it. Leave unchecked to hide it.', 'broadwell' ) ) ); /** * Shortcode for Contact Area * */ $wp_customize->add_control( // $id 'control_shortcode_contact', // $args array( 'settings' => 'setting_shortcode_contact', 'section' => 'broadwell_section_contact', 'type' => 'text', 'label' => __( 'Shortcode', 'broadwell' ), 'description' => __( 'Enter the whole shortcode that will generate your contact form, including the brackets. For example: [contact-form]', 'broadwell' ), ) ); /** * Additional Content for Contact Area * */ $wp_customize->add_control( // $id 'control_additional_contact', // $args array( 'settings' => 'setting_additional_contact', 'section' => 'broadwell_section_contact', 'type' => 'textarea', 'label' => __( 'Optional Contact Details', 'broadwell' ), 'description' => __( 'Enter content that you would like to appear next to your contact form, such as a Google map, your address or other details. HTML is allowed.', 'broadwell' ) ) ); /*++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++*/ } // Settings API options initilization and validation. add_action( 'customize_register', 'broadwell_register_customizer_controls_basic' ); /** * SANITIZATION FUNCTIONS * * @credit: Mostly adopted from the examples provided by the Theme Review Team. Don't reinvent the wheel. */ function broadwell_sanitize_checkbox( $checked ) { // Boolean check. return ( ( isset( $checked ) && true == $checked ) ? true : false ); } /** * CSS sanitization callback example. * * - Sanitization: css * - Control: text, textarea * * Sanitization callback for 'css' type textarea inputs. This callback sanitizes * `$css` for valid CSS. * * NOTE: wp_strip_all_tags() can be passed directly as `$wp_customize->add_setting()` * 'sanitize_callback'. It is wrapped in a callback here merely for example purposes. * * @see wp_strip_all_tags() https://developer.wordpress.org/reference/functions/wp_strip_all_tags/ * * @param string $css CSS to sanitize. * @return string Sanitized CSS. */ function broadwell_sanitize_css( $css ) { return wp_strip_all_tags( $css ); } /** * Drop-down Pages sanitization callback example. * * - Sanitization: dropdown-pages * - Control: dropdown-pages * * Sanitization callback for 'dropdown-pages' type controls. This callback sanitizes `$page_id` * as an absolute integer, and then validates that $input is the ID of a published page. * * @see absint() https://developer.wordpress.org/reference/functions/absint/ * @see get_post_status() https://developer.wordpress.org/reference/functions/get_post_status/ * * @param int $page Page ID. * @param WP_Customize_Setting $setting Setting instance. * @return int|string Page ID if the page is published; otherwise, the setting default. */ function broadwell_sanitize_dropdown_pages( $page_id, $setting ) { // Ensure $input is an absolute integer. $page_id = absint( $page_id ); // If $page_id is an ID of a published page, return it; otherwise, return the default. return ( 'publish' == get_post_status( $page_id ) ? $page_id : $setting->default ); } /** * Email sanitization callback example. * * - Sanitization: email * - Control: text * * Sanitization callback for 'email' type text controls. This callback sanitizes `$email` * as a valid email address. * * @see sanitize_email() https://developer.wordpress.org/reference/functions/sanitize_key/ * @link sanitize_email() https://codex.wordpress.org/Function_Reference/sanitize_email * * @param string $email Email address to sanitize. * @param WP_Customize_Setting $setting Setting instance. * @return string The sanitized email if not null; otherwise, the setting default. */ function broadwell_sanitize_email( $email, $setting ) { // Sanitize $input as a hex value without the hash prefix. $email = sanitize_email( $email ); // If $email is a valid email, return it; otherwise, return the default. return ( ! null( $email ) ? $email : $setting->default ); } /** * HEX Color sanitization callback example. * * - Sanitization: hex_color * - Control: text, WP_Customize_Color_Control * * Note: sanitize_hex_color_no_hash() can also be used here, depending on whether * or not the hash prefix should be stored/retrieved with the hex color value. * * @see sanitize_hex_color() https://developer.wordpress.org/reference/functions/sanitize_hex_color/ * @link sanitize_hex_color_no_hash() https://developer.wordpress.org/reference/functions/sanitize_hex_color_no_hash/ * * @param string $hex_color HEX color to sanitize. * @param WP_Customize_Setting $setting Setting instance. * @return string The sanitized hex color if not null; otherwise, the setting default. */ function broadwell_sanitize_hex_color( $hex_color, $setting ) { // Sanitize $input as a hex value without the hash prefix. $hex_color = sanitize_hex_color( $hex_color ); // If $input is a valid hex value, return it; otherwise, return the default. return ( ! null( $hex_color ) ? $hex_color : $setting->default ); } /** * HTML sanitization callback example. * * - Sanitization: html * - Control: text, textarea * * Sanitization callback for 'html' type text inputs. This callback sanitizes `$html` * for HTML allowable in posts. * * NOTE: wp_filter_post_kses() can be passed directly as `$wp_customize->add_setting()` * 'sanitize_callback'. It is wrapped in a callback here merely for example purposes. * * @see wp_filter_post_kses() https://developer.wordpress.org/reference/functions/wp_filter_post_kses/ * * @param string $html HTML to sanitize. * @return string Sanitized HTML. */ function broadwell_sanitize_html( $html ) { return wp_filter_post_kses( $html ); //return wp_kses( $html, 'iframe' ); } /** * Image sanitization callback example. * * Checks the image's file extension and mime type against a whitelist. If they're allowed, * send back the filename, otherwise, return the setting default. * * - Sanitization: image file extension * - Control: text, WP_Customize_Image_Control * * @see wp_check_filetype() https://developer.wordpress.org/reference/functions/wp_check_filetype/ * * @param string $image Image filename. * @param WP_Customize_Setting $setting Setting instance. * @return string The image filename if the extension is allowed; otherwise, the setting default. */ function broadwell_sanitize_image( $image, $setting ) { /* * Array of valid image file types. * * The array includes image mime types that are included in wp_get_mime_types() */ $mimes = array( 'jpg|jpeg|jpe' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', 'bmp' => 'image/bmp', 'tif|tiff' => 'image/tiff', 'ico' => 'image/x-icon' ); // Return an array with file extension and mime_type. $file = wp_check_filetype( $image, $mimes ); // If $image has a valid mime_type, return it; otherwise, return the default. return ( $file['ext'] ? $image : $setting->default ); } /** * No-HTML sanitization callback example. * * - Sanitization: nohtml * - Control: text, textarea, password * * Sanitization callback for 'nohtml' type text inputs. This callback sanitizes `$nohtml` * to remove all HTML. * * NOTE: wp_filter_nohtml_kses() can be passed directly as `$wp_customize->add_setting()` * 'sanitize_callback'. It is wrapped in a callback here merely for example purposes. * * @see wp_filter_nohtml_kses() https://developer.wordpress.org/reference/functions/wp_filter_nohtml_kses/ * * @param string $nohtml The no-HTML content to sanitize. * @return string Sanitized no-HTML content. */ function broadwell_sanitize_nohtml( $nohtml ) { return wp_filter_nohtml_kses( $nohtml ); } /** * Number sanitization callback example. * * - Sanitization: number_absint * - Control: number * * Sanitization callback for 'number' type text inputs. This callback sanitizes `$number` * as an absolute integer (whole number, zero or greater). * * NOTE: absint() can be passed directly as `$wp_customize->add_setting()` 'sanitize_callback'. * It is wrapped in a callback here merely for example purposes. * * @see absint() https://developer.wordpress.org/reference/functions/absint/ * * @param int $number Number to sanitize. * @param WP_Customize_Setting $setting Setting instance. * @return int Sanitized number; otherwise, the setting default. */ function broadwell_sanitize_number_absint( $number, $setting ) { // Ensure $number is an absolute integer (whole number, zero or greater). $number = absint( $number ); // If the input is an absolute integer, return it; otherwise, return the default return ( $number ? $number : $setting->default ); } /** * Number Range sanitization callback example. * * - Sanitization: number_range * - Control: number, tel * * Sanitization callback for 'number' or 'tel' type text inputs. This callback sanitizes * `$number` as an absolute integer within a defined min-max range. * * @see absint() https://developer.wordpress.org/reference/functions/absint/ * * @param int $number Number to check within the numeric range defined by the setting. * @param WP_Customize_Setting $setting Setting instance. * @return int|string The number, if it is zero or greater and falls within the defined range; otherwise, * the setting default. */ function broadwell_sanitize_number_range( $number, $setting ) { // Ensure input is an absolute integer. $number = absint( $number ); // Get the input attributes associated with the setting. $atts = $setting->manager->get_control( $setting->id )->input_attrs; // Get minimum number in the range. $min = ( isset( $atts['min'] ) ? $atts['min'] : $number ); // Get maximum number in the range. $max = ( isset( $atts['max'] ) ? $atts['max'] : $number ); // Get step. $step = ( isset( $atts['step'] ) ? $atts['step'] : 1 ); // If the number is within the valid range, return it; otherwise, return the default return ( $min <= $number && $number <= $max && is_int( $number / $step ) ? $number : $setting->default ); } /** * Select sanitization callback example. * * - Sanitization: select * - Control: select, radio * * Sanitization callback for 'select' and 'radio' type controls. This callback sanitizes `$input` * as a slug, and then validates `$input` against the choices defined for the control. * * @see sanitize_key() https://developer.wordpress.org/reference/functions/sanitize_key/ * @see $wp_customize->get_control() https://developer.wordpress.org/reference/classes/wp_customize_manager/get_control/ * * @param string $input Slug to sanitize. * @param WP_Customize_Setting $setting Setting instance. * @return string Sanitized slug if it is a valid choice; otherwise, the setting default. */ function broadwell_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 ); } /** * URL sanitization callback example. * * - Sanitization: url * - Control: text, url * * Sanitization callback for 'url' type text inputs. This callback sanitizes `$url` as a valid URL. * * NOTE: esc_url_raw() can be passed directly as `$wp_customize->add_setting()` 'sanitize_callback'. * It is wrapped in a callback here merely for example purposes. * * @see esc_url_raw() https://developer.wordpress.org/reference/functions/esc_url_raw/ * * @param string $url URL to sanitize. * @return string Sanitized URL. */ function broadwell_sanitize_url( $url ) { return esc_url_raw( $url ); } /** * Sanitize a Text Field * */ function broadwell_sanitize_text_field( $text ) { return sanitize_text_field( $text ); } /** * Allow Admins to embed Youtube videos. Sanitize everything else. * */ function broadwell_html_with_video( $text ) { $content = $text; $searchStr= "https://www.youtube.com/embed"; if( strpos( $content,$searchStr ) AND current_user_can( 'edit_theme_options' ) ) { return $text; } else { return wp_filter_post_kses( $text ); } } /** * Set Default Values * */ function broadwell_initialize_settings() { set_theme_mod ( 'setting_custom_logo', C_DEFAULT_LOGO ); set_theme_mod ( 'setting_flag_blog', C_DEFAULT_ENABLE_BLOG ); set_theme_mod ( 'setting_primary_color', C_DEFAULT_PRIMARY_COLOR ); set_theme_mod ( 'setting_secondary_color', C_DEFAULT_SECONDARY_COLOR ); set_theme_mod ( 'setting_footer_credit', C_DEFAULT_FOOTER_CREDIT ); set_theme_mod ( 'setting_custom_css', C_DEFAULT_CUSTOM_CSS ); set_theme_mod ( 'setting_footer_text', C_DEFAULT_FOOTER_TEXT ); set_theme_mod ( 'setting_show_recent_area1', C_DEFAULT_RECENT_AREA1 ); set_theme_mod ( 'setting_overlay_area1', C_DEFAULT_OVERLAY_AREA1 ); set_theme_mod ( 'setting_image_area1', C_DEFAULT_IMAGE_AREA1 ); set_theme_mod ( 'setting_content_area1', C_DEFAULT_CONTENT_AREA1 ); set_theme_mod ( 'setting_show_recent_area2', C_DEFAULT_RECENT_AREA2 ); set_theme_mod ( 'setting_menu_area2', C_DEFAULT_MENU_AREA2 ); set_theme_mod ( 'setting_overlay_area2', C_DEFAULT_OVERLAY_AREA2 ); set_theme_mod ( 'setting_image_area2', C_DEFAULT_IMAGE_AREA2 ); set_theme_mod ( 'setting_content_area2', C_DEFAULT_CONTENT_AREA2 ); set_theme_mod ( 'setting_show_recent_area3', C_DEFAULT_RECENT_AREA3 ); set_theme_mod ( 'setting_menu_area3', C_DEFAULT_MENU_AREA3 ); set_theme_mod ( 'setting_overlay_area3', C_DEFAULT_OVERLAY_AREA3 ); set_theme_mod ( 'setting_image_area3', C_DEFAULT_IMAGE_AREA3 ); set_theme_mod ( 'setting_content_area3', C_DEFAULT_CONTENT_AREA3 ); set_theme_mod ( 'setting_flag_area4', C_DEFAULT_FLAG_AREA4 ); set_theme_mod ( 'setting_show_recent_area4', C_DEFAULT_RECENT_AREA4 ); set_theme_mod ( 'setting_menu_area4', C_DEFAULT_MENU_AREA4 ); set_theme_mod ( 'setting_overlay_area4', C_DEFAULT_OVERLAY_AREA4 ); set_theme_mod ( 'setting_image_area4', C_DEFAULT_IMAGE_AREA4 ); set_theme_mod ( 'setting_content_area4', C_DEFAULT_CONTENT_AREA4 ); set_theme_mod ( 'setting_flag_area5', C_DEFAULT_FLAG_AREA5 ); set_theme_mod ( 'setting_show_recent_area5', C_DEFAULT_RECENT_AREA5 ); set_theme_mod ( 'setting_menu_area5', C_DEFAULT_MENU_AREA5 ); set_theme_mod ( 'setting_overlay_area5', C_DEFAULT_OVERLAY_AREA5 ); set_theme_mod ( 'setting_image_area5', C_DEFAULT_IMAGE_AREA5 ); set_theme_mod ( 'setting_content_area5', C_DEFAULT_CONTENT_AREA5 ); set_theme_mod ( 'setting_flag_contact', C_DEFAULT_FLAG_CONTACT ); set_theme_mod ( 'setting_shortcode_contact', C_DEFAULT_SHORTCODE_CONTACT ); set_theme_mod ( 'setting_additional_contact', C_DEFAULT_ADDITIONAL_CONTACT ); }