]> _ Git - physioassist-wordpress.git/commitdiff
wait #7216
authorsoufiane <soufiane@cubedesigners.com>
Mon, 2 Dec 2024 16:19:45 +0000 (17:19 +0100)
committersoufiane <soufiane@cubedesigners.com>
Mon, 2 Dec 2024 16:19:45 +0000 (17:19 +0100)
wp-content/mu-plugins/physioassist/src/Elementor/Setup.php

index dd050e5d5a28187b8dbf8d3feb20fd8270a2f8c4..d294a480b60d5e04f8e0b4534f559f2a372eaf5c 100644 (file)
@@ -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?)