PluginProbe
Elementor Website Builder – more than just a page builder / 3.28.0-dev2
Elementor Website Builder – more than just a page builder v3.28.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 +4 -151 4.2.33.28.0-dev2 View file →
@@ -1,18 +1,15 @@
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 9 use Elementor\Utils;
11 -use Elementor\Core\Admin\Admin_Notices;
12 10
13 11 class Hints {
14 -
15 12 const INFO = 'info';
16 13 const SUCCESS = 'success';
17 14 const WARNING = 'warning';
18 15 const DANGER = 'danger';
@@ -17,20 +14,13 @@
17 14 const WARNING = 'warning';
18 15 const DANGER = 'danger';
19 16
20 17 const DEFINED = 'defined';
21 - const NOT_DEFINED = 'not_defined';
22 18 const DISMISSED = 'dismissed';
23 19 const CAPABILITY = 'capability';
24 20 const PLUGIN_INSTALLED = 'plugin_installed';
25 21 const PLUGIN_ACTIVE = 'plugin_active';
26 - const NOT_HAS_OPTION = 'not_has_option';
27 22
28 - const INSTALL = 'install';
29 - const ACTIVATE = 'activate';
30 - const CONNECT = 'connect';
31 - const CUSTOMIZE = 'customize';
32 -
33 23 /**
34 24 * Get_notice_types
35 25 *
36 26 * @return string[]
@@ -67,24 +57,13 @@
67 57 self::DISMISSED => 'image_optimizer_hint',
68 58 self::CAPABILITY => 'install_plugins',
69 59 self::DEFINED => 'IMAGE_OPTIMIZATION_VERSION',
70 60 ],
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 61 'image-optimization-media-modal' => [
78 62 self::DISMISSED => 'image-optimization-media-modal',
79 63 self::CAPABILITY => 'install_plugins',
80 64 self::DEFINED => 'IMAGE_OPTIMIZATION_VERSION',
81 65 ],
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 66 ];
88 67 if ( ! $hint_key ) {
89 68 return $hints;
90 69 }
@@ -110,13 +89,13 @@
110 89 *
111 90 * Print or Retrieve the notice template.
112 91 *
113 92 * @param array $notice
114 - * @param bool $should_return
93 + * @param bool $return
115 94 *
116 95 * @return string|void
117 96 */
118 - public static function get_notice_template( array $notice, bool $should_return = false ) {
97 + public static function get_notice_template( array $notice, bool $return = false ) {
119 98 $default_settings = [
120 99 'type' => 'info',
121 100 'icon' => false,
122 101 'heading' => '',
@@ -187,9 +166,9 @@
187 166 $dismissible,
188 167 $notice_settings['display']
189 168 );
190 169
191 - if ( $should_return ) {
170 + if ( $return ) {
192 171 return $notice_template;
193 172 }
194 173 echo wp_kses( $notice_template, self::get_notice_allowed_html() );
195 174 }
@@ -260,53 +239,29 @@
260 239 case self::DISMISSED:
261 240 if ( self::is_dismissed( $value ) ) {
262 241 return false;
263 242 }
264 -
265 243 break;
266 -
267 244 case self::CAPABILITY:
268 245 if ( ! current_user_can( $value ) ) {
269 246 return false;
270 247 }
271 -
272 248 break;
273 -
274 249 case self::DEFINED:
275 250 if ( defined( $value ) ) {
276 251 return false;
277 252 }
278 -
279 253 break;
280 -
281 - case self::NOT_DEFINED:
282 - if ( ! defined( $value ) ) {
283 - return false;
284 - }
285 -
286 - break;
287 -
288 254 case self::PLUGIN_INSTALLED:
289 255 if ( ! self::is_plugin_installed( $value ) ) {
290 256 return false;
291 257 }
292 -
293 258 break;
294 -
295 259 case self::PLUGIN_ACTIVE:
296 260 if ( ! self::is_plugin_active( $value ) ) {
297 261 return false;
298 262 }
299 -
300 263 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 264 }
310 265 }
311 266 return true;
312 267 }
@@ -344,12 +299,8 @@
344 299 *
345 300 * @return bool
346 301 */
347 302 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 -
352 303 $plugins = get_plugins();
353 304 $plugin = self::ensure_plugin_folder( $plugin );
354 305 return ! empty( $plugins[ $plugin ] );
355 306 }
@@ -361,12 +312,8 @@
361 312 *
362 313 * @return bool
363 314 */
364 315 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 316 $plugin = self::ensure_plugin_folder( $plugin );
370 317 return is_plugin_active( $plugin );
371 318 }
372 319
@@ -446,100 +393,6 @@
446 393 'style' => [],
447 394 'target' => [],
448 395 ],
449 396 ];
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 397 }
545 398 }