| 1 |
<?php |
| 2 |
|
| 3 |
namespace PixelGallery\Modules\Ruby\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 Ruby extends Module_Base |
| 23 |
{ |
| 24 |
|
| 25 |
use Global_Widget_Controls; |
| 26 |
|
| 27 |
public function get_name() |
| 28 |
{ |
| 29 |
return 'pg-ruby'; |
| 30 |
} |
| 31 |
|
| 32 |
public function get_title() |
| 33 |
{ |
| 34 |
return BDTPG . esc_html__('Ruby', 'pixel-gallery'); |
| 35 |
} |
| 36 |
|
| 37 |
public function get_icon() |
| 38 |
{ |
| 39 |
return 'pg-icon-ruby'; |
| 40 |
} |
| 41 |
|
| 42 |
public function get_categories() |
| 43 |
{ |
| 44 |
return ['pixel-gallery']; |
| 45 |
} |
| 46 |
|
| 47 |
public function get_keywords() |
| 48 |
{ |
| 49 |
return ['ruby', 'grid', 'gallery']; |
| 50 |
} |
| 51 |
|
| 52 |
public function get_style_depends() |
| 53 |
{ |
| 54 |
return ['pg-ruby']; |
| 55 |
} |
| 56 |
|
| 57 |
public function get_script_depends() { |
| 58 |
if ( true === _is_pg_pro_activated() ) { |
| 59 |
return ['justified-gallery']; |
| 60 |
} else { |
| 61 |
return []; |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
public function get_custom_help_url() { |
| 66 |
return 'https://youtu.be/mQCrx2jVRRI'; |
| 67 |
} |
| 68 |
|
| 69 |
public function has_widget_inner_wrapper(): bool { |
| 70 |
return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 71 |
} |
| 72 |
protected function is_dynamic_content(): bool { |
| 73 |
return false; |
| 74 |
} |
| 75 |
|
| 76 |
protected function register_controls() { |
| 77 |
|
| 78 |
$this->start_controls_section( |
| 79 |
'section_layout', |
| 80 |
[ |
| 81 |
'label' => __('Layout', 'pixel-gallery'), |
| 82 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 83 |
] |
| 84 |
); |
| 85 |
|
| 86 |
//Global |
| 87 |
$this->register_grid_controls('ruby'); |
| 88 |
$this->register_global_height_controls('ruby'); |
| 89 |
|
| 90 |
/** |
| 91 |
* Justified Gallery Controls |
| 92 |
*/ |
| 93 |
$this->register_justified_gallery_controls(); |
| 94 |
|
| 95 |
$this->register_title_tag_controls(); |
| 96 |
$this->register_show_meta_controls(); |
| 97 |
$this->register_alignment_controls('ruby'); |
| 98 |
$this->register_thumbnail_size_controls(); |
| 99 |
|
| 100 |
//Global Lightbox Controls |
| 101 |
$this->register_lightbox_controls(); |
| 102 |
$this->register_link_target_controls(); |
| 103 |
$this->end_controls_section(); |
| 104 |
|
| 105 |
//Repeater |
| 106 |
$this->start_controls_section( |
| 107 |
'section_item_content', |
| 108 |
[ |
| 109 |
'label' => __('Items', 'pixel-gallery'), |
| 110 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 111 |
] |
| 112 |
); |
| 113 |
$repeater = new Repeater(); |
| 114 |
$repeater->start_controls_tabs('tabs_item_content'); |
| 115 |
$repeater->start_controls_tab( |
| 116 |
'tab_item_content', |
| 117 |
[ |
| 118 |
'label' => esc_html__('Content', 'pixel-gallery'), |
| 119 |
] |
| 120 |
); |
| 121 |
$this->register_repeater_media_controls($repeater); |
| 122 |
$this->register_repeater_title_controls($repeater); |
| 123 |
$this->register_repeater_meta_controls($repeater); |
| 124 |
$this->register_repeater_readmore_controls($repeater); |
| 125 |
$this->register_repeater_custom_url_controls($repeater); |
| 126 |
$this->register_repeater_hidden_item_controls($repeater); |
| 127 |
|
| 128 |
$repeater->end_controls_tab(); |
| 129 |
$repeater->start_controls_tab( |
| 130 |
'tab_item_grid', |
| 131 |
[ |
| 132 |
'label' => esc_html__('Grid', 'pixel-gallery'), |
| 133 |
] |
| 134 |
); |
| 135 |
$this->register_repeater_grid_controls($repeater, 'ruby'); |
| 136 |
$this->register_repeater_item_height_controls($repeater, 'ruby'); |
| 137 |
$repeater->end_controls_tab(); |
| 138 |
$repeater->end_controls_tabs(); |
| 139 |
$this->register_repeater_items_controls($repeater); |
| 140 |
$this->end_controls_section(); |
| 141 |
|
| 142 |
//Style |
| 143 |
$this->start_controls_section( |
| 144 |
'pg_section_style', |
| 145 |
[ |
| 146 |
'label' => esc_html__('Items', 'pixel-gallery'), |
| 147 |
'tab' => Controls_Manager::TAB_STYLE, |
| 148 |
] |
| 149 |
); |
| 150 |
|
| 151 |
$this->add_control( |
| 152 |
'item_bg_color', |
| 153 |
[ |
| 154 |
'label' => esc_html__('Background Color', 'pixel-gallery'), |
| 155 |
'type' => Controls_Manager::COLOR, |
| 156 |
'selectors' => [ |
| 157 |
'{{WRAPPER}} .pg-ruby-content' => 'background-color: {{VALUE}};', |
| 158 |
'{{WRAPPER}} .pg-ruby-item, {{WRAPPER}} .pg-ruby-content' => 'box-shadow: 0 0 0 0px {{VALUE}};', |
| 159 |
'{{WRAPPER}} .pg-ruby-item:hover, {{WRAPPER}} .pg-ruby-item:hover .pg-ruby-content' => 'box-shadow: 0 0 0 10px {{VALUE}};', |
| 160 |
], |
| 161 |
] |
| 162 |
); |
| 163 |
|
| 164 |
$this->add_responsive_control( |
| 165 |
'content_padding', |
| 166 |
[ |
| 167 |
'label' => esc_html__('Padding', 'pixel-gallery'), |
| 168 |
'type' => Controls_Manager::DIMENSIONS, |
| 169 |
'size_units' => ['px', 'em', '%'], |
| 170 |
'selectors' => [ |
| 171 |
'{{WRAPPER}} .pg-ruby-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 172 |
], |
| 173 |
] |
| 174 |
); |
| 175 |
|
| 176 |
$this->end_controls_section(); |
| 177 |
|
| 178 |
//Global Title Controls |
| 179 |
$this->register_title_controls('ruby'); |
| 180 |
|
| 181 |
//Global meta Controls |
| 182 |
$this->register_meta_controls('ruby'); |
| 183 |
|
| 184 |
//Global Readmore Controls |
| 185 |
$this->register_readmore_controls('ruby'); |
| 186 |
|
| 187 |
//Clip Path Controls |
| 188 |
$this->register_clip_path_controls('ruby'); |
| 189 |
} |
| 190 |
|
| 191 |
public function render_items() |
| 192 |
{ |
| 193 |
$settings = $this->get_settings_for_display(); |
| 194 |
$id = 'pg-ruby-' . $this->get_id(); |
| 195 |
$slide_index = 1; |
| 196 |
foreach ($settings['items'] as $index => $item) : |
| 197 |
|
| 198 |
$attr_name = 'grid-item' . $index; |
| 199 |
$this->add_render_attribute($attr_name, 'class', 'pg-ruby-item pg-item elementor-repeater-item-' . esc_attr($item['_id']), true); |
| 200 |
|
| 201 |
/** |
| 202 |
* Render Video Inject Here |
| 203 |
* Video Would be work on Media File & Lightbox |
| 204 |
* @since 1.0.0 |
| 205 |
*/ |
| 206 |
if ($item['media_type'] == 'video') { |
| 207 |
$this->render_video_frame($item, $attr_name, $id); |
| 208 |
} |
| 209 |
|
| 210 |
?> |
| 211 |
|
| 212 |
<div <?php $this->print_render_attribute_string($attr_name); ?>> |
| 213 |
<?php if ($item['item_hidden'] !== 'yes') : ?> |
| 214 |
<?php $this->render_image_wrap($item, 'ruby'); ?> |
| 215 |
<div class="pg-ruby-content"> |
| 216 |
<div class="pg-ruby-content-inner"> |
| 217 |
<?php $this->render_title($item, 'ruby'); ?> |
| 218 |
<?php $this->render_meta($item, 'ruby'); ?> |
| 219 |
</div> |
| 220 |
<?php if ('none' !== $settings['link_to'] && $settings['link_target'] == 'only_button') : ?> |
| 221 |
<?php $this->render_readmore($item, $index, $id, 'ruby'); ?> |
| 222 |
<?php endif; ?> |
| 223 |
</div> |
| 224 |
<?php if ('none' !== $settings['link_to'] && $settings['link_target'] == 'whole_item') : ?> |
| 225 |
<?php $this->render_lightbox_link_url($item, $index, $id); ?> |
| 226 |
<?php endif; ?> |
| 227 |
<?php endif; ?> |
| 228 |
</div> |
| 229 |
|
| 230 |
<?php |
| 231 |
$slide_index++; |
| 232 |
endforeach; |
| 233 |
} |
| 234 |
|
| 235 |
public function render() |
| 236 |
{ |
| 237 |
$settings = $this->get_settings_for_display(); |
| 238 |
$this->add_render_attribute('grid', 'class', 'pg-ruby-grid pg-grid'); |
| 239 |
|
| 240 |
/** |
| 241 |
* Render Justified Gallery Attributes |
| 242 |
*/ |
| 243 |
$this->render_justified_gallery_attributes('grid'); |
| 244 |
|
| 245 |
if (isset($settings['pg_in_animation_show']) && ($settings['pg_in_animation_show'] == 'yes')) { |
| 246 |
$this->add_render_attribute( 'grid', 'class', 'pg-in-animation' ); |
| 247 |
if (isset($settings['pg_in_animation_delay']['size'])) { |
| 248 |
$this->add_render_attribute( 'grid', 'data-in-animation-delay', $settings['pg_in_animation_delay']['size'] ); |
| 249 |
} |
| 250 |
} |
| 251 |
|
| 252 |
?> |
| 253 |
<div <?php $this->print_render_attribute_string('grid'); ?>> |
| 254 |
<?php $this->render_items(); ?> |
| 255 |
</div> |
| 256 |
<?php |
| 257 |
} |
| 258 |
/** |
| 259 |
* Elementor editor Backbone template. |
| 260 |
*/ |
| 261 |
protected function content_template() { |
| 262 |
?> |
| 263 |
<# |
| 264 |
var items = settings.items || []; |
| 265 |
var animDelay = ( settings.pg_in_animation_delay && settings.pg_in_animation_delay.size ) ? settings.pg_in_animation_delay.size : ''; |
| 266 |
var alwaysLb = false; |
| 267 |
var gridClass = 'pg-ruby-grid pg-grid'; |
| 268 |
if ( settings.pg_in_animation_show === 'yes' ) { |
| 269 |
gridClass += ' pg-in-animation'; |
| 270 |
} |
| 271 |
#> |
| 272 |
<div class="{{{ gridClass }}}" |
| 273 |
<# if ( settings.pg_in_animation_show === 'yes' && animDelay !== '' ) { #> data-in-animation-delay="{{ animDelay }}"<# } #> |
| 274 |
> |
| 275 |
<# _.each( items, function( item, index ) { |
| 276 |
var itemClass = 'pg-ruby-item pg-item elementor-repeater-item-' + item._id; |
| 277 |
#> |
| 278 |
<div class="{{{ itemClass }}}"> |
| 279 |
<# if ( item.item_hidden !== 'yes' ) { #> |
| 280 |
<div class="pg-ruby-image-wrap bdt-pg-img-mask"> |
| 281 |
<# if ( item.media_type === 'video' ) { #> |
| 282 |
<# if ( item.poster && item.poster.url ) { #> |
| 283 |
<img src="{{ item.poster.url }}" alt="{{ item.title }}" class="pg-ruby-img"> |
| 284 |
<# } #> |
| 285 |
<# } else if ( item.image && item.image.url ) { #> |
| 286 |
<img src="{{ item.image.url }}" alt="{{ item.title }}" class="pg-ruby-img"> |
| 287 |
<# } #> |
| 288 |
<# if ( settings.link_to === 'file' && item.media_type === 'video' ) { #> |
| 289 |
<span class="pg-video-icon-wrap"> |
| 290 |
<i class="pg-icon-play-circle pg-eicon-play"></i> |
| 291 |
</span> |
| 292 |
<# } #> |
| 293 |
</div> |
| 294 |
<div class="pg-ruby-content"> |
| 295 |
<div class="pg-ruby-content-inner"> |
| 296 |
<# if ( settings.show_title === 'yes' && item.title ) { #> |
| 297 |
<# var ttag = settings.title_tag || 'h3'; #> |
| 298 |
<{{{ ttag }}} class="pg-ruby-title">{{{ item.title }}}</{{{ ttag }}}> |
| 299 |
<# } #> |
| 300 |
<# if ( settings.show_meta === 'yes' && item.meta ) { #> |
| 301 |
<div class="pg-ruby-meta">{{{ item.meta }}}</div> |
| 302 |
<# } #> |
| 303 |
</div> |
| 304 |
<# if ( settings.link_to !== 'none' && ( settings.link_target || 'whole_item' ) === 'only_button' && item.readmore_text ) { #> |
| 305 |
<div class="pg-ruby-readmore"> |
| 306 |
<?php $this->print_content_template_item_link_prepare( 'ruby' ); ?> |
| 307 |
<?php $this->print_content_template_item_link_wrap_open(); ?> |
| 308 |
<?php $this->print_content_template_item_link_a_open(); ?> |
| 309 |
{{{ item.readmore_text }}} |
| 310 |
<?php $this->print_content_template_item_link_a_close(); ?> |
| 311 |
<?php $this->print_content_template_item_link_wrap_close(); ?> |
| 312 |
</div> |
| 313 |
<# } #> |
| 314 |
</div> |
| 315 |
<# if ( alwaysLb || ( settings.link_to !== 'none' && ( settings.link_target || 'whole_item' ) === 'whole_item' ) ) { #> |
| 316 |
<?php $this->print_content_template_lightbox_overlay( 'ruby' ); ?> |
| 317 |
<# } #> |
| 318 |
<# } #> |
| 319 |
</div> |
| 320 |
<# } ); #> |
| 321 |
</div> |
| 322 |
<?php |
| 323 |
} |
| 324 |
|
| 325 |
} |
| 326 |
|