PluginProbe
Elementor Website Builder – more than just a page builder / 3.19.4
Elementor Website Builder – more than just a page builder v3.19.4
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.19.4, at includes/controls/gallery.php

192 lines 6.4 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\Core\Utils\Hints;
5 use Elementor\Modules\DynamicTags\Module as TagsModule;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly.
9 }
10
11 /**
12 * Elementor gallery control.
13 *
14 * A base control for creating gallery chooser control. Based on the WordPress
15 * media library galleries. Used to select images from the WordPress media library.
16 *
17 * @since 1.0.0
18 */
19 class Control_Gallery extends Base_Data_Control {
20
21 /**
22 * Get gallery control type.
23 *
24 * Retrieve the control type, in this case `gallery`.
25 *
26 * @since 1.0.0
27 * @access public
28 *
29 * @return string Control type.
30 */
31 public function get_type() {
32 return 'gallery';
33 }
34
35 /**
36 * Import gallery images.
37 *
38 * Used to import gallery control files from external sites while importing
39 * Elementor template JSON file, and replacing the old data.
40 *
41 * @since 1.0.0
42 * @access public
43 *
44 * @param array $settings Control settings
45 *
46 * @return array Control settings.
47 */
48 public function on_import( $settings ) {
49 foreach ( $settings as &$attachment ) {
50 if ( empty( $attachment['url'] ) ) {
51 continue;
52 }
53
54 $attachment = Plugin::$instance->templates_manager->get_import_images_instance()->import( $attachment );
55 }
56
57 // Filter out attachments that don't exist
58 $settings = array_filter( $settings );
59
60 return $settings;
61 }
62
63 /**
64 * Render gallery control output in the editor.
65 *
66 * Used to generate the control HTML in the editor using Underscore JS
67 * template. The variables for the class are available using `data` JS
68 * object.
69 *
70 * @since 1.0.0
71 * @access public
72 */
73 public function content_template() {
74 ?>
75 <div class="elementor-control-field">
76 <div class="elementor-control-title">{{{ data.label }}}</div>
77 <div class="elementor-control-input-wrapper">
78 <# if ( data.description ) { #>
79 <div class="elementor-control-field-description">{{{ data.description }}}</div>
80 <# } #>
81 <div class="elementor-control-media__content elementor-control-tag-area">
82 <div class="elementor-control-gallery-status elementor-control-dynamic-switcher-wrapper">
83 <span class="elementor-control-gallery-status-title"></span>
84 <button class="elementor-control-gallery-clear elementor-control-unit-1 tooltip-target" data-tooltip="<?php echo esc_attr__( 'Clear gallery', 'elementor' ); ?>">
85 <i class="eicon-trash-o" aria-hidden="true"></i>
86 <span class="elementor-screen-only"><?php echo esc_html__( 'Clear gallery', 'elementor' ); ?></span>
87 </button>
88 </div>
89 <div class="elementor-control-gallery-content">
90 <div class="elementor-control-gallery-thumbnails" tabindex="0"></div>
91 <div class="elementor-control-gallery-edit">
92 <span><i class="eicon-pencil" aria-hidden="true"></i></span>
93 <span class="elementor-screen-only"><?php echo esc_html__( 'Edit gallery', 'elementor' ); ?></span>
94 </div>
95 <button class="elementor-button elementor-control-gallery-add tooltip-target" data-tooltip="<?php echo esc_attr__( 'Add Images', 'elementor' ); ?>">
96 <i class="eicon-plus-circle" aria-hidden="true"></i>
97 <span class="elementor-screen-only"><?php echo esc_html__( 'Add Images', 'elementor' ); ?></span>
98 </button>
99 </div>
100 </div>
101 <?php if ( ! Hints::should_display_hint( 'image-optimization-once' ) && ! Hints::should_display_hint( 'image-optimization' ) ) { ?>
102 <div class="elementor-control-media__warnings elementor-descriptor" role="alert" style="display: none;">
103 <?php
104 Hints::get_notice_template( [
105 'type' => 'warning',
106 'content' => esc_html__( 'Images marked in red don’t contain ALT text - which is necessary for accessibility and SEO.', 'elementor' ),
107 'icon' => true,
108 ] );
109 ?>
110 </div>
111 <?php } ?>
112 <?php if ( Hints::should_display_hint( 'image-optimization-once' ) || Hints::should_display_hint( 'image-optimization' ) ) :
113 $once_dismissed = Hints::is_dismissed( 'image-optimization-once' );
114 if ( $once_dismissed ) {
115 if ( Hints::is_plugin_installed( 'image-optimization' ) ) {
116 $content = sprintf(
117 __( 'This image is large and may slow things down. %1$sActivate Image Optimizer%2$s to reduce size without losing quality.', 'elementor' ),
118 '<a href="' . Hints::get_plugin_action_url( 'image-optimization' ) . '" target="_blank">',
119 '</a>'
120 );
121 } else {
122 $content = sprintf(
123 __( 'This image is large and may slow things down. %1$sInstall Image Optimizer%2$s to reduce size without losing quality.', 'elementor' ),
124 '<a href="' . Hints::get_plugin_action_url( 'image-optimization' ) . '" target="_blank">',
125 '</a>'
126 );
127 }
128 } else {
129 $content = sprintf(
130 '%1$s <a href="%2$s" target="_blank">%3$s</a>',
131 esc_html__( 'Don’t let unoptimized images be the downfall of your site’s performance.', 'elementor' ),
132 Hints::get_plugin_action_url( 'image-optimization' ),
133 Hints::is_plugin_installed( 'image-optimization' ) ? esc_html__( 'Activate Image Optimizer!', 'elementor' ) : esc_html__( 'Install Image Optimizer!', 'elementor' )
134 );
135 }
136 $dismissible = $once_dismissed ? 'image_optimizer_hint' : 'image-optimization-once';
137 ?>
138 <div class="elementor-control-media__promotions elementor-descriptor" role="alert" style="display: none;">
139 <?php
140 Hints::get_notice_template( [
141 'display' => ! $once_dismissed,
142 'type' => $once_dismissed ? 'warning' : 'info',
143 'content' => $content,
144 'icon' => true,
145 'dismissible' => $dismissible,
146 ] );
147 ?>
148 </div>
149 <?php endif; ?>
150 </div>
151 </div>
152 <?php
153 }
154
155 /**
156 * Get gallery control default settings.
157 *
158 * Retrieve the default settings of the gallery control. Used to return the
159 * default settings while initializing the gallery control.
160 *
161 * @since 1.0.0
162 * @access protected
163 *
164 * @return array Control default settings.
165 */
166 protected function get_default_settings() {
167 return [
168 'label_block' => true,
169 'separator' => 'none',
170 'dynamic' => [
171 'categories' => [ TagsModule::GALLERY_CATEGORY ],
172 'returnType' => 'object',
173 ],
174 ];
175 }
176
177 /**
178 * Get gallery control default values.
179 *
180 * Retrieve the default value of the gallery control. Used to return the default
181 * values while initializing the gallery control.
182 *
183 * @since 1.0.0
184 * @access public
185 *
186 * @return array Control default value.
187 */
188 public function get_default_value() {
189 return [];
190 }
191 }
192