XylotrechusZ
XylotrechusZ Shell
: /home/matican/amplecommodities.com/wp-content/plugins/rselements/widgets/image-box/ [ drwxr-xr-x ]
<?php
/**
* Image widget class
*
*/
use Elementor\Group_Control_Text_Shadow;
use Elementor\Repeater;
use Elementor\Core\Schemes\Typography;
use Elementor\Utils;
use Elementor\Control_Media;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Image_Size;
use Elementor\Group_Control_Css_Filter;
use Elementor\register_controls;
defined( 'ABSPATH' ) || die();
class Rsaddon_pro_Image_hover_Widget extends \Elementor\Widget_Base {
/**
* Get widget name.
*
* Retrieve rsgallery widget name.
*
* @since 1.0.0
* @access public
*
* @return string Widget name.
*/
public function get_name() {
return 'rs-image-hover';
}
/**
* Get widget title.
*
* @since 1.0.0
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return esc_html__( 'RS Image Parallax', 'rsaddon' );
}
/**
* Get widget icon.
*
* @since 1.0.0
* @access public
*
* @return string Widget icon.
*/
public function get_icon() {
return 'glyph-icon flaticon-image';
}
public function get_categories() {
return [ 'rsaddon_category' ];
}
public function get_keywords() {
return [ 'logo', 'clients', 'brand', 'parnter', 'image' ];
}
protected function register_controls() {
$this->start_controls_section(
'section_image',
[
'label' => __( 'Image', 'elementor' ),
]
);
$this->add_control(
'image',
[
'label' => __( 'Choose Image', 'elementor' ),
'type' => Controls_Manager::MEDIA,
'dynamic' => [
'active' => true,
],
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
]
);
$this->add_group_control(
Group_Control_Image_Size::get_type(),
[
'name' => 'image', // Usage: `{name}_size` and `{name}_custom_dimension`, in this case `image_size` and `image_custom_dimension`.
'default' => 'large',
'separator' => 'none',
]
);
$this->add_responsive_control(
'align',
[
'label' => __( 'Alignment', 'elementor' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __( 'Left', 'elementor' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => __( 'Center', 'elementor' ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => __( 'Right', 'elementor' ),
'icon' => 'eicon-text-align-right',
],
],
'selectors' => [
'{{WRAPPER}}' => 'text-align: {{VALUE}};',
],
]
);
$this->add_control(
'link_to',
[
'label' => __( 'Link', 'elementor' ),
'type' => Controls_Manager::SELECT,
'default' => 'none',
'options' => [
'none' => __( 'None', 'elementor' ),
'file' => __( 'Media File', 'elementor' ),
'custom' => __( 'Custom URL', 'elementor' ),
],
]
);
$this->add_control(
'link',
[
'label' => __( 'Link', 'elementor' ),
'type' => Controls_Manager::URL,
'dynamic' => [
'active' => true,
],
'placeholder' => __( 'https://your-link.com', 'elementor' ),
'condition' => [
'link_to' => 'custom',
],
'show_label' => false,
]
);
$this->add_control(
'open_lightbox',
[
'label' => __( 'Lightbox', 'elementor' ),
'type' => Controls_Manager::SELECT,
'default' => 'default',
'options' => [
'default' => __( 'Default', 'elementor' ),
'yes' => __( 'Yes', 'elementor' ),
'no' => __( 'No', 'elementor' ),
],
'condition' => [
'link_to' => 'file',
],
]
);
$this->add_control(
'view',
[
'label' => __( 'View', 'elementor' ),
'type' => Controls_Manager::HIDDEN,
'default' => 'traditional',
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_style_image',
[
'label' => __( 'Image', 'elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'width',
[
'label' => __( 'Width', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'unit' => '%',
],
'tablet_default' => [
'unit' => '%',
],
'mobile_default' => [
'unit' => '%',
],
'size_units' => [ '%', 'px', 'vw' ],
'range' => [
'%' => [
'min' => 1,
'max' => 100,
],
'px' => [
'min' => 1,
'max' => 1000,
],
'vw' => [
'min' => 1,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-image img' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'space',
[
'label' => __( 'Max Width', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'unit' => '%',
],
'tablet_default' => [
'unit' => '%',
],
'mobile_default' => [
'unit' => '%',
],
'size_units' => [ '%', 'px', 'vw' ],
'range' => [
'%' => [
'min' => 1,
'max' => 100,
],
'px' => [
'min' => 1,
'max' => 1000,
],
'vw' => [
'min' => 1,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-image img' => 'max-width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'separator_panel_style',
[
'type' => Controls_Manager::DIVIDER,
'style' => 'thick',
]
);
$this->start_controls_tabs( 'image_effects' );
$this->start_controls_tab( 'normal',
[
'label' => __( 'Normal', 'elementor' ),
]
);
$this->add_control(
'opacity',
[
'label' => __( 'Opacity', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'max' => 1,
'min' => 0.10,
'step' => 0.01,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-image img' => 'opacity: {{SIZE}};',
],
]
);
$this->add_group_control(
Group_Control_Css_Filter::get_type(),
[
'name' => 'css_filters',
'selector' => '{{WRAPPER}} .elementor-image img',
]
);
$this->end_controls_tab();
$this->start_controls_tab( 'hover',
[
'label' => __( 'Hover', 'elementor' ),
]
);
$this->add_control(
'opacity_hover',
[
'label' => __( 'Opacity', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'max' => 1,
'min' => 0.10,
'step' => 0.01,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-image:hover img' => 'opacity: {{SIZE}};',
],
]
);
$this->add_group_control(
Group_Control_Css_Filter::get_type(),
[
'name' => 'css_filters_hover',
'selector' => '{{WRAPPER}} .elementor-image:hover img',
]
);
$this->add_control(
'background_hover_transition',
[
'label' => __( 'Transition Duration', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'max' => 3,
'step' => 0.1,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-image img' => 'transition-duration: {{SIZE}}s',
],
]
);
$this->add_control(
'hover_animation',
[
'label' => __( 'Hover Animation', 'elementor' ),
'type' => Controls_Manager::HOVER_ANIMATION,
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'image_border',
'selector' => '{{WRAPPER}} .elementor-image img',
'separator' => 'before',
]
);
$this->add_responsive_control(
'image_border_radius',
[
'label' => __( 'Border Radius', 'elementor' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .elementor-image img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'image_box_shadow',
'exclude' => [
'box_shadow_position',
],
'selector' => '{{WRAPPER}} .elementor-image img',
]
);
$this->end_controls_section();
}
/**
* Render image widget output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @since 1.0.0
* @access protected
*/
protected function render() {
$settings = $this->get_settings_for_display();
if ( empty( $settings['image']['url'] ) ) {
return;
}
$this->add_render_attribute( 'wrapper', 'class', 'elementor-image' );
if ( ! empty( $settings['shape'] ) ) {
$this->add_render_attribute( 'wrapper', 'class', 'elementor-image-shape-' . $settings['shape'] );
}
$link = $this->get_link_url( $settings );
if ( $link ) {
$this->add_link_attributes( 'link', $link );
if ( Plugin::$instance->editor->is_edit_mode() ) {
$this->add_render_attribute( 'link', [
'class' => 'elementor-clickable',
] );
}
if ( 'custom' !== $settings['link_to'] ) {
$this->add_lightbox_data_attributes( 'link', $settings['image']['id'], $settings['open_lightbox'] );
}
} ?>
<div <?php echo $this->get_render_attribute_string( 'wrapper' ); ?>>
<div class="image titlt" data-tilt data-tilt-max="3">
<?php if ( $link ) : ?>
<a <?php echo $this->get_render_attribute_string( 'link' ); ?>>
<?php endif; ?>
<?php echo Group_Control_Image_Size::get_attachment_image_html( $settings ); ?>
<?php if ( $link ) : ?>
</a>
<?php endif; ?>
</div>
</div>
<?php
}
/**
* Render image widget output in the editor.
*
* Written as a Backbone JavaScript template and used to generate the live preview.
*
* @since 2.9.0
* @access protected
*/
protected function content_template() {
?>
<# if ( settings.image.url ) {
var image = {
id: settings.image.id,
url: settings.image.url,
size: settings.image_size,
dimension: settings.image_custom_dimension,
model: view.getEditModel()
};
var image_url = elementor.imagesManager.getImageUrl( image );
if ( ! image_url ) {
return;
}
var hasCaption = function() {
if( ! settings.caption_source || 'none' === settings.caption_source ) {
return false;
}
return true;
}
var ensureAttachmentData = function( id ) {
if ( 'undefined' === typeof wp.media.attachment( id ).get( 'caption' ) ) {
wp.media.attachment( id ).fetch().then( function( data ) {
view.render();
} );
}
}
var getAttachmentCaption = function( id ) {
if ( ! id ) {
return '';
}
ensureAttachmentData( id );
return wp.media.attachment( id ).get( 'caption' );
}
var getCaption = function() {
if ( ! hasCaption() ) {
return '';
}
return 'custom' === settings.caption_source ? settings.caption : getAttachmentCaption( settings.image.id );
}
var link_url;
if ( 'custom' === settings.link_to ) {
link_url = settings.link.url;
}
if ( 'file' === settings.link_to ) {
link_url = settings.image.url;
}
#><div class="elementor-image{{ settings.shape ? ' elementor-image-shape-' + settings.shape : '' }}"><#
var imgClass = '';
if ( '' !== settings.hover_animation ) {
imgClass = 'elementor-animation-' + settings.hover_animation;
}
if ( hasCaption() ) {
#><figure class="wp-caption"><#
}
if ( link_url ) {
#><a class="elementor-clickable" data-elementor-open-lightbox="{{ settings.open_lightbox }}" href="{{ link_url }}"><#
}
#><img src="{{ image_url }}" class="{{ imgClass }}" /><#
if ( link_url ) {
#></a><#
}
if ( hasCaption() ) {
#><figcaption class="widget-image-caption wp-caption-text">{{{ getCaption() }}}</figcaption><#
}
if ( hasCaption() ) {
#></figure><#
}
#></div><#
} #>
<?php
}
/**
* Retrieve image widget link URL.
*
* @since 1.0.0
* @access private
*
* @param array $settings
*
* @return array|string|false An array/string containing the link URL, or false if no link.
*/
private function get_link_url( $settings ) {
if ( 'none' === $settings['link_to'] ) {
return false;
}
if ( 'custom' === $settings['link_to'] ) {
if ( empty( $settings['link']['url'] ) ) {
return false;
}
return $settings['link'];
}
return [
'url' => $settings['image']['url'],
];
}
}