| 1 |
<?php |
| 2 |
|
| 3 |
namespace PixelGallery\Modules\Orbit\Widgets; |
| 4 |
|
| 5 |
use PixelGallery\Base\Module_Base; |
| 6 |
use Elementor\Controls_Manager; |
| 7 |
use Elementor\Group_Control_Border; |
| 8 |
use Elementor\Group_Control_Typography; |
| 9 |
use Elementor\Group_Control_Background; |
| 10 |
use Elementor\Group_Control_Box_Shadow; |
| 11 |
use Elementor\Group_Control_Image_Size; |
| 12 |
use Elementor\Group_Control_Text_Shadow; |
| 13 |
use Elementor\Icons_Manager; |
| 14 |
use Elementor\Group_Control_Css_Filter; |
| 15 |
use Elementor\Group_Control_Text_Stroke; |
| 16 |
use Elementor\Repeater; |
| 17 |
use PixelGallery\Utils; |
| 18 |
use PixelGallery\Traits\Global_Widget_Controls; |
| 19 |
|
| 20 |
if (!defined('ABSPATH')) exit; // Exit if accessed directly |
| 21 |
|
| 22 |
class Orbit extends Module_Base |
| 23 |
{ |
| 24 |
|
| 25 |
use Global_Widget_Controls; |
| 26 |
|
| 27 |
public function get_name() |
| 28 |
{ |
| 29 |
return 'pg-orbit'; |
| 30 |
} |
| 31 |
|
| 32 |
public function get_title() |
| 33 |
{ |
| 34 |
return BDTPG . esc_html__('Orbit', 'pixel-gallery'); |
| 35 |
} |
| 36 |
|
| 37 |
public function get_icon() |
| 38 |
{ |
| 39 |
return 'pg-icon-orbit'; |
| 40 |
} |
| 41 |
|
| 42 |
public function get_categories() |
| 43 |
{ |
| 44 |
return ['pixel-gallery']; |
| 45 |
} |
| 46 |
|
| 47 |
public function get_keywords() |
| 48 |
{ |
| 49 |
return ['orbit', 'grid', 'gallery']; |
| 50 |
} |
| 51 |
|
| 52 |
public function get_style_depends() |
| 53 |
{ |
| 54 |
return ['pg-orbit']; |
| 55 |
} |
| 56 |
|
| 57 |
public function get_script_depends() |
| 58 |
{ |
| 59 |
if ( true === _is_pg_pro_activated() ) { |
| 60 |
return ['justified-gallery']; |
| 61 |
} else { |
| 62 |
return []; |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
public function get_custom_help_url() { |
| 67 |
return 'https://youtu.be/gleOj0ByQpc'; |
| 68 |
} |
| 69 |
|
| 70 |
public function has_widget_inner_wrapper(): bool { |
| 71 |
return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 72 |
} |
| 73 |
protected function is_dynamic_content(): bool { |
| 74 |
return false; |
| 75 |
} |
| 76 |
|
| 77 |
protected function register_controls() { |
| 78 |
|
| 79 |
$this->start_controls_section( |
| 80 |
'section_layout', |
| 81 |
[ |
| 82 |
'label' => __('Layout', 'pixel-gallery'), |
| 83 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 84 |
] |
| 85 |
); |
| 86 |
|
| 87 |
//Global |
| 88 |
$this->register_grid_controls('orbit'); |
| 89 |
$this->register_global_height_controls('orbit'); |
| 90 |
|
| 91 |
/** |
| 92 |
* Justified Gallery Controls |
| 93 |
*/ |
| 94 |
$this->register_justified_gallery_controls(); |
| 95 |
|
| 96 |
$this->add_responsive_control( |
| 97 |
'content_width', |
| 98 |
[ |
| 99 |
'label' => __('Content Width', 'pixel-gallery'), |
| 100 |
'type' => Controls_Manager::SLIDER, |
| 101 |
'range' => [ |
| 102 |
'px' => [ |
| 103 |
'min' => 200, |
| 104 |
'max' => 600, |
| 105 |
], |
| 106 |
], |
| 107 |
'selectors' => [ |
| 108 |
'{{WRAPPER}} .pg-orbit-content' => 'width: {{SIZE}}{{UNIT}};', |
| 109 |
], |
| 110 |
] |
| 111 |
); |
| 112 |
|
| 113 |
$this->register_title_tag_controls(); |
| 114 |
$this->register_show_meta_controls(); |
| 115 |
$this->register_alignment_controls('orbit'); |
| 116 |
$this->register_thumbnail_size_controls(); |
| 117 |
|
| 118 |
//Global Lightbox Controls |
| 119 |
$this->register_lightbox_controls(); |
| 120 |
$this->register_link_target_controls(); |
| 121 |
$this->end_controls_section(); |
| 122 |
|
| 123 |
//Repeater |
| 124 |
$this->start_controls_section( |
| 125 |
'section_item_content', |
| 126 |
[ |
| 127 |
'label' => __('Items', 'pixel-gallery'), |
| 128 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 129 |
] |
| 130 |
); |
| 131 |
$repeater = new Repeater(); |
| 132 |
$repeater->start_controls_tabs('tabs_item_content'); |
| 133 |
$repeater->start_controls_tab( |
| 134 |
'tab_item_content', |
| 135 |
[ |
| 136 |
'label' => esc_html__('Content', 'pixel-gallery'), |
| 137 |
] |
| 138 |
); |
| 139 |
$this->register_repeater_media_controls($repeater); |
| 140 |
$this->register_repeater_title_controls($repeater); |
| 141 |
$this->register_repeater_meta_controls($repeater); |
| 142 |
$this->register_repeater_readmore_controls($repeater); |
| 143 |
$this->register_repeater_custom_url_controls($repeater); |
| 144 |
$this->register_repeater_hidden_item_controls($repeater); |
| 145 |
|
| 146 |
$repeater->end_controls_tab(); |
| 147 |
$repeater->start_controls_tab( |
| 148 |
'tab_item_grid', |
| 149 |
[ |
| 150 |
'label' => esc_html__('Grid', 'pixel-gallery'), |
| 151 |
] |
| 152 |
); |
| 153 |
$this->register_repeater_grid_controls($repeater, 'orbit'); |
| 154 |
$this->register_repeater_item_height_controls($repeater, 'orbit'); |
| 155 |
$repeater->end_controls_tab(); |
| 156 |
$repeater->end_controls_tabs(); |
| 157 |
$this->register_repeater_items_controls($repeater); |
| 158 |
$this->end_controls_section(); |
| 159 |
|
| 160 |
//Style |
| 161 |
$this->start_controls_section( |
| 162 |
'pg_section_style', |
| 163 |
[ |
| 164 |
'label' => esc_html__('Items', 'pixel-gallery'), |
| 165 |
'tab' => Controls_Manager::TAB_STYLE, |
| 166 |
] |
| 167 |
); |
| 168 |
|
| 169 |
$this->start_controls_tabs('tabs_item_style'); |
| 170 |
|
| 171 |
$this->start_controls_tab( |
| 172 |
'tab_item_normal', |
| 173 |
[ |
| 174 |
'label' => esc_html__('Normal', 'pixel-gallery'), |
| 175 |
] |
| 176 |
); |
| 177 |
|
| 178 |
$this->add_group_control( |
| 179 |
Group_Control_Background::get_type(), |
| 180 |
[ |
| 181 |
'name' => 'item_background', |
| 182 |
'label' => esc_html__('Background', 'pixel-gallery'), |
| 183 |
'types' => ['classic', 'gradient'], |
| 184 |
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams, WordPress.DB.SlowDBQuery -- Intentional bounded query; exclusions/keys are plugin-controlled, not user request input. |
| 185 |
'exclude' => ['image'], |
| 186 |
'selector' => '{{WRAPPER}} .pg-orbit-item', |
| 187 |
] |
| 188 |
); |
| 189 |
|
| 190 |
$this->add_group_control( |
| 191 |
Group_Control_Border::get_type(), |
| 192 |
[ |
| 193 |
'name' => 'item_border', |
| 194 |
'selector' => '{{WRAPPER}} .pg-orbit-item', |
| 195 |
'separator' => 'before', |
| 196 |
] |
| 197 |
); |
| 198 |
|
| 199 |
$this->add_responsive_control( |
| 200 |
'item_border_radius', |
| 201 |
[ |
| 202 |
'label' => esc_html__('Border Radius', 'pixel-gallery'), |
| 203 |
'type' => Controls_Manager::DIMENSIONS, |
| 204 |
'size_units' => ['px', 'em', '%'], |
| 205 |
'selectors' => [ |
| 206 |
'{{WRAPPER}} .pg-orbit-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 207 |
], |
| 208 |
] |
| 209 |
); |
| 210 |
|
| 211 |
$this->add_responsive_control( |
| 212 |
'item_padding', |
| 213 |
[ |
| 214 |
'label' => esc_html__('Padding', 'pixel-gallery'), |
| 215 |
'type' => Controls_Manager::DIMENSIONS, |
| 216 |
'size_units' => ['px', 'em', '%'], |
| 217 |
'selectors' => [ |
| 218 |
'{{WRAPPER}} .pg-orbit-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 219 |
], |
| 220 |
] |
| 221 |
); |
| 222 |
|
| 223 |
|
| 224 |
$this->add_responsive_control( |
| 225 |
'item_margin', |
| 226 |
[ |
| 227 |
'label' => esc_html__('Margin', 'pixel-gallery'), |
| 228 |
'type' => Controls_Manager::DIMENSIONS, |
| 229 |
'size_units' => ['px', 'em', '%'], |
| 230 |
'selectors' => [ |
| 231 |
'{{WRAPPER}} .pg-orbit-meta' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 232 |
], |
| 233 |
] |
| 234 |
); |
| 235 |
|
| 236 |
$this->add_group_control( |
| 237 |
Group_Control_Box_Shadow::get_type(), |
| 238 |
[ |
| 239 |
'name' => 'item_box_shadow', |
| 240 |
'selector' => '{{WRAPPER}} .pg-orbit-item', |
| 241 |
] |
| 242 |
); |
| 243 |
|
| 244 |
$this->end_controls_tab(); |
| 245 |
|
| 246 |
$this->start_controls_tab( |
| 247 |
'tab_item_hover', |
| 248 |
[ |
| 249 |
'label' => esc_html__('Hover', 'pixel-gallery'), |
| 250 |
] |
| 251 |
); |
| 252 |
|
| 253 |
$this->add_control( |
| 254 |
'item_hover_border_color', |
| 255 |
[ |
| 256 |
'label' => esc_html__('Border Color', 'pixel-gallery'), |
| 257 |
'type' => Controls_Manager::COLOR, |
| 258 |
'condition' => [ |
| 259 |
'item_border_border!' => '', |
| 260 |
], |
| 261 |
'selectors' => [ |
| 262 |
'{{WRAPPER}} .pg-orbit-item:hover' => 'border-color: {{VALUE}};', |
| 263 |
], |
| 264 |
] |
| 265 |
); |
| 266 |
|
| 267 |
$this->add_group_control( |
| 268 |
Group_Control_Box_Shadow::get_type(), |
| 269 |
[ |
| 270 |
'name' => 'item_hover_box_shadow', |
| 271 |
'selector' => '{{WRAPPER}} .pg-orbit-item:hover', |
| 272 |
] |
| 273 |
); |
| 274 |
|
| 275 |
$this->end_controls_tab(); |
| 276 |
|
| 277 |
$this->end_controls_tabs(); |
| 278 |
|
| 279 |
$this->end_controls_section(); |
| 280 |
|
| 281 |
$this->start_controls_section( |
| 282 |
'section_style_content', |
| 283 |
[ |
| 284 |
'label' => esc_html__('Content', 'pixel-gallery'), |
| 285 |
'tab' => Controls_Manager::TAB_STYLE, |
| 286 |
] |
| 287 |
); |
| 288 |
|
| 289 |
$this->add_group_control( |
| 290 |
Group_Control_Background::get_type(), |
| 291 |
[ |
| 292 |
'name' => 'content_background', |
| 293 |
'label' => esc_html__('Background', 'pixel-gallery'), |
| 294 |
'types' => ['classic', 'gradient'], |
| 295 |
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams, WordPress.DB.SlowDBQuery -- Intentional bounded query; exclusions/keys are plugin-controlled, not user request input. |
| 296 |
'exclude' => ['image'], |
| 297 |
'selector' => '{{WRAPPER}} .pg-orbit-content', |
| 298 |
'fields_options' => [ |
| 299 |
'background' => [ |
| 300 |
'default' => 'classic', |
| 301 |
], |
| 302 |
'color' => [ |
| 303 |
'default' => 'rgba(13, 59, 84, 0.8)', |
| 304 |
], |
| 305 |
], |
| 306 |
] |
| 307 |
); |
| 308 |
|
| 309 |
$this->add_group_control( |
| 310 |
Group_Control_Border::get_type(), |
| 311 |
[ |
| 312 |
'name' => 'content_border', |
| 313 |
'selector' => '{{WRAPPER}} .pg-orbit-content', |
| 314 |
'separator' => 'before', |
| 315 |
] |
| 316 |
); |
| 317 |
|
| 318 |
$this->add_responsive_control( |
| 319 |
'content_border_radius', |
| 320 |
[ |
| 321 |
'label' => esc_html__('Border Radius', 'pixel-gallery'), |
| 322 |
'type' => Controls_Manager::DIMENSIONS, |
| 323 |
'size_units' => ['px', 'em', '%'], |
| 324 |
'selectors' => [ |
| 325 |
'{{WRAPPER}} .pg-orbit-content' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 326 |
], |
| 327 |
] |
| 328 |
); |
| 329 |
|
| 330 |
$this->add_responsive_control( |
| 331 |
'content_padding', |
| 332 |
[ |
| 333 |
'label' => esc_html__('Padding', 'pixel-gallery'), |
| 334 |
'type' => Controls_Manager::DIMENSIONS, |
| 335 |
'size_units' => ['px', 'em', '%'], |
| 336 |
'selectors' => [ |
| 337 |
'{{WRAPPER}} .pg-orbit-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 338 |
], |
| 339 |
] |
| 340 |
); |
| 341 |
|
| 342 |
|
| 343 |
$this->add_responsive_control( |
| 344 |
'content_margin', |
| 345 |
[ |
| 346 |
'label' => esc_html__('Margin', 'pixel-gallery'), |
| 347 |
'type' => Controls_Manager::DIMENSIONS, |
| 348 |
'size_units' => ['px', 'em', '%'], |
| 349 |
'selectors' => [ |
| 350 |
'{{WRAPPER}} .pg-orbit-content' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 351 |
], |
| 352 |
] |
| 353 |
); |
| 354 |
|
| 355 |
$this->add_group_control( |
| 356 |
Group_Control_Box_Shadow::get_type(), |
| 357 |
[ |
| 358 |
'name' => 'content_box_shadow', |
| 359 |
'selector' => '{{WRAPPER}} .pg-orbit-content', |
| 360 |
] |
| 361 |
); |
| 362 |
|
| 363 |
$this->end_controls_section(); |
| 364 |
|
| 365 |
//Global Title Controls |
| 366 |
$this->register_title_controls('orbit'); |
| 367 |
|
| 368 |
//Global meta Controls |
| 369 |
$this->register_meta_controls('orbit'); |
| 370 |
|
| 371 |
//Global Readmore Controls |
| 372 |
$this->register_readmore_controls('orbit'); |
| 373 |
|
| 374 |
//Clip Path Controls |
| 375 |
$this->register_clip_path_controls('orbit'); |
| 376 |
} |
| 377 |
|
| 378 |
public function render_items() { |
| 379 |
$settings = $this->get_settings_for_display(); |
| 380 |
$id = 'pg-orbit-' . $this->get_id(); |
| 381 |
$slide_index = 1; |
| 382 |
foreach ($settings['items'] as $index => $item) : |
| 383 |
|
| 384 |
$attr_name = 'grid-item' . $index; |
| 385 |
$this->add_render_attribute($attr_name, 'class', 'pg-orbit-item pg-item elementor-repeater-item-' . esc_attr($item['_id']), true); |
| 386 |
|
| 387 |
/** |
| 388 |
* Render Video Inject Here |
| 389 |
* Video Would be work on Media File & Lightbox |
| 390 |
* @since 1.0.0 |
| 391 |
*/ |
| 392 |
if ($item['media_type'] == 'video') { |
| 393 |
$this->render_video_frame($item, $attr_name, $id); |
| 394 |
} |
| 395 |
|
| 396 |
?> |
| 397 |
|
| 398 |
<div <?php $this->print_render_attribute_string($attr_name); ?>> |
| 399 |
<?php if ($item['item_hidden'] !== 'yes') : ?> |
| 400 |
<?php $this->render_image_wrap($item, 'orbit'); ?> |
| 401 |
<div class="pg-orbit-content"> |
| 402 |
<div class="pg-orbit-content-inner"> |
| 403 |
<?php $this->render_title($item, 'orbit'); ?> |
| 404 |
<?php $this->render_meta($item, 'orbit'); ?> |
| 405 |
<?php if ('none' !== $settings['link_to'] && $settings['link_target'] == 'only_button') : ?> |
| 406 |
<?php $this->render_readmore($item, $index, $id, 'orbit'); ?> |
| 407 |
<?php endif; ?> |
| 408 |
</div> |
| 409 |
</div> |
| 410 |
<?php if ('none' !== $settings['link_to'] && $settings['link_target'] == 'whole_item') : ?> |
| 411 |
<?php $this->render_lightbox_link_url($item, $index, $id); ?> |
| 412 |
<?php endif; ?> |
| 413 |
<?php endif; ?> |
| 414 |
</div> |
| 415 |
|
| 416 |
<?php |
| 417 |
$slide_index++; |
| 418 |
endforeach; |
| 419 |
} |
| 420 |
|
| 421 |
public function render() |
| 422 |
{ |
| 423 |
$settings = $this->get_settings_for_display(); |
| 424 |
$this->add_render_attribute('grid', 'class', 'pg-orbit-grid pg-grid'); |
| 425 |
|
| 426 |
/** |
| 427 |
* Render Justified Gallery Attributes |
| 428 |
*/ |
| 429 |
$this->render_justified_gallery_attributes('grid'); |
| 430 |
|
| 431 |
if (isset($settings['pg_in_animation_show']) && ($settings['pg_in_animation_show'] == 'yes')) { |
| 432 |
$this->add_render_attribute( 'grid', 'class', 'pg-in-animation' ); |
| 433 |
if (isset($settings['pg_in_animation_delay']['size'])) { |
| 434 |
$this->add_render_attribute( 'grid', 'data-in-animation-delay', $settings['pg_in_animation_delay']['size'] ); |
| 435 |
} |
| 436 |
} |
| 437 |
|
| 438 |
?> |
| 439 |
<div <?php $this->print_render_attribute_string('grid'); ?>> |
| 440 |
<?php $this->render_items(); ?> |
| 441 |
</div> |
| 442 |
<?php |
| 443 |
} |
| 444 |
/** |
| 445 |
* Elementor editor Backbone template. |
| 446 |
*/ |
| 447 |
protected function content_template() { |
| 448 |
?> |
| 449 |
<# |
| 450 |
var items = settings.items || []; |
| 451 |
var animDelay = ( settings.pg_in_animation_delay && settings.pg_in_animation_delay.size ) ? settings.pg_in_animation_delay.size : ''; |
| 452 |
var alwaysLb = false; |
| 453 |
var gridClass = 'pg-orbit-grid pg-grid'; |
| 454 |
if ( settings.pg_in_animation_show === 'yes' ) { |
| 455 |
gridClass += ' pg-in-animation'; |
| 456 |
} |
| 457 |
#> |
| 458 |
<div class="{{{ gridClass }}}" |
| 459 |
<# if ( settings.pg_in_animation_show === 'yes' && animDelay !== '' ) { #> data-in-animation-delay="{{ animDelay }}"<# } #> |
| 460 |
> |
| 461 |
<# _.each( items, function( item, index ) { |
| 462 |
var itemClass = 'pg-orbit-item pg-item elementor-repeater-item-' + item._id; |
| 463 |
#> |
| 464 |
<div class="{{{ itemClass }}}"> |
| 465 |
<# if ( item.item_hidden !== 'yes' ) { #> |
| 466 |
<div class="pg-orbit-image-wrap bdt-pg-img-mask"> |
| 467 |
<# if ( item.media_type === 'video' ) { #> |
| 468 |
<# if ( item.poster && item.poster.url ) { #> |
| 469 |
<img src="{{ item.poster.url }}" alt="{{ item.title }}" class="pg-orbit-img"> |
| 470 |
<# } #> |
| 471 |
<# } else if ( item.image && item.image.url ) { #> |
| 472 |
<img src="{{ item.image.url }}" alt="{{ item.title }}" class="pg-orbit-img"> |
| 473 |
<# } #> |
| 474 |
<# if ( settings.link_to === 'file' && item.media_type === 'video' ) { #> |
| 475 |
<span class="pg-video-icon-wrap"> |
| 476 |
<i class="pg-icon-play-circle pg-eicon-play"></i> |
| 477 |
</span> |
| 478 |
<# } #> |
| 479 |
</div> |
| 480 |
<div class="pg-orbit-content"> |
| 481 |
<div class="pg-orbit-content-inner"> |
| 482 |
<# if ( settings.show_title === 'yes' && item.title ) { #> |
| 483 |
<# var ttag = settings.title_tag || 'h3'; #> |
| 484 |
<{{{ ttag }}} class="pg-orbit-title">{{{ item.title }}}</{{{ ttag }}}> |
| 485 |
<# } #> |
| 486 |
<# if ( settings.show_meta === 'yes' && item.meta ) { #> |
| 487 |
<div class="pg-orbit-meta">{{{ item.meta }}}</div> |
| 488 |
<# } #> |
| 489 |
<# if ( settings.link_to !== 'none' && ( settings.link_target || 'whole_item' ) === 'only_button' && item.readmore_text ) { #> |
| 490 |
<div class="pg-orbit-readmore"> |
| 491 |
<?php $this->print_content_template_item_link_prepare( 'orbit' ); ?> |
| 492 |
<?php $this->print_content_template_item_link_wrap_open(); ?> |
| 493 |
<?php $this->print_content_template_item_link_a_open(); ?> |
| 494 |
{{{ item.readmore_text }}} |
| 495 |
<?php $this->print_content_template_item_link_a_close(); ?> |
| 496 |
<?php $this->print_content_template_item_link_wrap_close(); ?> |
| 497 |
</div> |
| 498 |
<# } #> |
| 499 |
</div> |
| 500 |
</div> |
| 501 |
<# if ( alwaysLb || ( settings.link_to !== 'none' && ( settings.link_target || 'whole_item' ) === 'whole_item' ) ) { #> |
| 502 |
<?php $this->print_content_template_lightbox_overlay( 'orbit' ); ?> |
| 503 |
<# } #> |
| 504 |
<# } #> |
| 505 |
</div> |
| 506 |
<# } ); #> |
| 507 |
</div> |
| 508 |
<?php |
| 509 |
} |
| 510 |
|
| 511 |
} |
| 512 |
|