From a6267b0dbca23ecea34fbc6f1b9b85ebb0594b24 Mon Sep 17 00:00:00 2001 From: Maggie Serino Date: Fri, 10 Jan 2025 17:15:41 +0100 Subject: [PATCH 1/5] TMZ-290 adding basic inline editing to flex hero text elements --- .../render/widget-flex-hero-render.php | 41 +++++++------------ modules/content/widgets/flex-hero.php | 4 ++ 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/modules/content/classes/render/widget-flex-hero-render.php b/modules/content/classes/render/widget-flex-hero-render.php index 82165ab..ec28f96 100644 --- a/modules/content/classes/render/widget-flex-hero-render.php +++ b/modules/content/classes/render/widget-flex-hero-render.php @@ -9,6 +9,7 @@ use Elementor\Icons_Manager; use Elementor\Utils; use HelloPlus\Modules\Content\Widgets\Flex_Hero; +use HelloPlus\Includes\Utils as Theme_Utils; class Widget_Flex_Hero_Render { protected Flex_Hero $widget; @@ -111,34 +112,22 @@ public function render_content_container() { } public function render_text_container() { - $intro_text = $this->settings['intro_text']; - $intro_tag = $this->settings['intro_tag']; - $has_intro = '' !== $intro_text; + $this->maybe_render_text_html( 'intro_text', 'ehp-flex-hero__intro', $this->settings['intro_text'], $this->settings['intro_tag'] ); + $this->maybe_render_text_html( 'heading_text', 'ehp-flex-hero__heading', $this->settings['heading_text'], $this->settings['heading_tag'] ); + $this->maybe_render_text_html( 'subheading_text', 'ehp-flex-hero__subheading', $this->settings['subheading_text'], $this->settings['subheading_tag'] ); + } - $heading_text = $this->settings['heading_text']; - $heading_tag = $this->settings['heading_tag']; - $has_heading = '' !== $heading_text; + public function maybe_render_text_html( $render_key, $class, $settings_text, $settings_tag ) { + if ( '' !== $settings_text ) { + $this->widget->add_render_attribute( $render_key, 'class', $class ); - $subheading_text = $this->settings['subheading_text']; - $subheading_tag = $this->settings['subheading_tag']; - $has_subheading = '' !== $subheading_text; - ?> - %3$s', Utils::validate_html_tag( $intro_tag ), 'class="ehp-flex-hero__intro"', esc_html( $intro_text ) ); - // Escaped above - Utils::print_unescaped_internal_string( $intro_output ); - } ?> - %3$s', Utils::validate_html_tag( $heading_tag ), 'class="ehp-flex-hero__heading"', esc_html( $heading_text ) ); - // Escaped above - Utils::print_unescaped_internal_string( $heading_output ); - } ?> - %3$s', Utils::validate_html_tag( $subheading_tag ), 'class="ehp-flex-hero__subheading"', esc_html( $subheading_text ) ); - // Escaped above - Utils::print_unescaped_internal_string( $subheading_output ); - } ?> - %3$s', Utils::validate_html_tag( $settings_tag ), $this->widget->get_render_attribute_string( $render_key ), $element ); + + // PHPCS - the variable $element_html holds safe data. + echo $element_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + } } protected function render_ctas_container() { diff --git a/modules/content/widgets/flex-hero.php b/modules/content/widgets/flex-hero.php index 533a82f..4654b19 100644 --- a/modules/content/widgets/flex-hero.php +++ b/modules/content/widgets/flex-hero.php @@ -52,6 +52,10 @@ public function get_style_depends(): array { protected function render(): void { $render_strategy = new Widget_Flex_Hero_Render( $this ); + $this->add_inline_editing_attributes( 'intro_text', 'basic' ); + $this->add_inline_editing_attributes( 'heading_text', 'basic' ); + $this->add_inline_editing_attributes( 'subheading_text', 'basic' ); + $render_strategy->render(); } From 19709292127baaa9b439ab0f9bd7faa614c6edf5 Mon Sep 17 00:00:00 2001 From: Maggie Serino Date: Fri, 10 Jan 2025 17:16:46 +0100 Subject: [PATCH 2/5] TMZ-290 remove unused import --- modules/content/classes/render/widget-flex-hero-render.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/content/classes/render/widget-flex-hero-render.php b/modules/content/classes/render/widget-flex-hero-render.php index ec28f96..95cc29b 100644 --- a/modules/content/classes/render/widget-flex-hero-render.php +++ b/modules/content/classes/render/widget-flex-hero-render.php @@ -9,7 +9,6 @@ use Elementor\Icons_Manager; use Elementor\Utils; use HelloPlus\Modules\Content\Widgets\Flex_Hero; -use HelloPlus\Includes\Utils as Theme_Utils; class Widget_Flex_Hero_Render { protected Flex_Hero $widget; From addfa9968ce7af364101829eed720c12e9689e7a Mon Sep 17 00:00:00 2001 From: Maggie Serino Date: Fri, 10 Jan 2025 17:18:30 +0100 Subject: [PATCH 3/5] TMZ-290 lint --- modules/content/classes/render/widget-flex-hero-render.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/content/classes/render/widget-flex-hero-render.php b/modules/content/classes/render/widget-flex-hero-render.php index 95cc29b..5d5b740 100644 --- a/modules/content/classes/render/widget-flex-hero-render.php +++ b/modules/content/classes/render/widget-flex-hero-render.php @@ -121,7 +121,7 @@ public function maybe_render_text_html( $render_key, $class, $settings_text, $se $this->widget->add_render_attribute( $render_key, 'class', $class ); $element = wp_kses_post( $settings_text ); - + $element_html = sprintf( '<%1$s %2$s>%3$s', Utils::validate_html_tag( $settings_tag ), $this->widget->get_render_attribute_string( $render_key ), $element ); // PHPCS - the variable $element_html holds safe data. From 410cfa66bc6b5db3dc5ce8b40f4f42e13e99bd98 Mon Sep 17 00:00:00 2001 From: Maggie Serino Date: Fri, 10 Jan 2025 17:29:16 +0100 Subject: [PATCH 4/5] TMZ-290 lint --- modules/content/classes/render/widget-flex-hero-render.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/content/classes/render/widget-flex-hero-render.php b/modules/content/classes/render/widget-flex-hero-render.php index 5d5b740..c983d04 100644 --- a/modules/content/classes/render/widget-flex-hero-render.php +++ b/modules/content/classes/render/widget-flex-hero-render.php @@ -123,7 +123,7 @@ public function maybe_render_text_html( $render_key, $class, $settings_text, $se $element = wp_kses_post( $settings_text ); $element_html = sprintf( '<%1$s %2$s>%3$s', Utils::validate_html_tag( $settings_tag ), $this->widget->get_render_attribute_string( $render_key ), $element ); - + // PHPCS - the variable $element_html holds safe data. echo $element_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } From af633f0e549e3b865ac2a80b53b67582dde5fcfd Mon Sep 17 00:00:00 2001 From: Nurit Date: Sun, 12 Jan 2025 10:55:34 +0200 Subject: [PATCH 5/5] lint --- modules/content/classes/render/widget-flex-hero-render.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/content/classes/render/widget-flex-hero-render.php b/modules/content/classes/render/widget-flex-hero-render.php index c983d04..f510013 100644 --- a/modules/content/classes/render/widget-flex-hero-render.php +++ b/modules/content/classes/render/widget-flex-hero-render.php @@ -116,9 +116,9 @@ public function render_text_container() { $this->maybe_render_text_html( 'subheading_text', 'ehp-flex-hero__subheading', $this->settings['subheading_text'], $this->settings['subheading_tag'] ); } - public function maybe_render_text_html( $render_key, $class, $settings_text, $settings_tag ) { + public function maybe_render_text_html( $render_key, $css_class, $settings_text, $settings_tag ) { if ( '' !== $settings_text ) { - $this->widget->add_render_attribute( $render_key, 'class', $class ); + $this->widget->add_render_attribute( $render_key, 'class', $css_class ); $element = wp_kses_post( $settings_text );