Skip to content

Commit

Permalink
TMZ-70 addressing CR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mserino committed Oct 7, 2024
1 parent 386037d commit 2fc0050
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 38 deletions.
57 changes: 23 additions & 34 deletions modules/content/widgets/cta.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ protected function add_style_section_cta() {
);

$this->add_cta_button_controls( 'primary' );
$this->add_cta_button_controls( 'secondary', true );
$this->add_cta_button_controls( 'secondary' );

$this->add_responsive_control(
'cta_space_between',
Expand Down Expand Up @@ -446,20 +446,15 @@ protected function add_style_section_cta() {
$this->end_controls_section();
}

protected function add_cta_button_controls( string $type, bool $add_condition = false ) {
protected function add_cta_button_controls( $type ) {
$label = 'primary' === $type ? esc_html__( 'Primary CTA', 'hello-plus' ) : esc_html__( 'Secondary CTA', 'hello-plus' );
$show_button_border_default = 'primary' === $type ? 'no' : 'yes';

$add_type_condition = $add_condition ? [
$type . '_cta_show' => 'yes',
] : [];

$this->add_control(
$type . '_button_label',
[
'label' => $label,
'type' => Controls_Manager::HEADING,
'condition' => $add_type_condition,
]
);

Expand All @@ -473,7 +468,6 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
'button' => esc_html__( 'Button', 'hello-plus' ),
'link' => esc_html__( 'Link', 'hello-plus' ),
],
'condition' => $add_type_condition,
]
);

Expand All @@ -482,7 +476,6 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
[
'name' => $type . '_button_typography',
'selector' => '{{WRAPPER}} .ehp-cta__button--' . $type,
'condition' => $add_type_condition,
]
);

Expand Down Expand Up @@ -510,9 +503,9 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
'selectors' => [
'{{WRAPPER}} .ehp-cta__button--' . $type => 'flex-direction: {{VALUE}};',
],
'condition' => array_merge([
'condition' => [
$type . '_cta_button_icon[value]!' => '',
], $add_type_condition),
],
]
);

Expand All @@ -539,9 +532,9 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
'selectors' => [
'{{WRAPPER}} .ehp-cta' => '--cta-button-' . $type . '-icon-spacing: {{SIZE}}{{UNIT}};',
],
'condition' => array_merge([
'condition' => [
$type . '_cta_button_icon[value]!' => '',
], $add_type_condition),
],
]
);

Expand All @@ -553,7 +546,6 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
$type . '_button_normal_tab',
[
'label' => esc_html__( 'Normal', 'hello-plus' ),
'condition' => $add_type_condition,
]
);

Expand All @@ -565,7 +557,6 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
'selectors' => [
'{{WRAPPER}} .ehp-cta' => '--cta-button-' . $type . '-text-color: {{VALUE}}',
],
'condition' => $add_type_condition,
]
);

Expand All @@ -581,9 +572,9 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
'default' => 'classic',
],
],
'condition' => array_merge([
'condition' => [
$type . '_button_type' => 'button',
], $add_type_condition),
],
]
);

Expand All @@ -593,7 +584,6 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
$type . '_button_hover_tab',
[
'label' => esc_html__( 'Hover', 'hello-plus' ),
'condition' => $add_type_condition,
]
);

Expand All @@ -605,7 +595,6 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
'selectors' => [
'{{WRAPPER}} .ehp-cta' => '--cta-button-' . $type . '-text-color-hover: {{VALUE}}',
],
'condition' => $add_type_condition,
]
);

Expand All @@ -621,9 +610,9 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
'default' => 'classic',
],
],
'condition' => array_merge([
'condition' => [
$type . '_button_type' => 'button',
], $add_type_condition),
],
]
);

Expand All @@ -632,7 +621,7 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
[
'label' => esc_html__( 'Hover Animation', 'hello-plus' ),
'type' => Controls_Manager::HOVER_ANIMATION,
'condition' => $add_type_condition,

]
);

Expand All @@ -650,9 +639,9 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
'return_value' => 'yes',
'default' => $show_button_border_default,
'separator' => 'before',
'condition' => array_merge([
'condition' => [
$type . '_button_type' => 'button',
], $add_type_condition),
],
]
);

