Skip to content

Commit 5ff4e9d

Browse files
authored
Merge pull request #685 from newfold-labs/fix/8-337
Don't clear SiteGen data if request is page reload
2 parents a870ff4 + 7f871b6 commit 5ff4e9d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

includes/Services/StatusService.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,39 @@ private static function is_site_created_within_last_9_months(): bool {
5858
return $install_date_timestamp >= $nine_months_ago;
5959
}
6060

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+
6183
/**
6284
* Checks if the user is eligible to restart onboarding based on brand configuration and AI SiteGen capability.
6385
*
6486
* @return bool True if eligible, false otherwise.
6587
*/
6688
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+
6794
// Check if the brand is eligible for Restarting Onboarding
6895
$brand_config = Brands::get_brands()[ NFD_ONBOARDING_PLUGIN_BRAND ]['config'] ?? array();
6996
if ( empty( $brand_config['canRestartOnboarding'] ) || ! $brand_config['canRestartOnboarding'] ) {

0 commit comments

Comments
 (0)