𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /home/builxejc/public_html/wp-content/plugins/kinsley-plugin/elementor/widgets//footer-gallery.php
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Kinsley Footer Gallery Widget.
*
* @since 1.0
*/
class Kinsley_Footer_Gallery_Widget extends Widget_Base {
public function get_name() {
return 'kinsley-footer-gallery';
}
public function get_title() {
return esc_html__( 'Footer Gallery', 'kinsley-plugin' );
}
public function get_icon() {
return 'eicon-parallax';
}
public function get_categories() {
return [ 'kinsley-category' ];
}
/**
* Register widget controls.
*
* @since 1.0
*/
protected function register_controls() {
$this->start_controls_section(
'content_tab',
[
'label' => esc_html__( 'Content', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'source',
[
'label' => esc_html__( 'Parse from', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'custom',
'options' => [
'instagram' => __( 'Instagram', 'kinsley-plugin' ),
'custom' => __( 'Custom', 'kinsley-plugin' ),
],
]
);
$this->add_control(
'title',
[
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter title', 'kinsley-plugin' ),
'default' => esc_html__( 'Title', 'kinsley-plugin' ),
]
);
$this->add_responsive_control(
'align',
[
'label' => __( 'Alignment', 'kinsley-plugin' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __( 'Left', 'kinsley-plugin' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => __( 'Center', 'kinsley-plugin' ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => __( 'Right', 'kinsley-plugin' ),
'icon' => 'eicon-text-align-right',
],
],
'selectors' => [
'{{WRAPPER}}' => 'text-align: {{VALUE}};',
],
'default' => 'left',
]
);
$repeater = new \Elementor\Repeater();
$repeater->add_control(
'image', [
'label' => esc_html__( 'Image', 'kinsley-plugin' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => \Elementor\Utils::get_placeholder_image_src(),
],
]
);
$repeater->add_control(
'name', [
'label' => esc_html__( 'Caption', 'kinsley-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Enter name', 'kinsley-plugin' ),
'default' => esc_html__( 'Enter name', 'kinsley-plugin' ),
]
);
$repeater->add_control(
'url', [
'label' => esc_html__( 'URL', 'kinsley-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Enter URL', 'kinsley-plugin' ),
'default' => '',
]
);
$this->add_control(
'items',
[
'label' => esc_html__( 'Items', 'kinsley-plugin' ),
'type' => Controls_Manager::REPEATER,
'prevent_empty' => false,
'fields' => $repeater->get_controls(),
'title_field' => '{{{ name }}}',
'condition' => [
'source' => 'custom'
],
]
);
$this->add_control(
'access_token',
[
'label' => esc_html__( 'Access Token', 'kinsley-plugin' ),
'label_block' => true,
'description' => esc_html__( 'Access Token generated by Instagram', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXT,
'condition' => [
'source' => 'instagram'
],
]
);
$this->add_control(
'count',
[
'label' => esc_html__( 'Number of Images', 'kinsley-plugin' ),
'type' => Controls_Manager::NUMBER,
'placeholder' => 6,
'default' => 6,
'condition' => [
'source' => 'instagram'
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'content_styling',
[
'label' => esc_html__( 'Content Styles', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Title Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} h4' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => esc_html__( 'Title Typography:', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} h4',
]
);
$this->end_controls_section();
}
/**
* Render widget output on the frontend.
*
* @since 1.0
*/
protected function render() {
$settings = $this->get_settings_for_display();
$theme_lightbox = get_field( 'portfolio_lightbox_disable', 'option' );
if ( $settings['source'] == 'instagram' ) {
$data = get_instagram_data( $settings['count'], $settings['access_token'] );
}
?>
<?php if ( $settings['title'] ) : ?>
<h4>
<span <?php echo $this->get_render_attribute_string( 'title' ); ?>>
<?php echo wp_kses_post( $settings['title'] ); ?>
</span>
</h4>
<?php endif; ?>
<?php if ( $settings['source'] == 'instagram' ) : ?>
<div class="footer-insta">
<?php print_r( $data ); ?>
<?php foreach ( $data as $index => $item ) : ?>
<?php if ( $item['image'] ) : ?>
<a href="<?php echo esc_url( $item['url'] ); ?>" target="_blank"><img src="<?php echo esc_url( $item['image'] ); ?>" alt="<?php echo esc_url( $item['caption'] ); ?>" /></a>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?php else : ?>
<?php if ( $settings['items'] ) : ?>
<div class="footer-insta">
<?php foreach ( $settings['items'] as $index => $item ) : ?>
<?php if ( $item['image'] ) :
$image = wp_get_attachment_image_url( $item['image']['id'], 'kinsley_140x140' );
$image_full = wp_get_attachment_image_url( $item['image']['id'], 'kinsley_1920xAuto' );
if ( $item['url'] ) : $image_full = $item['url']; endif;
?>
<a href="<?php echo esc_url( $image_full ); ?>"<?php if ( ! $item['url'] ) : ?> <?php if ( ! $theme_lightbox ) : ?> data-magnific-gallery<?php endif; ?> data-elementor-lightbox-slideshow="footer-gallery" data-elementor-lightbox-title="<?php echo esc_attr( $item['name'] ); ?>"<?php else : ?> target="_blank"<?php endif; ?>>
<img src="<?php echo esc_url( $image ); ?>" alt="<?php echo esc_attr( $item['name'] ); ?>" />
</a>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php
}
/**
* Render widget output in the editor.
*
* Written as a Backbone JavaScript template and used to generate the live preview.
*
* @since 1.0.0
* @access protected
*/
protected function content_template() {
?>
<# if ( settings.title ) { #>
<h4>
<span {{{ view.getRenderAttributeString( 'title' ) }}}>
{{{ settings.title }}}
</span>
</h4>
<# } #>
<# if ( settings.source == 'custom' ) { #>
<# if ( settings.items ) { #>
<div class="footer-insta">
<# _.each( settings.items, function( item, index ) { #>
<# if ( item.image ) { #>
<a href="#"><img src="{{{ item.image.url }}}" alt="{{{ item.name }}}" /></a>
<# } #>
<# }); #>
</div>
<# } #>
<# } #>
<?php
}
}
Plugin::instance()->widgets_manager->register( new Kinsley_Footer_Gallery_Widget() );