id, $screens, true ) ) {
remove_all_actions( 'admin_notices' );
remove_all_actions( 'all_admin_notices' );
}
}
/**
* Black Friday Admin Notice
*
* @return void
*/
public function edac_black_friday_notice() {
// check if accessibility checker pro is active.
$pro = is_plugin_active( 'accessibility-checker-pro/accessibility-checker-pro.php' );
if ( $pro ) {
return;
}
// Get the value of the 'edac_gaad_notice_dismiss' option and sanitize it.
$dismissed = absint( get_option( 'edac_black_friday_2023_notice_dismiss', 0 ) );
// Check if the notice has been dismissed.
if ( $dismissed ) {
return;
}
// Show from November 20-30.
$current_date = date_i18n( 'Ymd' ); // Use date_i18n for localization.
$start_date = '20231120';
$end_date = '20231130';
if ( $current_date >= $start_date && $current_date <= $end_date ) {
// Get the promotional message from a separate function/file.
$message = $this->edac_get_black_friday_message();
// Output the message with appropriate sanitization.
echo wp_kses_post( $message );
}
}
/**
* Get GAAD Promo Message
*
* @return string
*/
public function edac_get_black_friday_message() {
// Construct the promotional message.
$message = '
';
return $message;
}
/**
* Black Friday Admin Notice Ajax
*
* @return void
*
* - '-1' means that nonce could not be varified
* - '-2' means that update option wasn't successful
*/
public function edac_black_friday_notice_ajax() {
// nonce security.
if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ajax-nonce' ) ) {
$error = new \WP_Error( '-1', 'Permission Denied' );
wp_send_json_error( $error );
}
$results = update_option( 'edac_black_friday_2023_notice_dismiss', true );
if ( ! $results ) {
$error = new \WP_Error( '-2', 'Update option wasn\'t successful' );
wp_send_json_error( $error );
}
wp_send_json_success( wp_json_encode( $results ) );
}
/**
* GAAD Notice
*
* @return string
*/
public function edac_gaad_notice() {
// Define constants for start and end dates.
define( 'EDAC_GAAD_NOTICE_START_DATE', '2023-05-11' );
define( 'EDAC_GAAD_NOTICE_END_DATE', '2023-05-24' );
// Check if Accessibility Checker Pro is active.
$pro = is_plugin_active( 'accessibility-checker-pro/accessibility-checker-pro.php' );
if ( $pro ) {
return;
}
// Get the value of the 'edac_gaad_notice_dismiss' option and sanitize it.
$dismissed = absint( get_option( 'edac_gaad_notice_dismiss', 0 ) );
// Check if the notice has been dismissed.
if ( $dismissed ) {
return;
}
// Get the current date in the 'Y-m-d' format.
$current_date = gmdate( 'Y-m-d' );
// Check if the current date is within the specified range.
if ( $current_date >= EDAC_GAAD_NOTICE_START_DATE && $current_date <= EDAC_GAAD_NOTICE_END_DATE ) {
// Get the promotional message from a separate function/file.
$message = $this->edac_get_gaad_promo_message();
// Output the message with appropriate sanitization.
echo wp_kses_post( $message );
}
}
/**
* Get GAAD Promo Message
*
* @return string
*/
public function edac_get_gaad_promo_message() {
// Construct the promotional message.
$message = '';
return $message;
}
/**
* Review Admin Notice Ajax
*
* @return void
*
* - '-1' means that nonce could not be varified
* - '-2' means that update option wasn't successful
*/
public function edac_gaad_notice_ajax() {
// nonce security.
if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ajax-nonce' ) ) {
$error = new \WP_Error( '-1', 'Permission Denied' );
wp_send_json_error( $error );
}
$results = update_option( 'edac_gaad_notice_dismiss', true );
if ( ! $results ) {
$error = new \WP_Error( '-2', 'Update option wasn\'t successful' );
wp_send_json_error( $error );
}
wp_send_json_success( wp_json_encode( $results ) );
}
/**
* Review Admin Notice
*
* @return void
*/
public function edac_review_notice() {
$option = 'edac_review_notice';
$edac_review_notice = get_option( $option );
// exit if option is set to stop.
if ( 'stop' === $edac_review_notice ) {
return;
}
$transient = 'edac_review_notice_reminder';
$edac_review_notice_reminder = get_transient( $transient );
// first time if notice has never been shown wait 14 days.
if ( false === $edac_review_notice_reminder && false === $edac_review_notice ) {
// if option isn't set and plugin has been active for more than 14 days show notice. This is for current users.
if ( edac_days_active() > 14 ) {
update_option( $option, 'play' );
} else {
// if plugin has been active less than 14 days set transient for 14 days.
set_transient( $transient, true, 14 * DAY_IN_SECONDS );
// set option to pause.
update_option( $option, 'pause' );
}
}
// if transient has expired and option is set to pause update option to play.
if ( false === $edac_review_notice_reminder && 'pause' === $edac_review_notice ) {
update_option( $option, 'play' );
}
// if option is not set to play exit.
if ( get_option( $option ) !== 'play' ) {
return;
}
?>
%2$s',
esc_attr__( 'Upgrade to accessibility checker pro. Opens in a new window.', 'accessibility-checker' ),
esc_html__( 'upgrade to pro', 'accessibility-checker' )
)
)
);
}
/**
* Password Protected Notice
*
* @return string
*/
public function edac_password_protected_notice() {
if ( (bool) get_option( 'edac_password_protected' )
&& ! (bool) get_option( 'edac_password_protected_notice_dismiss' )
) {
echo wp_kses( '' . $this->edac_password_protected_notice_text() . '
', 'post' );
return;
}
}
/**
* Review Admin Notice Ajax
*
* @return void
*
* - '-1' means that nonce could not be varified
* - '-2' means that update option wasn't successful
*/
public function edac_password_protected_notice_ajax() {
// nonce security.
if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'ajax-nonce' ) ) {
$error = new \WP_Error( '-1', 'Permission Denied' );
wp_send_json_error( $error );
}
$results = update_option( 'edac_password_protected_notice_dismiss', true );
if ( ! $results ) {
$error = new \WP_Error( '-2', 'Update option wasn\'t successful' );
wp_send_json_error( $error );
}
wp_send_json_success( wp_json_encode( $results ) );
}
}