get_setting('blogname')->transport = 'postMessage'; $wp_customize->get_setting('blogdescription')->transport = 'postMessage'; $wp_customize->get_setting('header_textcolor')->transport = 'postMessage'; $wp_customize->remove_control('display_header_text'); //$wp_customize->remove_control('header_textcolor'); function blog_build_sanitize_select($input, $setting) { $input = sanitize_key($input); $choices = $setting->manager->get_control($setting->id)->choices; return (array_key_exists($input, $choices) ? $input : $setting->default); } $wp_customize->add_setting( 'blog_build_hide_tagline', array( 'default' => 1, 'sanitize_callback' => 'absint', 'transport' => 'refresh', ) ); // Add the control $wp_customize->add_control( 'blog_build_hide_tagline', array( 'label' => __('Hide Tagline', 'blog-build'), 'description' => __('Check this to hide the tagline but keep the site title visible.', 'blog-build'), 'section' => 'title_tagline', 'settings' => 'blog_build_hide_tagline', 'type' => 'checkbox', 'priority' => 45, ) ); // Blog Build panel and section $wp_customize->add_panel('blog_build_settings', array( 'priority' => 50, 'title' => __('Blog Build Theme settings', 'blog-build'), 'description' => __('All Blog Build theme settings', 'blog-build'), )); /** * General Settings for Blog Build Theme */ // Add General Settings Section $wp_customize->add_section('blog_build_general_settings', array( 'title' => __('General Settings', 'blog-build'), 'panel' => 'blog_build_settings', 'priority' => 10, )); // Preloader Enable/Disable $wp_customize->add_setting('blog_build_show_preloader', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_show_preloader', array( 'label' => __('Enable Preloader', 'blog-build'), 'description' => __('Show or hide the site preloader.', 'blog-build'), 'section' => 'blog_build_general_settings', 'settings' => 'blog_build_show_preloader', 'type' => 'checkbox', )); // Back to Top Button $wp_customize->add_setting('blog_build_show_back_to_top', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_show_back_to_top', array( 'label' => __('Show Back to Top Button', 'blog-build'), 'description' => __('Display a button to scroll back to the top of the page.', 'blog-build'), 'section' => 'blog_build_general_settings', 'settings' => 'blog_build_show_back_to_top', 'type' => 'checkbox', )); // Breadcrumbs $wp_customize->add_setting('blog_build_show_breadcrumbs', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_show_breadcrumbs', array( 'label' => __('Show Breadcrumbs', 'blog-build'), 'description' => __('Display breadcrumb navigation on pages and posts.', 'blog-build'), 'section' => 'blog_build_general_settings', 'settings' => 'blog_build_show_breadcrumbs', 'type' => 'checkbox', )); /** * Typography Settings for Blog Build Theme */ // Add Typography Section $wp_customize->add_section('blog_build_typography', array( 'title' => __('Typography', 'blog-build'), 'panel' => 'blog_build_settings', 'priority' => 30, )); // Body Font Family $wp_customize->add_setting('blog_build_body_font_family', array( 'default' => 'Oxygen', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'blog_buildpro_sanitize_font', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_body_font_family', array( 'label' => __('Body Font Family', 'blog-build'), 'description' => __('Enter the font family for body text.', 'blog-build'), 'section' => 'blog_build_typography', 'settings' => 'blog_build_body_font_family', 'type' => 'select', 'choices' => blog_build_google_fonts(), )); // Body Font Size $wp_customize->add_setting('blog_build_body_font_size', array( 'default' => 16, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_body_font_size', array( 'label' => __('Body Font Size (px)', 'blog-build'), 'description' => __('Set the font size for body text.', 'blog-build'), 'section' => 'blog_build_typography', 'settings' => 'blog_build_body_font_size', 'type' => 'number', 'input_attrs' => array( 'min' => 10, 'max' => 32, 'step' => 1, ), )); // Body Font Weight $wp_customize->add_setting('blog_build_body_font_weight', array( 'default' => 400, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_body_font_weight', array( 'label' => __('Body Font Weight', 'blog-build'), 'description' => __('Set the font weight for body text.', 'blog-build'), 'section' => 'blog_build_typography', 'settings' => 'blog_build_body_font_weight', 'type' => 'number', 'input_attrs' => array( 'min' => 100, 'max' => 900, 'step' => 100, ), )); // Body Line Height $wp_customize->add_setting('blog_build_body_line_height', array( 'default' => 1.5, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'blog_build_sanitize_float', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_body_line_height', array( 'label' => __('Body Line Height', 'blog-build'), 'description' => __('Set the line height for body text.', 'blog-build'), 'section' => 'blog_build_typography', 'settings' => 'blog_build_body_line_height', 'type' => 'number', 'input_attrs' => array( 'min' => 0.8, 'max' => 3, 'step' => 0.1, ), )); // Body Letter Spacing $wp_customize->add_setting('blog_build_body_letter_spacing', array( 'default' => 0, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'blog_build_sanitize_float', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_body_letter_spacing', array( 'label' => __('Body Letter Spacing (px)', 'blog-build'), 'description' => __('Set the letter spacing for body text.', 'blog-build'), 'section' => 'blog_build_typography', 'settings' => 'blog_build_body_letter_spacing', 'type' => 'number', 'input_attrs' => array( 'min' => -2, 'max' => 5, 'step' => 0.1, ), )); // Link Color $wp_customize->add_setting('blog_build_link_color', array( 'default' => '#0D0C22', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'refresh', )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'blog_build_link_color', array( 'label' => __('Link Color', 'blog-build'), 'description' => __('Choose the color for links.', 'blog-build'), 'section' => 'blog_build_typography', 'settings' => 'blog_build_link_color', ))); // Link Hover Color $wp_customize->add_setting('blog_build_link_hover_color', array( 'default' => '#1F2447', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'refresh', )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'blog_build_link_hover_color', array( 'label' => __('Link Hover Color', 'blog-build'), 'description' => __('Choose the hover color for links.', 'blog-build'), 'section' => 'blog_build_typography', 'settings' => 'blog_build_link_hover_color', ))); // Link Text Decoration $wp_customize->add_setting('blog_build_link_text_decoration', array( 'default' => 'none', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'blog_build_sanitize_select', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_link_text_decoration', array( 'label' => __('Link Text Decoration', 'blog-build'), 'description' => __('Select text decoration for links.', 'blog-build'), 'section' => 'blog_build_typography', 'settings' => 'blog_build_link_text_decoration', 'type' => 'select', 'choices' => array( 'none' => __('None', 'blog-build'), 'underline' => __('Underline', 'blog-build'), 'overline' => __('Overline', 'blog-build'), 'line-through' => __('Line Through', 'blog-build'), ), )); // Link Text Decoration Hover $wp_customize->add_setting('blog_build_link_text_decoration_hover', array( 'default' => 'none', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'blog_build_sanitize_select', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_link_text_decoration_hover', array( 'label' => __('Link Hover Text Decoration', 'blog-build'), 'description' => __('Select text decoration for links on hover.', 'blog-build'), 'section' => 'blog_build_typography', 'settings' => 'blog_build_link_text_decoration_hover', 'type' => 'select', 'choices' => array( 'none' => __('None', 'blog-build'), 'underline' => __('Underline', 'blog-build'), 'overline' => __('Overline', 'blog-build'), 'line-through' => __('Line Through', 'blog-build'), ), )); // Header Font Family $wp_customize->add_setting('blog_build_header_font_family', array( 'default' => 'Encode Sans Condensed', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'blog_buildpro_sanitize_font', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_header_font_family', array( 'label' => __('Header Font Family', 'blog-build'), 'description' => __('Select the font family for headings.', 'blog-build'), 'section' => 'blog_build_typography', 'settings' => 'blog_build_header_font_family', 'type' => 'select', 'choices' => blog_build_google_fonts(), )); // Header Font Weight $wp_customize->add_setting('blog_build_header_font_weight', array( 'default' => 700, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_header_font_weight', array( 'label' => __('Header Font Weight', 'blog-build'), 'description' => __('Set the font weight for headings.', 'blog-build'), 'section' => 'blog_build_typography', 'settings' => 'blog_build_header_font_weight', 'type' => 'number', 'input_attrs' => array( 'min' => 100, 'max' => 900, 'step' => 100, ), )); // Header Line Height $wp_customize->add_setting('blog_build_header_line_height', array( 'default' => 1.5, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'blog_build_sanitize_float', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_header_line_height', array( 'label' => __('Header Line Height', 'blog-build'), 'description' => __('Set the line height for headings.', 'blog-build'), 'section' => 'blog_build_typography', 'settings' => 'blog_build_header_line_height', 'type' => 'number', 'input_attrs' => array( 'min' => 0.8, 'max' => 3, 'step' => 0.1, ), )); // Header Letter Spacing $wp_customize->add_setting('blog_build_header_letter_spacing', array( 'default' => 0, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'blog_build_sanitize_float', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_header_letter_spacing', array( 'label' => __('Header Letter Spacing (px)', 'blog-build'), 'description' => __('Set the letter spacing for headings.', 'blog-build'), 'section' => 'blog_build_typography', 'settings' => 'blog_build_header_letter_spacing', 'type' => 'number', 'input_attrs' => array( 'min' => -2, 'max' => 5, 'step' => 0.1, ), )); // Header Settings Section $wp_customize->add_section('blog_build_header', array( 'title' => __('Blog Build Header Settings', 'blog-build'), 'capability' => 'edit_theme_options', 'description' => __('Blog Build theme header settings', 'blog-build'), 'panel' => 'blog_build_settings', )); $wp_customize->add_setting('blog_build_header_style', array( 'default' => 'style1', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'blog_build_sanitize_select', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_header_style', array( 'label' => __('Header Style', 'blog-build'), 'description' => __('You can set the menu style one or two. ', 'blog-build'), 'section' => 'blog_build_header', 'settings' => 'blog_build_header_style', 'type' => 'select', 'choices' => array( 'style1' => __('Style One', 'blog-build'), 'style2' => __('Style Two', 'blog-build'), ), )); // Blog Settings Section $wp_customize->add_section('blog_build_blog', array( 'title' => __('Blog Build Blog Settings', 'blog-build'), 'capability' => 'edit_theme_options', 'description' => __('Blog Build theme blog settings', 'blog-build'), 'panel' => 'blog_build_settings', )); // 1. Container Type $wp_customize->add_setting('blog_build_container_type', array( 'default' => 'container', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'blog_build_sanitize_select', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_container_type', array( 'label' => __('Container Type', 'blog-build'), 'description' => __('Select container type for your blog layout.', 'blog-build'), 'section' => 'blog_build_blog', 'settings' => 'blog_build_container_type', 'type' => 'select', 'choices' => array( 'container' => __('Container', 'blog-build'), 'container-fluid' => __('Container Fluid', 'blog-build'), ), )); // 3. Blog Sidebar Position $wp_customize->add_setting('blog_build_blog_sidebar', array( 'default' => 'rightside', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'blog_build_sanitize_select', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_blog_sidebar', array( 'label' => __('Blog Sidebar Position', 'blog-build'), 'description' => __('Select sidebar position for blog pages.', 'blog-build'), 'section' => 'blog_build_blog', 'settings' => 'blog_build_blog_sidebar', 'type' => 'select', 'choices' => array( 'leftside' => __('Left Sidebar', 'blog-build'), 'rightside' => __('Right Sidebar', 'blog-build'), 'no-sidebar' => __('No Sidebar', 'blog-build'), ), )); // 2. Blog Layout $wp_customize->add_setting('blog_build_blog_layout', array( 'default' => 'grid', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'blog_build_sanitize_select', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_blog_layout', array( 'label' => __('Blog Layout', 'blog-build'), 'description' => __('Select layout for your blog posts.', 'blog-build'), 'section' => 'blog_build_blog', 'settings' => 'blog_build_blog_layout', 'type' => 'select', 'choices' => array( 'grid' => __('Grid', 'blog-build'), 'list' => __('List', 'blog-build'), 'classic' => __('Classic', 'blog-build'), ), )); // 4. Blog Category Display $wp_customize->add_setting('blog_build_show_categories', array( 'default' => '', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_show_categories', array( 'label' => __('Display Post Categories', 'blog-build'), 'description' => __('Show or hide post categories on blog posts.', 'blog-build'), 'section' => 'blog_build_blog', 'settings' => 'blog_build_show_categories', 'type' => 'checkbox', )); // 5. Blog Post Date Display $wp_customize->add_setting('blog_build_show_date', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_show_date', array( 'label' => __('Display Post Date', 'blog-build'), 'description' => __('Show or hide post date on blog posts.', 'blog-build'), 'section' => 'blog_build_blog', 'settings' => 'blog_build_show_date', 'type' => 'checkbox', )); // 6. Blog Post Author Display $wp_customize->add_setting('blog_build_show_author', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_show_author', array( 'label' => __('Display Post Author', 'blog-build'), 'description' => __('Show or hide post author on blog posts.', 'blog-build'), 'section' => 'blog_build_blog', 'settings' => 'blog_build_show_author', 'type' => 'checkbox', )); // 7. Blog Post Comment Display $wp_customize->add_setting('blog_build_show_comments', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_show_comments', array( 'label' => __('Display Comment Count', 'blog-build'), 'description' => __('Show or hide comment count on blog posts.', 'blog-build'), 'section' => 'blog_build_blog', 'settings' => 'blog_build_show_comments', 'type' => 'checkbox', )); // 8. Blog Post Content Display $wp_customize->add_setting('blog_build_show_content', array( 'default' => 0, // Default false for grid layout 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_show_content', array( 'label' => __('Display Post Content', 'blog-build'), 'description' => __('Show or hide post excerpt/content on blog posts. (Default: Hidden for Grid, Visible for List & Classic)', 'blog-build'), 'section' => 'blog_build_blog', 'settings' => 'blog_build_show_content', 'type' => 'checkbox', )); // 9. Blog Post Read More Link Display $wp_customize->add_setting('blog_build_show_readmore', array( 'default' => 0, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_show_readmore', array( 'label' => __('Display Read More Link', 'blog-build'), 'description' => __('Show or hide read more link on blog posts.', 'blog-build'), 'section' => 'blog_build_blog', 'settings' => 'blog_build_show_readmore', 'type' => 'checkbox', )); // 10. Blog Post Read More Text $wp_customize->add_setting('blog_build_readmore_text', array( 'default' => __('Read More', 'blog-build'), 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_readmore_text', array( 'label' => __('Read More Text', 'blog-build'), 'description' => __('Customize the read more link text.', 'blog-build'), 'section' => 'blog_build_blog', 'settings' => 'blog_build_readmore_text', 'type' => 'text', )); // Single Post Settings Section $wp_customize->add_section('blog_build_single_post', array( 'title' => __('Blog Build Single Post Settings', 'blog-build'), 'capability' => 'edit_theme_options', 'description' => __('Blog Build theme single post settings', 'blog-build'), 'panel' => 'blog_build_settings', )); // 1. Container Type $wp_customize->add_setting('blog_build_single_container_type', array( 'default' => 'container', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'blog_build_sanitize_select', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_single_container_type', array( 'label' => __('Container Type', 'blog-build'), 'description' => __('Select container type for single post layout.', 'blog-build'), 'section' => 'blog_build_single_post', 'settings' => 'blog_build_single_container_type', 'type' => 'select', 'choices' => array( 'container' => __('Container', 'blog-build'), 'container-fluid' => __('Container Fluid', 'blog-build'), ), )); // 2. Single Post Sidebar Position $wp_customize->add_setting('blog_build_single_sidebar', array( 'default' => 'rightside', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'blog_build_sanitize_select', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_single_sidebar', array( 'label' => __('Single Post Sidebar Position', 'blog-build'), 'description' => __('Select sidebar position for single post pages.', 'blog-build'), 'section' => 'blog_build_single_post', 'settings' => 'blog_build_single_sidebar', 'type' => 'select', 'choices' => array( 'leftside' => __('Left Sidebar', 'blog-build'), 'rightside' => __('Right Sidebar', 'blog-build'), 'no-sidebar' => __('No Sidebar', 'blog-build'), ), )); // 3. Single Post Date Display $wp_customize->add_setting('blog_build_single_show_date', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_single_show_date', array( 'label' => __('Display Post Date', 'blog-build'), 'description' => __('Show or hide post date on single post.', 'blog-build'), 'section' => 'blog_build_single_post', 'settings' => 'blog_build_single_show_date', 'type' => 'checkbox', )); // 4. Single Post Author Display $wp_customize->add_setting('blog_build_single_show_author', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_single_show_author', array( 'label' => __('Display Post Author', 'blog-build'), 'description' => __('Show or hide post author on single post.', 'blog-build'), 'section' => 'blog_build_single_post', 'settings' => 'blog_build_single_show_author', 'type' => 'checkbox', )); // 5. Single Post Category Display $wp_customize->add_setting('blog_build_single_show_categories', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_single_show_categories', array( 'label' => __('Display Categories', 'blog-build'), 'description' => __('Show or hide categories on single post.', 'blog-build'), 'section' => 'blog_build_single_post', 'settings' => 'blog_build_single_show_categories', 'type' => 'checkbox', )); // 6. Single Post Tags Display $wp_customize->add_setting('blog_build_single_show_tags', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_single_show_tags', array( 'label' => __('Display Tags', 'blog-build'), 'description' => __('Show or hide tags on single post.', 'blog-build'), 'section' => 'blog_build_single_post', 'settings' => 'blog_build_single_show_tags', 'type' => 'checkbox', )); // 7. Single Post Navigation Display $wp_customize->add_setting('blog_build_single_show_navigation', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_single_show_navigation', array( 'label' => __('Display Next/Previous Navigation', 'blog-build'), 'description' => __('Show or hide next/previous post navigation on single post.', 'blog-build'), 'section' => 'blog_build_single_post', 'settings' => 'blog_build_single_show_navigation', 'type' => 'checkbox', )); // 8. Single Post Comments Display $wp_customize->add_setting('blog_build_single_show_comments', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_single_show_comments', array( 'label' => __('Display Comments', 'blog-build'), 'description' => __('Show or hide comments section on single post.', 'blog-build'), 'section' => 'blog_build_single_post', 'settings' => 'blog_build_single_show_comments', 'type' => 'checkbox', )); // Page Settings Section $wp_customize->add_section('blog_build_page', array( 'title' => __('Blog Build Page Settings', 'blog-build'), 'capability' => 'edit_theme_options', 'description' => __('Blog Build theme page settings', 'blog-build'), 'panel' => 'blog_build_settings', )); // 1. Container Type $wp_customize->add_setting('blog_build_page_container_type', array( 'default' => 'container', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'blog_build_sanitize_select', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_page_container_type', array( 'label' => __('Container Type', 'blog-build'), 'description' => __('Select container type for pages.', 'blog-build'), 'section' => 'blog_build_page', 'settings' => 'blog_build_page_container_type', 'type' => 'select', 'choices' => array( 'container' => __('Container', 'blog-build'), 'container-fluid' => __('Container Fluid', 'blog-build'), ), )); // 3. Page Edit Link Display $wp_customize->add_setting('blog_build_page_show_edit_link', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_page_show_edit_link', array( 'label' => __('Display Edit Link For Admin', 'blog-build'), 'description' => __('Show or hide edit link on pages for logged-in users.', 'blog-build'), 'section' => 'blog_build_page', 'settings' => 'blog_build_page_show_edit_link', 'type' => 'checkbox', )); // Additional useful page options // 4. Page Title Display $wp_customize->add_setting('blog_build_page_show_title', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_page_show_title', array( 'label' => __('Display Page Title', 'blog-build'), 'description' => __('Show or hide page title on pages.', 'blog-build'), 'section' => 'blog_build_page', 'settings' => 'blog_build_page_show_title', 'type' => 'checkbox', )); // 5. Page Featured Image Display $wp_customize->add_setting('blog_build_page_show_featured_image', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_page_show_featured_image', array( 'label' => __('Display Featured Image', 'blog-build'), 'description' => __('Show or hide featured image on pages.', 'blog-build'), 'section' => 'blog_build_page', 'settings' => 'blog_build_page_show_featured_image', 'type' => 'checkbox', )); // 6. Page Comments Display $wp_customize->add_setting('blog_build_page_show_comments', array( 'default' => 0, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_page_show_comments', array( 'label' => __('Display Comments', 'blog-build'), 'description' => __('Show or hide comments section on pages.', 'blog-build'), 'section' => 'blog_build_page', 'settings' => 'blog_build_page_show_comments', 'type' => 'checkbox', )); // 404 Page Settings Section $wp_customize->add_section('blog_build_404', array( 'title' => __('Blog Build 404 Page Settings', 'blog-build'), 'capability' => 'edit_theme_options', 'description' => __('Blog Build theme 404 page settings', 'blog-build'), 'panel' => 'blog_build_settings', )); // 1. 404 Image Upload $wp_customize->add_setting('blog_build_404_image', array( 'default' => '', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'esc_url_raw', 'transport' => 'refresh', )); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'blog_build_404_image', array( 'label' => __('404 Page Image', 'blog-build'), 'description' => __('Upload an image for the 404 page.', 'blog-build'), 'section' => 'blog_build_404', 'settings' => 'blog_build_404_image', ))); // 2. 404 Page Title $wp_customize->add_setting('blog_build_404_title', array( 'default' => __('404', 'blog-build'), 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_404_title', array( 'label' => __('404 Page Title', 'blog-build'), 'description' => __('Enter the title for the 404 page.', 'blog-build'), 'section' => 'blog_build_404', 'settings' => 'blog_build_404_title', 'type' => 'text', )); // 3. 404 Page Description $wp_customize->add_setting('blog_build_404_description', array( 'default' => __('Page not found', 'blog-build'), 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_404_description', array( 'label' => __('404 Page Description', 'blog-build'), 'description' => __('Enter the description text for the 404 page.', 'blog-build'), 'section' => 'blog_build_404', 'settings' => 'blog_build_404_description', 'type' => 'text', )); // 4. 404 Page Button Show $wp_customize->add_setting('blog_build_404_button_show', array( 'default' => 1, 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'absint', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_404_button_show', array( 'label' => __('Display Back Button', 'blog-build'), 'description' => __('Show or hide the back button on 404 page.', 'blog-build'), 'section' => 'blog_build_404', 'settings' => 'blog_build_404_button_show', 'type' => 'checkbox', )); // 5. 404 Page Button Text - Show only if button is enabled $wp_customize->add_setting('blog_build_404_button_text', array( 'default' => __('Back to Home', 'blog-build'), 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_404_button_text', array( 'label' => __('Button Text', 'blog-build'), 'description' => __('Enter the text for the back button.', 'blog-build'), 'section' => 'blog_build_404', 'settings' => 'blog_build_404_button_text', 'type' => 'text', 'active_callback' => 'blog_build_is_404_button_enabled', )); // 6. 404 Page Button Link - Show only if button is enabled $wp_customize->add_setting('blog_build_404_button_link', array( 'default' => esc_url(home_url()), 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'esc_url_raw', 'transport' => 'refresh', )); $wp_customize->add_control('blog_build_404_button_link', array( 'label' => __('Button Link', 'blog-build'), 'description' => __('Enter the URL for the back button. Default is homepage.', 'blog-build'), 'section' => 'blog_build_404', 'settings' => 'blog_build_404_button_link', 'type' => 'text', 'input_attrs' => array( 'placeholder' => '/', ), 'active_callback' => 'blog_build_is_404_button_enabled', )); /** * Sanitize float value */ if (!function_exists('blog_build_sanitize_float')) { function blog_build_sanitize_float($input) { return filter_var($input, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); } } // Active callback function to check if 404 button is enabled if (!function_exists('blog_build_is_404_button_enabled')) { function blog_build_is_404_button_enabled() { if(get_theme_mod('blog_build_404_button_show', 1) == 1) { return true; } return false; } } if (isset($wp_customize->selective_refresh)) { $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'render_callback' => 'blog_build_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'blog_build_customize_partial_blogdescription', ) ); } } add_action('customize_register', 'blog_build_customize_register'); /** * Render the site title for the selective refresh partial. * * @return void */ function blog_build_customize_partial_blogname() { esc_html(bloginfo('name')); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function blog_build_customize_partial_blogdescription() { esc_html(bloginfo('description')); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function blog_build_customize_preview_js() { wp_enqueue_script('blog-build-customizer', get_template_directory_uri() . '/assets/js/customizer.js', array('customize-preview'), BLOG_BUILD_VERSION, true); } add_action('customize_preview_init', 'blog_build_customize_preview_js');