From 8b53c452b153bc47d9c35dbc83f66af0a7ef16f7 Mon Sep 17 00:00:00 2001 From: "stephen@cubedesigners.com" Date: Mon, 8 Jul 2019 10:22:26 +0000 Subject: [PATCH] Done #2864 @1.5 --- .../src/Elementor/Widgets/TextBlock.php | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextBlock.php b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextBlock.php index 4066aa35..0a60cceb 100644 --- a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextBlock.php +++ b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextBlock.php @@ -117,6 +117,33 @@ class TextBlock extends Widget_Base { ] ); + // Additional link control + // Ideally this would be a widget of its own but due to the text-block scaling + // and the need for absolute positioning it, we can't put another widget under + // the text-block without some big changes. This is the compromise... + + $this->add_control( + 'extra_link_text', + [ + 'label' => __('Extra link text', 'physioassist'), + 'type' => Controls_Manager::TEXT, + 'default' => '' + ] + ); + + $this->add_control( + 'extra_link_URL', + [ + 'label' => __('Extra link URL', 'physioassist'), + 'type' => Controls_Manager::URL, + 'default' => [ + 'url' => '', + 'is_external' => false, + ], + 'show_external' => true + ] + ); + $this->end_controls_section(); @@ -253,6 +280,8 @@ class TextBlock extends Widget_Base { $cta_text = $this->get_settings('cta_text'); $cta_link = $this->get_settings('cta_link'); $cta_tag = 'a'; // Default tag type + $extra_link_text = $this->get_settings('extra_link_text'); + $extra_link_URL = $this->get_settings('extra_link_URL'); if ( ! empty( $cta_link['url'] ) ) { @@ -275,17 +304,32 @@ class TextBlock extends Widget_Base { } } + if ( ! empty( $extra_link_URL['url'] ) ) { + + $this->add_render_attribute( 'extra_link_text', 'href', $extra_link_URL['url'] ); + + if ( $extra_link_URL['is_external'] ) { + $this->add_render_attribute( 'extra_link_text', 'target', '_blank' ); + } + + if ( $extra_link_URL['nofollow'] ) { + $this->add_render_attribute( 'extra_link_text', 'rel', 'nofollow' ); + } + } + // Inline Editing settings $this->add_inline_editing_attributes('subtitle', 'none'); $this->add_inline_editing_attributes('title', 'none'); $this->add_inline_editing_attributes('body', 'advanced'); $this->add_inline_editing_attributes('cta_text', 'none'); + $this->add_inline_editing_attributes('extra_link_text', 'none'); // CSS Classes for elements $this->add_render_attribute('subtitle', 'class', ['text-block-subtitle']); $this->add_render_attribute('title', 'class', ['text-block-title']); $this->add_render_attribute('body', 'class', ['text-block-body']); $this->add_render_attribute('cta_text', 'class', ['text-block-cta arrow-link']); + $this->add_render_attribute('extra_link_text', 'class', ['text-block-extra-link arrow-link']); // Rendered content echo '
'; @@ -295,6 +339,9 @@ class TextBlock extends Widget_Base { if (!empty($cta_text)) { echo "<$cta_tag {$this->get_render_attribute_string('cta_text')}>". \BladeSvgSage\svg_image('arrow')->toHtml() ."$cta_text"; } + if (!empty($extra_link_text)) { + echo "get_render_attribute_string('extra_link_text')}>". \BladeSvgSage\svg_image('arrow')->toHtml() ."$extra_link_text"; + } echo '
'; } @@ -313,11 +360,16 @@ class TextBlock extends Widget_Base { view.addRenderAttribute( 'title', 'class', ['text-block-title']); view.addRenderAttribute( 'body', 'class', ['text-block-body']); view.addRenderAttribute( 'cta_text', 'class', ['text-block-cta arrow-link']); + view.addRenderAttribute( 'cta_text', 'href', ['#']); + view.addRenderAttribute( 'extra_link_text', 'class', ['text-block-extra-link arrow-link']); + view.addRenderAttribute( 'extra_link_text', 'href', ['#']); + view.addInlineEditingAttributes( 'subtitle', 'none' ); view.addInlineEditingAttributes( 'title', 'none' ); view.addInlineEditingAttributes( 'body', 'advanced' ); view.addInlineEditingAttributes( 'cta_text', 'none' ); + view.addInlineEditingAttributes( 'extra_link_text', 'none' ); #>
@@ -337,6 +389,10 @@ class TextBlock extends Widget_Base { toHtml() ?>{{{ settings.cta_text }}} <# } #> + <# if ('' !== settings.extra_link_text) { #> + toHtml() ?>{{{ settings.extra_link_text }}} + <# } #> +