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

188 lines 5.7 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' ); ?>" aria-label="<?php echo esc_attr__( 'Clear gallery', 'elementor' ); ?>">
85 <i class="eicon-trash-o" aria-hidden="true"></i>
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' ); ?>" aria-label="<?php echo esc_attr__( 'Add Images', 'elementor' ); ?>">
95 <i class="eicon-plus-circle" aria-hidden="true"></i>
96 </button>
97 </div>
98 </div>
99
100 <?php
101 /*
102 ?>
103 <div class="elementor-control-media__warnings" role="alert" style="display: none;">
104 <?php
105 Hints::get_notice_template( [
106 'type' => 'warning',
107 'content' => esc_html__( 'This image doesn’t contain ALT text - which is necessary for accessibility and SEO.', 'elementor' ),
108 'icon' => true,
109 ] );
110 ?>
111 </div>
112 <?php
113 */ ?>
114 <?php $this->maybe_display_io_hints(); ?>
115 </div>
116 </div>
117 <?php
118 }
119
120 private function maybe_display_io_hints() {
121 if ( Hints::should_display_hint( 'image-optimization' ) ) {
122 $content_text = esc_html__( 'Optimize your images to enhance site performance by using Image Optimizer.', 'elementor' );
123 $button_text = Hints::is_plugin_installed( 'image-optimization' ) ? esc_html__( 'Activate Plugin', 'elementor' ) : esc_html__( 'Install Plugin', 'elementor' );
124 $action_url = Hints::get_plugin_action_url( 'image-optimization' );
125 } elseif ( Hints::should_display_hint( 'image-optimization-connect' ) ) {
126 $content_text = esc_html__( "This image isn't optimized. You need to connect your Image Optimizer account first.", 'elementor' );
127 $button_text = esc_html__( 'Connect Now', 'elementor' );
128 $action_url = admin_url( 'admin.php?page=image-optimization-settings' );
129 } else {
130 return;
131 }
132
133 ?>
134 <div class="elementor-control-media__promotions" role="alert" style="display: none;">
135 <?php
136 Hints::get_notice_template( [
137 'display' => ! Hints::is_dismissed( 'image-optimization' ),
138 'type' => 'info',
139 'content' => $content_text,
140 'icon' => true,
141 'dismissible' => 'image_optimizer_hint',
142 'button_text' => $button_text,
143 'button_event' => 'image_optimizer_hint',
144 'button_data' => [
145 'action_url' => $action_url,
146 ],
147 ] ); ?>
148 </div>
149 <?php
150 }
151
152 /**
153 * Get gallery control default settings.
154 *
155 * Retrieve the default settings of the gallery control. Used to return the
156 * default settings while initializing the gallery control.
157 *
158 * @since 1.0.0
159 * @access protected
160 *
161 * @return array Control default settings.
162 */
163 protected function get_default_settings() {
164 return [
165 'label_block' => true,
166 'dynamic' => [
167 'categories' => [ TagsModule::GALLERY_CATEGORY ],
168 'returnType' => 'object',
169 ],
170 ];
171 }
172
173 /**
174 * Get gallery control default values.
175 *
176 * Retrieve the default value of the gallery control. Used to return the default
177 * values while initializing the gallery control.
178 *
179 * @since 1.0.0
180 * @access public
181 *
182 * @return array Control default value.
183 */
184 public function get_default_value() {
185 return [];
186 }
187 }
188