From 04b3051b595610ce50d4843c64a914fc1d9f0899 Mon Sep 17 00:00:00 2001 From: Nurit Shahar <43785095+nuritsha@users.noreply.github.com> Date: Fri, 25 Oct 2024 09:06:47 +0300 Subject: [PATCH 1/4] tweak register & enqueue and some code cleanup [TMZ-61] (#38) --- .../classes/render/widget-footer-render.php | 29 ++++++++----- .../classes/render/widget-header-render.php | 40 +++++++++++------- modules/template-parts/module.php | 42 ++++++++++++------- modules/template-parts/widgets/footer.php | 5 +-- 4 files changed, 72 insertions(+), 44 deletions(-) diff --git a/modules/template-parts/classes/render/widget-footer-render.php b/modules/template-parts/classes/render/widget-footer-render.php index 24f4e3a8..a5d32de1 100644 --- a/modules/template-parts/classes/render/widget-footer-render.php +++ b/modules/template-parts/classes/render/widget-footer-render.php @@ -1,24 +1,28 @@ widget = $widget; - $this->settings = $widget->get_settings_for_display(); - } + protected array $settings; public function render(): void { $layout_classnames = self::LAYOUT_CLASSNAME; @@ -267,4 +271,9 @@ public function handle_link_classes( $atts, $item ) { return $atts; } + + public function __construct( Footer $widget ) { + $this->widget = $widget; + $this->settings = $widget->get_settings_for_display(); + } } diff --git a/modules/template-parts/classes/render/widget-header-render.php b/modules/template-parts/classes/render/widget-header-render.php index d0873993..e1e82392 100644 --- a/modules/template-parts/classes/render/widget-header-render.php +++ b/modules/template-parts/classes/render/widget-header-render.php @@ -2,27 +2,30 @@ namespace HelloPlus\Modules\TemplateParts\Classes\Render; -use Elementor\Group_Control_Image_Size; -use Elementor\Icons_Manager; -use Elementor\Utils; +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly. +} + +use Elementor\{ + Group_Control_Image_Size, + Icons_Manager, + Utils +}; use HelloPlus\Modules\TemplateParts\Widgets\Header; +/** + * class Widget_Header_Render + */ class Widget_Header_Render { - - protected Header $widget; - const LAYOUT_CLASSNAME = 'ehp-header'; const SITE_LINK_CLASSNAME = 'ehp-header__site-link'; const CTAS_CONTAINER_CLASSNAME = 'ehp-header__ctas-container'; const BUTTON_CLASSNAME = 'ehp-header__button'; - protected array $settings; + protected Header $widget; - public function __construct( Header $widget ) { - $this->widget = $widget; - $this->settings = $widget->get_settings_for_display(); - } + protected array $settings; public function render(): void { $layout_classnames = self::LAYOUT_CLASSNAME; @@ -58,7 +61,7 @@ public function render(): void { 'data-behavior-float' => $behavior_float, ] ); ?> -
widget->get_render_attribute_string( 'layout' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> +
widget->print_render_attribute_string( 'layout' ); ?>>
render_site_link(); @@ -86,7 +89,7 @@ public function render_site_link(): void { $this->widget->add_link_attributes( 'site-link', $site_link ); } ?> - widget->get_render_attribute_string( 'site-link' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> + widget->print_render_attribute_string( 'site-link' ); ?>> settings, 'site_logo_image' ); ?> - + $ctas_container_classnames, ] ); ?> -
widget->get_render_attribute_string( 'ctas-container' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> +
widget->print_render_attribute_string( 'ctas-container' ); ?>> render_button( 'primary' ); } ?> @@ -264,7 +267,7 @@ protected function render_button( $type ) { } ?> - widget->get_render_attribute_string( $type . '-button' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> + widget->print_render_attribute_string( $type . '-button' ); ?>> widget = $widget; + $this->settings = $widget->get_settings_for_display(); + } } diff --git a/modules/template-parts/module.php b/modules/template-parts/module.php index 0d5fb44a..e59195d0 100644 --- a/modules/template-parts/module.php +++ b/modules/template-parts/module.php @@ -40,30 +40,41 @@ protected function get_widget_ids(): array { ]; } - public function enqueue(): void { - wp_enqueue_style( + /** + * @return void + */ + public function register_scripts(): void { + wp_register_script( + 'hello-plus-header', + HELLO_PLUS_SCRIPTS_URL . 'hello-plus-header.js', + [ 'elementor-frontend' ], + HELLO_PLUS_VERSION, + true + ); + } + + /** + * @return void + */ + public function register_styles(): void { + wp_register_style( 'hello-plus-header', HELLO_PLUS_STYLE_URL . 'hello-plus-header.css', - [], + [ 'elementor-frontend' ], HELLO_PLUS_VERSION ); - wp_enqueue_style( + wp_register_style( 'hello-plus-footer', HELLO_PLUS_STYLE_URL . 'hello-plus-footer.css', - [], - HELLO_PLUS_ELEMENTOR_VERSION - ); - - wp_enqueue_script( - 'hello-plus-header', - HELLO_PLUS_SCRIPTS_URL . 'hello-plus-header.js', - [ 'jquery' ], - HELLO_PLUS_VERSION, - true + [ 'elementor-frontend' ], + HELLO_PLUS_VERSION ); } + /** + * @return void + */ public function editor_enqueue(): void { wp_enqueue_script( 'hello-plus-template-parts-editor', @@ -86,7 +97,8 @@ public static function is_active(): bool { */ protected function register_hooks(): void { parent::register_hooks(); - add_action( 'wp_enqueue_scripts', [ $this, 'enqueue' ] ); add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'editor_enqueue' ] ); + add_action( 'elementor/frontend/after_register_scripts', [ $this, 'register_scripts' ] ); + add_action( 'elementor/frontend/after_register_styles', [ $this, 'register_styles' ] ); } } diff --git a/modules/template-parts/widgets/footer.php b/modules/template-parts/widgets/footer.php index 86435fd6..fbce165f 100644 --- a/modules/template-parts/widgets/footer.php +++ b/modules/template-parts/widgets/footer.php @@ -48,13 +48,12 @@ public function get_icon(): string { } public function get_style_depends(): array { - $widget_name = $this->get_name(); - $style_depends = Theme_Utils::elementor()->experiments->is_feature_active( 'e_font_icon_svg' ) ? parent::get_style_depends() : [ 'elementor-icons-fa-solid', 'elementor-icons-fa-brands', 'elementor-icons-fa-regular' ]; - $style_depends[] = "widget-{$widget_name}"; + $style_depends[] = 'hello-plus-footer'; + $style_depends[] = 'e-apple-webkit'; return $style_depends; } From f134559ec3391ced2d677e589ae96e9a13b51102 Mon Sep 17 00:00:00 2001 From: Maggie Serino <7341759+mserino@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:43:38 +0200 Subject: [PATCH 2/4] Zigzag round 2 fixes [TMZ-94](#41) --- .../content/assets/scss/hello-plus-zigzag.scss | 15 +-------------- modules/content/widgets/zig-zag.php | 4 ++-- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/modules/content/assets/scss/hello-plus-zigzag.scss b/modules/content/assets/scss/hello-plus-zigzag.scss index d6bc3c94..1a99e069 100644 --- a/modules/content/assets/scss/hello-plus-zigzag.scss +++ b/modules/content/assets/scss/hello-plus-zigzag.scss @@ -133,20 +133,6 @@ &.is-graphic-icon { width: calc(100% - var(--zigzag-icon-width)); } - - .row-even & { - - @media screen and (min-width: $screen-tablet-min) { - padding-inline-end: var(--zigzag-elements-gap); - } - } - - .row-odd & { - - @media screen and (min-width: $screen-tablet-min) { - padding-inline-start: var(--zigzag-elements-gap); - } - } } &__title { @@ -200,6 +186,7 @@ &__item-container { display: flex; + gap: var(--zigzag-elements-gap); padding-block: calc(var(--zigzag-rows-spacing) / 2); max-width: var(--zigzag-content-width); width: 100%; diff --git a/modules/content/widgets/zig-zag.php b/modules/content/widgets/zig-zag.php index 14f71d17..75bf3495 100644 --- a/modules/content/widgets/zig-zag.php +++ b/modules/content/widgets/zig-zag.php @@ -278,7 +278,7 @@ private function add_style_zigzags_section() { ], ], 'default' => 'left', - 'description' => esc_html__( 'Zigzag content will be stacked on smaller screens.', 'hello-plus' ), + 'description' => esc_html__( 'Content will be stacked on smaller screens', 'hello-plus' ), ] ); @@ -475,7 +475,7 @@ private function add_style_zigzags_section() { $this->add_control( 'style_description', [ - 'label' => esc_html__( 'Paragraph', 'hello-plus' ), + 'label' => esc_html__( 'Description', 'hello-plus' ), 'type' => Controls_Manager::HEADING, 'separator' => 'default', ] From d6efee092e57e2bec5719d6ab2e9045fc1bb5c2b Mon Sep 17 00:00:00 2001 From: Nurit Shahar <43785095+nuritsha@users.noreply.github.com> Date: Sun, 27 Oct 2024 11:12:57 +0200 Subject: [PATCH 3/4] linter errors (#43) --- modules/admin/classes/rest/onboarding-settings.php | 2 +- modules/theme/components/theme-integration.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/admin/classes/rest/onboarding-settings.php b/modules/admin/classes/rest/onboarding-settings.php index a5e8b25a..198bdf33 100644 --- a/modules/admin/classes/rest/onboarding-settings.php +++ b/modules/admin/classes/rest/onboarding-settings.php @@ -48,7 +48,7 @@ public function get_kits() { set_transient( 'e_hello_plus_kits', $kits, 24 * HOUR_IN_SECONDS ); } catch ( \Exception $e ) { // just to avoid linting errors - error_log( $e->getMessage() ); + error_log( $e->getMessage() ); //phpcs:ignore } } diff --git a/modules/theme/components/theme-integration.php b/modules/theme/components/theme-integration.php index 1325e81a..d5e40feb 100644 --- a/modules/theme/components/theme-integration.php +++ b/modules/theme/components/theme-integration.php @@ -31,9 +31,9 @@ public function redirect_on_first_activation() { } public function __construct() { - // the original hooks: - //add_action( 'after_switch_theme', [ $this, 'activate' ] ); - //add_action( 'admin_init', [ $this, 'redirect_on_first_activation' ] ); + // TODO: check and update the hooks, these are the original hooks: + //'after_switch_theme' -> 'activate'; + //'admin_init' -> 'redirect_on_first_activation'; add_action( 'hello_plus_theme/redirect_on_first_activation', [ $this, 'activate' ] ); add_action( 'hello_plus_theme/after_switch_theme', [ $this, 'redirect_on_first_activation' ] ); From 340a090587ce4a79c5cf0b6bfbb607b9c34ff5f6 Mon Sep 17 00:00:00 2001 From: Maggie Serino <7341759+mserino@users.noreply.github.com> Date: Sun, 27 Oct 2024 10:23:05 +0100 Subject: [PATCH 4/4] cta 2nd round [TMZ-95] (#42) --- .../content/assets/scss/hello-plus-cta.scss | 22 +++++++-- .../classes/render/widget-cta-render.php | 14 +++--- modules/content/widgets/cta.php | 48 ++++++++++++++++--- 3 files changed, 67 insertions(+), 17 deletions(-) diff --git a/modules/content/assets/scss/hello-plus-cta.scss b/modules/content/assets/scss/hello-plus-cta.scss index cf707c16..0a012424 100644 --- a/modules/content/assets/scss/hello-plus-cta.scss +++ b/modules/content/assets/scss/hello-plus-cta.scss @@ -68,9 +68,18 @@ --cta-button-icon-spacing: var(--cta-button-primary-icon-spacing); --cta-button-icon-size: var(--cta-button-primary-icon-size); + --cta-box-padding-block-end: 60px; + --cta-box-padding-block-start: 60px; + --cta-box-padding-inline-end: 60px; + --cta-box-padding-inline-start: 60px; + display: flex; justify-content: center; height: var(--cta-box-height); + padding-block-end: var(--cta-box-padding-block-end); + padding-block-start: var(--cta-box-padding-block-start); + padding-inline-end: var(--cta-box-padding-inline-end); + padding-inline-start: var(--cta-box-padding-inline-start); @media screen and (min-width: $screen-tablet-min) { --cta-text-default-heading: 512px; @@ -144,12 +153,16 @@ &__ctas-container { flex-grow: 1; + } + + &__buttons-wrapper { display: flex; - flex-direction: column; gap: var(--cta-buttons-space-between); + flex-direction: column; justify-content: center; - + @media screen and (min-width: $screen-tablet-min) { + align-items: center; flex-direction: row; justify-content: flex-start; } @@ -226,6 +239,7 @@ &-link, &-link:not([href]):not([tabindex]) { + align-self: center; text-decoration: underline; } @@ -280,7 +294,7 @@ &-center { - .ehp-cta__ctas-container { + .ehp-cta__buttons-wrapper { justify-content: center; } } @@ -301,7 +315,7 @@ flex-direction: row; } - .ehp-cta__ctas-container { + .ehp-cta__buttons-wrapper { align-items: var(--cta-buttons-position); justify-content: flex-end; } diff --git a/modules/content/classes/render/widget-cta-render.php b/modules/content/classes/render/widget-cta-render.php index a8841b4f..8834370a 100644 --- a/modules/content/classes/render/widget-cta-render.php +++ b/modules/content/classes/render/widget-cta-render.php @@ -102,12 +102,14 @@ protected function render_ctas_container() { ] ); ?>
widget->get_render_attribute_string( 'ctas-container' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> - render_button( 'primary' ); - } ?> - render_button( 'secondary' ); - } ?> +
+ render_button( 'primary' ); + } ?> + render_button( 'secondary' ); + } ?> +
add_control( - 'primary_cta_button_text', + 'primary_cta_heading', [ 'label' => esc_html__( 'Primary CTA', 'hello-plus' ), + 'type' => Controls_Manager::HEADING, + ] + ); + + $this->add_control( + 'primary_cta_button_text', + [ + 'label' => esc_html__( 'Text', 'hello-plus' ), 'type' => Controls_Manager::TEXT, 'default' => esc_html__( 'Schedule Now', 'hello-plus' ), 'dynamic' => [ @@ -201,7 +209,7 @@ protected function add_content_cta_section() { 'label_on' => esc_html__( 'Show', 'hello-plus' ), 'label_off' => esc_html__( 'Hide', 'hello-plus' ), 'return_value' => 'yes', - 'default' => 'no', + 'default' => 'yes', 'separator' => 'before', ] ); @@ -209,7 +217,7 @@ protected function add_content_cta_section() { $this->add_control( 'secondary_cta_button_text', [ - 'label' => esc_html__( 'Secondary CTA', 'hello-plus' ), + 'label' => esc_html__( 'Text', 'hello-plus' ), 'type' => Controls_Manager::TEXT, 'default' => esc_html__( 'Contact Us', 'hello-plus' ), 'dynamic' => [ @@ -330,7 +338,7 @@ protected function add_style_section_text() { 'name' => 'heading_typography', 'selector' => '{{WRAPPER}} .ehp-cta__heading', 'global' => [ - 'default' => Global_Typography::TYPOGRAPHY_ACCENT, + 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, ], ] ); @@ -413,9 +421,8 @@ protected function add_style_section_cta() { $this->add_control( 'cta_position', [ - 'label' => esc_html__( 'Position', 'hello-plus' ), + 'label' => esc_html__( 'Desktop Position', 'hello-plus' ), 'type' => Controls_Manager::CHOOSE, - 'description' => esc_html__( 'Position controls Desktop layout', 'hello-plus' ), 'options' => [ 'flex-start' => [ 'title' => esc_html__( 'Start', 'hello-plus' ), @@ -815,7 +822,14 @@ protected function add_style_box_section() { 'types' => [ 'classic', 'gradient' ], 'exclude' => [ 'image' ], 'selector' => '{{WRAPPER}} .ehp-cta', - + 'fields_options' => [ + 'background' => [ + 'default' => 'classic', + ], + 'color' => [ + 'default' => '#F6F7F8', + ], + ], ] ); @@ -877,6 +891,26 @@ protected function add_style_box_section() { ] ); + $this->add_responsive_control( + 'box_padding', + [ + 'label' => esc_html__( 'Padding', 'hello-plus' ), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => [ 'px', '%', 'em', 'rem' ], + 'selectors' => [ + '{{WRAPPER}} .ehp-cta' => '--cta-box-padding-block-end: {{BOTTOM}}{{UNIT}}; --cta-box-padding-block-start: {{TOP}}{{UNIT}}; --cta-box-padding-inline-end: {{RIGHT}}{{UNIT}}; --cta-box-padding-inline-start: {{LEFT}}{{UNIT}};', + ], + 'default' => [ + 'top' => '60', + 'right' => '60', + 'bottom' => '60', + 'left' => '60', + 'unit' => 'px', + ], + 'separator' => 'before', + ] + ); + $this->add_control( 'box_full_screen_height', [