Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sitegen flow related data #37

Merged
merged 88 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
afac9ae
PRESS2-1259 | added get current user info
Nov 6, 2023
e31c024
Add SiteGen flow brand wise
arunshenoy99 Nov 7, 2023
b989ca2
Add sitegen detection
arunshenoy99 Nov 7, 2023
f81e6ce
Consistent naming conventions
arunshenoy99 Nov 8, 2023
ce7043d
Merge pull request #12 from newfold-labs/add/support-for-ai-onboarding
arunshenoy99 Nov 8, 2023
33a9d7b
Add keys to store site logo
arunshenoy99 Nov 9, 2023
1967ac6
Merge pull request #11 from newfold-labs/PRESS2-1259-admin-bar-details
diwanshuster Nov 15, 2023
05f4977
Merge pull request #13 from newfold-labs/add/sitegen-sitelogo
diwanshuster Nov 15, 2023
e0ceeb0
Update Flows.php
officiallygod Nov 16, 2023
7cb3b2f
Merge pull request #14 from newfold-labs/add-data-for-sitegen-exp-and…
officiallygod Nov 22, 2023
4887900
Start the code :star2:
officiallygod Nov 22, 2023
c6914ad
Add Dependency to AI
officiallygod Nov 22, 2023
9709623
Imitate Calls and maintain state :rotating_light:
officiallygod Nov 24, 2023
36a337f
Update SiteGenService.php
officiallygod Nov 24, 2023
7735c4e
Remove Fake Call
officiallygod Nov 24, 2023
c113354
Merge pull request #16 from newfold-labs/Integrate-APIs-to-AI-Onboarding
diwanshuster Nov 28, 2023
5392bbc
Add file name and file size to data
arunshenoy99 Nov 30, 2023
33b5275
Merge pull request #18 from newfold-labs/enhance/site-logo
arunshenoy99 Nov 30, 2023
c9d7557
updating sitegen flow
girish-lokapure Dec 5, 2023
2f5dd9b
updating flows
girish-lokapure Dec 6, 2023
fae6d5c
Add aiPreviewSettings
mr-vara Dec 7, 2023
b930a93
Add sitegen child theme generation
arunshenoy99 Dec 7, 2023
85444e9
Lint fixes
arunshenoy99 Dec 11, 2023
00b389d
Merge branch 'enhance/ai-onboarding' of https://github.com/newfold-la…
arunshenoy99 Dec 13, 2023
568db6d
Merge pull request #21 from newfold-labs/enhance/child-theme-generation
arunshenoy99 Dec 13, 2023
143e1e3
Add plugin recommendations helper
arunshenoy99 Dec 20, 2023
9e20156
Improve logic since API is not reliable
arunshenoy99 Dec 21, 2023
1ecd5d2
Add Wonder to SiteGen
arunshenoy99 Dec 21, 2023
ce8d3d8
Create SiteGenData.php
girish-lokapure Dec 21, 2023
94b0ac6
Update SiteGenData.php
girish-lokapure Dec 25, 2023
e0add94
Merge pull request #23 from newfold-labs/enhance/sitegen-plugins
arunshenoy99 Dec 26, 2023
bf3ea63
PRESS2-1465 | added regenerate
Dec 28, 2023
1f1f0e0
PRESS2-1465 | updated annotations
ajayadav09 Jan 2, 2024
272930b
Merge branch 'enhance/ai-onboarding' of https://github.com/newfold-la…
ajayadav09 Jan 2, 2024
0ab8a77
Press2-1465 | fixed get options from Options class
ajayadav09 Jan 4, 2024
2fe9bee
PRESS2-1465
ajayadav09 Jan 5, 2024
cab01d4
PRESS2-1465 | replaced with Options
ajayadav09 Jan 5, 2024
403867b
press2-1465 | fixed linting php
ajayadav09 Jan 8, 2024
9f808a0
Add get_customize_sidebar_data
mr-vara Jan 8, 2024
5a3e243
Merge branch 'enhance/ai-onboarding' of https://github.com/newfold-la…
ajayadav09 Jan 9, 2024
edf32a4
Update SiteGenData.php
girish-lokapure Jan 9, 2024
96857aa
PRESS2-1465 | added string and array checks and fixed suffix
ajayadav09 Jan 10, 2024
5dff069
PRESS2-1465 | added error responses
ajayadav09 Jan 10, 2024
213b6cb
Press2-1465 | fix lint
ajayadav09 Jan 11, 2024
8d7ce5a
added error for color palattes
ajayadav09 Jan 11, 2024
60bab55
Update SiteGenService.php
officiallygod Jan 12, 2024
e5f101d
updated regenerated pages
ajayadav09 Jan 12, 2024
42f113a
removed extra annotations
ajayadav09 Jan 12, 2024
ab7e371
added strict comparison checks
ajayadav09 Jan 12, 2024
048b3c4
Add service method for the Customize sidebar (#28)
mr-vara Jan 12, 2024
48c278d
Update SiteGenData.php
girish-lokapure Jan 15, 2024
35aa9c3
PR changes
girish-lokapure Jan 15, 2024
7044379
Merge branch 'enhance/ai-onboarding' into add/sitedetails/simple
girish-lokapure Jan 15, 2024
88274c9
Add Capability Check
officiallygod Jan 15, 2024
52ad376
Merge branch 'enhance/ai-onboarding' of https://github.com/newfold-la…
ajayadav09 Jan 15, 2024
37d9d33
Merge pull request #24 from newfold-labs/api-integration-preview-home…
arunshenoy99 Jan 15, 2024
f778abd
Get the default to be activated plugins dynamically
officiallygod Jan 15, 2024
189d868
Add homepages to Wonder Blocks templates
arunshenoy99 Jan 15, 2024
450b42f
Merge branch 'main' of https://github.com/newfold-labs/wp-module-onbo…
arunshenoy99 Jan 15, 2024
1405efd
Merge branch 'enhance/ai-onboarding' of https://github.com/newfold-la…
arunshenoy99 Jan 15, 2024
2ba6446
Fix file
arunshenoy99 Jan 15, 2024
d22f27b
Update lock file
arunshenoy99 Jan 15, 2024
710983d
Merge pull request #20 from newfold-labs/add/sitedetails/simple
arunshenoy99 Jan 15, 2024
173e3f1
Fix issue with get_customize_sidebar_data
mr-vara Jan 16, 2024
dba7101
Use the new option
arunshenoy99 Jan 16, 2024
d6dc98a
Merge branch 'enhance/ai-onboarding' of https://github.com/newfold-la…
arunshenoy99 Jan 16, 2024
85644d8
Merge pull request #30 from newfold-labs/activate-woocommerce-by-prev…
arunshenoy99 Jan 16, 2024
40fb93c
Merge pull request #31 from newfold-labs/enhance/wonder-blocks-homepages
arunshenoy99 Jan 16, 2024
8aedb28
Merge branch 'enhance/ai-onboarding' into sitegen-hiive-capability-flag
officiallygod Jan 17, 2024
d8480b3
Update Brands.php
officiallygod Jan 17, 2024
72dd29f
Use a common variable.
officiallygod Jan 17, 2024
1751432
Update plugin recommendation structure
arunshenoy99 Jan 17, 2024
ff2229b
Merge pull request #32 from newfold-labs/enhance/plugin-recommendations
arunshenoy99 Jan 17, 2024
df12b9f
Merge pull request #29 from newfold-labs/sitegen-hiive-capability-flag
arunshenoy99 Jan 17, 2024
bd6aa2e
Fix issues post integration
arunshenoy99 Jan 19, 2024
79c27e2
Code refactor pt 1
arunshenoy99 Jan 22, 2024
0e43d00
Code refactor pt 2
arunshenoy99 Jan 23, 2024
fd89fee
Merge pull request #33 from newfold-labs/fix/child-theme-generation
arunshenoy99 Jan 25, 2024
5b3c12d
Use header and footer patterns for template parts
arunshenoy99 Jan 30, 2024
35eb606
Lint fixes
arunshenoy99 Jan 30, 2024
7f60353
Sitegen: Publish sitemap pages
arunshenoy99 Jan 30, 2024
b577250
Merge pull request #35 from newfold-labs/fix/double-header-footer
arunshenoy99 Jan 31, 2024
8b63e86
Bump flow data version to 2.0.0
arunshenoy99 Jan 31, 2024
bfa064d
Merge pull request #36 from newfold-labs/enhance/sitegen-other-pages
arunshenoy99 Jan 31, 2024
29a6a44
Use a static image for sitegen generated themes
arunshenoy99 Feb 1, 2024
222ebee
Add screenshot
arunshenoy99 Feb 1, 2024
34a0e6f
Lint fix
arunshenoy99 Feb 1, 2024
c6f6dff
Merge pull request #38 from newfold-labs/enhance/generate-theme-scree…
arunshenoy99 Feb 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
},
"require": {
"newfold-labs/wp-module-installer": "^1.1",
"newfold-labs/wp-module-data": "^2.4.16",
"newfold-labs/wp-module-patterns": "^0.1.12",
"newfold-labs/wp-module-ai": "^1.0.4",
"wp-forge/wp-upgrade-handler": "^1.0",
"mustache/mustache": "^2.14",
"newfold-labs/wp-module-data": "^2.4.16",
"newfold-labs/wp-module-coming-soon": "^1.1.13"
},
"require-dev": {
Expand All @@ -35,4 +38,4 @@
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
}
273 changes: 237 additions & 36 deletions composer.lock

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions includes/Brands.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public static function get_default_brand() {
*/
public static function get_brands() {

// Checks if customer has acess to AI Sitegen
$has_ai_sitegen = Config::has_ai_sitegen();

return array(
'bluehost' => array(
'brand' => 'bluehost',
Expand Down Expand Up @@ -103,6 +106,7 @@ public static function get_brands() {
'enabled_flows' => array(
'ecommerce' => true,
'wp-setup' => true,
'sitegen' => $has_ai_sitegen,
),
'wonder_blocks' => true,
'prioritization' => false,
Expand Down Expand Up @@ -165,6 +169,7 @@ public static function get_brands() {
'enabled_flows' => array(
'ecommerce' => true,
'wp-setup' => false,
'sitegen' => $has_ai_sitegen,
),
'wonder_blocks' => true,
'prioritization' => false,
Expand Down Expand Up @@ -225,6 +230,7 @@ public static function get_brands() {
'enabled_flows' => array(
'ecommerce' => false,
'wp-setup' => false,
'sitegen' => $has_ai_sitegen,
),
'wonder_blocks' => true,
'prioritization' => false,
Expand Down Expand Up @@ -285,6 +291,7 @@ public static function get_brands() {
'enabled_flows' => array(
'ecommerce' => true,
'wp-setup' => true,
'sitegen' => $has_ai_sitegen,
),
'wonder_blocks' => true,
'prioritization' => false,
Expand Down Expand Up @@ -352,6 +359,7 @@ public static function get_brands() {
'enabled_flows' => array(
'ecommerce' => true,
'wp-setup' => true,
'sitegen' => $has_ai_sitegen,
),
'wonder_blocks' => true,
'prioritization' => false,
Expand Down Expand Up @@ -437,6 +445,7 @@ public static function get_brands() {
'enabled_flows' => array(
'ecommerce' => true,
'wp-setup' => true,
'sitegen' => $has_ai_sitegen,
),
'wonder_blocks' => true,
'prioritization' => false,
Expand Down
9 changes: 9 additions & 0 deletions includes/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,13 @@ public static function get_site_capability( $capability ) {
public static function is_jarvis() {
return self::get_site_capability( 'isJarvis' );
}

/**
* Gets the current customer capability if he has access to AI Sitegen.
*
* @return boolean
*/
public static function has_ai_sitegen() {
return self::get_site_capability( 'hasAISiteGen' );
}
}
53 changes: 44 additions & 9 deletions includes/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,23 @@ final class Data {
*/
public static function runtime() {
return array(
'buildUrl' => \NFD_ONBOARDING_BUILD_URL,
'siteUrl' => \get_site_url(),
'restUrl' => \get_home_url() . '/index.php?rest_route=',
'adminUrl' => \admin_url(),
'currentBrand' => self::current_brand(),
'currentPlan' => self::current_plan(),
'currentFlow' => self::current_flow(),
'pluginInstallHash' => PluginInstaller::rest_get_plugin_install_hash(),
'previewSettings' => array(
'buildUrl' => \NFD_ONBOARDING_BUILD_URL,
'siteUrl' => \get_site_url(),
'restUrl' => \get_home_url() . '/index.php?rest_route=',
'adminUrl' => \admin_url(),
'currentBrand' => self::current_brand(),
'currentPlan' => self::current_plan(),
'currentFlow' => self::current_flow(),
'pluginInstallHash' => PluginInstaller::rest_get_plugin_install_hash(),
'previewSettings' => array(
'settings' => Preview::get_settings(),
'stepPreviewData' => Themes::step_preview_data(),
),
'aiPreviewSettings' => array(
'settings' => Preview::get_settings(),
'stepPreviewData' => Themes::step_preview_data(),
),
'currentUserDetails' => self::wp_current_user_details(),
);
}

Expand All @@ -51,6 +56,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 );
Expand Down Expand Up @@ -140,4 +154,25 @@ public static function coming_soon() {
$coming_soon_service = container()->get( 'comingSoon' );
return $coming_soon_service->is_enabled();
}

/**
* Get the current WordPress admin user details.
*
* @return array
*/
public static function wp_current_user_details() {
$user = wp_get_current_user();
if ( $user->exists() ) {
return array(
'displayName' => $user->display_name,
'avatarUrl' => get_avatar_url( $user->ID ),
);
}

// If no user is found, return an empty array or default values as appropriate
return array(
'displayName' => '',
'avatarUrl' => '',
);
}
}
61 changes: 58 additions & 3 deletions includes/Flows/Flows.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class Flows {
* @var array
*/
protected static $data = array(
'version' => '1.0.3',
'version' => '2.0.0',

// Each time step is viewed, insert GMT timestamp to array.
'isViewed' => array(),
Expand Down Expand Up @@ -67,8 +67,10 @@ final class Flows {

// This integer will map to the attachment ID for an uploaded image to the WordPress media library
'siteLogo' => array(
'id' => 0,
'url' => '',
'id' => 0,
'url' => '',
'fileName' => '',
'fileSize' => 0,
),

// key-value store for social media accounts
Expand Down Expand Up @@ -110,6 +112,8 @@ final class Flows {
'comingSoon' => false,
),

'activeFlow' => '',

// we will store active flows (abandoned wp-setup, abandoned wp-commerce) with their identifier and use as a reference to access currentStep and data
'currentFlows' => array(),

Expand All @@ -132,6 +136,37 @@ final class Flows {
'product_types' => array(),
),
),

'sitegen' => array(
'siteDetails' => array(
'name' => '',
'type' => '',
'style' => '',
'prompt' => '',
'uniqueAboutBusiness' => '',
'mode' => 'simple',
),
'siteLogo' => array(
'id' => 0,
'url' => '',
'fileName' => '',
'fileSize' => 0,
),
'experience' => array(
'level' => 0,
),
'siteGenMetaStatus' => array(
'currentStatus' => 0,
'totalCount' => 8,
),
'homepages' => array(
'active' => array(),
'data' => array(),
),
'skipCache' => true,
'sitemapPagesGenerated' => false,
'customDesign' => false,
),
);

/**
Expand Down Expand Up @@ -184,6 +219,7 @@ public static function get_flows() {
? $current_brand['config']['enabled_flows'] : array(
'wp-setup' => false,
'ecommerce' => false,
'sitegen' => false,
);
}

Expand Down Expand Up @@ -273,6 +309,25 @@ 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() {
if ( ! self::get_flows()['sitegen'] ) {
return false;
}

$flow_data = FlowService::read_data_from_wp_option();
if ( ! $flow_data || empty( $flow_data['activeFlow'] ) ) {
return false;
}

return 'sitegen' === $flow_data['activeFlow'];
}

/**
* Get the corresponding flow from the top priority in flow data.
*
Expand Down
37 changes: 37 additions & 0 deletions includes/Mustache/Mustache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
namespace NewfoldLabs\WP\Module\Onboarding\Data\Mustache;

/**
* Class Mustache
*/
class Mustache {

/**
* Mustache Engine.
*
* @var array
*/
protected $mustache_engine;

/**
* Setup mustache engine.
*/
public function __construct() {
$this->mustache_engine = new \Mustache_Engine(
array(
'loader' => new \Mustache_Loader_FilesystemLoader( __DIR__ . '/Templates' ),
)
);
}

/**
* Render respective template data.
*
* @param string $template_name Template Name
* @param array $data Data
* @return string
*/
public function render_template( $template_name, $data ) {
return $this->mustache_engine->loadTemplate( $template_name )->render( $data );
}
}
9 changes: 9 additions & 0 deletions includes/Mustache/Templates/themeStylesheet.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
Theme Name: {{ theme_name }}
Author: {{ site_title }} & {{ brand_name }}
Author URI: {{ site_url }}
Description: A Custom WordPress Theme built for {{ site_title }} by {{ brand_name }}
Version: 1.0.0
Template: {{ parent_theme_slug }}
Text Domain: {{ child_theme_slug }}
*/
1 change: 1 addition & 0 deletions includes/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ final class Options {
'wc_calc_taxes' => 'woocommerce_calc_taxes',
'wc_no_sales_tax' => 'woocommerce_no_sales_tax',
'filter_active_plugins' => 'filter_active_plugins',
'sitegen_regenerated_homepages' => 'sitegen_regenerated_homepages',
'status' => 'status',
);

Expand Down
16 changes: 16 additions & 0 deletions includes/Plugins.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace NewfoldLabs\WP\Module\Onboarding\Data;

use NewfoldLabs\WP\Module\Installer\Data\Plugins as PluginsInstaller;

use function NewfoldLabs\WP\ModuleLoader\container;

/**
* List of Plugin Slugs/URLs/Domains
*/
Expand Down Expand Up @@ -232,4 +236,16 @@ public static function get_init() {
public static function wc_prevent_redirect_on_activation() {
\delete_transient( '_wc_activation_redirect' );
}

/**
* List of plugins that should stay active even with the filter option
*
* @return array
*/
public static function get_active_plugins_list() {
return array(
container()->plugin()->basename,
isset( PluginsInstaller::get_wp_slugs()['woocommerce']['path'] ) ? PluginsInstaller::get_wp_slugs()['woocommerce']['path'] : false,
);
}
}
2 changes: 1 addition & 1 deletion includes/Services/FlowService.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private static function update_data_for_ecommerce( $data ) {
*
* @return array
*/
private static function update_data_in_wp_option( $data ) {
public static function update_data_in_wp_option( $data ) {
return \update_option( Options::get_option_name( 'flow' ), $data );
}

Expand Down
Loading
Loading