PluginProbe
Elementor Website Builder – more than just a page builder / 3.20.0-dev2
Elementor Website Builder – more than just a page builder v3.20.0-dev2
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
← All changes | core/utils/hints.php +22 -221 4.2.23.20.0-dev2 View file →
@@ -1,18 +1,14 @@
1 1 <?php
2 -namespace Elementor\Core\Utils;
2 +namespace elementor\core\utils;
3 3
4 4 if ( ! defined( 'ABSPATH' ) ) {
5 5 exit; // Exit if accessed directly.
6 6 }
7 7
8 -use Elementor\Plugin;
9 8 use Elementor\User;
10 -use Elementor\Utils;
11 -use Elementor\Core\Admin\Admin_Notices;
12 9
13 10 class Hints {
14 -
15 11 const INFO = 'info';
16 12 const SUCCESS = 'success';
17 13 const WARNING = 'warning';
18 14 const DANGER = 'danger';
@@ -17,23 +13,15 @@
17 13 const WARNING = 'warning';
18 14 const DANGER = 'danger';
19 15
20 16 const DEFINED = 'defined';
21 - const NOT_DEFINED = 'not_defined';
22 17 const DISMISSED = 'dismissed';
23 18 const CAPABILITY = 'capability';
24 19 const PLUGIN_INSTALLED = 'plugin_installed';
25 20 const PLUGIN_ACTIVE = 'plugin_active';
26 - const NOT_HAS_OPTION = 'not_has_option';
27 21
28 - const INSTALL = 'install';
29 - const ACTIVATE = 'activate';
30 - const CONNECT = 'connect';
31 - const CUSTOMIZE = 'customize';
32 -
33 22 /**
34 - * Get_notice_types
35 - *
23 + * get_notice_types
36 24 * @return string[]
37 25 */
38 26 public static function get_notice_types(): array {
39 27 return [
@@ -44,9 +32,9 @@
44 32 ];
45 33 }
46 34
47 35 /**
48 - * Get_hints
36 + * get_hints
49 37 *
50 38 * @param $hint_key
51 39 *
52 40 * @return array|string[]|\string[][]
@@ -57,34 +45,13 @@
57 45 self::DISMISSED => 'image-optimization-once',
58 46 self::CAPABILITY => 'install_plugins',
59 47 self::DEFINED => 'IMAGE_OPTIMIZATION_VERSION',
60 48 ],
61 - 'image-optimization-once-media-modal' => [
62 - self::DISMISSED => 'image-optimization-once-media-modal',
63 - self::CAPABILITY => 'install_plugins',
64 - self::DEFINED => 'IMAGE_OPTIMIZATION_VERSION',
65 - ],
66 49 'image-optimization' => [
67 50 self::DISMISSED => 'image_optimizer_hint',
68 51 self::CAPABILITY => 'install_plugins',
69 52 self::DEFINED => 'IMAGE_OPTIMIZATION_VERSION',
70 53 ],
71 - 'image-optimization-connect' => [
72 - self::DISMISSED => 'image_optimizer_hint',
73 - self::CAPABILITY => 'manage_options',
74 - self::NOT_DEFINED => 'IMAGE_OPTIMIZATION_VERSION',
75 - self::NOT_HAS_OPTION => 'image_optimizer_access_token',
76 - ],
77 - 'image-optimization-media-modal' => [
78 - self::DISMISSED => 'image-optimization-media-modal',
79 - self::CAPABILITY => 'install_plugins',
80 - self::DEFINED => 'IMAGE_OPTIMIZATION_VERSION',
81 - ],
82 - 'ally_heading_notice' => [
83 - self::DISMISSED => 'ally_heading_notice',
84 - self::CAPABILITY => 'install_plugins',
85 - self::NOT_HAS_OPTION => 'ea11y_access_token',
86 - ],
87 54 ];
88 55 if ( ! $hint_key ) {
89 56 return $hints;
90 57 }
@@ -92,10 +59,9 @@
92 59 return $hints[ $hint_key ] ?? [];
93 60 }
94 61
95 62 /**
96 - * Get_notice_icon
97 - *
63 + * get_notice_icon
98 64 * @return string
99 65 */
100 66 public static function get_notice_icon(): string {
101 67 return '<div class="elementor-control-notice-icon">
@@ -105,18 +71,17 @@
105 71 </div>';
106 72 }
107 73
108 74 /**
109 - * Get_notice_template
75 + * get_notice_template
110 76 *
111 77 * Print or Retrieve the notice template.
112 - *
113 78 * @param array $notice
114 - * @param bool $should_return
79 + * @param bool $return
115 80 *
116 81 * @return string|void
117 82 */
118 - public static function get_notice_template( array $notice, bool $should_return = false ) {
83 + public static function get_notice_template( array $notice, bool $return = false ) {
119 84 $default_settings = [
120 85 'type' => 'info',
121 86 'icon' => false,
122 87 'heading' => '',
@@ -155,9 +120,9 @@
155 120 $content = '<div class="elementor-control-notice-main-content">' . $notice_settings['content'] . '</div>';
156 121 }
157 122
158 123 if ( ! empty( $notice_settings['button_text'] ) ) {
159 - $button_settings = ( ! empty( $notice_settings['button_data'] ) ) ? ' data-settings="' . esc_attr( wp_json_encode( $notice_settings['button_data'] ) ) . '"' : '';
124 + $button_settings = ( ! empty( $notice_settings['button_data'] ) ) ? ' data-settings="' . esc_attr( json_encode( $notice_settings['button_data'] ) ) . '"' : '';
160 125 $button = '<div class="elementor-control-notice-main-actions">
161 126 <button type="button" class="e-btn e-' . $notice_settings['type'] . ' e-btn-1" data-event="' . $notice_settings['button_event'] . '"' . $button_settings . '>
162 127 ' . $notice_settings['button_text'] . '
163 128 </button>
@@ -164,10 +129,11 @@
164 129 </div>';
165 130 }
166 131
167 132 if ( $notice_settings['dismissible'] ) {
168 - $dismissible = '<button class="elementor-control-notice-dismiss tooltip-target" data-event="' . $notice_settings['dismissible'] . '" data-tooltip="' . esc_attr__( 'Don’t show again.', 'elementor' ) . '" aria-label="' . esc_attr__( 'Don’t show again.', 'elementor' ) . '">
133 + $dismissible = '<button class="elementor-control-notice-dismiss tooltip-target" data-event="' . $notice_settings['dismissible'] . '" data-tooltip="' . esc_attr__( 'Don’t show again.', 'elementor' ) . '">
169 134 <i class="eicon eicon-close" aria-hidden="true"></i>
135 + <span class="elementor-screen-only">' . esc_html__( 'Don’t show again.', 'elementor' ) . '</span>
170 136 </button>';
171 137 }
172 138
173 139 $notice_template = sprintf( '<div class="elementor-control-notice elementor-control-notice-type-%1$s" data-display="%7$s">
@@ -187,9 +153,9 @@
187 153 $dismissible,
188 154 $notice_settings['display']
189 155 );
190 156
191 - if ( $should_return ) {
157 + if ( $return ) {
192 158 return $notice_template;
193 159 }
194 160 echo wp_kses( $notice_template, self::get_notice_allowed_html() );
195 161 }
@@ -194,10 +160,9 @@
194 160 echo wp_kses( $notice_template, self::get_notice_allowed_html() );
195 161 }
196 162
197 163 /**
198 - * Get_plugin_install_url
199 - *
164 + * get_plugin_install_url
200 165 * @param $plugin_slug
201 166 *
202 167 * @return string
203 168 */
@@ -215,25 +180,19 @@
215 180 );
216 181 }
217 182
218 183 /**
219 - * Get_plugin_activate_url
220 - *
184 + * get_plugin_activate_url
221 185 * @param $plugin_slug
222 186 *
223 187 * @return string
224 188 */
225 189 public static function get_plugin_activate_url( $plugin_slug ): string {
226 - $path = "$plugin_slug/$plugin_slug.php";
227 - return wp_nonce_url(
228 - admin_url( 'plugins.php?action=activate&plugin=' . $path ),
229 - 'activate-plugin_' . $path
230 - );
190 + return admin_url( 'plugins.php' );
231 191 }
232 192
233 193 /**
234 - * Is_dismissed
235 - *
194 + * is_dismissed
236 195 * @param $key
237 196 *
238 197 * @return bool
239 198 */
@@ -242,10 +201,9 @@
242 201 return in_array( $key, $dismissed, true );
243 202 }
244 203
245 204 /**
246 - * Should_display_hint
247 - *
205 + * should_display_hint
248 206 * @param $hint_key
249 207 *
250 208 * @return bool
251 209 */
@@ -260,96 +218,41 @@
260 218 case self::DISMISSED:
261 219 if ( self::is_dismissed( $value ) ) {
262 220 return false;
263 221 }
264 -
265 222 break;
266 -
267 223 case self::CAPABILITY:
268 224 if ( ! current_user_can( $value ) ) {
269 225 return false;
270 226 }
271 -
272 227 break;
273 -
274 228 case self::DEFINED:
275 229 if ( defined( $value ) ) {
276 230 return false;
277 231 }
278 -
279 232 break;
280 -
281 - case self::NOT_DEFINED:
282 - if ( ! defined( $value ) ) {
283 - return false;
284 - }
285 -
286 - break;
287 -
288 233 case self::PLUGIN_INSTALLED:
289 234 if ( ! self::is_plugin_installed( $value ) ) {
290 235 return false;
291 236 }
292 -
293 237 break;
294 -
295 238 case self::PLUGIN_ACTIVE:
296 239 if ( ! self::is_plugin_active( $value ) ) {
297 240 return false;
298 241 }
299 -
300 242 break;
301 -
302 - case self::NOT_HAS_OPTION:
303 - $option = get_option( $value );
304 - if ( ! empty( $option ) ) {
305 - return false;
306 - }
307 -
308 - break;
309 243 }
310 244 }
311 245 return true;
312 246 }
313 247
314 - private static function is_conflict_plugin_installed(): bool {
315 - if ( ! Utils::has_pro() ) {
316 - return false;
317 - }
318 -
319 - $conflicting_plugins = [
320 - 'imagify/imagify.php',
321 - 'optimole-wp/optimole-wp.php',
322 - 'ewww-image-optimizer/ewww-image-optimizer.php',
323 - 'ewww-image-optimizer-cloud/ewww-image-optimizer-cloud.php',
324 - 'kraken-image-optimizer/kraken.php',
325 - 'shortpixel-image-optimiser/wp-shortpixel.php',
326 - 'wp-smushit/wp-smush.php',
327 - 'wp-smush-pro/wp-smush.php',
328 - 'tiny-compress-images/tiny-compress-images.php',
329 - ];
330 -
331 - foreach ( $conflicting_plugins as $plugin ) {
332 - if ( self::is_plugin_active( $plugin ) ) {
333 - return true;
334 - }
335 - }
336 -
337 - return false;
338 - }
339 -
340 248 /**
341 - * Is_plugin_installed
342 - *
249 + * is_plugin_installed
343 250 * @param $plugin
344 251 *
345 252 * @return bool
346 253 */
347 - public static function is_plugin_installed( $plugin ): bool {
348 - if ( ! function_exists( 'get_plugins' ) ) {
349 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
350 - }
351 -
254 + public static function is_plugin_installed( $plugin ) : bool {
352 255 $plugins = get_plugins();
353 256 $plugin = self::ensure_plugin_folder( $plugin );
354 257 return ! empty( $plugins[ $plugin ] );
355 258 }
@@ -354,26 +257,20 @@
354 257 return ! empty( $plugins[ $plugin ] );
355 258 }
356 259
357 260 /**
358 - * Is_plugin_active
359 - *
261 + * is_plugin_active
360 262 * @param $plugin
361 263 *
362 264 * @return bool
363 265 */
364 266 public static function is_plugin_active( $plugin ): bool {
365 - if ( ! function_exists( 'is_plugin_active' ) ) {
366 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
367 - }
368 -
369 267 $plugin = self::ensure_plugin_folder( $plugin );
370 268 return is_plugin_active( $plugin );
371 269 }
372 270
373 271 /**
374 - * Get_plugin_action_url
375 - *
272 + * get_plugin_action_url
376 273 * @param $plugin
377 274 *
378 275 * @return string
379 276 */
@@ -389,10 +286,9 @@
389 286 return '';
390 287 }
391 288
392 289 /**
393 - * Ensure_plugin_folder
394 - *
290 + * ensure_plugin_folder
395 291 * @param $plugin
396 292 *
397 293 * @return string
398 294 */
@@ -403,10 +299,9 @@
403 299 return $plugin;
404 300 }
405 301
406 302 /**
407 - * Get_notice_allowed_html
408 - *
303 + * get_notice_allowed_html
409 304 * @return array[]
410 305 */
411 306 public static function get_notice_allowed_html(): array {
412 307 return [
@@ -446,100 +341,6 @@
446 341 'style' => [],
447 342 'target' => [],
448 343 ],
449 344 ];
450 - }
451 -
452 - public static function is_plugin_connected( $option_prefix ): bool {
453 - return ! empty( get_option( $option_prefix . '_access_token' ) );
454 - }
455 -
456 - public static function is_plugin_connected_to_one_subscription(): bool {
457 - return self::is_plugin_connected( 'elementor_one' );
458 - }
459 -
460 - private static function get_all_widget_content( $step, $one_subscription = false ) {
461 - if ( $one_subscription ) {
462 - $steps = [
463 - self::INSTALL => esc_html__( 'Want to create an inclusive experience? Install Web Accessibility, included in ONE, and add an accessibility widget to your site.', 'elementor' ),
464 - self::ACTIVATE => esc_html__( 'Your ONE subscription includes Web Accessibility. Activate it to place an accessibility widget on your site.', 'elementor' ),
465 - self::CONNECT => esc_html__( "Connect the Web Accessibility plugin to your account to access all of it's accessibility features.", 'elementor' ),
466 - self::CUSTOMIZE => esc_html__( "Customize the widget's look, position and the capabilities available for your visitors.", 'elementor' ),
467 - ];
468 - } else {
469 - $steps = [
470 - self::INSTALL => esc_html__( 'Install Web Accessibility to add an accessibility widget visitors can use to navigate your site.', 'elementor' ),
471 - self::ACTIVATE => esc_html__( 'Activate the Web Accessibility plugin to turn its accessibility features on across your site.', 'elementor' ),
472 - self::CONNECT => esc_html__( "Connect the Web Accessibility plugin to your account to access all of it's accessibility features.", 'elementor' ),
473 - self::CUSTOMIZE => esc_html__( "Customize the widget's look, position and the capabilities available for your visitors.", 'elementor' ),
474 - ];
475 - }
476 - return $steps[ $step ];
477 - }
478 -
479 - private static function get_all_widget_action_button( $step ) {
480 - $steps = [
481 - self::INSTALL => esc_html__( 'Install now', 'elementor' ),
482 - self::ACTIVATE => esc_html__( 'Activate now', 'elementor' ),
483 - self::CONNECT => esc_html__( 'Connect now', 'elementor' ),
484 - self::CUSTOMIZE => esc_html__( 'Customize', 'elementor' ),
485 - ];
486 - return $steps[ $step ];
487 - }
488 -
489 - private static function get_all_widget_action_url( $step, $one_subscription = false ) {
490 - if ( in_array( $step, [ self::INSTALL, self::ACTIVATE ], true ) ) {
491 - $action = ( self::INSTALL === $step ? 'install' : 'activate' );
492 - if ( $one_subscription ) {
493 - $campaign_data = [
494 - 'name' => 'elementor_ea11y_campaign',
495 - 'campaign' => 'acc-usability-widget-plg-ally-one-' . $action,
496 - 'source' => 'editor-ally-widget-one-' . $action,
497 - 'medium' => 'editor-one',
498 - ];
499 - } else {
500 - $campaign_data = [
501 - 'name' => 'elementor_ea11y_campaign',
502 - 'campaign' => 'acc-usability-widget-plg-ally',
503 - 'source' => 'editor-ally-widget',
504 - 'medium' => 'editor',
505 - ];
506 - }
507 - return Admin_Notices::add_plg_campaign_data( self::get_plugin_action_url( 'pojo-accessibility' ), $campaign_data );
508 - }
509 - return self::CONNECT === $step ? admin_url( 'admin.php?page=accessibility-settings' ) : admin_url( 'admin.php?page=accessibility-settings#design' );
510 - }
511 -
512 - private static function get_ally_cta_button( $step, $one_subscription = false ) {
513 - return [
514 - 'text' => self::get_all_widget_action_button( $step ),
515 - 'url' => self::get_all_widget_action_url( $step, $one_subscription ),
516 - 'classes' => [ 'elementor-button' ],
517 - ];
518 - }
519 -
520 - public static function get_ally_action_data(): array {
521 - $plugin_slug = 'pojo-accessibility';
522 - $is_installed = self::is_plugin_installed( $plugin_slug );
523 - $is_active = self::is_plugin_active( $plugin_slug );
524 - $is_connected = self::is_plugin_connected( 'ea11y' );
525 - $one_subscription = self::is_plugin_connected_to_one_subscription();
526 -
527 - if ( ! $is_installed ) {
528 - $step = self::INSTALL;
529 - } elseif ( ! $is_active ) {
530 - $step = self::ACTIVATE;
531 - } elseif ( ! $is_connected ) {
532 - $step = self::CONNECT;
533 - } else {
534 - $step = self::CUSTOMIZE;
535 - }
536 -
537 - $data = [
538 - 'title' => __( 'Web accessibility', 'elementor' ),
539 - 'content' => self::get_all_widget_content( $step, $one_subscription ),
540 - 'action_button' => self::get_ally_cta_button( $step, $one_subscription ),
541 - ];
542 -
543 - return $data;
544 345 }
545 346 }