🧑‍💻 Add a temporary branded-only simulation mode

This commit is contained in:
Philipp Stracker 2025-03-25 17:29:12 +01:00
parent 62e9a5e4ec
commit 7652bc8fea
No known key found for this signature in database
3 changed files with 23 additions and 1 deletions

View file

@ -44,7 +44,10 @@ export const wooSettings = ( state ) => {
const settings = getState( state ).wooSettings || EMPTY_OBJ; const settings = getState( state ).wooSettings || EMPTY_OBJ;
// For development and testing. Remove this eventually! // For development and testing. Remove this eventually!
const simulateBrandedOnly = localStorage.getItem( 'simulate-branded-only' ); const simulateBrandedOnly = document.cookie
.split( '; ' )
.find( ( row ) => row.startsWith( 'simulate-branded-only=' ) )
?.split( '=' )[ 1 ];
/** /**
* The "own-brand-only" experience is determined on server-side, based on the installation path. * The "own-brand-only" experience is determined on server-side, based on the installation path.

View file

@ -168,6 +168,16 @@ export const addDebugTools = ( context, modules ) => {
onboarding.persist(); onboarding.persist();
}; };
/**
* Sets a cookie to simulate the branded-only experience.
* @param {boolean} value - Whether to simulate branded-only experience.
*/
debugApi.simulateBrandedOnly = ( value ) => {
const expirationDate = new Date( Date.now() + 3600000 ).toUTCString();
document.cookie = `simulate-branded-only=${ value }; expires=${ expirationDate }; path=/`;
window.location.reload();
};
// Expose original debug API. // Expose original debug API.
Object.assign( context, debugApi ); Object.assign( context, debugApi );
}; };

View file

@ -306,6 +306,15 @@ class GeneralSettings extends AbstractDataModel {
* @return bool * @return bool
*/ */
public function own_brand_only() : bool { public function own_brand_only() : bool {
// Temporary dev/test mode.
$simulate_cookie = sanitize_key( wp_unslash( $_COOKIE['simulate-branded-only'] ?? '' ) );
if ( $simulate_cookie === 'true' ) {
return true;
} elseif ( $simulate_cookie === 'false' ) {
return false;
}
$brand_only_paths = array( $brand_only_paths = array(
InstallationPathEnum::CORE_PROFILER, InstallationPathEnum::CORE_PROFILER,
InstallationPathEnum::PAYMENT_SETTINGS, InstallationPathEnum::PAYMENT_SETTINGS,