Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
Merge pull request #952 from bluehost/add/context-module
Browse files Browse the repository at this point in the history
Add/context module
  • Loading branch information
circlecube authored Feb 27, 2024
2 parents 236b072 + a1a0637 commit bcbbe12
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 50 deletions.
47 changes: 38 additions & 9 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
use WP_Forge\UpgradeHandler\UpgradeHandler;
use NewfoldLabs\WP\ModuleLoader\Container;
use NewfoldLabs\WP\ModuleLoader\Plugin;
use NewfoldLabs\WP\Context\Context;
use function NewfoldLabs\WP\ModuleLoader\container as setContainer;
use function NewfoldLabs\WP\Context\setContext;
use function NewfoldLabs\WP\Context\getContext;

// Composer autoloader
if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
Expand All @@ -25,12 +28,17 @@
}

/*
* Initialize coming soon module via container
* Initialize module settings via container
*/
$bluehost_module_container = new Container(
array(
'cache_types' => array( 'browser', 'skip404' ),
)
$bluehost_module_container = new Container();

// Context setup
add_action(
'newfold/context/set',
function () {
// set brand
setContext( 'brand.name', 'bluehost' );
}
);

// Set plugin to container
Expand All @@ -51,12 +59,32 @@ function () {
)
);

$bluehost_module_container->set(
'marketplace_brand',
'bluehost'
// Assign container values based on context
add_action(
'plugins_loaded',
function () {
global $bluehost_module_container;

// Performance default settings
$cache_types = array( 'browser', 'skip404' );
// Marketplace default settings
$marketplace_brand = 'bluehost';

// Platform overrides
if ( 'atomic' === getContext( 'platform' ) ) {
$cache_types = array();
$marketplace_brand = 'bluehost-cloud';
}

if ( $bluehost_module_container ) {
$bluehost_module_container->set( 'cache_types', $cache_types );
$bluehost_module_container->set( 'marketplace_brand', $marketplace_brand );
}
},
11
);

// properly get branding links depending on market
// Properly get branding links depending on market
$wordpress_hosting_page = ( get_option( 'mm_brand' ) === 'Bluehost_India' ) ? 'https://www.bluehost.in?utm_source=coming-soon-template&utm_medium=bluehost_plugin' : 'https://bluehost.com?utm_source=coming-soon-template&utm_medium=bluehost_plugin';
$my_panel = ( get_option( 'mm_brand' ) === 'Bluehost_India' ) ? 'https://my.bluehost.in/web-hosting/cplogin' : 'https://my.bluehost.com/web-hosting/cplogin';
$website_guide_link = 'https://www.bluehost.com/blog/how-to-create-a-website-guide/';
Expand Down Expand Up @@ -106,6 +134,7 @@ function () {
'template_styles' => esc_url( BLUEHOST_PLUGIN_URL . 'assets/styles/coming-soon.css' ),
)
);

setContainer( $bluehost_module_container );

// Set up the updater endpoint and map values
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"require": {
"newfold-labs/wp-module-business-reviews": "^1.1.1",
"newfold-labs/wp-module-coming-soon": "^1.2.0",
"newfold-labs/wp-module-context": "^1.0.0",
"newfold-labs/wp-module-ctb": "^1.1.3",
"newfold-labs/wp-module-customer-bluehost": "^1.6.0",
"newfold-labs/wp-module-data": "^2.4.18",
Expand All @@ -80,12 +81,12 @@
"newfold-labs/wp-module-notifications": "^1.2.5",
"newfold-labs/wp-module-onboarding": "^2.1.3",
"newfold-labs/wp-module-patterns": "^0.1.14",
"newfold-labs/wp-module-performance": "^1.3.1",
"newfold-labs/wp-module-performance": "^1.4.0",
"newfold-labs/wp-module-runtime": "^1.0.9",
"newfold-labs/wp-module-secure-passwords": "^1.1.1",
"newfold-labs/wp-module-sso": "^1.0.4",
"newfold-labs/wp-module-staging": "^1.2.3",
"wp-forge/wp-update-handler": "^1.0",
"newfold-labs/wp-module-staging": "^1.3.0",
"wp-forge/wp-update-handler": "^1.0.2",
"wp-forge/wp-upgrade-handler": "^1.0"
}
}
84 changes: 71 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 43 additions & 6 deletions inc/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Bluehost;

