mirror of
https://gh.wpcy.net/https://github.com/elementor/one-click-accessibility.git
synced 2026-04-21 13:06:02 +08:00
* Added `Notice_Base` and `Notices` component to core module
* Always load core module and load all other modules based on legacy status
* added filter in customizer settings
* added bubble / pimple in admin menu to indicate upgrade
* added `Dismissible_Deprecated_Nag` notice to none legacy pages
* added `Dismissible_Deprecated_Nag` notice to legacy pages
* Added `Upgrade` component to legacy module
includes:
* loading of notices
* introduction modal
* admin menu pimple
* customizer notice
* pointer
* confirmation modal
* upgrade logic and handler
* ✅ Fixed legacy module test
* added `local:quick-run` command to run in browser mode
* update phpunit workflow
* ensure wp.ajax is loaded
* wrong translations
* Updated strings
* added "Equally"
* remove unused test
61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace EA11y\Modules\Core\Components;
|
|
|
|
use EA11y\Classes\Utils\Notice_Base;
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit; // Exit if accessed directly.
|
|
}
|
|
|
|
class Notices {
|
|
const AJAX_ACTION = 'ea11y_admin_notice_dismiss';
|
|
|
|
/**
|
|
* @var Notice_Base[] $notices
|
|
*/
|
|
public array $notices = [];
|
|
|
|
public function register_notice( $notice_instance ) {
|
|
$this->notices[ $notice_instance->get_id() ] = $notice_instance;
|
|
}
|
|
|
|
public function show_notices() {
|
|
foreach ( $this->notices as $notice ) {
|
|
$notice->maybe_show_notice();
|
|
}
|
|
}
|
|
|
|
public function handle_dismiss() {
|
|
if ( empty( $_REQUEST['notice_id'] ) ) {
|
|
wp_send_json_error( [ 'message' => 'Invalid ID' ] );
|
|
}
|
|
|
|
$notice = $this->get_notice( sanitize_text_field( wp_unslash( $_REQUEST['notice_id'] ) ) );
|
|
if ( ! $notice ) {
|
|
wp_send_json_error( [ 'message' => 'Invalid ID' ] );
|
|
}
|
|
|
|
$notice->handle_dismiss();
|
|
|
|
wp_send_json_success( [] );
|
|
}
|
|
|
|
/**
|
|
* @param string $sanitize_text_field
|
|
*
|
|
* @return Notice_Base|null
|
|
*/
|
|
private function get_notice( string $sanitize_text_field ): ?Notice_Base {
|
|
return $this->notices[ $sanitize_text_field ] ?? null;
|
|
}
|
|
|
|
public function __construct() {
|
|
if ( ! is_admin() ) {
|
|
return;
|
|
}
|
|
add_action( 'admin_notices', [ $this, 'show_notices' ] );
|
|
add_action( 'wp_ajax_' . self::AJAX_ACTION, [ $this, 'handle_dismiss' ] );
|
|
do_action( 'ea11y_register_notices', $this );
|
|
}
|
|
}
|