| 1 |
<?php |
| 2 |
|
| 3 |
namespace PixelGallery\Modules\Aware\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 Aware extends Module_Base { |
| 23 |
|
| 24 |
use Global_Widget_Controls; |
| 25 |
|
| 26 |
public function get_name() { |
| 27 |
return 'pg-aware'; |
| 28 |
} |
| 29 |
|
| 30 |
public function get_title() { |
| 31 |
return BDTPG . esc_html__('Aware', 'pixel-gallery'); |
| 32 |
} |
| 33 |
|
| 34 |
public function get_icon() { |
| 35 |
return 'pg-icon-aware'; |
| 36 |
} |
| 37 |
|
| 38 |
public function get_categories() { |
| 39 |
return ['pixel-gallery']; |
| 40 |
} |
| 41 |
|
| 42 |
public function get_keywords() { |
| 43 |
return ['aware', 'grid', 'gallery']; |
| 44 |
} |
| 45 |
|
| 46 |
public function get_style_depends() { |
| 47 |
return ['pg-aware']; |
| 48 |
} |
| 49 |
|
| 50 |
public function get_custom_help_url() { |
| 51 |
return 'https://youtu.be/r6XFiNTDFOA'; |
| 52 |
} |
| 53 |
|
| 54 |
public function has_widget_inner_wrapper(): bool { |
| 55 |
return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 56 |
} |
| 57 |
protected function is_dynamic_content(): bool { |
| 58 |
return false; |
| 59 |
} |
| 60 |
|
| 61 |
protected function register_controls() { |
| 62 |
|
| 63 |
$this->start_controls_section( |
| 64 |
'section_layout', |
| 65 |
[ |
| 66 |
'label' => __('Layout', 'pixel-gallery'), |
| 67 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 68 |
] |
| 69 |
); |
| 70 |
|
| 71 |
$this->add_control( |
| 72 |
'layout_style', |
| 73 |
[ |
| 74 |
'label' => __('Layout Style', 'pixel-gallery'), |
| 75 |
'type' => Controls_Manager::SELECT, |
| 76 |
'default' => '1', |
| 77 |
'options' => [ |
| 78 |
'1' => esc_html__('01', 'pixel-gallery'), |
| 79 |
'2' => esc_html__('02', 'pixel-gallery'), |
| 80 |
'3' => esc_html__('03', 'pixel-gallery'), |
| 81 |
'4' => esc_html__('04', 'pixel-gallery'), |
| 82 |
'5' => esc_html__('05', 'pixel-gallery'), |
| 83 |
], |
| 84 |
] |
| 85 |
); |
| 86 |
|
| 87 |
//Global |
| 88 |
/** |
| 89 |
* Masonry Columns |
| 90 |
*/ |
| 91 |
$this->add_responsive_control( |
| 92 |
'columns', |
| 93 |
[ |
| 94 |
'label' => __('Columns', 'pixel-gallery'), |
| 95 |
'type' => Controls_Manager::SELECT, |
| 96 |
'default' => '3', |
| 97 |
'tablet_default' => '2', |
| 98 |
'mobile_default' => '1', |
| 99 |
'options' => [ |
| 100 |
'1' => esc_html__('1', 'pixel-gallery'), |
| 101 |
'2' => esc_html__('2', 'pixel-gallery'), |
| 102 |
'3' => esc_html__('3', 'pixel-gallery'), |
| 103 |
'4' => esc_html__('4', 'pixel-gallery'), |
| 104 |
'5' => esc_html__('5', 'pixel-gallery'), |
| 105 |
'6' => esc_html__('6', 'pixel-gallery'), |
| 106 |
], |
| 107 |
'selectors' => [ |
| 108 |
'{{WRAPPER}} .pg-aware-grid' => 'columns: {{SIZE}}; display: block;' |
| 109 |
], |
| 110 |
'condition' => [ |
| 111 |
'masonry' => 'yes' |
| 112 |
], |
| 113 |
] |
| 114 |
); |
| 115 |
|
| 116 |
$this->add_control( |
| 117 |
'grid_template_columns', |
| 118 |
[ |
| 119 |
'label' => esc_html__('Grid Template Columns', 'pixel-gallery'), |
| 120 |
'description' => esc_html__('Note: If you Changed Grid Template Columns then you must set Column Span and Row Span from Repeater Items.', 'pixel-gallery'), |
| 121 |
'type' => Controls_Manager::NUMBER, |
| 122 |
'min' => 1, |
| 123 |
'max' => 12, |
| 124 |
'default' => 12, |
| 125 |
'selectors' => [ |
| 126 |
'{{WRAPPER}} .pg-aware-grid' => 'grid-template-columns: repeat({{VALUE}}, 1fr); grid-auto-flow: dense;', |
| 127 |
], |
| 128 |
'condition' => [ |
| 129 |
'masonry' => '' |
| 130 |
], |
| 131 |
] |
| 132 |
); |
| 133 |
|
| 134 |
$this->add_responsive_control( |
| 135 |
'row_gap', |
| 136 |
[ |
| 137 |
'label' => esc_html__('Row Gap', 'pixel-gallery'), |
| 138 |
'type' => Controls_Manager::SLIDER, |
| 139 |
'default' => [ |
| 140 |
'size' => 40, |
| 141 |
], |
| 142 |
'selectors' => [ |
| 143 |
'{{WRAPPER}} .pg-aware-grid' => 'grid-row-gap: {{SIZE}}{{UNIT}};', |
| 144 |
'(mobile){{WRAPPER}}.pg-masonry--yes .pg-aware-grid' => 'margin-bottom: -{{SIZE}}{{UNIT}};', |
| 145 |
'{{WRAPPER}}.pg-masonry--yes .pg-aware-grid .pg-aware-item' => 'margin-bottom: {{SIZE}}{{UNIT}};', |
| 146 |
], |
| 147 |
] |
| 148 |
); |
| 149 |
|
| 150 |
$this->add_responsive_control( |
| 151 |
'column_gap', |
| 152 |
[ |
| 153 |
'label' => esc_html__('Column Gap', 'pixel-gallery'), |
| 154 |
'type' => Controls_Manager::SLIDER, |
| 155 |
'default' => [ |
| 156 |
'size' => 40, |
| 157 |
], |
| 158 |
'selectors' => [ |
| 159 |
'{{WRAPPER}} .pg-aware-grid' => 'grid-column-gap: {{SIZE}}{{UNIT}};', |
| 160 |
'{{WRAPPER}}.pg-masonry--yes .pg-aware-grid' => 'gap: {{SIZE}}{{UNIT}};', |
| 161 |
], |
| 162 |
] |
| 163 |
); |
| 164 |
$this->register_global_height_controls('aware'); |
| 165 |
$this->register_title_tag_controls(); |
| 166 |
$this->register_thumbnail_size_controls(); |
| 167 |
|
| 168 |
//Global Lightbox Controls |
| 169 |
$this->register_lightbox_controls(); |
| 170 |
|
| 171 |
$this->end_controls_section(); |
| 172 |
|
| 173 |
$this->start_controls_section( |
| 174 |
'section_item_content', |
| 175 |
[ |
| 176 |
'label' => __('Items', 'pixel-gallery'), |
| 177 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 178 |
] |
| 179 |
); |
| 180 |
|
| 181 |
$repeater = new Repeater(); |
| 182 |
$repeater->start_controls_tabs('tabs_item_content'); |
| 183 |
$repeater->start_controls_tab( |
| 184 |
'tab_item_content', |
| 185 |
[ |
| 186 |
'label' => esc_html__('Content', 'pixel-gallery'), |
| 187 |
] |
| 188 |
); |
| 189 |
$this->register_repeater_media_controls($repeater); |
| 190 |
$this->register_repeater_title_controls($repeater); |
| 191 |
$this->register_repeater_custom_url_controls($repeater); |
| 192 |
$this->register_repeater_hidden_item_controls($repeater); |
| 193 |
|
| 194 |
$repeater->end_controls_tab(); |
| 195 |
$repeater->start_controls_tab( |
| 196 |
'tab_item_grid', |
| 197 |
[ |
| 198 |
'label' => esc_html__('Grid', 'pixel-gallery'), |
| 199 |
] |
| 200 |
); |
| 201 |
$this->register_repeater_grid_controls($repeater, 'aware'); |
| 202 |
$this->register_repeater_item_height_controls($repeater, 'aware'); |
| 203 |
$repeater->end_controls_tab(); |
| 204 |
$repeater->end_controls_tabs(); |
| 205 |
$this->register_repeater_items_controls($repeater); |
| 206 |
$this->end_controls_section(); |
| 207 |
|
| 208 |
//Style |
| 209 |
$this->start_controls_section( |
| 210 |
'pg_section_style', |
| 211 |
[ |
| 212 |
'label' => esc_html__('Items', 'pixel-gallery'), |
| 213 |
'tab' => Controls_Manager::TAB_STYLE, |
| 214 |
] |
| 215 |
); |
| 216 |
|
| 217 |
$this->start_controls_tabs('tabs_item_style'); |
| 218 |
|
| 219 |
$this->start_controls_tab( |
| 220 |
'tab_item_normal', |
| 221 |
[ |
| 222 |
'label' => esc_html__('Normal', 'pixel-gallery'), |
| 223 |
] |
| 224 |
); |
| 225 |
|
| 226 |
$this->add_group_control( |
| 227 |
Group_Control_Background::get_type(), |
| 228 |
[ |
| 229 |
'name' => 'item_background', |
| 230 |
'selector' => '{{WRAPPER}} .pg-aware-item', |
| 231 |
] |
| 232 |
); |
| 233 |
|
| 234 |
$this->add_group_control( |
| 235 |
Group_Control_Border::get_type(), |
| 236 |
[ |
| 237 |
'name' => 'item_border', |
| 238 |
'selector' => '{{WRAPPER}} .pg-aware-item', |
| 239 |
'separator' => 'before', |
| 240 |
] |
| 241 |
); |
| 242 |
|
| 243 |
$this->add_responsive_control( |
| 244 |
'item_border_radius', |
| 245 |
[ |
| 246 |
'label' => esc_html__('Border Radius', 'pixel-gallery'), |
| 247 |
'type' => Controls_Manager::DIMENSIONS, |
| 248 |
'size_units' => ['px', 'em', '%'], |
| 249 |
'selectors' => [ |
| 250 |
'{{WRAPPER}} .pg-aware-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 251 |
], |
| 252 |
] |
| 253 |
); |
| 254 |
|
| 255 |
$this->add_responsive_control( |
| 256 |
'item_padding', |
| 257 |
[ |
| 258 |
'label' => esc_html__('Padding', 'pixel-gallery'), |
| 259 |
'type' => Controls_Manager::DIMENSIONS, |
| 260 |
'size_units' => ['px', 'em', '%'], |
| 261 |
'selectors' => [ |
| 262 |
'{{WRAPPER}} .pg-aware-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 263 |
], |
| 264 |
] |
| 265 |
); |
| 266 |
|
| 267 |
|
| 268 |
$this->add_responsive_control( |
| 269 |
'item_margin', |
| 270 |
[ |
| 271 |
'label' => esc_html__('Margin', 'pixel-gallery'), |
| 272 |
'type' => Controls_Manager::DIMENSIONS, |
| 273 |
'size_units' => ['px', 'em', '%'], |
| 274 |
'selectors' => [ |
| 275 |
'{{WRAPPER}} .pg-aware-item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 276 |
], |
| 277 |
] |
| 278 |
); |
| 279 |
|
| 280 |
// $this->add_group_control( |
| 281 |
// Group_Control_Box_Shadow::get_type(), |
| 282 |
// [ |
| 283 |
// 'name' => 'item_box_shadow', |
| 284 |
// 'selector' => '{{WRAPPER}} .pg-aware-item', |
| 285 |
// ] |
| 286 |
// ); |
| 287 |
|
| 288 |
$this->add_control( |
| 289 |
'item_accent_shadow_color', |
| 290 |
[ |
| 291 |
'label' => __('Accent Color', 'pixel-gallery'), |
| 292 |
'type' => Controls_Manager::COLOR, |
| 293 |
// 'default' => '#ffeb37', |
| 294 |
'selectors' => [ |
| 295 |
'{{WRAPPER}}' => '--pg-accent: {{VALUE}}', |
| 296 |
], |
| 297 |
'separator' => 'before' |
| 298 |
] |
| 299 |
); |
| 300 |
|
| 301 |
|
| 302 |
$this->add_control( |
| 303 |
'item_primary_shadow_color', |
| 304 |
[ |
| 305 |
'label' => __('Primary Color', 'pixel-gallery'), |
| 306 |
'type' => Controls_Manager::COLOR, |
| 307 |
// 'default' => '#d1fefc', |
| 308 |
'selectors' => [ |
| 309 |
'{{WRAPPER}}' => '--pg-primary: {{VALUE}}', |
| 310 |
], |
| 311 |
|
| 312 |
] |
| 313 |
); |
| 314 |
|
| 315 |
$this->add_control( |
| 316 |
'item_secondary_shadow_color', |
| 317 |
[ |
| 318 |
'label' => __('Secondary Color', 'pixel-gallery'), |
| 319 |
'type' => Controls_Manager::COLOR, |
| 320 |
// 'default' => '#ffe1e1', |
| 321 |
'selectors' => [ |
| 322 |
'{{WRAPPER}}' => '--pg-secondary: {{VALUE}}', |
| 323 |
], |
| 324 |
] |
| 325 |
); |
| 326 |
|
| 327 |
|
| 328 |
$this->end_controls_tab(); |
| 329 |
|
| 330 |
$this->start_controls_tab( |
| 331 |
'tab_item_hover', |
| 332 |
[ |
| 333 |
'label' => esc_html__('Hover', 'pixel-gallery'), |
| 334 |
] |
| 335 |
); |
| 336 |
|
| 337 |
$this->add_group_control( |
| 338 |
Group_Control_Background::get_type(), |
| 339 |
[ |
| 340 |
'name' => 'item_hover_background', |
| 341 |
'selector' => '{{WRAPPER}} .pg-aware-item:hover', |
| 342 |
] |
| 343 |
); |
| 344 |
|
| 345 |
$this->add_control( |
| 346 |
'item_hover_border_color', |
| 347 |
[ |
| 348 |
'label' => esc_html__('Border Color', 'pixel-gallery'), |
| 349 |
'type' => Controls_Manager::COLOR, |
| 350 |
'condition' => [ |
| 351 |
'item_border_border!' => '', |
| 352 |
], |
| 353 |
'selectors' => [ |
| 354 |
'{{WRAPPER}} .pg-aware-item:hover' => 'border-color: {{VALUE}};', |
| 355 |
], |
| 356 |
] |
| 357 |
); |
| 358 |
|
| 359 |
$this->end_controls_tab(); |
| 360 |
|
| 361 |
$this->end_controls_tabs(); |
| 362 |
|
| 363 |
$this->end_controls_section(); |
| 364 |
|
| 365 |
//Global Title Controls |
| 366 |
$this->register_title_controls('aware'); |
| 367 |
|
| 368 |
} |
| 369 |
|
| 370 |
public function render_items() { |
| 371 |
$settings = $this->get_settings_for_display(); |
| 372 |
$id = 'pg-aware-' . $this->get_id(); |
| 373 |
$slide_index = 1; |
| 374 |
foreach ($settings['items'] as $index => $item) : |
| 375 |
|
| 376 |
$attr_name = 'grid-item' . $index; |
| 377 |
$this->add_render_attribute($attr_name, 'class', 'pg-aware-item pg-item elementor-repeater-item-' . esc_attr($item['_id']), true); |
| 378 |
|
| 379 |
/** |
| 380 |
* Render Video Inject Here |
| 381 |
* Video Would be work on Media File & Lightbox |
| 382 |
* @since 1.0.0 |
| 383 |
*/ |
| 384 |
if ($item['media_type'] == 'video') { |
| 385 |
$this->render_video_frame($item, $attr_name, $id); |
| 386 |
} |
| 387 |
|
| 388 |
?> |
| 389 |
|
| 390 |
<div <?php $this->print_render_attribute_string($attr_name); ?>> |
| 391 |
<?php if ($item['item_hidden'] !== 'yes' ) : ?> |
| 392 |
<?php $this->render_image_wrap($item, 'aware'); ?> |
| 393 |
<?php $this->render_title($item, 'aware'); ?> |
| 394 |
<?php $this->render_lightbox_link_url($item, $index, $id); ?> |
| 395 |
<?php endif; ?> |
| 396 |
</div> |
| 397 |
|
| 398 |
<?php |
| 399 |
$slide_index++; |
| 400 |
endforeach; |
| 401 |
} |
| 402 |
|
| 403 |
public function render() { |
| 404 |
$settings = $this->get_settings_for_display(); |
| 405 |
$this->add_render_attribute('grid', 'class', 'pg-aware-grid pg-grid pg-aware-style-' . $settings["layout_style"]); |
| 406 |
|
| 407 |
if (isset($settings['pg_in_animation_show']) && ($settings['pg_in_animation_show'] == 'yes')) { |
| 408 |
$this->add_render_attribute( 'grid', 'class', 'pg-in-animation' ); |
| 409 |
if (isset($settings['pg_in_animation_delay']['size'])) { |
| 410 |
$this->add_render_attribute( 'grid', 'data-in-animation-delay', $settings['pg_in_animation_delay']['size'] ); |
| 411 |
} |
| 412 |
} |
| 413 |
|
| 414 |
?> |
| 415 |
<div <?php $this->print_render_attribute_string('grid'); ?>> |
| 416 |
<?php $this->render_items(); ?> |
| 417 |
</div> |
| 418 |
<?php |
| 419 |
} |
| 420 |
/** |
| 421 |
* Elementor editor Backbone template. |
| 422 |
*/ |
| 423 |
protected function content_template() { |
| 424 |
?> |
| 425 |
<# |
| 426 |
var items = settings.items || []; |
| 427 |
var animDelay = ( settings.pg_in_animation_delay && settings.pg_in_animation_delay.size ) ? settings.pg_in_animation_delay.size : ''; |
| 428 |
var gridClass = 'pg-aware-grid pg-grid'; |
| 429 |
if ( settings.layout_style ) { |
| 430 |
gridClass += ' pg-aware-style-' + settings.layout_style; |
| 431 |
} |
| 432 |
if ( settings.pg_in_animation_show === 'yes' ) { |
| 433 |
gridClass += ' pg-in-animation'; |
| 434 |
} |
| 435 |
#> |
| 436 |
<div class="{{{ gridClass }}}" |
| 437 |
<# if ( settings.pg_in_animation_show === 'yes' && animDelay !== '' ) { #> data-in-animation-delay="{{ animDelay }}"<# } #> |
| 438 |
> |
| 439 |
<# _.each( items, function( item, index ) { |
| 440 |
var itemClass = 'pg-aware-item pg-item elementor-repeater-item-' + item._id; |
| 441 |
#> |
| 442 |
<div class="{{{ itemClass }}}"> |
| 443 |
<# if ( item.item_hidden !== 'yes' ) { #> |
| 444 |
<div class="pg-aware-image-wrap bdt-pg-img-mask"> |
| 445 |
<# if ( item.media_type === 'video' ) { #> |
| 446 |
<# if ( item.poster && item.poster.url ) { #> |
| 447 |
<img src="{{ item.poster.url }}" alt="{{ item.title }}" class="pg-aware-img"> |
| 448 |
<# } #> |
| 449 |
<# } else if ( item.image && item.image.url ) { #> |
| 450 |
<img src="{{ item.image.url }}" alt="{{ item.title }}" class="pg-aware-img"> |
| 451 |
<# } #> |
| 452 |
<# if ( settings.link_to === 'file' && item.media_type === 'video' ) { #> |
| 453 |
<span class="pg-video-icon-wrap"> |
| 454 |
<i class="pg-icon-play-circle pg-eicon-play"></i> |
| 455 |
</span> |
| 456 |
<# } #> |
| 457 |
</div> |
| 458 |
<# if ( settings.show_title === 'yes' && item.title ) { #> |
| 459 |
<# var ttag = settings.title_tag || 'h3'; #> |
| 460 |
<{{{ ttag }}} class="pg-aware-title">{{{ item.title }}}</{{{ ttag }}}> |
| 461 |
<# } #> |
| 462 |
<# if ( settings.link_to !== 'none' && ( settings.link_target || 'whole_item' ) === 'whole_item' ) { #> |
| 463 |
<?php $this->print_content_template_lightbox_overlay( 'aware' ); ?> |
| 464 |
<# } #> |
| 465 |
<# } #> |
| 466 |
</div> |
| 467 |
<# } ); #> |
| 468 |
</div> |
| 469 |
<?php |
| 470 |
} |
| 471 |
|
| 472 |
} |
| 473 |
|