| @@ -4,12 +4,10 @@ | ||
| 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 | 12 | |
| 15 | 13 | const INFO = 'info'; |
| @@ -24,13 +22,8 @@ | ||
| 24 | 22 | const PLUGIN_INSTALLED = 'plugin_installed'; |
| 25 | 23 | const PLUGIN_ACTIVE = 'plugin_active'; |
| 26 | 24 | const NOT_HAS_OPTION = 'not_has_option'; |
| 27 | 25 | |
| 28 | - const INSTALL = 'install'; | |
| 29 | - const ACTIVATE = 'activate'; | |
| 30 | - const CONNECT = 'connect'; | |
| 31 | - const CUSTOMIZE = 'customize'; | |
| 32 | - | |
| 33 | 26 | /** |
| 34 | 27 | * Get_notice_types |
| 35 | 28 | * |
| 36 | 29 | * @return string[] |
| @@ -78,13 +71,8 @@ | ||
| 78 | 71 | self::DISMISSED => 'image-optimization-media-modal', |
| 79 | 72 | self::CAPABILITY => 'install_plugins', |
| 80 | 73 | self::DEFINED => 'IMAGE_OPTIMIZATION_VERSION', |
| 81 | 74 | ], |
| 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 | 75 | ]; |
| 88 | 76 | if ( ! $hint_key ) { |
| 89 | 77 | return $hints; |
| 90 | 78 | } |
| @@ -110,13 +98,13 @@ | ||
| 110 | 98 | * |
| 111 | 99 | * Print or Retrieve the notice template. |
| 112 | 100 | * |
| 113 | 101 | * @param array $notice |
| 114 | - * @param bool $should_return | |
| 102 | + * @param bool $return | |
| 115 | 103 | * |
| 116 | 104 | * @return string|void |
| 117 | 105 | */ |
| 118 | - public static function get_notice_template( array $notice, bool $should_return = false ) { | |
| 106 | + public static function get_notice_template( array $notice, bool $return = false ) { | |
| 119 | 107 | $default_settings = [ |
| 120 | 108 | 'type' => 'info', |
| 121 | 109 | 'icon' => false, |
| 122 | 110 | 'heading' => '', |
| @@ -187,9 +175,9 @@ | ||
| 187 | 175 | $dismissible, |
| 188 | 176 | $notice_settings['display'] |
| 189 | 177 | ); |
| 190 | 178 | |
| 191 | - if ( $should_return ) { | |
| 179 | + if ( $return ) { | |
| 192 | 180 | return $notice_template; |
| 193 | 181 | } |
| 194 | 182 | echo wp_kses( $notice_template, self::get_notice_allowed_html() ); |
| 195 | 183 | } |
| @@ -344,12 +332,8 @@ | ||
| 344 | 332 | * |
| 345 | 333 | * @return bool |
| 346 | 334 | */ |
| 347 | 335 | 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 | 336 | $plugins = get_plugins(); |
| 353 | 337 | $plugin = self::ensure_plugin_folder( $plugin ); |
| 354 | 338 | return ! empty( $plugins[ $plugin ] ); |
| 355 | 339 | } |
| @@ -442,100 +426,6 @@ | ||
| 442 | 426 | 'style' => [], |
| 443 | 427 | 'target' => [], |
| 444 | 428 | ], |
| 445 | 429 | ]; |
| 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 | 430 | } |
| 541 | 431 | } |