From 7bfacdc7d0e564e76cdd6e59ad56baede71b2d1e Mon Sep 17 00:00:00 2001 From: Mike Hemberger Date: Wed, 27 Apr 2022 16:36:19 -0400 Subject: [PATCH 1/2] Fix issue with upgrade notice still showing after dismissing. --- lib/admin/admin.php | 106 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 97 insertions(+), 9 deletions(-) diff --git a/lib/admin/admin.php b/lib/admin/admin.php index d450e47..1c0d8e0 100644 --- a/lib/admin/admin.php +++ b/lib/admin/admin.php @@ -3,34 +3,62 @@ /** * Add dismissible upgrade notice. * - * @since TBD + * @since 1.13.0 * * @return void */ add_action( 'admin_notices', 'mai_upgrade_notice', 4 ); function mai_upgrade_notice() { - $days = 14; - $dismissible = sprintf( 'mai_upgrade_notice-%s', $days ); - $url = 'https://help.bizbudding.com/article/209-upgrade?utm_source=mai-theme-engine&utm_medium=link&utm_campaign=v1'; - - if ( class_exists( 'PAnD' ) && ! PAnD::is_admin_notice_active( $dismissible ) ) { + if ( ! current_user_can( 'switch_themes' ) ) { return; } - printf( '
', $dismissible ); + $url = 'https://help.bizbudding.com/article/209-upgrade?utm_source=mai-theme-engine&utm_medium=link&utm_campaign=v1'; + $timestamp = get_user_option( 'mai_upgrade_notice', get_current_user_id() ); + + // Bail if already dismissed. + if ( $timestamp && current_time( 'timestamp' ) < $timestamp ) { + return; + } ?> +
+

+ + | +   +

', MAI_THEME_ENGINE_PLUGIN_URL . 'assets/images/icon-128x128.png' ); ?>
@@ -70,6 +103,61 @@ function mai_upgrade_notice() {
+ + 403, + ] + ); + } + + $weeks = filter_input( INPUT_POST, 'weeks', FILTER_SANITIZE_NUMBER_INT ); + $weeks = $weeks ?: 4; + $now = current_time( 'timestamp' ); + $again = strtotime( sprintf( '+%s weeks', $weeks ), $now ); + + update_user_option( get_current_user_id(), 'mai_upgrade_notice', $again ); } /** From 19a4e509497f8b338c1a7bbb9d908922c23c4bf0 Mon Sep 17 00:00:00 2001 From: Mike Hemberger Date: Wed, 27 Apr 2022 16:39:19 -0400 Subject: [PATCH 2/2] 1.13.1 --- CHANGES.md | 3 +++ mai-theme-engine.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2417f31..4d0a681 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,8 @@ # Changelog +## 1.13.1 (4/27/22) +* Fixed: Admin notice not staying dismissed after Dashboard page refresh in some scenarios. + ## 1.13.0 (4/25/22) * Added: Admin notice about WordPress ending support for the classic editor and upgrading to Mai Theme v2. * Changed: Update CMB2 to 2.10.1. diff --git a/mai-theme-engine.php b/mai-theme-engine.php index 0c421e9..9a7dacf 100644 --- a/mai-theme-engine.php +++ b/mai-theme-engine.php @@ -5,7 +5,7 @@ * Plugin URI: https://bizbudding.com/mai-theme/ * Description: The Mai Theme Engine plugin * - * Version: 1.13.0 + * Version: 1.13.1 * * GitHub URI: maithemewp/mai-theme-engine * @@ -89,7 +89,7 @@ public function __wakeup() { private function setup_constants() { // Plugin version. - define( 'MAI_THEME_ENGINE_VERSION', '1.13.0' ); + define( 'MAI_THEME_ENGINE_VERSION', '1.13.1' ); // DB version. define( 'MAI_THEME_ENGINE_DB_VERSION', '1600' );