start_controls_section( 'section_gallery', array( 'label' => '3pika Gallery' ) ); $options = tpika_gallery_options(); $this->add_control( 'gallery_id', array( 'label' => __( 'Gallery', '3pika-gallery' ), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => array( '' => __( '— Select a gallery —', '3pika-gallery' ) ) + $options, 'default' => '', 'description' => sprintf( '%s', esc_url( tpika_admin_url( 'tpika-new' ) ), __( 'Create a new gallery', '3pika-gallery' ) ), ) ); $this->add_control( 'override_heading', array( 'label' => __( 'Overrides (optional)', '3pika-gallery' ), 'type' => \Elementor\Controls_Manager::HEADING, 'separator' => 'before', ) ); $layouts = array( '' => __( 'Gallery default', '3pika-gallery' ), 'grid' => __( 'Grid', '3pika-gallery' ), 'mosaic' => __( 'Mosaic', '3pika-gallery' ), 'list' => __( 'List', '3pika-gallery' ), ); $paginations = array( '' => __( 'Gallery default', '3pika-gallery' ), 'none' => __( 'None', '3pika-gallery' ), 'numbers' => __( 'Numbers', '3pika-gallery' ), 'loadmore' => __( 'Load more', '3pika-gallery' ), ); $this->add_control( 'layout', array( 'label' => __( 'Layout', '3pika-gallery' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => '', 'options' => $layouts, ) ); $this->add_responsive_control( 'columns', array( 'label' => __( 'Columns', '3pika-gallery' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => '', 'options' => array( '' => __( 'Gallery default', '3pika-gallery' ), '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6' ), ) ); $this->add_control( 'filter', array( 'label' => __( 'Default filter (ID)', '3pika-gallery' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => '', 'description' => __( 'Leave empty to show all items.', '3pika-gallery' ), ) ); $this->add_control( 'pagination', array( 'label' => __( 'Pagination', '3pika-gallery' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => '', 'options' => $paginations, ) ); $this->add_control( 'per_page', array( 'label' => __( 'Items per page', '3pika-gallery' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'default' => '', 'min' => 1, 'max' => 200, ) ); $this->end_controls_section(); } protected function render() { $s = $this->get_settings_for_display(); $id = ! empty( $s['gallery_id'] ) ? absint( $s['gallery_id'] ) : 0; if ( ! $id ) { if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) { echo '
' . esc_html__( 'Select a gallery in the widget settings.', '3pika-gallery' ) . '
'; } return; } $args = array( 'layout' => $s['layout'], 'columns' => $s['columns'], 'columns_tablet' => isset( $s['columns_tablet'] ) ? $s['columns_tablet'] : '', 'columns_mobile' => isset( $s['columns_mobile'] ) ? $s['columns_mobile'] : '', 'filter' => $s['filter'], 'pagination' => $s['pagination'], 'per_page' => $s['per_page'], ); // In the editor the gallery script starts new galleries by itself (it watches the page for added galleries). echo wp_kses( TPIKA_Renderer::render( $id, $args ), tpika_kses_gallery() ); } }