Skip to content

Commit

Permalink
Internal: Link in Bio - change waze control to URL
Browse files Browse the repository at this point in the history
  • Loading branch information
mserino committed Jun 14, 2024
1 parent 87df909 commit 54ec2c9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
14 changes: 10 additions & 4 deletions modules/conversion-center/base/widget-link-in-bio-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,17 +468,20 @@ protected function add_cta_controls() {
'cta_link_location',
[
'label' => esc_html__( 'Location', 'elementor' ),
'type' => Controls_Manager::TEXT,
'type' => Controls_Manager::URL,
'dynamic' => [
'active' => true,
],
'default' => [
'is_external' => true,
],
'label_block' => true,
'condition' => [
'cta_link_type' => [
Social_Network_Provider::WAZE,
],
],
'placeholder' => esc_html__( 'Enter your location', 'elementor' ),
'placeholder' => esc_html__( 'Paste Waze link', 'elementor' ),
],
);

Expand Down Expand Up @@ -716,12 +719,15 @@ protected function add_icons_controls(): void {
'icon_location',
[
'label' => esc_html__( 'Location', 'elementor' ),
'type' => Controls_Manager::TEXT,
'type' => Controls_Manager::URL,
'dynamic' => [
'active' => true,
],
'default' => [
'is_external' => true,
],
'label_block' => true,
'placeholder' => esc_html__( 'Enter your location', 'elementor' ),
'placeholder' => esc_html__( 'Paste Waze link', 'elementor' ),
'condition' => [
'icon_platform' => [
Social_Network_Provider::WAZE,
Expand Down
35 changes: 25 additions & 10 deletions modules/conversion-center/classes/render/render-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,30 @@ protected function render_ctas(): void {
$url_attrs['download'] = 'download';
}

$url_combined_attrs = $this->get_link_attributes(
$cta['cta_link_url'],
$url_attrs
);
if ( $cta['cta_link_url'] ) {
$url_combined_attrs = $this->get_link_attributes(
$cta['cta_link_url'],
$url_attrs
);

foreach ( $url_combined_attrs as $attr_key => $attr_value ) {
$this->widget->add_render_attribute( 'cta-' . $key, [
$attr_key => $attr_value,
] );
}
}

foreach ( $url_combined_attrs as $attr_key => $attr_value ) {
$this->widget->add_render_attribute( 'cta-' . $key, [
$attr_key => $attr_value,
] );
if ( $cta['cta_link_location'] ) {
$waze_combined_attrs = $this->get_link_attributes(
$cta['cta_link_location'],
$url_attrs
);

foreach ( $waze_combined_attrs as $attr_key => $attr_value ) {
$this->widget->add_render_attribute( 'cta-' . $key, [
$attr_key => $attr_value,
] );
}
}
?>
<a <?php echo $this->widget->get_render_attribute_string( 'cta-' . $key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
Expand Down Expand Up @@ -461,7 +476,7 @@ protected function get_formatted_link_based_on_type_for_cta( array $cta ): strin
'';
break;
case Social_Network_Provider::WAZE:
$formatted_link = ! empty( $cta['cta_link_location'] ) ? 'https://www.waze.com/ul?ll=' . $cta['cta_link_location'] . '&navigate=yes' : '';
$formatted_link = ! empty( $cta['cta_link_location']['url'] ) ? $cta['cta_link_location']['url'] : '';
break;
case Social_Network_Provider::WHATSAPP:
$formatted_link = ! empty( $cta['cta_link_number'] ) ? 'https://wa.me/' . $cta['cta_link_number'] : '';
Expand Down Expand Up @@ -496,7 +511,7 @@ protected function get_formatted_link_for_icon( array $icon ): string {
'';
break;
case Social_Network_Provider::WAZE:
$formatted_link = ! empty( $icon['icon_location'] ) ? 'https://www.waze.com/ul?ll=' . $icon['icon_location'] . '&navigate=yes' : '';
$formatted_link = ! empty( $icon['icon_location']['url'] ) ? $icon['icon_location']['url'] : '';
break;
case Social_Network_Provider::WHATSAPP:
$formatted_link = ! empty( $icon['icon_number'] ) ? 'https://wa.me/' . $icon['icon_number'] : '';
Expand Down

0 comments on commit 54ec2c9

Please sign in to comment.