Done !
| Server IP : 46.105.57.169 / Your IP : 216.73.216.67 Web Server : Apache System : Linux webm002.cluster120.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : verseaumee ( 152031) PHP Version : 8.5.7 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/verseaumee/TF89388/wp-content/plugins/noisa-toolkit/includes/widgets/ |
Upload File : |
<?php
/**
* Rascals Gallery Widget
*
* Displays images from gallery
*
* @author Rascals Themes
* @category Widgets
* @package NoisaToolkit/Widgets
* @version 1.0.0
* @extends WP_Widget
*/
class RascalsGalleryWidget extends WP_Widget {
/**
* Constructor
*/
function __construct() {
/* Widget settings */
$widget_ops = array(
'classname' => 'widget_r_gallery',
'description' => esc_html__( 'Display images from Gallery', 'noisa-toolkit' )
);
/* Create the widget */
parent::__construct( 'r-gallery-widget', esc_html__( 'Gallery (RT)', 'noisa-toolkit' ), $widget_ops );
}
/**
* Widget function.
*
* @see WP_Widget
* @access public
* @param array $args
* @param array $instance
* @return void
*/
function widget( $args, $instance ) {
extract( $args );
$title = ( isset( $instance['title'] ) ) ? sanitize_text_field( $instance['title'] ) : '';
$title = apply_filters( 'widget_title', $title );
$gallery_id = ( isset( $instance['gallery_id'] ) ) ? sanitize_text_field( $instance['gallery_id'] ) : 0;
$type = ( isset( $instance['type'] ) ) ? sanitize_text_field( $instance['type'] ) : 'latest_albums';
$button = ( isset( $instance['button'] ) ) ? sanitize_text_field( $instance['button'] ) : '0';
$button = ( $button === 'yes' ) ? '1' : '0';
$in_row = ( isset( $instance['in_row'] ) ) ? sanitize_text_field( $instance['in_row'] ) : '3';
$url = ( isset( $instance['url'] ) ) ? sanitize_text_field( $instance['url'] ) : '3';
$limit = ( isset( $instance['limit'] ) ) ? absint( $instance['limit'] ) : 6;
$classes = ( isset( $instance['classes'] ) ) ? sanitize_text_field( $instance['classes'] ) : '';
echo wp_kses_post( $before_widget );
// Title
if ( ! empty( $title ) ) {
echo wp_kses_post( $before_title ) . esc_attr( $title) . wp_kses_post( $after_title );
}
// Display gallery
if ( $type === 'latest_images' ) {
echo do_shortcode('[gallery_images album_id="' . esc_attr( $gallery_id ) . '" url="' . esc_attr( $button ) . '" limit="' . esc_attr( $limit ) . '" in_row="' . esc_attr( $in_row ) . '" thumb_style="simple" masonry="1" classes="' . esc_attr( $classes ) . '" ]');
} else if ( $type === 'latest_albums' ) {
echo do_shortcode('[gallery_albums url="' . esc_attr( $url ) . '" limit="' . esc_attr( $limit ) . '" in_row="' . esc_attr( $in_row ) . '" thumb_style="simple" masonry="1" classes="' . esc_attr( $classes ) . '"]');
}
echo wp_kses_post( $after_widget );
}
/**
* Update function.
*
* @see WP_Widget->update
* @access public
* @param array $new_instance
* @param array $old_instance
* @return array
*/
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = sanitize_text_field( $new_instance['title'] );
$instance['gallery_id'] = sanitize_text_field( $new_instance['gallery_id'] );
$instance['type'] = sanitize_text_field( $new_instance['type'] );
$instance['button'] = sanitize_text_field( $new_instance['button'] );
$instance['in_row'] = sanitize_text_field( $new_instance['in_row'] );
$instance['link'] = sanitize_text_field( $new_instance['link'] );
$instance['url'] = sanitize_text_field( $new_instance['url'] );
$instance['limit'] = sanitize_text_field( $new_instance['limit'] );
$instance['classes'] = sanitize_text_field( $new_instance['classes'] );
return $instance;
}
/**
* Form function.
*
* @see WP_Widget->form
* @access public
* @param array $instance
* @return void
*/
function form( $instance ) {
$defaults = array(
'title' => esc_html__( 'Gallery', 'noisa-toolkit' ),
'gallery_id' => '',
'type' => 'latest_albums',
'button' => '',
'in_row' => '2',
'link' => '',
'url' => '',
'limit' => '4',
'classes' => ''
);
$instance = wp_parse_args( (array ) $instance, $defaults );
// Get acces to RascalsWidgets Class -> Fields
$RW = new RascalsWidgets();
// Tabs
$RW->tabsStart(
array(
esc_html__( 'General', 'noisa-toolkit' ),
esc_html__( 'Advanced', 'noisa-toolkit' )
)
);
// ----------------------- Tab 01
$RW->tabStart(1);
// Title
$RW->input_e( array(
'label' => esc_html__( 'Title:', 'noisa-toolkit' ),
'value' => $instance['title'],
'id' => $this->get_field_id( 'title' ),
'name' => $this->get_field_name( 'title' ),
'desc' => ''
));
// Gallery ID
$RW->select_e( array(
'label' => esc_html__( 'Select Album', 'noisa-toolkit' ),
'value' => $instance['gallery_id'],
'id' => $this->get_field_id( 'gallery_id' ),
'options' => $RW->getPosts( 'noisa_gallery' ),
'name' => $this->get_field_name( 'gallery_id' ),
'desc' => ''
));
// Type
$RW->select_e( array(
'label' => esc_html__( 'Display', 'noisa-toolkit' ),
'value' => $instance['type'],
'id' => $this->get_field_id( 'type' ),
'options' => array(
array(
'value' => 'latest_albums',
'label' => 'Latest Albums'
),
array(
'value' => 'latest_images',
'label' => 'Latest Images'
)
),
'name' => $this->get_field_name( 'type' ),
'desc' => ''
));
// Button
$RW->checkbox_e( array(
'label' => esc_html__( 'Last item as a button?', 'noisa-toolkit' ),
'value' => $instance['button'],
'id' => $this->get_field_id( 'button' ),
'name' => $this->get_field_name( 'button' ),
'desc' => ''
));
// URL
$RW->input_e( array(
'label' => esc_html__( 'Gallery link', 'noisa-toolkit' ),
'value' => $instance['url'],
'id' => $this->get_field_id( 'url' ),
'name' => $this->get_field_name( 'url' ),
'desc' => ''
));
// Limit
$RW->number_e( array(
'label' => esc_html__( 'Display limit', 'noisa-toolkit' ),
'value' => $instance['limit'],
'id' => $this->get_field_id( 'limit' ),
'min' => '1',
'max' => '100',
'units' => esc_html__( 'images', 'noisa-toolkit' ),
'name' => $this->get_field_name( 'limit' ),
'desc' => esc_html__( 'Number of photos to show.', 'noisa-toolkit' )
));
// Number of photos in row
$RW->select_e( array(
'label' => esc_html__( 'Items Per Row', 'noisa-toolkit' ),
'value' => $instance['in_row'],
'id' => $this->get_field_id( 'in_row' ),
'options' => array(
array(
'value' => '2',
'label' => '2'
),
array(
'value' => '3',
'label' => '3'
),
array(
'value' => '4',
'label' => '4'
),
array(
'value' => '5',
'label' => '5'
)
),
'name' => $this->get_field_name( 'in_row' ),
'desc' => esc_html__( 'Number of photos in one row.', 'noisa-toolkit' )
));
$RW->tabEnd();
// ----------------------- Tab 02
$RW->tabStart(2);
// Classes
$RW->input_e( array(
'label' => esc_html__( 'Classes', 'noisa-toolkit' ),
'value' => $instance['classes'],
'id' => $this->get_field_id( 'classes' ),
'name' => $this->get_field_name( 'classes' ),
'desc' => esc_html__( 'Style particular content element differently - add a class name and refer to it in custom CSS', 'noisa-toolkit' )
));
$RW->tabEnd();
$RW->tabsEnd();
}
}