Welbim_Video.php (6895B)
1 <?php 2 namespace Welbim\Helper\Elementor\Widgets; 3 use Elementor\Utils; 4 use Elementor\Controls_Manager; 5 use Elementor\Widget_Base; 6 use Elementor\Plugin; 7 use \Elementor\Repeater; 8 use Elementor\Group_Control_Typography; 9 10 class Welbim_Video extends Widget_Base 11 { 12 13 public function get_name() 14 { 15 return 'welbim video'; 16 } 17 18 public function get_title() 19 { 20 return esc_html__('Welbim Video', 'welbim'); 21 } 22 23 public function get_icon() 24 { 25 return 'sds-widget-ico'; 26 } 27 28 public function get_categories() 29 { 30 return ['Welbim']; 31 } 32 33 protected function _register_controls() 34 { 35 36 $this->start_controls_section( 37 'general', 38 [ 39 'label' => esc_html__('General', 'welbim'), 40 ] 41 ); 42 43 $this->add_control( 44 'background_img', 45 [ 46 'label' => esc_html__('Background Image', 'welbim'), 47 'type' => Controls_Manager::MEDIA, 48 'default' => [ 49 'url' => Utils::get_placeholder_image_src(), 50 ], 51 ] 52 ); 53 54 $this->add_control( 55 'title', 56 [ 57 'label' => esc_html__('Title', 'welbim'), 58 'type' => Controls_Manager::TEXT, 59 'default' => __('PROVIDING PREMIUM<br>METAL WORKS...', 'welbim'), 60 ] 61 ); 62 63 $this->add_control( 64 'video_icon', 65 [ 66 'label' => __('Video Icon', 'text-domain'), 67 'type' => \Elementor\Controls_Manager::ICONS, 68 ] 69 ); 70 71 $this->add_control( 72 'video_url', 73 [ 74 'label' => esc_html__('Video URL', 'welbim'), 75 'type' => Controls_Manager::URL, 76 'placeholder' => esc_html__('https://your-link.com', 'welbim'), 77 'show_external' => true, 78 'default' => [ 79 'url' => '', 80 'is_external' => false, 81 'nofollow' => false, 82 ], 83 ] 84 ); 85 86 $this->add_control( 87 'sub_title', 88 [ 89 'label' => esc_html__('Sub-Title', 'welbim'), 90 'type' => Controls_Manager::TEXT, 91 'default' => __('we’re <br> Running <br> Business <br> Since 1985', 'welbim'), 92 ] 93 ); 94 95 $this->add_control( 96 'icon', 97 [ 98 'label' => __('Icon', 'text-domain'), 99 'type' => \Elementor\Controls_Manager::ICONS, 100 ] 101 ); 102 103 $this->add_control( 104 'image', 105 [ 106 'label' => esc_html__('Image', 'welbim'), 107 'type' => Controls_Manager::MEDIA, 108 'default' => [ 109 'url' => Utils::get_placeholder_image_src(), 110 ], 111 ] 112 ); 113 114 $this->end_controls_section(); 115 116 //Typography Section 117 $this->start_controls_section( 118 'typography_section', 119 array( 120 'label' => __( 'Typography Section', 'welbim' ), 121 'tab' => Controls_Manager::TAB_STYLE, 122 ) 123 ); 124 125 $this->add_group_control( 126 Group_Control_Typography::get_type(), 127 array( 128 'name' => 'title_typography', 129 'label' => __( 'Title', 'welbim' ), 130 'selector' => '{{WRAPPER}} .video-section h2', 131 132 ) 133 ); 134 135 $this->add_group_control( 136 Group_Control_Typography::get_type(), 137 array( 138 'name' => 'subtitle_typography', 139 'label' => __( 'Sub-Title', 'welbim' ), 140 'selector' => '{{WRAPPER}} .video-section .icon-box h4', 141 142 ) 143 ); 144 145 $this->end_controls_section(); 146 //Color Section 147 $this->start_controls_section( 148 'color_section', 149 array( 150 'label' => __('Color Section', 'welbim'), 151 'tab' => \Elementor\Controls_Manager::TAB_STYLE, 152 ) 153 ); 154 155 $this->add_control( 156 'title_color', 157 array( 158 'label' => __('Title Color', 'welbim'), 159 'separator' => 'before', 160 'type' => \Elementor\Controls_Manager::COLOR, 161 'selectors' => array( 162 '{{WRAPPER}} .video-section h2' => 'color: {{VALUE}}', 163 ), 164 ) 165 ); 166 167 $this->add_control( 168 'subtitle_color', 169 array( 170 'label' => __('Sub-Title Color', 'welbim'), 171 'separator' => 'before', 172 'type' => \Elementor\Controls_Manager::COLOR, 173 'selectors' => array( 174 '{{WRAPPER}} .video-section .icon-box h4' => 'color: {{VALUE}}', 175 ), 176 ) 177 ); 178 179 $this->add_control( 180 'icon_color', 181 array( 182 'label' => __('Icon Color', 'welbim'), 183 'separator' => 'before', 184 'type' => \Elementor\Controls_Manager::COLOR, 185 'selectors' => array( 186 '{{WRAPPER}} .video-section .icon-box .icon' => 'color: {{VALUE}}', 187 ), 188 ) 189 ); 190 191 $this->add_control( 192 'play_button_icon_color', 193 array( 194 'label' => __('Play Button Icon Color', 'welbim'), 195 'separator' => 'before', 196 'type' => \Elementor\Controls_Manager::COLOR, 197 'selectors' => array( 198 '{{WRAPPER}} .video-section .video-btn a' => 'color: {{VALUE}}', 199 ), 200 ) 201 ); 202 203 $this->end_controls_section(); 204 } 205 protected function render() 206 { 207 $settings = $this->get_settings_for_display(); 208 $sub_title = $settings["sub_title"]; 209 $title = $settings["title"]; 210 $video_icon = $settings["video_icon"]; 211 $video_url = $settings["video_url"]["url"]; 212 $video_url_external = $settings["video_url"]["is_external"] ? 'target="_blank"' : ''; 213 $video_url_nofollow = $settings["video_url"]["nofollow"] ? 'rel="nofollow"' : ''; 214 $image = ($settings["image"]["id"] != "") ? wp_get_attachment_image_url($settings["image"]["id"], "full") : $settings["image"]["url"]; 215 $background_img = ($settings["background_img"]["id"] != "") ? wp_get_attachment_image_url($settings["background_img"]["id"], "full") : $settings["background_img"]["url"]; 216 ?> 217 <section class="video-section" style="background-image: url(<?php echo $background_img; ?>);"> 218 <div class="auto-container"> 219 <div class="row"> 220 <div class="col-lg-9"> 221 <h2><?php echo $title; ?></h2> 222 <div class="video-btn"><a href="<?php echo esc_url($video_url); ?>" <?php echo $video_url_external; ?> <?php echo $video_url_nofollow; ?> class="overlay-link play-now ripple" data-fancybox="gallery" data-caption=""> 223 <?php \Elementor\Icons_Manager::render_icon($video_icon, ['aria-hidden' => 'true']); ?> 224 </a></div> 225 </div> 226 <div class="col-lg-3"> 227 <div class="icon-box" style="background-image: url(<?php echo $image; ?>);"> 228 <div class="icon"><?php \Elementor\Icons_Manager::render_icon($settings['icon'], ['aria-hidden' => 'true']); ?></div> 229 <h4><?php echo $sub_title; ?></h4> 230 </div> 231 </div> 232 </div> 233 </div> 234 </section> 235 <?php 236 } 237 }