PluginProbe
Elementor Website Builder – more than just a page builder / 3.20.3
Elementor Website Builder – more than just a page builder v3.20.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
← All changes | core/utils/hints.php +22 -207 4.1.0-dev23.20.3 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[][]
@@ -67,24 +55,13 @@
67 55 self::DISMISSED => 'image_optimizer_hint',
68 56 self::CAPABILITY => 'install_plugins',
69 57 self::DEFINED => 'IMAGE_OPTIMIZATION_VERSION',
70 58 ],
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 59 'image-optimization-media-modal' => [
78 60 self::DISMISSED => 'image-optimization-media-modal',
79 61 self::CAPABILITY => 'install_plugins',
80 62 self::DEFINED => 'IMAGE_OPTIMIZATION_VERSION',
81 63 ],
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 64 ];
88 65 if ( ! $hint_key ) {
89 66 return $hints;
90 67 }
@@ -92,10 +69,9 @@
92 69 return $hints[ $hint_key ] ?? [];
93 70 }
94 71
95 72 /**
96 - * Get_notice_icon
97 - *
73 + * get_notice_icon
98 74 * @return string
99 75 */
100 76 public static function get_notice_icon(): string {
101 77 return '<div class="elementor-control-notice-icon">
@@ -105,18 +81,17 @@
105 81 </div>';
106 82 }
107 83
108 84 /**
109 - * Get_notice_template
85 + * get_notice_template
110 86 *
111 87 * Print or Retrieve the notice template.
112 - *
113 88 * @param array $notice
114 - * @param bool $should_return
89 + * @param bool $return
115 90 *
116 91 * @return string|void
117 92 */
118 - public static function get_notice_template( array $notice, bool $should_return = false ) {
93 + public static function get_notice_template( array $notice, bool $return = false ) {
119 94 $default_settings = [
120 95 'type' => 'info',
121 96 'icon' => false,
122 97 'heading' => '',
@@ -155,9 +130,9 @@
155 130 $content = '<div class="elementor-control-notice-main-content">' . $notice_settings['content'] . '</div>';
156 131 }
157 132
158 133 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'] ) ) . '"' : '';
134 + $button_settings = ( ! empty( $notice_settings['button_data'] ) ) ? ' data-settings="' . esc_attr( json_encode( $notice_settings['button_data'] ) ) . '"' : '';
160 135 $button = '<div class="elementor-control-notice-main-actions">
161 136 <button type="button" class="e-btn e-' . $notice_settings['type'] . ' e-btn-1" data-event="' . $notice_settings['button_event'] . '"' . $button_settings . '>
162 137 ' . $notice_settings['button_text'] . '
163 138 </button>
@@ -164,10 +139,11 @@
164 139 </div>';
165 140 }
166 141
167 142 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' ) . '">
143 + $dismissible = '<button class="elementor-control-notice-dismiss tooltip-target" data-event="' . $notice_settings['dismissible'] . '" data-tooltip="' . esc_attr__( 'Don’t show again.', 'elementor' ) . '">
169 144 <i class="eicon eicon-close" aria-hidden="true"></i>
145 + <span class="elementor-screen-only">' . esc_html__( 'Don’t show again.', 'elementor' ) . '</span>
170 146 </button>';
171 147 }
172 148
173 149 $notice_template = sprintf( '<div class="elementor-control-notice elementor-control-notice-type-%1$s" data-display="%7$s">
@@ -187,9 +163,9 @@
187 163 $dismissible,
188 164 $notice_settings['display']
189 165 );
190 166
191 - if ( $should_return ) {
167 + if ( $return ) {
192 168 return $notice_template;
193 169 }
194 170 echo wp_kses( $notice_template, self::get_notice_allowed_html() );
195 171 }
@@ -194,10 +170,9 @@
194 170 echo wp_kses( $notice_template, self::get_notice_allowed_html() );
195 171 }
196 172
197 173 /**
198 - * Get_plugin_install_url
199 - *
174 + * get_plugin_install_url
200 175 * @param $plugin_slug
201 176 *
202 177 * @return string
203 178 */
@@ -215,25 +190,19 @@
215 190 );
216 191 }
217 192
218 193 /**
219 - * Get_plugin_activate_url
220 - *
194 + * get_plugin_activate_url
221 195 * @param $plugin_slug
222 196 *
223 197 * @return string
224 198 */
225 199 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 - );
200 + return admin_url( 'plugins.php' );
231 201 }
232 202
233 203 /**
234 - * Is_dismissed
235 - *
204 + * is_dismissed
236 205 * @param $key
237 206 *
238 207 * @return bool
239 208 */
@@ -242,10 +211,9 @@
242 211 return in_array( $key, $dismissed, true );
243 212 }
244 213
245 214 /**
246 - * Should_display_hint
247 - *
215 + * should_display_hint
248 216 * @param $hint_key
249 217 *
250 218 * @return bool
251 219 */
@@ -260,96 +228,41 @@
260 228 case self::DISMISSED:
261 229 if ( self::is_dismissed( $value ) ) {
262 230 return false;
263 231 }
264 -
265 232 break;
266 -
267 233 case self::CAPABILITY:
268 234 if ( ! current_user_can( $value ) ) {
269 235 return false;
270 236 }
271 -
272 237 break;
273 -
274 238 case self::DEFINED:
275 239 if ( defined( $value ) ) {
276 240 return false;
277 241 }
278 -
279 242 break;
280 -
281 - case self::NOT_DEFINED:
282 - if ( ! defined( $value ) ) {
283 - return false;
284 - }
285 -
286 - break;
287 -
288 243 case self::PLUGIN_INSTALLED:
289 244 if ( ! self::is_plugin_installed( $value ) ) {
290 245 return false;
291 246 }
292 -
293 247 break;
294 -
295 248 case self::PLUGIN_ACTIVE:
296 249 if ( ! self::is_plugin_active( $value ) ) {
297 250 return false;
298 251 }
299 -
300 252 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 253 }
310 254 }
311 255 return true;
312 256 }
313 257
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 258 /**
341 - * Is_plugin_installed
342 - *
259 + * is_plugin_installed
343 260 * @param $plugin
344 261 *
345 262 * @return bool
346 263 */
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 -
264 + public static function is_plugin_installed( $plugin ) : bool {
352 265 $plugins = get_plugins();
353 266 $plugin = self::ensure_plugin_folder( $plugin );
354 267 return ! empty( $plugins[ $plugin ] );
355 268 }
@@ -354,10 +267,9 @@
354 267 return ! empty( $plugins[ $plugin ] );
355 268 }
356 269
357 270 /**
358 - * Is_plugin_active
359 - *
271 + * is_plugin_active
360 272 * @param $plugin
361 273 *
362 274 * @return bool
363 275 */
@@ -366,10 +278,9 @@
366 278 return is_plugin_active( $plugin );
367 279 }
368 280
369 281 /**
370 - * Get_plugin_action_url
371 - *
282 + * get_plugin_action_url
372 283 * @param $plugin
373 284 *
374 285 * @return string
375 286 */
@@ -385,10 +296,9 @@
385 296 return '';
386 297 }
387 298
388 299 /**
389 - * Ensure_plugin_folder
390 - *
300 + * ensure_plugin_folder
391 301 * @param $plugin
392 302 *
393 303 * @return string
394 304 */
@@ -399,10 +309,9 @@
399 309 return $plugin;
400 310 }
401 311
402 312 /**
403 - * Get_notice_allowed_html
404 - *
313 + * get_notice_allowed_html
405 314 * @return array[]
406 315 */
407 316 public static function get_notice_allowed_html(): array {
408 317 return [
@@ -442,100 +351,6 @@
442 351 'style' => [],
443 352 'target' => [],
444 353 ],
445 354 ];
446 - }
447 -
448 - public static function is_plugin_connected( $option_prefix ): bool {
449 - return ! empty( get_option( $option_prefix . '_access_token' ) );
450 - }
451 -
452 - public static function is_plugin_connected_to_one_subscription(): bool {
453 - return self::is_plugin_connected( 'elementor_one' );
454 - }
455 -
456 - private static function get_all_widget_content( $step, $one_subscription = false ) {
457 - if ( $one_subscription ) {
458 - $steps = [
459 - self::INSTALL => esc_html__( 'Want to create an inclusive experience? Install Ally, included in ONE, and add an accessibility widget to your site.', 'elementor' ),
460 - self::ACTIVATE => esc_html__( 'Your ONE subscription includes Ally. Activate it to place an accessibility widget on your site.', 'elementor' ),
461 - self::CONNECT => esc_html__( "Connect the Ally plugin to your account to access all of it's accessibility features.", 'elementor' ),
462 - self::CUSTOMIZE => esc_html__( "Customize the widget's look, position and the capabilities available for your visitors.", 'elementor' ),
463 - ];
464 - } else {
465 - $steps = [
466 - self::INSTALL => esc_html__( 'Install Ally to add an accessibility widget visitors can use to navigate your site.', 'elementor' ),
467 - self::ACTIVATE => esc_html__( 'Activate the Ally plugin to turn its accessibility features on across your site.', 'elementor' ),
468 - self::CONNECT => esc_html__( "Connect the Ally plugin to your account to access all of it's accessibility features.", 'elementor' ),
469 - self::CUSTOMIZE => esc_html__( "Customize the widget's look, position and the capabilities available for your visitors.", 'elementor' ),
470 - ];
471 - }
472 - return $steps[ $step ];
473 - }
474 -
475 - private static function get_all_widget_action_button( $step ) {
476 - $steps = [
477 - self::INSTALL => esc_html__( 'Install now', 'elementor' ),
478 - self::ACTIVATE => esc_html__( 'Activate now', 'elementor' ),
479 - self::CONNECT => esc_html__( 'Connect now', 'elementor' ),
480 - self::CUSTOMIZE => esc_html__( 'Customize', 'elementor' ),
481 - ];
482 - return $steps[ $step ];
483 - }
484 -
485 - private static function get_all_widget_action_url( $step, $one_subscription = false ) {
486 - if ( in_array( $step, [ self::INSTALL, self::ACTIVATE ], true ) ) {
487 - $action = ( self::INSTALL === $step ? 'install' : 'activate' );
488 - if ( $one_subscription ) {
489 - $campaign_data = [
490 - 'name' => 'elementor_ea11y_campaign',
491 - 'campaign' => 'acc-usability-widget-plg-ally-one-' . $action,
492 - 'source' => 'editor-ally-widget-one-' . $action,
493 - 'medium' => 'editor-one',
494 - ];
495 - } else {
496 - $campaign_data = [
497 - 'name' => 'elementor_ea11y_campaign',
498 - 'campaign' => 'acc-usability-widget-plg-ally',
499 - 'source' => 'editor-ally-widget',
500 - 'medium' => 'editor',
501 - ];
502 - }
503 - return Admin_Notices::add_plg_campaign_data( self::get_plugin_action_url( 'pojo-accessibility' ), $campaign_data );
504 - }
505 - return self::CONNECT === $step ? admin_url( 'admin.php?page=accessibility-settings' ) : admin_url( 'admin.php?page=accessibility-settings#design' );
506 - }
507 -
508 - private static function get_ally_cta_button( $step, $one_subscription = false ) {
509 - return [
510 - 'text' => self::get_all_widget_action_button( $step ),
511 - 'url' => self::get_all_widget_action_url( $step, $one_subscription ),
512 - 'classes' => [ 'elementor-button' ],
513 - ];
514 - }
515 -
516 - public static function get_ally_action_data(): array {
517 - $plugin_slug = 'pojo-accessibility';
518 - $is_installed = self::is_plugin_installed( $plugin_slug );
519 - $is_active = self::is_plugin_active( $plugin_slug );
520 - $is_connected = self::is_plugin_connected( 'ea11y' );
521 - $one_subscription = self::is_plugin_connected_to_one_subscription();
522 -
523 - if ( ! $is_installed ) {
524 - $step = self::INSTALL;
525 - } elseif ( ! $is_active ) {
526 - $step = self::ACTIVATE;
527 - } elseif ( ! $is_connected ) {
528 - $step = self::CONNECT;
529 - } else {
530 - $step = self::CUSTOMIZE;
531 - }
532 -
533 - $data = [
534 - 'title' => __( 'Ally web accessibility', 'elementor' ),
535 - 'content' => self::get_all_widget_content( $step, $one_subscription ),
536 - 'action_button' => self::get_ally_cta_button( $step, $one_subscription ),
537 - ];
538 -
539 - return $data;
540 355 }
541 356 }