-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
545 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ public static function get_module_list(): array { | |
'Connect', | ||
'Settings', | ||
'Widget', | ||
'Core', | ||
]; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace EA11y\Modules\Core\Components; | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; // Exit if accessed directly. | ||
} | ||
|
||
class Pointers { | ||
const DISMISSED_POINTERS_META_KEY = 'ea11y_dismissed_pointers'; | ||
|
||
public function dismiss_pointers() { | ||
if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'ea11y-pointer-dismissed' ) ) { | ||
wp_send_json_error( [ 'message' => 'Invalid nonce' ] ); | ||
} | ||
|
||
$pointer = sanitize_text_field( $_POST['data']['pointer'] ) ?? null; | ||
|
||
if ( empty( $pointer ) ) { | ||
wp_send_json_error( [ 'message' => 'The pointer id must be provided' ] ); | ||
} | ||
|
||
$pointer = explode( ',', $pointer ); | ||
|
||
$user_dismissed_meta = get_user_meta( get_current_user_id(), self::DISMISSED_POINTERS_META_KEY, true ); | ||
|
||
if ( ! $user_dismissed_meta ) { | ||
$user_dismissed_meta = []; | ||
} | ||
|
||
foreach ( $pointer as $item ) { | ||
$user_dismissed_meta[ $item ] = true; | ||
} | ||
|
||
update_user_meta( get_current_user_id(), self::DISMISSED_POINTERS_META_KEY, $user_dismissed_meta ); | ||
|
||
wp_send_json_success( [] ); | ||
} | ||
|
||
public static function is_dismissed( string $slug ): bool { | ||
$meta = (array) get_user_meta( get_current_user_id(), self::DISMISSED_POINTERS_META_KEY, true ); | ||
|
||
return key_exists( $slug, $meta ); | ||
} | ||
|
||
public function __construct() { | ||
add_action( 'wp_ajax_ea11y_pointer_dismissed', [ $this, 'dismiss_pointers' ] ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
namespace EA11y\Modules\Core; | ||
|
||
use EA11y\Classes\Module_Base; | ||
use EA11y\Modules\Connect\Module as Connect; | ||
use EA11y\Modules\Settings\Module as Settings; | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; // Exit if accessed directly. | ||
} | ||
|
||
class Module extends Module_Base { | ||
public function get_name(): string { | ||
return 'core'; | ||
} | ||
|
||
public static function component_list() : array { | ||
return [ | ||
'Pointers', | ||
]; | ||
} | ||
|
||
public function add_plugin_links( $links, $plugin_file_name ): array { | ||
if ( ! str_ends_with( $plugin_file_name, '/pojo-accessibility.php' ) ) { | ||
return (array) $links; | ||
} | ||
|
||
$custom_links = [ | ||
'dashboard' => sprintf( | ||
'<a href="%s">%s</a>', | ||
admin_url( 'admin.php?page=' . Settings::SETTING_BASE_SLUG ), | ||
esc_html__( 'Dashboard', 'pojo-accessibility' ) | ||
), | ||
]; | ||
|
||
if ( Connect::is_connected() ) { | ||
$custom_links['upgrade'] = sprintf( | ||
'<a href="%s" style="color: #524CFF; font-weight: 700;" target="_blank" rel="noopener noreferrer">%s</a>', | ||
'https://go.elementor.com/sm-panel-wp-dash-upgrade-plugins/', | ||
esc_html__( 'Upgrade', 'pojo-accessibility' ) | ||
); | ||
} else { | ||
$custom_links['connect'] = sprintf( | ||
'<a href="%s" style="color: #524CFF; font-weight: 700;">%s</a>', | ||
admin_url( 'admin.php?page=' . Settings::SETTING_BASE_SLUG ), | ||
esc_html__( 'Connect', 'pojo-accessibility' ) | ||
); | ||
} | ||
|
||
return array_merge( $custom_links, $links ); | ||
} | ||
|
||
/** | ||
* Module constructor. | ||
*/ | ||
public function __construct() { | ||
$this->register_components(); | ||
|
||
add_filter( 'plugin_action_links', [ $this, 'add_plugin_links' ], 10, 2 ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.