Expand All @@ -676,9 +665,9 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
'selectors' => [
'{{WRAPPER}} .ehp-cta' => '--cta-button-' . $type . '-border-width: {{SIZE}}{{UNIT}};',
],
'condition' => array_merge([
'condition' => [
$type . '_show_button_border' => 'yes',
], $add_type_condition),
],
]
);

Expand All @@ -690,9 +679,9 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
'selectors' => [
'{{WRAPPER}} .ehp-cta' => '--cta-button-' . $type . '-border-color: {{VALUE}}',
],
'condition' => array_merge([
'condition' => [
$type . '_show_button_border' => 'yes',
], $add_type_condition),
],
]
);

Expand All @@ -708,9 +697,9 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
'round' => esc_html__( 'Round', 'hello-plus' ),
'rounded' => esc_html__( 'Rounded', 'hello-plus' ),
],
'condition' => array_merge([
'condition' => [
$type . '_button_type' => 'button',
], $add_type_condition),
],
]
);

Expand All @@ -719,9 +708,9 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
[
'name' => $type . '_button_box_shadow',
'selector' => '{{WRAPPER}} .ehp-cta__button--' . $type,
'condition' => array_merge([
'condition' => [
$type . '_button_type' => 'button',
], $add_type_condition),
],
]
);

Expand All @@ -735,9 +724,9 @@ protected function add_cta_button_controls( string $type, bool $add_condition =
'{{WRAPPER}} .ehp-cta' => '--cta-button-' . $type . '-padding-block-end: {{BOTTOM}}{{UNIT}}; --cta-button-' . $type . '-padding-block-start: {{TOP}}{{UNIT}}; --cta-button-' . $type . '-padding-inline-end: {{RIGHT}}{{UNIT}}; --cta-button-' . $type . '-padding-inline-start: {{LEFT}}{{UNIT}};',
],
'separator' => 'before',
'condition' => array_merge([
'condition' => [
$type . '_button_type' => 'button',
], $add_type_condition),
],
]
);
}
Expand Down
5 changes: 1 addition & 4 deletions modules/header/widgets/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use HelloPlus\Includes\Utils as Theme_Utils;

use HelloPlus\Modules\Header\Classes\Render\Widget_Header_Render;
use ElementorPro\Modules\ThemeBuilder\Classes\Control_Media_Preview;
use HelloPlus\Modules\Theme\Classes\Control_Media_Preview;

use HelloPlus\Modules\Theme\Module as Theme_Module;

Expand Down Expand Up @@ -112,9 +112,6 @@ protected function add_content_site_logo_section() {
'label' => esc_html__( 'Site Logo', 'hello-plus' ),
'type' => Control_Media_Preview::CONTROL_TYPE,
'src' => $this->get_site_logo(),
'dynamic' => [
'default' => Theme_Utils::elementor()->dynamic_tags->tag_data_to_tag_text( null, 'site-logo' ),
],
'condition' => [
'site_logo_brand_select' => 'logo',
],
Expand Down
35 changes: 35 additions & 0 deletions modules/theme/classes/control-media-preview.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
namespace HelloPlus\Modules\Theme\Classes;

use Elementor\Control_Media;

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}

class Control_Media_Preview extends Control_Media {

const CONTROL_TYPE = 'media-preview';

public function get_type() {
return self::CONTROL_TYPE;
}

public function content_template() {
?>
<div class="elementor-control-field elementor-control-media">
<label class="elementor-control-title">{{{ data.label }}}</label>
<div class="elementor-control-input-wrapper">
<div class="elementor-control-media-area">
<div class="elementor-control-media__preview" style="background-image: url('{{ data.src }}');"></div>
</div>
</div>
<# if ( data.description ) { #>
<div class="elementor-control-field-description">{{{ data.description }}}</div>
<# } #>
<input type="hidden" data-setting="{{ data.name }}"/>
</div>
<?php
}

}

Check failure on line 35 in modules/theme/classes/control-media-preview.php

View workflow job for this annotation

GitHub Actions / Lint PHP files

The closing brace for the class must go on the next line after the body

0 comments on commit 2fc0050

Please sign in to comment.