balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

Welbim_Banner.php (11853B)


      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_Banner extends Widget_Base
     11 {
     12 
     13 	public function get_name()
     14 	{
     15 		return 'welbim_banner';
     16 	}
     17 
     18 	public function get_title()
     19 	{
     20 		return esc_html__('Welbim Banner', '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 		$this->start_controls_section(
     36 			'item',
     37 			[
     38 				'label' => esc_html__('item', 'welbim'),
     39 			]
     40 		);
     41 
     42 		$this->add_control(
     43 			'layout_style',
     44 			[
     45 				'label'   => esc_html__('Layout Style', 'welbim'),
     46 				'type'    => Controls_Manager::SELECT,
     47 				'options' => [
     48 					'style_1' => esc_html__('Style One', 'welbim'),
     49 					'style_2' => esc_html__('Style Two', 'welbim'),
     50 
     51 				],
     52 				'default' => 'style_1',
     53 			]
     54 		);
     55 
     56 		$repeater = new Repeater();
     57 
     58 		$repeater->add_control(
     59 			'item_title',
     60 			[
     61 				'label'   => esc_html__('Title', 'welbim'),
     62 				'type'    => Controls_Manager::TEXT,
     63 				'default' => __('Best Welding <br> &amp; Metal Works', 'welbim'),
     64 			]
     65 		);
     66 
     67 		$repeater->add_control(
     68 			'item_background_image',
     69 			[
     70 				'label'   => esc_html__('Background Image', 'welbim'),
     71 				'type'    => Controls_Manager::MEDIA,
     72 				'default' => [
     73 					'url' => Utils::get_placeholder_image_src(),
     74 				],
     75 			]
     76 		);
     77 
     78 		$repeater->add_control(
     79 			'item_button_title',
     80 			[
     81 				'label'   => esc_html__('Button Title', 'welbim'),
     82 				'type'    => Controls_Manager::TEXT,
     83 				'default' => __('Discover More', 'welbim'),
     84 			]
     85 		);
     86 
     87 		$repeater->add_control(
     88 			'item_button_url',
     89 			[
     90 				'label'         => esc_html__('Button URL', 'welbim'),
     91 				'type'          => Controls_Manager::URL,
     92 				'placeholder'   => esc_html__('https://your-link.com', 'welbim'),
     93 				'show_external' => true,
     94 				'default'       => [
     95 					'url'         => '',
     96 					'is_external' => false,
     97 					'nofollow'    => false,
     98 				],
     99 			]
    100 		);
    101 
    102 		$this->add_control(
    103 			'items',
    104 			[
    105 				'label'   => esc_html__('Repeater List', 'welbim'),
    106 				'type'    => Controls_Manager::REPEATER,
    107 				'fields'  => $repeater->get_controls(),
    108 				'default' => [
    109 					[
    110 						'list_title'   => esc_html__('Title #1', 'welbim'),
    111 						'list_content' => esc_html__('Item content. Click the edit button to change this text.', 'welbim'),
    112 					],
    113 					[
    114 						'list_title'   => esc_html__('Title #2', 'welbim'),
    115 						'list_content' => esc_html__('Item content. Click the edit button to change this text.', 'welbim'),
    116 					],
    117 				],
    118 			]
    119 		);
    120 
    121 		$this->end_controls_section();
    122 
    123 		 // Typography Section
    124 
    125 		$this->start_controls_section(
    126 			'typography_section',
    127 			array(
    128 				'label' => __( 'Typography Section', 'welbim' ),
    129 				'tab'   => Controls_Manager::TAB_STYLE,
    130 			)
    131 		);
    132 
    133 		$this->add_group_control(
    134 			Group_Control_Typography::get_type(),
    135 			array(
    136 				'name'     => 'heading_typography',   
    137 				'label'    => __( 'Title', 'welbim' ),
    138 				'selector' => '{{WRAPPER}} .banner-section .swiper-slide-active .content-box h1',
    139 
    140 			)
    141 		);
    142 		
    143 		$this->add_group_control(
    144 			Group_Control_Typography::get_type(),
    145 			array(
    146 				'name'     => 'button_text_typography',   
    147 				'label'    => __( 'Button Title', 'welbim' ),
    148 				'selector' => '{{WRAPPER}} .btn-style-one span',
    149 
    150 			)
    151 		);
    152 		
    153 		$this->end_controls_section();
    154 
    155 			//color section
    156 
    157 			$this->start_controls_section(
    158 				'color_section',
    159 				array(
    160 					'label' => __('Color Section', 'welbim'),
    161 					'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
    162 				)
    163 			);
    164 
    165 			$this->add_control(
    166 				'heading_color',
    167 				array(
    168 					'label'     => __('Title Color', 'welbim'),
    169 					'separator' => 'before',
    170 					'type'      => \Elementor\Controls_Manager::COLOR,
    171 					'selectors' => array(
    172 						'{{WRAPPER}} .banner-section .swiper-slide-active .content-box h1' => 'color: {{VALUE}}',
    173 					),
    174 				)
    175 			);
    176 
    177 			$this->add_control(
    178 				'button_bg_color',
    179 				array(
    180 					'label'     => __('Button BG Color', 'welbim'),
    181 					'separator' => 'before',
    182 					'type'      => \Elementor\Controls_Manager::COLOR,
    183 					'selectors' => array(
    184 						'{{WRAPPER}} .btn-style-one' => 'background-color: {{VALUE}}',
    185 					),
    186 				)
    187 			);
    188 
    189 			$this->add_control(
    190 				'button_text_color',
    191 				array(
    192 					'label'     => __('Button Title Color', 'welbim'),
    193 					'separator' => 'before',
    194 					'type'      => \Elementor\Controls_Manager::COLOR,
    195 					'selectors' => array(
    196 						'{{WRAPPER}} .btn-style-one span' => 'color: {{VALUE}}',
    197 					),
    198 				)
    199 			);
    200 		
    201 			$this->start_controls_tabs('tabs_button_style');
    202 			$this->start_controls_tab(
    203 				'tab_button_normal',
    204 				array(
    205 					'label' => __('Normal', 'welbim'),
    206 				)
    207 			);
    208 
    209 			$this->add_control(
    210 				'slider_button_left_color',
    211 				array(
    212 					'label'     => __('Slider Button Left BG Color', 'welbim'),
    213 					'separator' => 'before',
    214 					'type'      => \Elementor\Controls_Manager::COLOR,
    215 					'selectors' => array(
    216 						'{{WRAPPER}} .banner-section .banner-slider-button-prev' => 'background-color: {{VALUE}}',
    217 					),
    218 				)
    219 			);
    220 
    221 			$this->add_control(
    222 				'slider_button_left_icon_color',
    223 				array(
    224 					'label'     => __('Slider Button Left Icon Color', 'welbim'),
    225 					'separator' => 'before',
    226 					'type'      => \Elementor\Controls_Manager::COLOR,
    227 					'selectors' => array(
    228 						'{{WRAPPER}} .banner-section .banner-slider-button-prev' => 'color: {{VALUE}}',
    229 					),
    230 				)
    231 			);
    232 
    233 			$this->add_control(
    234 				'slider_button_right_color',
    235 				array(
    236 					'label'     => __('Slider Button Right BG Color', 'welbim'),
    237 					'separator' => 'before',
    238 					'type'      => \Elementor\Controls_Manager::COLOR,
    239 					'selectors' => array(
    240 						'{{WRAPPER}} .banner-section .banner-slider-button-next' => 'background-color: {{VALUE}}',
    241 					),
    242 				)
    243 			);
    244 
    245 			$this->add_control(
    246 				'slider_button_right_icon_color',
    247 				array(
    248 					'label'     => __('Slider Button Right Icon Color', 'welbim'),
    249 					'separator' => 'before',
    250 					'type'      => \Elementor\Controls_Manager::COLOR,
    251 					'selectors' => array(
    252 						'{{WRAPPER}} .banner-section .banner-slider-button-next' => 'color: {{VALUE}}',
    253 					),
    254 				)
    255 			);
    256 			
    257 			$this->end_controls_tab();
    258 		
    259 			$this->start_controls_tab(
    260 				'tab_button_hover',
    261 				array(
    262 					'label' => __('Hover', 'welbim'),
    263 				)
    264 			);
    265 		
    266 			$this->add_control(
    267 				'slider_button_left_bg_hover_color',
    268 				array(
    269 					'label'     => __('Slider Button BG Hover Left Color', 'welbim'),
    270 					'separator' => 'before',
    271 					'type'      => \Elementor\Controls_Manager::COLOR,
    272 					'selectors' => array(
    273 						'{{WRAPPER}} .banner-section .banner-slider-button-prev:hover' => 'background-color: {{VALUE}}',
    274 					),
    275 				)
    276 			);
    277 
    278 			$this->add_control(
    279 				'slider_button_left_icon_hover_color',
    280 				array(
    281 					'label'     => __('Slider Button Left Icon Hover Color', 'welbim'),
    282 					'separator' => 'before',
    283 					'type'      => \Elementor\Controls_Manager::COLOR,
    284 					'selectors' => array(
    285 						'{{WRAPPER}} .banner-section .banner-slider-button-prev:hover' => 'color: {{VALUE}}',
    286 					),
    287 				)
    288 			);
    289 
    290 			$this->add_control(
    291 				'slider_button_right_bg_hover_color',
    292 				array(
    293 					'label'     => __('Slider Button Right BG Hover Color', 'welbim'),
    294 					'separator' => 'before',
    295 					'type'      => \Elementor\Controls_Manager::COLOR,
    296 					'selectors' => array(
    297 						'{{WRAPPER}} .banner-section .banner-slider-button-next:hover' => 'background-color: {{VALUE}}',
    298 					),
    299 				)
    300 			);
    301 
    302 			$this->add_control(
    303 				'slider_button_right_icon_hover_color',
    304 				array(
    305 					'label'     => __('Slider Button Right Icon Hover Color', 'welbim'),
    306 					'separator' => 'before',
    307 					'type'      => \Elementor\Controls_Manager::COLOR,
    308 					'selectors' => array(
    309 						'{{WRAPPER}} .banner-section .banner-slider-button-next:hover' => 'color: {{VALUE}}',
    310 					),
    311 				)
    312 			);
    313 			
    314 		
    315 		$this->end_controls_tab();
    316 		$this->end_controls_tabs();
    317 		$this->end_controls_section();
    318 	
    319 
    320 	}
    321 	protected function render()
    322 	{
    323 		$settings     = $this->get_settings_for_display();
    324 		$layout_style = $settings['layout_style'];
    325 
    326 		if ($layout_style == 'style_1') { ?>
    327 			<section class="banner-section">
    328 				<div class="swiper-container banner-slider">
    329 					<div class="swiper-wrapper">
    330 						<!-- Slide Item -->
    331 						<?php
    332 						$i = 1;
    333 						foreach ($settings["items"] as $item) {
    334 							$item_title               = $item["item_title"];
    335 							$item_background_image    = ($item["item_background_image"]["id"] != "") ? wp_get_attachment_image_url($item["item_background_image"]["id"], "full") : $item["item_background_image"]["url"];
    336 							$item_button_title        = $item["item_button_title"];
    337 							$item_button_url          = $item["item_button_url"]["url"];
    338 							$item_button_url_external = $item["item_button_url"]["is_external"] ? 'target="_blank"' : '';
    339 							$item_button_url_nofollow = $item["item_button_url"]["nofollow"] ? 'rel="nofollow"' : '';
    340 						?>
    341 							<div class="swiper-slide" style="background-image: url(<?php echo $item_background_image; ?>);">
    342 								<div class="content-outer">
    343 									<div class="content-box">
    344 										<div class="inner text-center">
    345 											<h1><?php echo $item_title; ?></h1>
    346 											<div class="link-box">
    347 												<a href="<?php echo esc_url($item_button_url); ?>" <?php echo $item_button_url_external; ?> <?php echo $item_button_url_nofollow; ?> class="theme-btn btn-style-one"><span><?php echo $item_button_title; ?></span></a>
    348 											</div>
    349 										</div>
    350 									</div>
    351 								</div>
    352 							</div>
    353 						<?php
    354 							$i++;
    355 						}
    356 						?>
    357 						<!-- Slide Item -->
    358 					</div>
    359 				</div>
    360 				<div class="banner-slider-nav">
    361 					<div class="banner-slider-control banner-slider-button-prev"><span><i class="flaticon-left-arrow"></i></span></div>
    362 					<div class="banner-slider-control banner-slider-button-next"><span><i class="flaticon-left-arrow"></i></span> </div>
    363 				</div>
    364 			</section>
    365 		<?php } elseif ($layout_style == 'style_2') { ?>
    366 			<!-- Bnner Section -->
    367 			<section class="banner-section style-two">
    368 				<div class="swiper-container banner-slider">
    369 					<div class="swiper-wrapper">
    370 					<?php
    371 						$i = 1;
    372 						foreach ($settings["items"] as $item) {
    373 							$item_title               = $item["item_title"];
    374 							$item_background_image    = ($item["item_background_image"]["id"] != "") ? wp_get_attachment_image_url($item["item_background_image"]["id"], "full") : $item["item_background_image"]["url"];
    375 							$item_button_title        = $item["item_button_title"];
    376 							$item_button_url          = $item["item_button_url"]["url"];
    377 							$item_button_url_external = $item["item_button_url"]["is_external"] ? 'target="_blank"' : '';
    378 							$item_button_url_nofollow = $item["item_button_url"]["nofollow"] ? 'rel="nofollow"' : '';
    379 						?>
    380 						<div class="swiper-slide" style="background-image: url(<?php echo $item_background_image; ?>);">
    381 							<div class="content-outer">
    382 								<div class="content-box">
    383 									<div class="inner">
    384 										<h1><?php echo $item_title; ?></h1>
    385 										<div class="link-box">
    386 											<a href="<?php echo esc_url($item_button_url); ?>" <?php echo $item_button_url_external; ?> <?php echo $item_button_url_nofollow; ?> class="theme-btn btn-style-one"><span><?php echo $item_button_title; ?></span></a>
    387 										</div>
    388 									</div>
    389 								</div>
    390 							</div>
    391 						</div>			
    392 						<?php	$i++; }	?>
    393 
    394 						<!-- Slide Item -->
    395 					</div>
    396 				</div>
    397 				<div class="banner-slider-nav">
    398 					<div class="banner-slider-control banner-slider-button-prev"><span><i class="flaticon-left-arrow"></i></span></div>
    399 					<div class="banner-slider-control banner-slider-button-next"><span><i class="flaticon-left-arrow"></i></span> </div>
    400 				</div>
    401 			</section>
    402 			<!-- End Bnner Section -->
    403 
    404 <?php }
    405 	}
    406 }