Skip to content

Commit b73b1de

Browse files
committed
Show admin notice only once
1 parent 425cf0f commit b73b1de

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

plugins/optimization-detective/helper.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,17 +298,18 @@ function od_maybe_render_installed_extensions_admin_notice(): void {
298298
echo wp_kses( $notice, wp_kses_allowed_html( 'post' ) );
299299
}
300300
/**
301-
* Checks for installed extensions and displays an admin notice if none are found.
301+
* Checks for installed extensions and displays an admin notice once if none are found.
302302
*
303303
* @since n.e.x.t
304304
* @access private
305305
*/
306306
function od_maybe_check_installed_extensions(): void {
307-
$installed_extensions = get_transient( 'od_installed_extensions' );
308-
if ( ! is_array( $installed_extensions ) ) {
309-
$installed_extensions = od_check_installed_extensions();
310-
set_transient( 'od_installed_extensions', $installed_extensions, WEEK_IN_SECONDS );
307+
if ( 1 === (int) get_option( 'od_installed_extensions_admin_notice', '0' ) ) {
308+
return;
311309
}
310+
update_option( 'od_installed_extensions_admin_notice', '1' );
311+
312+
$installed_extensions = od_check_installed_extensions();
312313
if ( count( $installed_extensions ) > 0 ) {
313314
return;
314315
}

plugins/optimization-detective/uninstall.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
OD_URL_Metrics_Post_Type::delete_all_posts();
1919
wp_unschedule_hook( OD_URL_Metrics_Post_Type::GC_CRON_EVENT_NAME );
2020

21-
// Clear out site health check data.
21+
// Clear out options and transients.
2222
delete_option( 'od_rest_api_unavailable' );
23+
delete_option( 'od_installed_extensions_admin_notice' );
2324
delete_transient( 'od_rest_api_health_check_response' );
2425
};
2526

0 commit comments

Comments
 (0)