PluginProbe
Elementor Website Builder – more than just a page builder / 3.16.6
Elementor Website Builder – more than just a page builder v3.16.6
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / includes / controls / gallery.php

gallery.php in Elementor Website Builder – more than just a page builder 3.16.6, at includes/controls/gallery.php

142 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 use Elementor\Modules\DynamicTags\Module as TagsModule;
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly.
8 }
9
10 /**
11 * Elementor gallery control.
12 *
13 * A base control for creating gallery chooser control. Based on the WordPress
14 * media library galleries. Used to select images from the WordPress media library.
15 *
16 * @since 1.0.0
17 */
18 class Control_Gallery extends Base_Data_Control {
19
20 /**
21 * Get gallery control type.
22 *
23 * Retrieve the control type, in this case `gallery`.
24 *
25 * @since 1.0.0
26 * @access public
27 *
28 * @return string Control type.
29 */
30 public function get_type() {
31 return 'gallery';
32 }
33
34 /**
35 * Import gallery images.
36 *
37 * Used to import gallery control files from external sites while importing
38 * Elementor template JSON file, and replacing the old data.
39 *
40 * @since 1.0.0
41 * @access public
42 *
43 * @param array $settings Control settings
44 *
45 * @return array Control settings.
46 */
47 public function on_import( $settings ) {
48 foreach ( $settings as &$attachment ) {
49 if ( empty( $attachment['url'] ) ) {
50 continue;
51 }
52
53 $attachment = Plugin::$instance->templates_manager->get_import_images_instance()->import( $attachment );
54 }
55
56 // Filter out attachments that don't exist
57 $settings = array_filter( $settings );
58
59 return $settings;
60 }
61
62 /**
63 * Render gallery control output in the editor.
64 *
65 * Used to generate the control HTML in the editor using Underscore JS
66 * template. The variables for the class are available using `data` JS
67 * object.
68 *
69 * @since 1.0.0
70 * @access public
71 */
72 public function content_template() {
73 ?>
74 <div class="elementor-control-field">
75 <div class="elementor-control-title">{{{ data.label }}}</div>
76 <div class="elementor-control-input-wrapper">
77 <# if ( data.description ) { #>
78 <div class="elementor-control-field-description">{{{ data.description }}}</div>
79 <# } #>
80 <div class="elementor-control-media__content elementor-control-tag-area">
81 <div class="elementor-control-gallery-status elementor-control-dynamic-switcher-wrapper">
82 <span class="elementor-control-gallery-status-title"></span>
83 <button class="elementor-control-gallery-clear elementor-control-unit-1 tooltip-target" data-tooltip="<?php echo esc_attr__( 'Clear gallery', 'elementor' ); ?>">
84 <i class="eicon-trash-o" aria-hidden="true"></i>
85 <span class="elementor-screen-only"><?php echo esc_html__( 'Clear gallery', 'elementor' ); ?></span>
86 </button>
87 </div>
88 <div class="elementor-control-gallery-content">
89 <div class="elementor-control-gallery-thumbnails" tabindex="0"></div>
90 <div class="elementor-control-gallery-edit">
91 <span><i class="eicon-pencil" aria-hidden="true"></i></span>
92 <span class="elementor-screen-only"><?php echo esc_html__( 'Edit gallery', 'elementor' ); ?></span>
93 </div>
94 <button class="elementor-button elementor-control-gallery-add tooltip-target" data-tooltip="<?php echo esc_attr__( 'Add Images', 'elementor' ); ?>">
95 <i class="eicon-plus-circle" aria-hidden="true"></i>
96 <span class="elementor-screen-only"><?php echo esc_html__( 'Add Images', 'elementor' ); ?></span>
97 </button>
98 </div>
99 </div>
100 </div>
101 </div>
102 <?php
103 }
104
105 /**
106 * Get gallery control default settings.
107 *
108 * Retrieve the default settings of the gallery control. Used to return the
109 * default settings while initializing the gallery control.
110 *
111 * @since 1.0.0
112 * @access protected
113 *
114 * @return array Control default settings.
115 */
116 protected function get_default_settings() {
117 return [
118 'label_block' => true,
119 'separator' => 'none',
120 'dynamic' => [
121 'categories' => [ TagsModule::GALLERY_CATEGORY ],
122 'returnType' => 'object',
123 ],
124 ];
125 }
126
127 /**
128 * Get gallery control default values.
129 *
130 * Retrieve the default value of the gallery control. Used to return the default
131 * values while initializing the gallery control.
132 *
133 * @since 1.0.0
134 * @access public
135 *
136 * @return array Control default value.
137 */
138 public function get_default_value() {
139 return [];
140 }
141 }
142