| @@ -4,9 +4,8 @@ | ||
| 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 | 10 | use Elementor\Core\Admin\Admin_Notices; |
| 12 | 11 | |
| @@ -110,13 +109,13 @@ | ||
| 110 | 109 | * |
| 111 | 110 | * Print or Retrieve the notice template. |
| 112 | 111 | * |
| 113 | 112 | * @param array $notice |
| 114 | - * @param bool $should_return | |
| 113 | + * @param bool $return | |
| 115 | 114 | * |
| 116 | 115 | * @return string|void |
| 117 | 116 | */ |
| 118 | - public static function get_notice_template( array $notice, bool $should_return = false ) { | |
| 117 | + public static function get_notice_template( array $notice, bool $return = false ) { | |
| 119 | 118 | $default_settings = [ |
| 120 | 119 | 'type' => 'info', |
| 121 | 120 | 'icon' => false, |
| 122 | 121 | 'heading' => '', |
| @@ -187,9 +186,9 @@ | ||
| 187 | 186 | $dismissible, |
| 188 | 187 | $notice_settings['display'] |
| 189 | 188 | ); |
| 190 | 189 | |
| 191 | - if ( $should_return ) { | |
| 190 | + if ( $return ) { | |
| 192 | 191 | return $notice_template; |
| 193 | 192 | } |
| 194 | 193 | echo wp_kses( $notice_template, self::get_notice_allowed_html() ); |
| 195 | 194 | } |
| @@ -344,12 +343,8 @@ | ||
| 344 | 343 | * |
| 345 | 344 | * @return bool |
| 346 | 345 | */ |
| 347 | 346 | 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 | 347 | $plugins = get_plugins(); |
| 353 | 348 | $plugin = self::ensure_plugin_folder( $plugin ); |
| 354 | 349 | return ! empty( $plugins[ $plugin ] ); |
| 355 | 350 | } |
| @@ -361,12 +356,8 @@ | ||
| 361 | 356 | * |
| 362 | 357 | * @return bool |
| 363 | 358 | */ |
| 364 | 359 | 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 | 360 | $plugin = self::ensure_plugin_folder( $plugin ); |
| 370 | 361 | return is_plugin_active( $plugin ); |
| 371 | 362 | } |
| 372 | 363 | |
| @@ -452,68 +443,45 @@ | ||
| 452 | 443 | public static function is_plugin_connected( $option_prefix ): bool { |
| 453 | 444 | return ! empty( get_option( $option_prefix . '_access_token' ) ); |
| 454 | 445 | } |
| 455 | 446 | |
| 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 | - } | |
| 447 | + private static function get_all_widget_content( $step ) { | |
| 448 | + $steps = [ | |
| 449 | + self::INSTALL => esc_html__( 'Install Ally to add an accessibility widget visitors can use to navigate your site.', 'elementor' ), | |
| 450 | + self::ACTIVATE => esc_html__( 'Activate the Ally plugin to turn its accessibility features on across your site.', 'elementor' ), | |
| 451 | + self::CONNECT => esc_html__( "Connect the Ally plugin to your account to access all of it's accessibility features.", 'elementor' ), | |
| 452 | + self::CUSTOMIZE => esc_html__( "Customize the widget's look, position and the capabilities available for your visitors.", 'elementor' ), | |
| 453 | + ]; | |
| 476 | 454 | return $steps[ $step ]; |
| 477 | 455 | } |
| 478 | 456 | |
| 479 | 457 | private static function get_all_widget_action_button( $step ) { |
| 480 | 458 | $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' ), | |
| 459 | + self::INSTALL => esc_html__( 'install Now', 'elementor' ), | |
| 460 | + self::ACTIVATE => esc_html__( 'Activate', 'elementor' ), | |
| 461 | + self::CONNECT => esc_html__( 'Connect', 'elementor' ), | |
| 484 | 462 | self::CUSTOMIZE => esc_html__( 'Customize', 'elementor' ), |
| 485 | 463 | ]; |
| 486 | 464 | return $steps[ $step ]; |
| 487 | 465 | } |
| 488 | 466 | |
| 489 | - private static function get_all_widget_action_url( $step, $one_subscription = false ) { | |
| 467 | + private static function get_all_widget_action_url( $step ) { | |
| 490 | 468 | 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 | - } | |
| 469 | + $campaign_data = [ | |
| 470 | + 'name' => 'elementor_ea11y_campaign', | |
| 471 | + 'campaign' => 'acc-usability-widget-plg-ally', | |
| 472 | + 'source' => 'editor-ally-widget', | |
| 473 | + 'medium' => 'editor', | |
| 474 | + ]; | |
| 507 | 475 | return Admin_Notices::add_plg_campaign_data( self::get_plugin_action_url( 'pojo-accessibility' ), $campaign_data ); |
| 508 | 476 | } |
| 509 | 477 | return self::CONNECT === $step ? admin_url( 'admin.php?page=accessibility-settings' ) : admin_url( 'admin.php?page=accessibility-settings#design' ); |
| 510 | 478 | } |
| 511 | 479 | |
| 512 | - private static function get_ally_cta_button( $step, $one_subscription = false ) { | |
| 480 | + private static function get_ally_cta_button( $step ) { | |
| 513 | 481 | return [ |
| 514 | 482 | 'text' => self::get_all_widget_action_button( $step ), |
| 515 | - 'url' => self::get_all_widget_action_url( $step, $one_subscription ), | |
| 483 | + 'url' => self::get_all_widget_action_url( $step ), | |
| 516 | 484 | 'classes' => [ 'elementor-button' ], |
| 517 | 485 | ]; |
| 518 | 486 | } |
| 519 | 487 | |
| @@ -521,15 +489,14 @@ | ||
| 521 | 489 | $plugin_slug = 'pojo-accessibility'; |
| 522 | 490 | $is_installed = self::is_plugin_installed( $plugin_slug ); |
| 523 | 491 | $is_active = self::is_plugin_active( $plugin_slug ); |
| 524 | 492 | $is_connected = self::is_plugin_connected( 'ea11y' ); |
| 525 | - $one_subscription = self::is_plugin_connected_to_one_subscription(); | |
| 526 | 493 | |
| 527 | 494 | if ( ! $is_installed ) { |
| 528 | 495 | $step = self::INSTALL; |
| 529 | - } elseif ( ! $is_active ) { | |
| 496 | + } else if ( ! $is_active ) { | |
| 530 | 497 | $step = self::ACTIVATE; |
| 531 | - } elseif ( ! $is_connected ) { | |
| 498 | + } else if ( ! $is_connected ) { | |
| 532 | 499 | $step = self::CONNECT; |
| 533 | 500 | } else { |
| 534 | 501 | $step = self::CUSTOMIZE; |
| 535 | 502 | } |
| @@ -534,11 +501,11 @@ | ||
| 534 | 501 | $step = self::CUSTOMIZE; |
| 535 | 502 | } |
| 536 | 503 | |
| 537 | 504 | $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 ), | |
| 505 | + 'title' => __( 'Ally web accessibility', 'elementor' ), | |
| 506 | + 'content' => self::get_all_widget_content( $step ), | |
| 507 | + 'action_button' => self::get_ally_cta_button( $step ), | |
| 541 | 508 | ]; |
| 542 | 509 | |
| 543 | 510 | return $data; |
| 544 | 511 | } |