]> _ Git - physioassist-wordpress.git/commitdiff
Done #2864 @1.5
authorstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 8 Jul 2019 10:22:26 +0000 (10:22 +0000)
committerstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 8 Jul 2019 10:22:26 +0000 (10:22 +0000)
wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextBlock.php

index 4066aa3532b124d3ce34d906e5491aa61cf5b293..0a60cceb997b021d2d689b26a11accc0f7deeb9b 100644 (file)
@@ -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 '<div class="text-block">';
@@ -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</$cta_tag>";
         }
+        if (!empty($extra_link_text)) {
+            echo "<a {$this->get_render_attribute_string('extra_link_text')}>". \BladeSvgSage\svg_image('arrow')->toHtml() ."$extra_link_text</a>";
+        }
         echo '</div>';
     }
 
@@ -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' );
         #>
         <div class="text-block">
             
@@ -337,6 +389,10 @@ class TextBlock extends Widget_Base {
                 <a {{{ view.getRenderAttributeString( 'cta_text' ) }}}><?= \BladeSvgSage\svg_image('arrow')->toHtml() ?>{{{ settings.cta_text }}}</a>
             <# } #>
 
+            <# if ('' !== settings.extra_link_text) { #>
+                <a {{{ view.getRenderAttributeString( 'extra_link_text' ) }}}><?= \BladeSvgSage\svg_image('arrow')->toHtml() ?>{{{ settings.extra_link_text }}}</a>
+            <# } #>
+
         </div>
     <?php
        }