use function NewfoldLabs\WP\Context\getContext;

/**
* \Bluehost\Admin
*/
Expand Down Expand Up @@ -56,14 +58,49 @@ public static function add_to_runtime( $sdk ) {
* @return array
*/
public static function subpages() {
return array(
'bluehost#/home' => __( 'Home', 'wp-plugin-bluehost' ),
'bluehost#/store' => __( 'Store', 'wp-plugin-bluehost' ),
global $bluehost_module_container;

$home = array(
'bluehost#/home' => __( 'Home', 'wp-plugin-bluehost' ),
);
$store = array(
'bluehost#/store' => __( 'Store', 'wp-plugin-bluehost' ),
);
$marketplace = array(
'bluehost#/marketplace' => __( 'Marketplace', 'wp-plugin-bluehost' ),
);
$performance = array(
'bluehost#/performance' => __( 'Performance', 'wp-plugin-bluehost' ),
'bluehost#/settings' => __( 'Settings', 'wp-plugin-bluehost' ),
'bluehost#/staging' => __( 'Staging', 'wp-plugin-bluehost' ),
'bluehost#/help' => __( 'Help', 'wp-plugin-bluehost' ),
);
$settings = array(
'bluehost#/settings' => __( 'Settings', 'wp-plugin-bluehost' ),
);
$staging = array(
'bluehost#/staging' => __( 'Staging', 'wp-plugin-bluehost' ),
);
$help = array(
'bluehost#/help' => __( 'Help', 'wp-plugin-bluehost' ),
);

// wp-cloud adjustments
if ( 'atomic' === getContext( 'platform' ) ) {
return array_merge(
$home,
$store,
$marketplace,
$settings,
$help
);
}

return array_merge(
$home,
$store,
$marketplace,
$performance,
$settings,
$staging,
$help
);
}

Expand Down
20 changes: 11 additions & 9 deletions src/app/components/app-nav/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ export const SideNavMenu = () => {
return (
<ul className="nfd-flex nfd-flex-col nfd-gap-1.5">
{ topRoutes.map( ( page ) => (

Check failure on line 24 in src/app/components/app-nav/index.js

View workflow job for this annotation

GitHub Actions / ESLint

Replace `·(·page·)·=>·(` with `⏎↹↹↹↹↹(·page·)·=>`
<SideNavMenuItem
key={ page.name }
label={ page.title }
name={ page.name }
icon={ page.Icon }
path={ page.name }
action={ page.action }
subItems={ page.subRoutes }
/>
true === page.condition && (

Check failure on line 25 in src/app/components/app-nav/index.js

View workflow job for this annotation

GitHub Actions / ESLint

Insert `↹`
<SideNavMenuItem

Check failure on line 26 in src/app/components/app-nav/index.js

View workflow job for this annotation

GitHub Actions / ESLint

Insert `↹`
key={ page.name }

Check failure on line 27 in src/app/components/app-nav/index.js

View workflow job for this annotation

GitHub Actions / ESLint

Insert `↹`
label={ page.title }

Check failure on line 28 in src/app/components/app-nav/index.js

View workflow job for this annotation

GitHub Actions / ESLint

Insert `↹`
name={ page.name }

Check failure on line 29 in src/app/components/app-nav/index.js

View workflow job for this annotation

GitHub Actions / ESLint

Insert `↹`
icon={ page.Icon }

Check failure on line 30 in src/app/components/app-nav/index.js

View workflow job for this annotation

GitHub Actions / ESLint

Insert `↹`
path={ page.name }

Check failure on line 31 in src/app/components/app-nav/index.js

View workflow job for this annotation

GitHub Actions / ESLint

Insert `↹`
action={ page.action }

Check failure on line 32 in src/app/components/app-nav/index.js

View workflow job for this annotation

GitHub Actions / ESLint

Insert `↹`
subItems={ page.subRoutes }

Check failure on line 33 in src/app/components/app-nav/index.js

View workflow job for this annotation

GitHub Actions / ESLint

Insert `↹`
/>
)
) ) }
</ul>
);
Expand Down
Loading

0 comments on commit bcbbe12

Please sign in to comment.