balmet.com

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

Our_Services.php (14427B)


      1 <?php
      2 namespace Welbim\Helper\Elementor\Widgets;
      3 
      4 use Elementor\Utils;
      5 use Elementor\Controls_Manager;
      6 use Elementor\Widget_Base;
      7 use Elementor\Plugin;
      8 use \Elementor\Repeater;
      9 use Elementor\Group_Control_Typography;
     10 
     11 class Our_Services extends Widget_Base {
     12 
     13 
     14 	public function get_name() {
     15 		return 'our_services';
     16 	}
     17 
     18 	public function get_title() {
     19 		return esc_html__( 'Welbim Our Services', 'welbim' );
     20 	}
     21 
     22 	public function get_icon() {
     23 		return 'sds-widget-ico';
     24 	}
     25 
     26 	public function get_categories() {
     27 		return array( 'Welbim' );
     28 	}
     29 
     30 	protected function _register_controls() {
     31 		$this->start_controls_section(
     32 			'layout',
     33 			array(
     34 				'label' => __( 'Layout Style', 'welbim' ),
     35 				'tab'   => \Elementor\Controls_Manager::TAB_CONTENT,
     36 			)
     37 		);
     38 
     39 		$this->add_control(
     40 			'layout_style',
     41 			array(
     42 				'label'   => __( 'Layout', 'welbim' ),
     43 				'type'    => \Elementor\Controls_Manager::SELECT,
     44 				'default' => '1',
     45 				'options' => array(
     46 					'1' => __( 'One', 'welbim' ),
     47 					'2' => __( 'Two', 'welbim' ),
     48 					'3' => __( 'Three', 'welbim' ),
     49 				),
     50 			)
     51 		);
     52 
     53 		$this->end_controls_section();
     54 
     55 		$this->start_controls_section(
     56 			'general',
     57 			array(
     58 				'label' => esc_html__( 'General', 'welbim' ),
     59 			)
     60 		);
     61 
     62 		$this->add_control(
     63 			'background_img',
     64 			array(
     65 				'label'     => esc_html__( 'Background Image', 'welbim' ),
     66 				'type'      => Controls_Manager::MEDIA,
     67 				'default'   => array(
     68 					'url' => Utils::get_placeholder_image_src(),
     69 				),
     70 				'condition' => array(
     71 					'layout_style' => '1',
     72 				),
     73 			)
     74 		);
     75 
     76 		$this->add_control(
     77 			'sub_title',
     78 			array(
     79 				'label'   => esc_html__( 'Sub Title', 'welbim' ),
     80 				'type'    => Controls_Manager::TEXT,
     81 				'default' => __( 'Our Services', 'welbim' ),
     82 			)
     83 		);
     84 
     85 		$this->add_control(
     86 			'heading',
     87 			array(
     88 				'label'   => esc_html__( 'Heading', 'welbim' ),
     89 				'type'    => Controls_Manager::TEXT,
     90 				'default' => __( 'What we offer', 'welbim' ),
     91 			)
     92 		);
     93 
     94 		$this->add_group_control(
     95 			\Elementor\Group_Control_Background::get_type(),
     96 			array(
     97 				'name'     => 'background',
     98 				'label'    => __( 'Background', 'plugin-domain' ),
     99 				'types'    => array( 'classic', 'gradient', 'video' ),
    100 				'selector' => '{{WRAPPER}} .services-section.style-two:before',
    101 			)
    102 		);
    103 
    104 		$this->end_controls_section();
    105 
    106 		$this->start_controls_section(
    107 			'item',
    108 			array(
    109 				'label' => esc_html__( 'item', 'welbim' ),
    110 			)
    111 		);
    112 
    113 		$repeater = new Repeater();
    114 
    115 		$repeater->add_control(
    116 			'item_title',
    117 			array(
    118 				'label'   => esc_html__( 'Title', 'welbim' ),
    119 				'type'    => Controls_Manager::TEXT,
    120 				'default' => __( 'STEEL WELDING', 'welbim' ),
    121 			)
    122 		);
    123 
    124 		$repeater->add_control(
    125 			'item_image',
    126 			array(
    127 				'label'   => esc_html__( 'Image', 'welbim' ),
    128 				'type'    => Controls_Manager::MEDIA,
    129 				'default' => array(
    130 					'url' => Utils::get_placeholder_image_src(),
    131 				),
    132 			)
    133 		);
    134 
    135 		$repeater->add_control(
    136 			'item_discription',
    137 			array(
    138 				'label'   => esc_html__( 'Discription', 'welbim' ),
    139 				'type'    => Controls_Manager::TEXT,
    140 				'default' => __( 'Lorem ipsum is simply free <br> text dolor sit am adipi we help you is in <br> the right jobs sicing elit.', 'welbim' ),
    141 			)
    142 		);
    143 
    144 		$repeater->add_control(
    145 			'item_bottom_title',
    146 			array(
    147 				'label'   => esc_html__( 'Bottom Title', 'welbim' ),
    148 				'type'    => Controls_Manager::TEXT,
    149 				'default' => __( 'Read More', 'welbim' ),
    150 			)
    151 		);
    152 
    153 		$repeater->add_control(
    154 			'item_url',
    155 			array(
    156 				'label'         => esc_html__( 'URL', 'welbim' ),
    157 				'type'          => Controls_Manager::URL,
    158 				'placeholder'   => esc_html__( 'https://your-link.com', 'welbim' ),
    159 				'show_external' => true,
    160 				'default'       => array(
    161 					'url'         => '',
    162 					'is_external' => false,
    163 					'nofollow'    => false,
    164 				),
    165 			)
    166 		);
    167 
    168 		$this->add_control(
    169 			'items',
    170 			array(
    171 				'label'   => esc_html__( 'Repeater List', 'welbim' ),
    172 				'type'    => Controls_Manager::REPEATER,
    173 				'fields'  => $repeater->get_controls(),
    174 				'default' => array(
    175 					array(
    176 						'list_title'   => esc_html__( 'Title #1', 'welbim' ),
    177 						'list_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'welbim' ),
    178 					),
    179 					array(
    180 						'list_title'   => esc_html__( 'Title #2', 'welbim' ),
    181 						'list_content' => esc_html__( 'Item content. Click the edit button to change this text.', 'welbim' ),
    182 					),
    183 				),
    184 			)
    185 		);
    186 
    187 		$this->end_controls_section();
    188 
    189 		$this->start_controls_section(
    190 			'typography_section',
    191 			array(
    192 				'label' => __( 'Typography Section', 'welbim' ),
    193 				'tab'   => Controls_Manager::TAB_STYLE,
    194 			)
    195 		);
    196 
    197 		$this->add_group_control(
    198 			Group_Control_Typography::get_type(),
    199 			array(
    200 				'name'     => 'subtitle_typography',
    201 				'label'    => __( 'Sub Title', 'welbim' ),
    202 				'selector' => '{{WRAPPER}} .sec-title .sub-title',
    203 			)
    204 		);
    205 
    206 		$this->add_group_control(
    207 			Group_Control_Typography::get_type(),
    208 			array(
    209 				'name'     => 'heading_typography',
    210 				'label'    => __( 'Heading', 'welbim' ),
    211 				'selector' => '{{WRAPPER}} .sec-title.light h2,{{WRAPPER}} .sec-title h2',
    212 
    213 			)
    214 		);
    215 
    216 		$this->add_group_control(
    217 			Group_Control_Typography::get_type(),
    218 			array(
    219 				'name'     => 'items_title',
    220 				'label'    => __( 'Items Title', 'welbim' ),
    221 				'selector' => '{{WRAPPER}} .service-block .content h3',
    222 
    223 			)
    224 		);
    225 
    226 		$this->add_group_control(
    227 			Group_Control_Typography::get_type(),
    228 			array(
    229 				'name'     => 'items_description',
    230 				'label'    => __( 'Items Description', 'welbim' ),
    231 				'selector' => '{{WRAPPER}} .service-block .content .text',
    232 
    233 			)
    234 		);
    235 
    236 		$this->end_controls_section();
    237 
    238 		$this->start_controls_section(
    239 			'color_section',
    240 			array(
    241 				'label' => __( 'Color Section', 'welbim' ),
    242 				'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
    243 			)
    244 		);
    245 
    246 		$this->start_controls_tabs( 'tabs_button_style' );
    247 		$this->start_controls_tab(
    248 			'tab_button_normal',
    249 			array(
    250 				'label' => __( 'Normal', 'welbim' ),
    251 			)
    252 		);
    253 
    254 			$this->add_control(
    255 				'subtitle_color',
    256 				array(
    257 					'label'     => __( 'Sub Title Color', 'welbim' ),
    258 					'separator' => 'before',
    259 					'type'      => \Elementor\Controls_Manager::COLOR,
    260 					'selectors' => array(
    261 						'{{WRAPPER}} .sec-title .sub-title' => 'color: {{VALUE}}',
    262 					),
    263 				)
    264 			);
    265 
    266 			$this->add_control(
    267 				'heading_color',
    268 				array(
    269 					'label'     => __( 'Heading Color', 'welbim' ),
    270 					'separator' => 'before',
    271 					'type'      => \Elementor\Controls_Manager::COLOR,
    272 					'selectors' => array(
    273 						'{{WRAPPER}} .sec-title.light h2' => 'color: {{VALUE}}',
    274 						'{{WRAPPER}} .sec-title h2'       => 'color: {{VALUE}}',
    275 					),
    276 				)
    277 			);
    278 
    279 			$this->add_control(
    280 				'button_text_color',
    281 				array(
    282 					'label'     => __( 'Button Text Color', 'welbim' ),
    283 					'separator' => 'before',
    284 					'type'      => \Elementor\Controls_Manager::COLOR,
    285 					'selectors' => array(
    286 						'{{WRAPPER}} .service-block .content .theme-btn' => 'color: {{VALUE}}',
    287 						'{{WRAPPER}} .service-block .content .theme-btn' => 'color: {{VALUE}}',
    288 					),
    289 				)
    290 			);
    291 
    292 			$this->end_controls_tab();
    293 
    294 			$this->start_controls_tab(
    295 				'tab_button_hover',
    296 				array(
    297 					'label' => __( 'Hover', 'welbim' ),
    298 				)
    299 			);
    300 
    301 			$this->add_control(
    302 				'button_bg_hover_color',
    303 				array(
    304 					'label'     => __( 'Button BG Hover Color', 'welbim' ),
    305 					'separator' => 'before',
    306 					'type'      => \Elementor\Controls_Manager::COLOR,
    307 					'selectors' => array(
    308 						'{{WRAPPER}} .service-block .content .btn-style-one:before' => 'background-color: {{VALUE}}',
    309 						// '{{WRAPPER}} .service-block .content .btn-style-one:before' => 'background-color: {{VALUE}}!important',
    310 					),
    311 				)
    312 			);
    313 
    314 		$this->end_controls_tab();
    315 		$this->end_controls_tabs();
    316 		$this->end_controls_section();
    317 
    318 	}
    319 	protected function render() {
    320 		$settings  = $this->get_settings_for_display();
    321 		$sub_title = $settings['sub_title'];
    322 		$heading   = $settings['heading'];
    323 		$layout    = $settings['layout_style'];
    324 
    325 		if ( $layout == '1' ) {
    326 			$background_img = ( $settings['background_img']['id'] != '' ) ? wp_get_attachment_image_url( $settings['background_img']['id'], 'full' ) : $settings['background_img']['url'];
    327 			?>
    328 			<section class="services-section pb-0">
    329 				<div class="sec-bg" style="background-image: url(<?php echo $background_img; ?>);"></div>
    330 				<div class="auto-container">
    331 					<div class="sec-title text-center light">
    332 						<div class="sub-title"><?php echo $sub_title; ?></div>
    333 						<h2><?php echo $heading; ?></h2>
    334 					</div>
    335 					<div class="row">
    336 						<?php
    337 						$i = 1;
    338 						foreach ( $settings['items'] as $item ) {
    339 							$item_title        = $item['item_title'];
    340 							$item_image        = ( $item['item_image']['id'] != '' ) ? wp_get_attachment_image( $item['item_image']['id'], 'full' ) : $item['item_image']['url'];
    341 							$item_image_alt    = get_post_meta( $item['item_image']['id'], '_wp_attachment_image_alt', true );
    342 							$item_discription  = $item['item_discription'];
    343 							$item_bottom_title = $item['item_bottom_title'];
    344 
    345 							$item_url          = $item['item_url']['url'];
    346 							$item_url_external = $item['item_url']['is_external'] ? 'target="_blank"' : '';
    347 							$item_url_nofollow = $item['item_url']['nofollow'] ? 'rel="nofollow"' : '';
    348 							?>
    349 							<div class="col-lg-4 col-md-6 service-block">
    350 								<div class="inner-box">
    351 									<div class="image">
    352 										<?php
    353 										if ( wp_http_validate_url( $item_image ) ) {
    354 											?>
    355 											<img src="<?php echo esc_url( $item_image ); ?>" alt="<?php esc_url( $item_image_alt ); ?>">
    356 											<?php
    357 										} else {
    358 											echo $item_image;
    359 										}
    360 										?>
    361 									</div>
    362 									<div class="content">
    363 										<h3><a href="<?php echo esc_url( $item_url ); ?>" <?php echo $item_url_external; ?> <?php echo $item_url_nofollow; ?>><?php echo $item_title; ?></a></h3>
    364 										<div class="text"><?php echo $item_discription; ?></div>
    365 										<div class="link">
    366 											<a href="<?php echo esc_url( $item_url ); ?>" <?php echo $item_url_external; ?> <?php echo $item_url_nofollow; ?> class="theme-btn btn-style-one"><span><?php echo $item_bottom_title; ?></span></a>
    367 										</div>
    368 									</div>
    369 								</div>
    370 							</div>
    371 							<?php
    372 							$i++;
    373 						}
    374 						?>
    375 					</div>
    376 				</div>
    377 			</section>
    378 			<?php
    379 		} elseif ( $layout == '2' ) {
    380 			?>
    381 			<section class="services-section style-two">
    382 				<div class="auto-container">
    383 					<div class="sec-title text-center">
    384 						<div class="sub-title"><?php echo $sub_title; ?></div>
    385 						<h2><?php echo $heading; ?></h2>
    386 					</div>
    387 					<div class="row">
    388 						<?php
    389 						$i = 1;
    390 						foreach ( $settings['items'] as $item ) {
    391 							$item_title     = $item['item_title'];
    392 							$item_image     = ( $item['item_image']['id'] != '' ) ? wp_get_attachment_image( $item['item_image']['id'], 'full' ) : $item['item_image']['url'];
    393 							$item_image_alt = get_post_meta( $item['item_image']['id'], '_wp_attachment_image_alt', true );
    394 
    395 							$item_discription  = $item['item_discription'];
    396 							$item_bottom_title = $item['item_bottom_title'];
    397 
    398 							$item_url          = $item['item_url']['url'];
    399 							$item_url_external = $item['item_url']['is_external'] ? 'target="_blank"' : '';
    400 							$item_url_nofollow = $item['item_url']['nofollow'] ? 'rel="nofollow"' : '';
    401 							?>
    402 							<div class="col-lg-4 col-md-6 service-block">
    403 								<div class="inner-box ">
    404 									<div class="image"><span class="border-shape"></span>
    405 										<?php
    406 										if ( wp_http_validate_url( $item_image ) ) {
    407 											?>
    408 											<img src="<?php echo esc_url( $item_image ); ?>" alt="<?php esc_url( $item_image_alt ); ?>">
    409 											<?php
    410 										} else {
    411 											echo $item_image;
    412 										}
    413 										?>
    414 									</div>
    415 									<div class="content">
    416 										<h3><a href="<?php echo esc_url( $item_url ); ?>" <?php echo $item_url_external; ?> <?php echo $item_url_nofollow; ?>><?php echo $item_title; ?></a></h3>
    417 										<div class="text"><?php echo $item_discription; ?></div>
    418 										<div class="link">
    419 											<a href="<?php echo esc_url( $item_url ); ?>" <?php echo $item_url_external; ?> <?php echo $item_url_nofollow; ?> class="theme-btn btn-style-one"><span><?php echo $item_bottom_title; ?></span></a>
    420 										</div>
    421 									</div>
    422 								</div>
    423 							</div>
    424 							<?php
    425 							$i++;
    426 						}
    427 						?>
    428 					</div>
    429 				</div>
    430 			</section>
    431 			<?php
    432 		} elseif ( $layout == '3' ) {
    433 			?>
    434 			<!-- Services Section -->
    435 			<section class="services-section style-two">
    436 				<div class="auto-container">
    437 					<div class="row">
    438 						<?php
    439 						$i = 1;
    440 						foreach ( $settings['items'] as $item ) {
    441 							$item_title     = $item['item_title'];
    442 							$item_image     = ( $item['item_image']['id'] != '' ) ? wp_get_attachment_image( $item['item_image']['id'], 'full' ) : $item['item_image']['url'];
    443 							$item_image_alt = get_post_meta( $item['item_image']['id'], '_wp_attachment_image_alt', true );
    444 
    445 							$item_discription  = $item['item_discription'];
    446 							$item_bottom_title = $item['item_bottom_title'];
    447 
    448 							$item_url          = $item['item_url']['url'];
    449 							$item_url_external = $item['item_url']['is_external'] ? 'target="_blank"' : '';
    450 							$item_url_nofollow = $item['item_url']['nofollow'] ? 'rel="nofollow"' : '';
    451 							?>
    452 							<div class="col-lg-4 col-md-6 service-block">
    453 								<div class="inner-box 
    454 								">
    455 									<div class="image"><span class="border-shape"></span>
    456 										<?php
    457 										if ( wp_http_validate_url( $item_image ) ) {
    458 											?>
    459 											<img src="<?php echo esc_url( $item_image ); ?>" alt="<?php esc_url( $item_image_alt ); ?>">
    460 											<?php
    461 										} else {
    462 											echo $item_image;
    463 										}
    464 										?>
    465 									</div>
    466 									<div class="content">
    467 										<h3><a href="<?php echo esc_url( $item_url ); ?>" <?php echo $item_url_external; ?> <?php echo $item_url_nofollow; ?>><?php echo $item_title; ?></a></h3>
    468 										<div class="text"><?php echo $item_discription; ?></div>
    469 										<div class="link">
    470 											<a href="<?php echo esc_url( $item_url ); ?>" <?php echo $item_url_external; ?> <?php echo $item_url_nofollow; ?> class="theme-btn btn-style-one"><span><?php echo $item_bottom_title; ?></span></a>
    471 										</div>
    472 									</div>
    473 								</div>
    474 							</div>
    475 							<?php
    476 							$i++;
    477 						}
    478 						?>
    479 					</div>
    480 				</div>
    481 			</section>
    482 			<?php
    483 		}
    484 	}
    485 }