File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -58,12 +58,39 @@ private static function is_site_created_within_last_9_months(): bool {
58
58
return $ install_date_timestamp >= $ nine_months_ago ;
59
59
}
60
60
61
+ /**
62
+ * Checks if the request is a page refresh/reload.
63
+ *
64
+ * @return bool True if the page is a page refresh, false otherwise.
65
+ */
66
+ private static function is_page_refresh (): bool {
67
+ if ( isset ( $ _SERVER ['HTTP_CACHE_CONTROL ' ] ) && 'max-age=0 ' === $ _SERVER ['HTTP_CACHE_CONTROL ' ] ) {
68
+ return true ;
69
+ }
70
+
71
+ if ( ! isset ( $ _SERVER ['HTTP_REFERER ' ] ) ) {
72
+ return true ;
73
+ }
74
+
75
+ $ referer = wp_parse_url ( $ _SERVER ['HTTP_REFERER ' ] );
76
+ if ( isset ( $ referer ['query ' ] ) && strpos ( $ referer ['query ' ], 'page=nfd-onboarding ' ) !== false ) {
77
+ return true ;
78
+ }
79
+
80
+ return false ;
81
+ }
82
+
61
83
/**
62
84
* Checks if the user is eligible to restart onboarding based on brand configuration and AI SiteGen capability.
63
85
*
64
86
* @return bool True if eligible, false otherwise.
65
87
*/
66
88
public static function is_onboarding_restart_eligible (): bool {
89
+ // If request is a page refresh, we either installing the theme or a user-invoked page refresh
90
+ if ( self ::is_page_refresh () ) {
91
+ return false ;
92
+ }
93
+
67
94
// Check if the brand is eligible for Restarting Onboarding
68
95
$ brand_config = Brands::get_brands ()[ NFD_ONBOARDING_PLUGIN_BRAND ]['config ' ] ?? array ();
69
96
if ( empty ( $ brand_config ['canRestartOnboarding ' ] ) || ! $ brand_config ['canRestartOnboarding ' ] ) {
You can’t perform that action at this time.
0 commit comments