CTA.php (4113B)
1 <?php 2 3 namespace Welbim\Helper\Elementor\Widgets; 4 5 use Elementor\Utils; 6 use Elementor\Controls_Manager; 7 use Elementor\Widget_Base; 8 use Elementor\Plugin; 9 use \Elementor\Repeater; 10 use Elementor\Group_Control_Typography; 11 12 class CTA extends Widget_Base 13 { 14 15 public function get_name() 16 { 17 return 'cta'; 18 } 19 20 public function get_title() 21 { 22 return esc_html__('Welbim CTA', 'welbim'); 23 } 24 25 public function get_icon() 26 { 27 return 'sds-widget-ico'; 28 } 29 30 public function get_categories() 31 { 32 return ['Welbim']; 33 } 34 35 protected function _register_controls() 36 { 37 38 $this->start_controls_section( 39 'general', 40 [ 41 'label' => esc_html__('General', 'welbim'), 42 ] 43 ); 44 45 $this->add_control( 46 'title', 47 [ 48 'label' => esc_html__('Title', 'welbim'), 49 'type' => Controls_Manager::TEXT, 50 'default' => __('Looking for a quality and <br>affordable project?', 'welbim'), 51 ] 52 ); 53 54 $this->add_control( 55 'button_title', 56 [ 57 'label' => esc_html__('Button Title', 'welbim'), 58 'type' => Controls_Manager::TEXT, 59 'default' => __('Contact Us', 'welbim'), 60 ] 61 ); 62 63 $this->add_control( 64 'button_link', 65 [ 66 'label' => esc_html__('Button Link', 'welbim'), 67 'type' => Controls_Manager::URL, 68 'placeholder' => esc_html__('https://your-link.com', 'welbim'), 69 'show_external' => true, 70 'default' => [ 71 'url' => '', 72 'is_external' => false, 73 'nofollow' => false, 74 ], 75 ] 76 ); 77 78 $this->end_controls_section(); 79 80 $this->start_controls_section( 81 'typography_section', 82 array( 83 'label' => __('Typography Section', 'welbim'), 84 'tab' => Controls_Manager::TAB_STYLE, 85 ) 86 ); 87 88 $this->add_group_control( 89 Group_Control_Typography::get_type(), 90 array( 91 'name' => 'heading_typography', 92 'label' => __('Title', 'welbim'), 93 'selector' => '{{WRAPPER}} .cta-section h3', 94 95 ) 96 ); 97 $this->add_group_control( 98 Group_Control_Typography::get_type(), 99 array( 100 'name' => 'button_title_typography', 101 'label' => __('Button Title', 'welbim'), 102 'selector' => '{{WRAPPER}} .btn-style-one span', 103 104 ) 105 ); 106 107 108 $this->end_controls_section(); 109 110 $this->start_controls_section( 111 'color_section', 112 array( 113 'label' => __('Color Section', 'welbim'), 114 'tab' => \Elementor\Controls_Manager::TAB_STYLE, 115 ) 116 ); 117 118 $this->add_control( 119 'heading_color', 120 array( 121 'label' => __('Heading Color', 'welbim'), 122 'separator' => 'before', 123 'type' => \Elementor\Controls_Manager::COLOR, 124 'selectors' => array( 125 '{{WRAPPER}} .cta-section h3' => 'color: {{VALUE}}', 126 ), 127 ) 128 ); 129 130 131 $this->add_control( 132 'button_bg_color', 133 array( 134 'label' => __('Button BG Color', 'welbim'), 135 'separator' => 'before', 136 'type' => \Elementor\Controls_Manager::COLOR, 137 'selectors' => array( 138 '{{WRAPPER}} .btn-style-one' => 'background-color: {{VALUE}}', 139 ), 140 ) 141 ); 142 143 $this->add_control( 144 'button_text_color', 145 array( 146 'label' => __('Button Title Color', 'welbim'), 147 'separator' => 'before', 148 'type' => \Elementor\Controls_Manager::COLOR, 149 'selectors' => array( 150 '{{WRAPPER}} .btn-style-one' => 'color: {{VALUE}}', 151 ), 152 ) 153 ); 154 155 156 $this->end_controls_section(); 157 } 158 protected function render() 159 { 160 $settings = $this->get_settings_for_display(); 161 $title = $settings["title"]; 162 $button_title = $settings["button_title"]; 163 $button_link = $settings["button_link"]["url"]; 164 $button_link_external = $settings["button_link"]["is_external"] ? 'target="_blank"' : ''; 165 $button_link_nofollow = $settings["button_link"]["nofollow"] ? 'rel="nofollow"' : ''; 166 ?> 167 <section class="cta-section"> 168 <div class="auto-container"> 169 <div class="wrapper-box"> 170 <h3><?php echo $title; ?></h3> 171 <div class="link "> 172 <a href="<?php echo esc_url($button_link); ?>" <?php echo $button_link_external; ?> <?php echo $button_link_nofollow; ?> class="theme-btn btn-style-one"><span><?php echo $button_title; ?></span></a> 173 </div> 174 </div> 175 </div> 176 </section> 177 <?php 178 } 179 }