From 3e4d3d60adedf6d320a520ead2f8d7abd65edfa8 Mon Sep 17 00:00:00 2001 From: Aigars Silkalns Date: Wed, 12 Aug 2026 14:57:12 +0300 Subject: [PATCH 1/4] Add theme.json and convert the customizer off Epsilon controls theme.json (v2, matching the WordPress 6.4 floor) becomes the source of truth for the palette, type scale and layout widths. The customizer stays where a site owner changes colours: each colour theme mod overrides the corresponding --wp--preset--color-- custom property, so blocks and the classic front end resolve to one value instead of two palettes disagreeing. All 31 Epsilon_Control_Toggle usages become core checkbox controls and the one Epsilon_Control_Slider becomes Shapely_Control_Range, a ~45-line control that renders a range input with its value alongside -- core's plain 'range' type shows no number, which is unhelpful for an opacity setting. Epsilon_Section_Pro becomes Shapely_Section_Link. The class_exists( 'Epsilon_*' ) guards and their else branches are collapsed to a single registration each. Worth recording why the else branches could not simply be kept: they were never complete. Two of them registered 6 controls where the Epsilon branch registered 11, and one had no else at all -- so had Epsilon ever failed to load, these 11 controls would have silently vanished: post_author, post_category, post_date, title_above_post, title_in_header, project_author, project_category, project_date, project_title_in_header, title_above_project The Epsilon branch was the complete one, so the core registrations are generated from it instead. Counts before and after, as the check that nothing was dropped: add_setting 52 -> 52 add_control 74 -> 52 (22 duplicate registrations from the else branches removed: 10 single-control blocks plus 2 blocks of 6) Control ids registered: no change, none lost. Co-Authored-By: Claude Opus 5 (1M context) --- .../class-shapely-control-range.php | 82 +++ .../class-shapely-section-link.php | 82 +++ inc/customizer.php | 690 ++++++------------ inc/extras.php | 37 + theme.json | 156 ++++ 5 files changed, 600 insertions(+), 447 deletions(-) create mode 100644 inc/custom-controls/class-shapely-control-range.php create mode 100644 inc/custom-controls/class-shapely-section-link.php create mode 100644 theme.json diff --git a/inc/custom-controls/class-shapely-control-range.php b/inc/custom-controls/class-shapely-control-range.php new file mode 100644 index 0000000..a628530 --- /dev/null +++ b/inc/custom-controls/class-shapely-control-range.php @@ -0,0 +1,82 @@ +id; + $output_id = $input_id . '-value'; + $attrs = wp_parse_args( + $this->input_attrs, + array( + 'min' => 0, + 'max' => 100, + 'step' => 1, + ) + ); + $describedby = ''; + + if ( ! empty( $this->description ) ) { + $describedby = '_customize-description-' . $this->id; + } + ?> + + + description ) ) : ?> + description ); ?> + + + + aria-describedby="" + min="" + max="" + step="" + value="value() ); ?>" + oninput="document.getElementById('').value = this.value" + link(); ?> + /> + value() ); ?> + + button_text; + $json['button_url'] = $this->button_url; + + return $json; + } + + /** + * Underscore template for the section. + * + * Rendered in place of the usual accordion heading, so the whole row is + * the link rather than something that expands to reveal controls. + */ + protected function render_template() { + ?> + + register_section_type( 'Shapely_Section_Link' ); + + /* + * Section id kept as 'epsilon-section-pro'. It is not a setting, so nothing + * is stored against it, but renaming it would drop any customizer state + * keyed on the id for no benefit. + */ $wp_customize->add_section( - new Epsilon_Section_Pro( + new Shapely_Section_Link( $wp_customize, 'epsilon-section-pro', array( 'title' => esc_html__( 'Theme documentation', 'shapely' ), 'button_text' => esc_html__( 'Learn more', 'shapely' ), @@ -187,28 +196,15 @@ function shapely_customizer( $wp_customize ) { ) ); - if ( class_exists( 'Epsilon_Control_Toggle' ) ) { - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'shapely_placeholder_image_enabled', array( - 'label' => esc_html__( 'Show Placeholder Images', 'shapely' ), - 'description' => esc_html__( 'Show/hide placeholder images for posts without a featured image', 'shapely' ), - 'section' => 'shapely_blog_section', - 'priority' => 25, - ) - ) - ); - } else { - $wp_customize->add_control( - 'shapely_placeholder_image_enabled', array( + $wp_customize->add_control( + 'shapely_placeholder_image_enabled', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Show Placeholder Images', 'shapely' ), 'description' => esc_html__( 'Show/hide placeholder images for posts without a featured image', 'shapely' ), 'section' => 'shapely_blog_section', 'priority' => 25, - 'type' => 'checkbox', - ) - ); - } + ) + ); $wp_customize->add_setting( 'shapely_placeholder_image', array( @@ -316,28 +312,15 @@ function shapely_customizer( $wp_customize ) { ) ); - if ( class_exists( 'Epsilon_Control_Toggle' ) ) { - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'top_callout', array( - 'label' => esc_html__( 'Show Blog Title', 'shapely' ), - 'description' => esc_html__( 'Show/hide the title from the Blog Page', 'shapely' ), - 'section' => 'shapely_blog_section', - 'priority' => 20, - ) - ) - ); - } else { - $wp_customize->add_control( - 'top_callout', array( + $wp_customize->add_control( + 'top_callout', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Show Blog Title', 'shapely' ), 'description' => esc_html__( 'Show/hide the title from the Blog Page', 'shapely' ), 'section' => 'shapely_blog_section', 'priority' => 20, - 'type' => 'checkbox', - ) - ); - } + ) + ); $wp_customize->add_setting( 'hide_post_title', array( @@ -346,24 +329,13 @@ function shapely_customizer( $wp_customize ) { ) ); - if ( class_exists( 'Epsilon_Control_Toggle' ) ) { - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'hide_post_title', array( - 'label' => esc_html__( 'Title in Blog Post', 'shapely' ), - 'section' => 'wpseo_breadcrumbs_customizer_section', - ) - ) - ); - } else { - $wp_customize->add_control( - 'hide_post_title', array( + $wp_customize->add_control( + 'hide_post_title', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Title in Blog Post', 'shapely' ), 'section' => 'wpseo_breadcrumbs_customizer_section', - 'type' => 'checkbox', - ) - ); - } + ) + ); $wp_customize->add_setting( 'blog_name', array( @@ -387,26 +359,14 @@ function shapely_customizer( $wp_customize ) { ) ); - if ( class_exists( 'Epsilon_Control_Toggle' ) ) { - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'mobile_menu_on_desktop', array( - 'label' => esc_html__( 'Mobile Menu on Desktop', 'shapely' ), - 'description' => esc_html__( 'Always the menu will be like the mobile menu', 'shapely' ), - 'section' => 'shapely_main_section', - ) - ) - ); - } else { - $wp_customize->add_control( - 'mobile_menu_on_desktop', array( + $wp_customize->add_control( + 'mobile_menu_on_desktop', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Mobile Menu on Desktop', 'shapely' ), 'description' => esc_html__( 'Always the menu will be like the mobile menu', 'shapely' ), 'section' => 'shapely_main_section', - 'type' => 'checkbox', - ) - ); - } + ) + ); $wp_customize->add_setting( 'footer_callout_text', array( @@ -467,26 +427,14 @@ function shapely_customizer( $wp_customize ) { ) ); - if ( class_exists( 'Epsilon_Control_Toggle' ) ) { - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'shapely_transparent_header', array( - 'label' => esc_html__( 'Transparent header', 'shapely' ), - 'description' => esc_html__( 'Toggling this to ON will make the header have a transparent background', 'shapely' ), - 'section' => 'shapely_main_section', - ) - ) - ); - } else { - $wp_customize->add_control( - 'shapely_transparent_header', array( + $wp_customize->add_control( + 'shapely_transparent_header', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Transparent header', 'shapely' ), 'description' => esc_html__( 'Toggling this to ON will make the header have a transparent background', 'shapely' ), 'section' => 'shapely_main_section', - 'type' => 'checkbox', - ) - ); - } + ) + ); // transparent header: opacity range slider $wp_customize->add_setting( @@ -496,35 +444,21 @@ function shapely_customizer( $wp_customize ) { ) ); - if ( class_exists( 'Epsilon_Control_Slider' ) ) { - $wp_customize->add_control( - new Epsilon_Control_Slider( - $wp_customize, 'shapely_sticky_header_transparency', array( - 'label' => esc_html__( 'Sticky header background opacity', 'shapely' ), - 'description' => esc_html__( 'Increase the header background opacity', 'shapely' ), - 'section' => 'shapely_main_section', - 'type' => 'epsilon-slider', - 'choices' => array( - 'min' => 10, - 'max' => 100, - 'step' => 5, - ), - 'active_callback' => 'active_callback_toggle_choice', - - ) - ) - ); - } else { - $wp_customize->add_control( - 'shapely_sticky_header_transparency', array( + $wp_customize->add_control( + new Shapely_Control_Range( + $wp_customize, 'shapely_sticky_header_transparency', array( 'label' => esc_html__( 'Sticky header background opacity', 'shapely' ), 'description' => esc_html__( 'Increase the header background opacity', 'shapely' ), 'section' => 'shapely_main_section', - 'type' => 'number', + 'input_attrs' => array( + 'min' => 10, + 'max' => 100, + 'step' => 5, + ), 'active_callback' => 'active_callback_toggle_choice', ) - ); - } + ) + ); // sticky header $wp_customize->add_setting( @@ -534,28 +468,14 @@ function shapely_customizer( $wp_customize ) { ) ); - if ( class_exists( 'Epsilon_Control_Toggle' ) ) { - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'shapely_sticky_header', array( - 'label' => esc_html__( 'Sticky header', 'shapely' ), - 'description' => esc_html__( 'Toggling this to ON will make your header stick to the top of the browser bar', 'shapely' ), - 'section' => 'shapely_main_section', - - ) - ) - ); - } else { - $wp_customize->add_control( - 'shapely_sticky_header', array( + $wp_customize->add_control( + 'shapely_sticky_header', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Sticky header', 'shapely' ), 'description' => esc_html__( 'Toggling this to ON will make your header stick to the top of the browser bar', 'shapely' ), 'section' => 'shapely_main_section', - 'type' => 'checkbox', - - ) - ); - } + ) + ); /** * @@ -658,162 +578,99 @@ function shapely_customizer( $wp_customize ) { ); // Single Post Settings - if ( class_exists( 'Epsilon_Control_Toggle' ) ) { - - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'title_in_header', array( - 'label' => esc_html__( 'Show title in header', 'shapely' ), - 'description' => esc_html__( 'This will show/hide the post title from callout', 'shapely' ), - 'section' => 'shapely_single_post_section', - ) - ) - ); + $wp_customize->add_control( + 'title_in_header', array( + 'type' => 'checkbox', + 'label' => esc_html__( 'Show title in header', 'shapely' ), + 'description' => esc_html__( 'This will show/hide the post title from callout', 'shapely' ), + 'section' => 'shapely_single_post_section', + ) + ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'title_above_post', array( - 'label' => esc_html__( 'Show title above post', 'shapely' ), - 'description' => esc_html__( 'This will show/hide the post title above post content', 'shapely' ), - 'section' => 'shapely_single_post_section', - ) - ) - ); + $wp_customize->add_control( + 'title_above_post', array( + 'type' => 'checkbox', + 'label' => esc_html__( 'Show title above post', 'shapely' ), + 'description' => esc_html__( 'This will show/hide the post title above post content', 'shapely' ), + 'section' => 'shapely_single_post_section', + ) + ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'post_date', array( - 'label' => esc_html__( 'Show the date', 'shapely' ), - 'description' => esc_html__( 'This will show/hide the date when post was published', 'shapely' ), - 'section' => 'shapely_single_post_section', - ) - ) - ); + $wp_customize->add_control( + 'post_date', array( + 'type' => 'checkbox', + 'label' => esc_html__( 'Show the date', 'shapely' ), + 'description' => esc_html__( 'This will show/hide the date when post was published', 'shapely' ), + 'section' => 'shapely_single_post_section', + ) + ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'post_author', array( - 'label' => esc_html__( 'Show the author', 'shapely' ), - 'description' => esc_html__( 'This will show/hide the author who written the post under the post title', 'shapely' ), - 'section' => 'shapely_single_post_section', - ) - ) - ); + $wp_customize->add_control( + 'post_author', array( + 'type' => 'checkbox', + 'label' => esc_html__( 'Show the author', 'shapely' ), + 'description' => esc_html__( 'This will show/hide the author who written the post under the post title', 'shapely' ), + 'section' => 'shapely_single_post_section', + ) + ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'post_category', array( - 'label' => esc_html__( 'Show the category', 'shapely' ), - 'description' => esc_html__( 'This will show/hide the categories of post', 'shapely' ), - 'section' => 'shapely_single_post_section', - ) - ) - ); + $wp_customize->add_control( + 'post_category', array( + 'type' => 'checkbox', + 'label' => esc_html__( 'Show the category', 'shapely' ), + 'description' => esc_html__( 'This will show/hide the categories of post', 'shapely' ), + 'section' => 'shapely_single_post_section', + ) + ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'first_letter_caps', array( - 'label' => esc_html__( 'First Letter Caps', 'shapely' ), - 'description' => esc_html__( 'This will transform your first letter from a post into uppercase', 'shapely' ), - 'section' => 'shapely_single_post_section', - ) - ) - ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'tags_post_meta', array( - 'label' => esc_html__( 'Tags Post Meta', 'shapely' ), - 'description' => esc_html__( 'This will show/hide tags from the end of post', 'shapely' ), - 'section' => 'shapely_single_post_section', - ) - ) - ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'related_posts_area', array( - 'label' => esc_html__( 'Related Posts Area', 'shapely' ), - 'description' => esc_html__( 'This will enable/disable the related posts', 'shapely' ), - 'section' => 'shapely_single_post_section', - ) - ) - ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'post_author_area', array( - 'label' => esc_html__( 'Post Author Area', 'shapely' ), - 'description' => esc_html__( 'This will show/hide the author box', 'shapely' ), - 'section' => 'shapely_single_post_section', - ) - ) - ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'post_author_left_side', array( - 'label' => esc_html__( 'Post Author Left Side', 'shapely' ), - 'description' => esc_html__( 'This will move the author box from the bottom of the post on top on the left side', 'shapely' ), - 'section' => 'shapely_single_post_section', - ) - ) - ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'post_author_email', array( - 'label' => esc_html__( 'Show Author Email', 'shapely' ), - 'description' => esc_html__( 'This will show/hide the author\'s email from the author box', 'shapely' ), - 'section' => 'shapely_single_post_section', - ) - ) - ); - } else { - $wp_customize->add_control( - 'first_letter_caps', array( + $wp_customize->add_control( + 'first_letter_caps', array( + 'type' => 'checkbox', 'label' => esc_html__( 'First Letter Caps', 'shapely' ), 'description' => esc_html__( 'This will transform your first letter from a post into uppercase', 'shapely' ), 'section' => 'shapely_single_post_section', - 'type' => 'checkbox', - ) - ); - $wp_customize->add_control( - 'tags_post_meta', array( + ) + ); + $wp_customize->add_control( + 'tags_post_meta', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Tags Post Meta', 'shapely' ), 'description' => esc_html__( 'This will show/hide tags from the end of post', 'shapely' ), 'section' => 'shapely_single_post_section', - 'type' => 'checkbox', - ) - ); - $wp_customize->add_control( - 'related_posts_area', array( + ) + ); + $wp_customize->add_control( + 'related_posts_area', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Related Posts Area', 'shapely' ), 'description' => esc_html__( 'This will enable/disable the related posts', 'shapely' ), 'section' => 'shapely_single_post_section', - 'type' => 'checkbox', - ) - ); - $wp_customize->add_control( - 'post_author_area', array( + ) + ); + $wp_customize->add_control( + 'post_author_area', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Post Author Area', 'shapely' ), 'description' => esc_html__( 'This will show/hide the author box', 'shapely' ), 'section' => 'shapely_single_post_section', - 'type' => 'checkbox', - ) - ); - $wp_customize->add_control( - 'post_author_left_side', array( + ) + ); + $wp_customize->add_control( + 'post_author_left_side', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Post Author Left Side', 'shapely' ), 'description' => esc_html__( 'This will move the author box from the bottom of the post on top on the left side', 'shapely' ), 'section' => 'shapely_single_post_section', - 'type' => 'checkbox', - ) - ); - $wp_customize->add_control( - 'post_author_email', array( + ) + ); + $wp_customize->add_control( + 'post_author_email', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Show Author Email', 'shapely' ), 'description' => esc_html__( 'This will show/hide the author\'s email from the author box', 'shapely' ), 'section' => 'shapely_single_post_section', - 'type' => 'checkbox', - ) - ); - } // End if(). + ) + ); $wp_customize->add_setting( 'single_post_layout_template', array( 'default' => 'sidebar-right', @@ -886,26 +743,14 @@ function shapely_customizer( $wp_customize ) { 'sanitize_callback' => 'shapely_sanitize_checkbox', ) ); - if ( class_exists( 'Epsilon_Control_Toggle' ) ) { - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'show_category_on_category_page', array( - 'label' => esc_html__( 'Show Category on Posts', 'shapely' ), - 'description' => esc_html__( 'Show/hide posts\' categories from the Category Page', 'shapely' ), - 'section' => 'shapely_blog_section', - ) - ) - ); - } else { - $wp_customize->add_control( - 'show_category_on_category_page', array( + $wp_customize->add_control( + 'show_category_on_category_page', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Show Category on Posts', 'shapely' ), 'description' => esc_html__( 'Show/hide posts\' categories from the Category Page', 'shapely' ), 'section' => 'shapely_blog_section', - 'type' => 'checkbox', - ) - ); - } + ) + ); // Global category display setting $wp_customize->add_setting( @@ -914,26 +759,14 @@ function shapely_customizer( $wp_customize ) { 'sanitize_callback' => 'shapely_sanitize_checkbox', ) ); - if ( class_exists( 'Epsilon_Control_Toggle' ) ) { - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'show_categories_globally', array( - 'label' => esc_html__( 'Show Categories Globally', 'shapely' ), - 'description' => esc_html__( 'Show/hide categories on all blog pages and single posts', 'shapely' ), - 'section' => 'shapely_blog_section', - ) - ) - ); - } else { - $wp_customize->add_control( - 'show_categories_globally', array( + $wp_customize->add_control( + 'show_categories_globally', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Show Categories Globally', 'shapely' ), 'description' => esc_html__( 'Show/hide categories on all blog pages and single posts', 'shapely' ), 'section' => 'shapely_blog_section', - 'type' => 'checkbox', - ) - ); - } + ) + ); if ( post_type_exists( 'jetpack-portfolio' ) ) { @@ -970,26 +803,14 @@ function shapely_customizer( $wp_customize ) { 'sanitize_callback' => 'shapely_sanitize_checkbox', ) ); - if ( class_exists( 'Epsilon_Control_Toggle' ) ) { - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'portfolio_archive_title', array( - 'label' => esc_html__( 'Show Portfolio Archive Title', 'shapely' ), - 'description' => esc_html__( 'Show/hide the title from the Portfolio Archive Page', 'shapely' ), - 'section' => 'shapely_projects_section', - ) - ) - ); - } else { - $wp_customize->add_control( - 'portfolio_archive_title', array( + $wp_customize->add_control( + 'portfolio_archive_title', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Show Portfolio Archive Title', 'shapely' ), 'description' => esc_html__( 'Show/hide the title from the Portfolio Archive Page', 'shapely' ), 'section' => 'shapely_projects_section', - 'type' => 'checkbox', - ) - ); - } + ) + ); $wp_customize->add_setting( 'portfolio_name', array( 'default' => '', @@ -1132,162 +953,99 @@ function shapely_customizer( $wp_customize ) { ); // Single Project Settings - if ( class_exists( 'Epsilon_Control_Toggle' ) ) { - - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'project_title_in_header', array( - 'label' => esc_html__( 'Show title in header', 'shapely' ), - 'description' => esc_html__( 'This will show/hide the project title from callout', 'shapely' ), - 'section' => 'shapely_single_project_section', - ) - ) - ); + $wp_customize->add_control( + 'project_title_in_header', array( + 'type' => 'checkbox', + 'label' => esc_html__( 'Show title in header', 'shapely' ), + 'description' => esc_html__( 'This will show/hide the project title from callout', 'shapely' ), + 'section' => 'shapely_single_project_section', + ) + ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'title_above_project', array( - 'label' => esc_html__( 'Show title above project', 'shapely' ), - 'description' => esc_html__( 'This will show/hide the project title above project content', 'shapely' ), - 'section' => 'shapely_single_project_section', - ) - ) - ); + $wp_customize->add_control( + 'title_above_project', array( + 'type' => 'checkbox', + 'label' => esc_html__( 'Show title above project', 'shapely' ), + 'description' => esc_html__( 'This will show/hide the project title above project content', 'shapely' ), + 'section' => 'shapely_single_project_section', + ) + ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'project_date', array( - 'label' => esc_html__( 'Show the date', 'shapely' ), - 'description' => esc_html__( 'This will show/hide the date when project was published', 'shapely' ), - 'section' => 'shapely_single_project_section', - ) - ) - ); + $wp_customize->add_control( + 'project_date', array( + 'type' => 'checkbox', + 'label' => esc_html__( 'Show the date', 'shapely' ), + 'description' => esc_html__( 'This will show/hide the date when project was published', 'shapely' ), + 'section' => 'shapely_single_project_section', + ) + ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'project_author', array( - 'label' => esc_html__( 'Show the author', 'shapely' ), - 'description' => esc_html__( 'This will show/hide the author who written the project under the project title', 'shapely' ), - 'section' => 'shapely_single_project_section', - ) - ) - ); + $wp_customize->add_control( + 'project_author', array( + 'type' => 'checkbox', + 'label' => esc_html__( 'Show the author', 'shapely' ), + 'description' => esc_html__( 'This will show/hide the author who written the project under the project title', 'shapely' ), + 'section' => 'shapely_single_project_section', + ) + ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'project_category', array( - 'label' => esc_html__( 'Show the project type', 'shapely' ), - 'description' => esc_html__( 'This will show/hide the type of project', 'shapely' ), - 'section' => 'shapely_single_project_section', - ) - ) - ); + $wp_customize->add_control( + 'project_category', array( + 'type' => 'checkbox', + 'label' => esc_html__( 'Show the project type', 'shapely' ), + 'description' => esc_html__( 'This will show/hide the type of project', 'shapely' ), + 'section' => 'shapely_single_project_section', + ) + ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'project_first_letter_caps', array( - 'label' => esc_html__( 'First Letter Caps', 'shapely' ), - 'description' => esc_html__( 'This will transform your first letter from a project into uppercase', 'shapely' ), - 'section' => 'shapely_single_project_section', - ) - ) - ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'tags_project_meta', array( - 'label' => esc_html__( 'Tags Project Meta', 'shapely' ), - 'description' => esc_html__( 'This will show/hide tags from the end of project', 'shapely' ), - 'section' => 'shapely_single_project_section', - ) - ) - ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'related_projects_area', array( - 'label' => esc_html__( 'Related Projects Area', 'shapely' ), - 'description' => esc_html__( 'This will enable/disable the related projects', 'shapely' ), - 'section' => 'shapely_single_project_section', - ) - ) - ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'project_author_area', array( - 'label' => esc_html__( 'Project Author Area', 'shapely' ), - 'description' => esc_html__( 'This will show/hide the author box', 'shapely' ), - 'section' => 'shapely_single_project_section', - ) - ) - ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'project_author_left_side', array( - 'label' => esc_html__( 'Project Author Left Side', 'shapely' ), - 'description' => esc_html__( 'This will move the author box from the bottom of the project on top on the left side', 'shapely' ), - 'section' => 'shapely_single_project_section', - ) - ) - ); - $wp_customize->add_control( - new Epsilon_Control_Toggle( - $wp_customize, 'project_author_email', array( - 'label' => esc_html__( 'Show Author Email', 'shapely' ), - 'description' => esc_html__( 'This will show/hide the author\'s email from the author box', 'shapely' ), - 'section' => 'shapely_single_project_section', - ) - ) - ); - } else { - $wp_customize->add_control( - 'project_first_letter_caps', array( + $wp_customize->add_control( + 'project_first_letter_caps', array( + 'type' => 'checkbox', 'label' => esc_html__( 'First Letter Caps', 'shapely' ), 'description' => esc_html__( 'This will transform your first letter from a project into uppercase', 'shapely' ), 'section' => 'shapely_single_project_section', - 'type' => 'checkbox', - ) - ); - $wp_customize->add_control( - 'tags_project_meta', array( + ) + ); + $wp_customize->add_control( + 'tags_project_meta', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Tags Project Meta', 'shapely' ), 'description' => esc_html__( 'This will show/hide tags from the end of project', 'shapely' ), 'section' => 'shapely_single_project_section', - 'type' => 'checkbox', - ) - ); - $wp_customize->add_control( - 'related_projects_area', array( + ) + ); + $wp_customize->add_control( + 'related_projects_area', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Related Projects Area', 'shapely' ), 'description' => esc_html__( 'This will enable/disable the related projects', 'shapely' ), 'section' => 'shapely_single_project_section', - 'type' => 'checkbox', - ) - ); - $wp_customize->add_control( - 'project_author_area', array( + ) + ); + $wp_customize->add_control( + 'project_author_area', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Project Author Area', 'shapely' ), 'description' => esc_html__( 'This will show/hide the author box', 'shapely' ), 'section' => 'shapely_single_project_section', - 'type' => 'checkbox', - ) - ); - $wp_customize->add_control( - 'project_author_left_side', array( + ) + ); + $wp_customize->add_control( + 'project_author_left_side', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Project Author Left Side', 'shapely' ), 'description' => esc_html__( 'This will move the author box from the bottom of the project on top on the left side', 'shapely' ), 'section' => 'shapely_single_project_section', - 'type' => 'checkbox', - ) - ); - $wp_customize->add_control( - 'project_author_email', array( + ) + ); + $wp_customize->add_control( + 'project_author_email', array( + 'type' => 'checkbox', 'label' => esc_html__( 'Show Author Email', 'shapely' ), 'description' => esc_html__( 'This will show/hide the author\'s email from the author box', 'shapely' ), 'section' => 'shapely_single_project_section', - 'type' => 'checkbox', - ) - ); - } // End if(). + ) + ); $wp_customize->add_setting( 'single_project_layout_template', array( 'default' => 'sidebar-right', @@ -1453,6 +1211,44 @@ function shapely_customizer_custom_label_css() { color: #555; font-style: italic; } + + /* Shapely_Control_Range: slider with its value alongside. */ + .shapely-range { + display: flex; + align-items: center; + gap: 10px; + } + .shapely-range input[type="range"] { + flex: 1 1 auto; + min-width: 0; + } + .shapely-range__value { + flex: 0 0 auto; + min-width: 3ch; + text-align: right; + font-variant-numeric: tabular-nums; + color: #50575e; + } + + /* Shapely_Section_Link: a section that is just an outbound button. */ + .shapely-link-section { + display: flex; + align-items: center; + justify-content: space-between; + gap: 10px; + padding: 12px 15px; + border-bottom: 1px solid #ddd; + background: #fff; + } + .shapely-link-section__title { + margin: 0; + font-size: 14px; + font-weight: 600; + color: #50575e; + } + .shapely-link-section__button { + flex: 0 0 auto; + } 'primary', + 'link_hover_color' => 'primary-hover', + 'button_color' => 'primary', + 'button_hover_color' => 'primary-hover', + ); + + $vars = array(); + foreach ( $presets as $mod => $slug ) { + $value = get_theme_mod( $mod ); + if ( $value ) { + // Later keys win, which is why button_* follows link_*. + $vars[ $slug ] = $value; + } + } + + if ( ! empty( $vars ) ) { + $declarations = ''; + foreach ( $vars as $slug => $value ) { + $declarations .= '--wp--preset--color--' . sanitize_key( $slug ) . ':' . esc_attr( $value ) . ';'; + } + $css = ':root{' . $declarations . '}' . $css; + } + // Drop the wrapping