From 80424d15b30bb05b6c8fcff661a809ad7f093b16 Mon Sep 17 00:00:00 2001 From: soufiane Date: Mon, 2 Dec 2024 17:01:51 +0100 Subject: [PATCH] wait #7216 @2:00 --- .../physioassist/src/Elementor/Setup.php | 23 +++++++------------ .../assets/styles/components/headings.styl | 10 ++++---- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/wp-content/mu-plugins/physioassist/src/Elementor/Setup.php b/wp-content/mu-plugins/physioassist/src/Elementor/Setup.php index 8b0d1ab..f9e13ff 100644 --- a/wp-content/mu-plugins/physioassist/src/Elementor/Setup.php +++ b/wp-content/mu-plugins/physioassist/src/Elementor/Setup.php @@ -22,20 +22,14 @@ class Setup { //--- Heading Widget // Extend Elementor's heading widget to add a CSS class based on the alignment setting so we can also control the position of the underline - add_action( 'elementor/element/heading/section_title/before_section_end', function( $element, $args ) { - $elementor = Plugin::instance(); - - // Get the align control for updating - $control_data = $elementor->controls_manager->get_control_from_stack( $element->get_name(), 'align' ); - - if (is_wp_error($control_data)) { - return; + add_action( 'elementor/widget/before_render_content', function( $widget ) { + if ('heading' === $widget->get_name()) { + $settings = $widget->get_settings(); + if ( ! empty( $settings['align'] ) ) { + $widget->add_render_attribute('_wrapper', 'class', 'heading-align-'. $settings['align']); + } } - - // Add a prefix class so heading will have correct class applied when alignment is changed - $control_data['prefix_class'] = 'heading-align-'; - $element->update_control( 'align', $control_data ); - }, 10, 2); + }); // Todo: consider add a control to the existing heading widget that allows the underline to be disabled (via prefix_class?) @@ -58,7 +52,6 @@ class Setup { $element->update_control( 'icon_active', $icon_active_control ); }, 10, 2); - } public function register_widgets() { @@ -135,4 +128,4 @@ class Setup { } -} +} \ No newline at end of file diff --git a/wp-content/themes/physioassist/resources/assets/styles/components/headings.styl b/wp-content/themes/physioassist/resources/assets/styles/components/headings.styl index 9a6a1a5..f343189 100644 --- a/wp-content/themes/physioassist/resources/assets/styles/components/headings.styl +++ b/wp-content/themes/physioassist/resources/assets/styles/components/headings.styl @@ -39,11 +39,11 @@ h1, h2 height: 3px background-color: currentColor - // Center underline - .heading-align-center & - margin-left: auto - margin-right: auto - // Right-align underline .heading-align-right & margin-left: auto + +.heading-align-center .elementor-heading-title:after, +.heading-align-center .main-heading:after + margin-left: auto + margin-right: auto -- 2.39.5