balmet.com

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

Welbim_FAQ.php (9117B)


      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 Welbim_FAQ extends Widget_Base
     13 {
     14 
     15 	public function get_name()
     16 	{
     17 		return 'welbim_faq';
     18 	}
     19 
     20 	public function get_title()
     21 	{
     22 		return esc_html__('Welbim FAQ', '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 		$this->start_controls_section(
     38 			'general',
     39 			[
     40 				'label' => esc_html__('General', 'welbim'),
     41 			]
     42 		);
     43 
     44 		$this->add_control(
     45 			'layout_style',
     46 			[
     47 				'label'   => esc_html__('Layout Style', 'welbim'),
     48 				'type'    => Controls_Manager::SELECT,
     49 				'options' => [
     50 					'style_1' => esc_html__('Style One', 'welbim'),
     51 					'style_2' => esc_html__('Style Two', 'welbim'),
     52 				],
     53 				'default' => 'style_1',
     54 			]
     55 		);
     56 
     57 		$this->add_control(
     58 			'image_one',
     59 			[
     60 				'label'   => esc_html__('Image One', 'welbim'),
     61 				'type'    => Controls_Manager::MEDIA,
     62 				'default' => [
     63 					'url' => Utils::get_placeholder_image_src(),
     64 				],
     65 				'conditions' => [
     66 					'relation' => 'or',
     67 					'terms' => [
     68 						[
     69 							'name' => 'layout_style',
     70 							'operator' => '==',
     71 							'value' => 'style_1'
     72 						],
     73 
     74 					]
     75 				]
     76 			]
     77 		);
     78 
     79 		$this->add_control(
     80 			'image_two',
     81 			[
     82 				'label'   => esc_html__('Image Two', 'welbim'),
     83 				'type'    => Controls_Manager::MEDIA,
     84 				'default' => [
     85 					'url' => Utils::get_placeholder_image_src(),
     86 				],
     87 				'conditions' => [
     88 					'relation' => 'or',
     89 					'terms' => [
     90 						[
     91 							'name' => 'layout_style',
     92 							'operator' => '==',
     93 							'value' => 'style_1'
     94 						],
     95 
     96 					]
     97 				]
     98 			]
     99 
    100 		);
    101 
    102 		$this->add_control(
    103 			'sub_title',
    104 			[
    105 				'label'   => esc_html__('Sub Title', 'welbim'),
    106 				'type'    => Controls_Manager::TEXT,
    107 				'default' => __('Our FAQs', 'welbim'),
    108 				'conditions' => [
    109 					'relation' => 'or',
    110 					'terms' => [
    111 						[
    112 							'name' => 'layout_style',
    113 							'operator' => '==',
    114 							'value' => 'style_1'
    115 						],
    116 
    117 					]
    118 				]
    119 			]
    120 		);
    121 
    122 		$this->add_control(
    123 			'title',
    124 			[
    125 				'label'   => esc_html__('Title', 'welbim'),
    126 				'type'    => Controls_Manager::TEXT,
    127 				'default' => __('faq for inquiry', 'welbim'),
    128 				'conditions' => [
    129 					'relation' => 'or',
    130 					'terms' => [
    131 						[
    132 							'name' => 'layout_style',
    133 							'operator' => '==',
    134 							'value' => 'style_1'
    135 						],
    136 
    137 					]
    138 				]
    139 			]
    140 		);
    141 
    142 		$this->end_controls_section();
    143 
    144 		$this->start_controls_section(
    145 			'item',
    146 			[
    147 				'label' => esc_html__('Item', 'welbim'),
    148 			]
    149 		);
    150 
    151 		$repeater = new Repeater();
    152 
    153 		$repeater->add_control(
    154 			'item_title',
    155 			[
    156 				'label'   => esc_html__('Title', 'welbim'),
    157 				'type'    => Controls_Manager::TEXT,
    158 				'default' => __('Providing full range of high metal services solution', 'welbim'),
    159 			]
    160 		);
    161 
    162 		$repeater->add_control(
    163 			'item_description',
    164 			[
    165 				'label'       => esc_html__('Description', 'welbim'),
    166 				'type'        => Controls_Manager::TEXTAREA,
    167 				'default'     => __('There are many variations of passages of available but majority have alteration in some by inject humour or random words.', 'welbim'),
    168 				'placeholder' => esc_html__('Type your description here', 'welbim'),
    169 			]
    170 		);
    171 
    172 		$this->add_control(
    173 			'items',
    174 			[
    175 				'label'   => esc_html__('Repeater List', 'welbim'),
    176 				'type'    => Controls_Manager::REPEATER,
    177 				'fields'  => $repeater->get_controls(),
    178 				'default' => [
    179 					[
    180 						'list_title'   => esc_html__('Title #1', 'welbim'),
    181 						'list_content' => esc_html__('Item content. Click the edit button to change this text.', 'welbim'),
    182 					],
    183 					[
    184 						'list_title'   => esc_html__('Title #2', 'welbim'),
    185 						'list_content' => esc_html__('Item content. Click the edit button to change this text.', 'welbim'),
    186 					],
    187 				],
    188 			]
    189 		);
    190 
    191 		$this->end_controls_section();
    192 
    193 		//Typography Section
    194 		$this->start_controls_section(
    195 			'typography_section',
    196 			array(
    197 				'label' => __('Typography Section', 'welbim'),
    198 				'tab'   => Controls_Manager::TAB_STYLE,
    199 			)
    200 		);
    201 
    202 		$this->add_group_control(
    203 			Group_Control_Typography::get_type(),
    204 			array(
    205 				'name'     => 'title_typography',
    206 				'label'    => __('Title', 'welbim'),
    207 				'selector' => '{{WRAPPER}} .sec-title h2',
    208 
    209 			)
    210 		);
    211 
    212 		$this->add_group_control(
    213 			Group_Control_Typography::get_type(),
    214 			array(
    215 				'name'     => 'sub_title_typography',
    216 				'label'    => __('Sub-Title', 'welbim'),
    217 				'selector' => '{{WRAPPER}} .sec-title .sub-title',
    218 
    219 			)
    220 		);
    221 
    222 		$this->end_controls_section();
    223 
    224 		//Color Section
    225 		$this->start_controls_section(
    226 			'color_section',
    227 			array(
    228 				'label' => __('Color Section', 'welbim'),
    229 				'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
    230 			)
    231 		);
    232 
    233 		$this->add_control(
    234 			'title_color',
    235 			array(
    236 				'label'     => __('Title Color', 'welbim'),
    237 				'separator' => 'before',
    238 				'type'      => \Elementor\Controls_Manager::COLOR,
    239 				'selectors' => array(
    240 					'{{WRAPPER}} .sec-title h2' => 'color: {{VALUE}}',
    241 				),
    242 			)
    243 		);
    244 
    245 		$this->add_control(
    246 			'sub_title_color',
    247 			array(
    248 				'label'     => __('Sub-Title Color', 'welbim'),
    249 				'separator' => 'before',
    250 				'type'      => \Elementor\Controls_Manager::COLOR,
    251 				'selectors' => array(
    252 					'{{WRAPPER}} .sec-title .sub-title' => 'color: {{VALUE}}',
    253 				),
    254 			)
    255 		);
    256 
    257 
    258 		$this->end_controls_section();
    259 	}
    260 	protected function render()
    261 	{
    262 		$settings      = $this->get_settings_for_display();
    263 		$layout_style  = $settings["layout_style"];
    264 
    265 		if ($layout_style == 'style_1') {
    266 			$image_one     = ($settings["image_one"]["id"] != "") ? wp_get_attachment_image($settings["image_one"]["id"], "full") : $settings["image_one"]["url"];
    267 			$image_one_alt = get_post_meta($settings["image_one"]["id"], "_wp_attachment_image_alt", true);
    268 			$image_two     = ($settings["image_two"]["id"] != "") ? wp_get_attachment_image_url($settings["image_two"]["id"], "full") : $settings["image_two"]["url"];
    269 			$image_two_alt = get_post_meta($settings["image_two"]["id"], "_wp_attachment_image_alt", true);
    270 			$sub_title     = $settings["sub_title"];
    271 			$title         = $settings["title"];
    272 ?>
    273 			<section class="faq-section">
    274 				<div class="side-image">
    275 					<?php
    276 					if (wp_http_validate_url($image_one)) {
    277 					?>
    278 						<img src="<?php echo esc_url($image_one); ?>" alt="<?php esc_url($image_one_alt); ?>">
    279 					<?php
    280 					} else {
    281 						echo $image_one;
    282 					}
    283 					?>
    284 				</div>
    285 				<div class="auto-container">
    286 					<div class="row">
    287 						<div class="col-lg-6 column" style="background-image: url(<?php echo $image_two ?>);">
    288 							<div class="image">
    289 								<?php
    290 								if (wp_http_validate_url($image_two)) {
    291 								?>
    292 									<img src="<?php echo esc_url($image_two); ?>" alt="<?php esc_url($image_two_alt); ?>">
    293 								<?php
    294 								} else {
    295 									echo $image_two;
    296 								}
    297 								?>
    298 							</div>
    299 						</div>
    300 						<div class="col-lg-6">
    301 							<div class="inner-container">
    302 								<div class="sec-title">
    303 									<div class="sub-title"><?php echo $sub_title; ?></div>
    304 									<h2><?php echo $title; ?></h2>
    305 								</div>
    306 								<ul class="accordion-box">
    307 									<?php
    308 									$i = 1;
    309 									foreach ($settings["items"] as $item) {
    310 										$item_title       = $item["item_title"];
    311 										$item_description = $item["item_description"];
    312 										$active           = '';
    313 										$current          = '';
    314 										if ($i == 2) {
    315 											$active  = 'active';
    316 											$current = 'current';
    317 										}
    318 									?>
    319 										<li class="accordion block">
    320 											<div class="acc-btn <?php echo $active; ?>">
    321 												<div class="icon-outer"><span class="fas fa-plus"></span></div><?php echo $item_title; ?>
    322 											</div>
    323 											<div class="acc-content <?php echo $current; ?>">
    324 												<div class="content">
    325 													<div class="text"><?php echo $item_description; ?>
    326 													</div>
    327 												</div>
    328 											</div>
    329 										</li>
    330 									<?php
    331 										$i++;
    332 									}
    333 									?>
    334 								</ul>
    335 							</div>
    336 						</div>
    337 					</div>
    338 				</div>
    339 			</section>
    340 		<?php
    341 		} elseif ($layout_style == 'style_2') {
    342 		?>
    343 			<ul class="accordion-box <?php echo esc_attr($layout_style); ?>">
    344 				<!--Accordion Block-->
    345 				<?php
    346 				$i = 1;
    347 				foreach ($settings["items"] as $item) {
    348 					$item_title       = $item["item_title"];
    349 					$item_description = $item["item_description"];
    350 					$active           = '';
    351 					$current          = '';
    352 					if ($i == 2) {
    353 						$active  = 'active';
    354 						$current = 'current';
    355 					}
    356 				?>
    357 					<li class="accordion block">
    358 						<div class="acc-btn <?php echo $active; ?>">
    359 							<div class="icon-outer"><span class="fas fa-plus"></span></div><?php echo $item_title; ?>
    360 						</div>
    361 						<div class="acc-content <?php echo $current; ?>">
    362 							<div class="content">
    363 								<div class="text"><?php echo $item_description; ?>
    364 								</div>
    365 							</div>
    366 						</div>
    367 					</li>
    368 					<!-- End Block -->
    369 				<?php
    370 					$i++;
    371 				}
    372 				?>
    373 			</ul>
    374 <?php
    375 		}
    376 	}
    377 }