From b989ca2f9522168268efece8774178e35e320faa Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Tue, 7 Nov 2023 23:40:16 +0530 Subject: [PATCH] Add sitegen detection --- includes/Data.php | 9 +++++++++ includes/Flows/Flows.php | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/includes/Data.php b/includes/Data.php index 078ee4c..940da8a 100644 --- a/includes/Data.php +++ b/includes/Data.php @@ -49,6 +49,15 @@ public static function current_brand() { * @return array */ public static function current_plan() { + $is_sitegen = Flows::is_sitegen(); + if ( $is_sitegen ) { + return array( + 'flow' => 'sitegen', + 'subtype' => null, + 'type' => null, + ); + } + $customer_data = self::customer_data(); $current_flow = Flows::get_flow_from_customer_data( $customer_data ); diff --git a/includes/Flows/Flows.php b/includes/Flows/Flows.php index 251cb88..f676076 100644 --- a/includes/Flows/Flows.php +++ b/includes/Flows/Flows.php @@ -275,6 +275,22 @@ public static function get_flow_from_plan_subtype( $plan_subtype ) { } return false; } + + /** + * Determines whether SiteGen flow was ever visited. + * + * @return boolean + */ + public static function is_sitegen() { + $flow_data = FlowService::read_data_from_wp_option(); + if ( ! ( $flow_data && empty( $flow_data['sitegen'] ) ) ) { + return false; + } + + return true === self::get_flows()['sitegen']; + + } + /** * Get the corresponding flow from the top priority in flow data. *