# pixel-gallery/trunk/modules/ruby/widgets/ruby.php

Pixel Gallery Addons for Elementor – Easy Grid, Creative Gallery, Drag and Drop Grid, Custom Grid Layout, Portfolio Gallery, version trunk. 326 lines.

- Page: https://pluginprobe.com/plugins/pixel-gallery/trunk/code/modules/ruby/widgets/ruby.php
- Raw: https://pluginprobe.com/plugins/pixel-gallery/trunk/raw/modules/ruby/widgets/ruby.php
- Modified: 2026-04-15T11:31:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/pixel-gallery/trunk/code/modules/ruby/widgets/ruby.php#L10-L20`.

```php
<?php

namespace PixelGallery\Modules\Ruby\Widgets;

use PixelGallery\Base\Module_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Image_Size;
use Elementor\Group_Control_Text_Shadow;
use Elementor\Icons_Manager;
use Elementor\Group_Control_Css_Filter;
use Elementor\Group_Control_Text_Stroke;
use Elementor\Repeater;
use PixelGallery\Utils;
use PixelGallery\Traits\Global_Widget_Controls;

if (!defined('ABSPATH')) exit; // Exit if accessed directly

class Ruby extends Module_Base
{

	use Global_Widget_Controls;

	public function get_name()
	{
		return 'pg-ruby';
	}

	public function get_title()
	{
		return BDTPG . esc_html__('Ruby', 'pixel-gallery');
	}

	public function get_icon()
	{
		return 'pg-icon-ruby';
	}

	public function get_categories()
	{
		return ['pixel-gallery'];
	}

	public function get_keywords()
	{
		return ['ruby', 'grid', 'gallery'];
	}

	public function get_style_depends()
	{
		return ['pg-ruby'];
	}

	public function get_script_depends() {
		if ( true === _is_pg_pro_activated() ) {
			return ['justified-gallery'];
		} else {
			return [];
		}
	}

	public function get_custom_help_url() {
		return 'https://youtu.be/mQCrx2jVRRI';
	}

	public function has_widget_inner_wrapper(): bool {
        return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
    }
	protected function is_dynamic_content(): bool {
		return false;
	}

	protected function register_controls() {

		$this->start_controls_section(
			'section_layout',
			[
				'label' => __('Layout', 'pixel-gallery'),
				'tab'   => Controls_Manager::TAB_CONTENT,
			]
		);

		//Global
		$this->register_grid_controls('ruby');
		$this->register_global_height_controls('ruby');
		
		/**
		 * Justified Gallery Controls
		 */
		$this->register_justified_gallery_controls();
		
		$this->register_title_tag_controls();
		$this->register_show_meta_controls();
		$this->register_alignment_controls('ruby');
		$this->register_thumbnail_size_controls();

		//Global Lightbox Controls
		$this->register_lightbox_controls();
		$this->register_link_target_controls();
		$this->end_controls_section();

		//Repeater
		$this->start_controls_section(
			'section_item_content',
			[
				'label' => __('Items', 'pixel-gallery'),
				'tab'   => Controls_Manager::TAB_CONTENT,
			]
		);
		$repeater = new Repeater();
		$repeater->start_controls_tabs('tabs_item_content');
		$repeater->start_controls_tab(
			'tab_item_content',
			[
				'label' => esc_html__('Content', 'pixel-gallery'),
			]
		);
		$this->register_repeater_media_controls($repeater);
		$this->register_repeater_title_controls($repeater);
		$this->register_repeater_meta_controls($repeater);
		$this->register_repeater_readmore_controls($repeater);
		$this->register_repeater_custom_url_controls($repeater);
		$this->register_repeater_hidden_item_controls($repeater);

		$repeater->end_controls_tab();
		$repeater->start_controls_tab(
			'tab_item_grid',
			[
				'label' => esc_html__('Grid', 'pixel-gallery'),
			]
		);
		$this->register_repeater_grid_controls($repeater, 'ruby');
		$this->register_repeater_item_height_controls($repeater, 'ruby');
		$repeater->end_controls_tab();
		$repeater->end_controls_tabs();
		$this->register_repeater_items_controls($repeater);
		$this->end_controls_section();

		//Style
		$this->start_controls_section(
			'pg_section_style',
			[
				'label'     => esc_html__('Items', 'pixel-gallery'),
				'tab'       => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_control(
			'item_bg_color',
			[
				'label'     => esc_html__('Background Color', 'pixel-gallery'),
				'type'      => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .pg-ruby-content' => 'background-color: {{VALUE}};',
					'{{WRAPPER}} .pg-ruby-item, {{WRAPPER}} .pg-ruby-content' => 'box-shadow: 0 0 0 0px {{VALUE}};',
					'{{WRAPPER}} .pg-ruby-item:hover, {{WRAPPER}} .pg-ruby-item:hover .pg-ruby-content' => 'box-shadow: 0 0 0 10px {{VALUE}};',
				],
			]
		);

		$this->add_responsive_control(
			'content_padding',
			[
				'label'      => esc_html__('Padding', 'pixel-gallery'),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => ['px', 'em', '%'],
				'selectors'  => [
					'{{WRAPPER}} .pg-ruby-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);

		$this->end_controls_section();

		//Global Title Controls
		$this->register_title_controls('ruby');

		//Global meta Controls
		$this->register_meta_controls('ruby');

		//Global Readmore Controls
		$this->register_readmore_controls('ruby');

		//Clip Path Controls
		$this->register_clip_path_controls('ruby');
	}

	public function render_items()
	{
		$settings = $this->get_settings_for_display();
		$id = 'pg-ruby-' . $this->get_id();
		$slide_index = 1;
		foreach ($settings['items'] as $index => $item) :

			$attr_name = 'grid-item' . $index;
			$this->add_render_attribute($attr_name, 'class', 'pg-ruby-item pg-item elementor-repeater-item-' . esc_attr($item['_id']), true);

			/**
			 * Render Video Inject Here
			 * Video Would be work on Media File & Lightbox
			 * @since 1.0.0
			 */
			if ($item['media_type'] == 'video') {
				$this->render_video_frame($item, $attr_name, $id);
			}

		?>

		<div <?php $this->print_render_attribute_string($attr_name); ?>>
			<?php if ($item['item_hidden'] !== 'yes') : ?>
			<?php $this->render_image_wrap($item, 'ruby'); ?>
					<div class="pg-ruby-content">
						<div class="pg-ruby-content-inner">
							<?php $this->render_title($item, 'ruby'); ?>
							<?php $this->render_meta($item, 'ruby'); ?>
						</div>
						<?php if ('none' !== $settings['link_to'] && $settings['link_target'] == 'only_button') : ?>
							<?php $this->render_readmore($item, $index, $id, 'ruby'); ?>
						<?php endif; ?>
					</div>
					<?php if ('none' !== $settings['link_to'] && $settings['link_target'] == 'whole_item') : ?>
						<?php $this->render_lightbox_link_url($item, $index, $id); ?>
					<?php endif; ?>
				<?php endif; ?>
			</div>

		<?php
			$slide_index++;
		endforeach;
	}

	public function render()
	{
		$settings   = $this->get_settings_for_display();
		$this->add_render_attribute('grid', 'class', 'pg-ruby-grid pg-grid');

		/**
		 * Render Justified Gallery Attributes
		 */
		$this->render_justified_gallery_attributes('grid');
		
		if (isset($settings['pg_in_animation_show']) && ($settings['pg_in_animation_show'] == 'yes')) {
			$this->add_render_attribute( 'grid', 'class', 'pg-in-animation' );
			if (isset($settings['pg_in_animation_delay']['size'])) {
				$this->add_render_attribute( 'grid', 'data-in-animation-delay', $settings['pg_in_animation_delay']['size'] );
			}
		}

		?>
		<div <?php $this->print_render_attribute_string('grid'); ?>>
			<?php $this->render_items(); ?>
		</div>
<?php
	}
	/**
	 * Elementor editor Backbone template.
	 */
	protected function content_template() {
		?>
		<#
	var items = settings.items || [];
	var animDelay = ( settings.pg_in_animation_delay && settings.pg_in_animation_delay.size ) ? settings.pg_in_animation_delay.size : '';
	var alwaysLb = false;
	var gridClass = 'pg-ruby-grid pg-grid';
	if ( settings.pg_in_animation_show === 'yes' ) {
		gridClass += ' pg-in-animation';
	}
	#>
		<div class="{{{ gridClass }}}"
			<# if ( settings.pg_in_animation_show === 'yes' && animDelay !== '' ) { #> data-in-animation-delay="{{ animDelay }}"<# } #>
		>
		<# _.each( items, function( item, index ) {
			var itemClass = 'pg-ruby-item pg-item elementor-repeater-item-' + item._id;
		#>
			<div class="{{{ itemClass }}}">
				<# if ( item.item_hidden !== 'yes' ) { #>
										<div class="pg-ruby-image-wrap bdt-pg-img-mask">
						<# if ( item.media_type === 'video' ) { #>
							<# if ( item.poster && item.poster.url ) { #>
								<img src="{{ item.poster.url }}" alt="{{ item.title }}" class="pg-ruby-img">
							<# } #>
						<# } else if ( item.image && item.image.url ) { #>
							<img src="{{ item.image.url }}" alt="{{ item.title }}" class="pg-ruby-img">
						<# } #>
						<# if ( settings.link_to === 'file' && item.media_type === 'video' ) { #>
							<span class="pg-video-icon-wrap">
								<i class="pg-icon-play-circle pg-eicon-play"></i>
							</span>
						<# } #>
					</div>
					<div class="pg-ruby-content">
						<div class="pg-ruby-content-inner">
							<# if ( settings.show_title === 'yes' && item.title ) { #>
								<# var ttag = settings.title_tag || 'h3'; #>
								<{{{ ttag }}} class="pg-ruby-title">{{{ item.title }}}</{{{ ttag }}}>
							<# } #>
							<# if ( settings.show_meta === 'yes' && item.meta ) { #>
								<div class="pg-ruby-meta">{{{ item.meta }}}</div>
							<# } #>
						</div>
						<# if ( settings.link_to !== 'none' && ( settings.link_target || 'whole_item' ) === 'only_button' && item.readmore_text ) { #>
							<div class="pg-ruby-readmore">
<?php $this->print_content_template_item_link_prepare( 'ruby' ); ?>
<?php $this->print_content_template_item_link_wrap_open(); ?>
<?php $this->print_content_template_item_link_a_open(); ?>
							{{{ item.readmore_text }}}
<?php $this->print_content_template_item_link_a_close(); ?>
<?php $this->print_content_template_item_link_wrap_close(); ?>
						</div>
						<# } #>
					</div>
					<# if ( alwaysLb || ( settings.link_to !== 'none' && ( settings.link_target || 'whole_item' ) === 'whole_item' ) ) { #>
<?php $this->print_content_template_lightbox_overlay( 'ruby' ); ?>
					<# } #>
				<# } #>
			</div>
		<# } ); #>
		</div>
		<?php
	}

}

```
