From 09fc74333b91a0677cfbd02a36585b9ea8f7941d Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Fri, 26 Apr 2024 11:35:04 -0400 Subject: [PATCH] add features module and updated staging module add features to runtime and adjust menus accordingly --- bootstrap.php | 4 +++ composer.json | 3 +- composer.lock | 71 +++++++++++++++++++++++++++++++++++++----- inc/Admin.php | 33 +++++++++----------- inc/Data.php | 3 +- src/app/data/routes.js | 2 +- 6 files changed, 86 insertions(+), 30 deletions(-) diff --git a/bootstrap.php b/bootstrap.php index 962ac77f1..8429ff7fd 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -199,3 +199,7 @@ function () { if ( is_admin() ) { new Admin(); } + + + +require_once BLUEHOST_PLUGIN_DIR . '/vendor/newfold-labs/wp-module-features/bootstrap.php'; \ No newline at end of file diff --git a/composer.json b/composer.json index 4773939a0..16d8965b2 100644 --- a/composer.json +++ b/composer.json @@ -72,6 +72,7 @@ "newfold-labs/wp-module-data": "^2.4.24", "newfold-labs/wp-module-deactivation": "^1.1.1", "newfold-labs/wp-module-ecommerce": "^1.3.27", + "newfold-labs/wp-module-features": "dev-main", "newfold-labs/wp-module-global-ctb": "^1.0.11", "newfold-labs/wp-module-help-center": "^1.0.24", "newfold-labs/wp-module-loader": "^1.0.10", @@ -83,7 +84,7 @@ "newfold-labs/wp-module-runtime": "^1.0.10", "newfold-labs/wp-module-secure-passwords": "^1.1.1", "newfold-labs/wp-module-sso": "^1.0.5", - "newfold-labs/wp-module-staging": "^1.3.3", + "newfold-labs/wp-module-staging": "dev-develop", "wp-forge/wp-update-handler": "^1.0.2", "wp-forge/wp-upgrade-handler": "^1.0" } diff --git a/composer.lock b/composer.lock index 6389cd838..4374a9055 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3b6feba64a1a3a41aca68f84d00bab32", + "content-hash": "af3b1480664ef81c9f69ed24f42e6204", "packages": [ { "name": "doctrine/inflector", @@ -620,6 +620,58 @@ }, "time": "2024-02-12T08:48:41+00:00" }, + { + "name": "newfold-labs/wp-module-features", + "version": "dev-main", + "source": { + "type": "git", + "url": "https://github.com/newfold-labs/wp-module-features.git", + "reference": "b8642cadff5ec6909c134fa87c605b5de4d2585a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/newfold-labs/wp-module-features/zipball/b8642cadff5ec6909c134fa87c605b5de4d2585a", + "reference": "b8642cadff5ec6909c134fa87c605b5de4d2585a", + "shasum": "" + }, + "require-dev": { + "newfold-labs/wp-php-standards": "^1.2" + }, + "default-branch": true, + "type": "library", + "autoload": { + "psr-4": { + "NewfoldLabs\\WP\\Module\\Features\\": "includes" + } + }, + "scripts": { + "fix": [ + "vendor/bin/phpcbf . --standard=phpcs.xml" + ], + "lint": [ + "vendor/bin/phpcs . --standard=phpcs.xml -s" + ] + }, + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Micah Wood", + "homepage": "https://wpscholar.com" + }, + { + "name": "Evan Mullins", + "homepage": "https://evanmullins.com" + } + ], + "description": "A module for providing an interface for features.", + "support": { + "source": "https://github.com/newfold-labs/wp-module-features/tree/main", + "issues": "https://github.com/newfold-labs/wp-module-features/issues" + }, + "time": "2024-04-19T20:13:00+00:00" + }, { "name": "newfold-labs/wp-module-global-ctb", "version": "1.0.11", @@ -1297,20 +1349,21 @@ }, { "name": "newfold-labs/wp-module-staging", - "version": "1.3.3", + "version": "dev-develop", "source": { "type": "git", "url": "https://github.com/newfold-labs/wp-module-staging.git", - "reference": "c464472e3a5886d9639563262e776b33f8135398" + "reference": "079390d91200c0d12c2d537baca7a1c7ba7ca29c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/newfold-labs/wp-module-staging/zipball/c464472e3a5886d9639563262e776b33f8135398", - "reference": "c464472e3a5886d9639563262e776b33f8135398", + "url": "https://api.github.com/repos/newfold-labs/wp-module-staging/zipball/079390d91200c0d12c2d537baca7a1c7ba7ca29c", + "reference": "079390d91200c0d12c2d537baca7a1c7ba7ca29c", "shasum": "" }, "require": { - "newfold-labs/wp-module-context": "^1.0" + "newfold-labs/wp-module-context": "^1.0", + "newfold-labs/wp-module-features": "dev-main" }, "require-dev": { "newfold-labs/wp-php-standards": "^1.2" @@ -1343,10 +1396,10 @@ ], "description": "Newfold module for staging functionality in brand plugins", "support": { - "source": "https://github.com/newfold-labs/wp-module-staging/tree/1.3.3", + "source": "https://github.com/newfold-labs/wp-module-staging/tree/add/staging-feature", "issues": "https://github.com/newfold-labs/wp-module-staging/issues" }, - "time": "2024-04-10T20:37:51+00:00" + "time": "2024-04-25T21:19:11+00:00" }, { "name": "wp-cli/wp-config-transformer", @@ -3879,6 +3932,8 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { + "newfold-labs/wp-module-features": 20, + "newfold-labs/wp-module-staging": 20, "roave/security-advisories": 20 }, "prefer-stable": false, diff --git a/inc/Admin.php b/inc/Admin.php index 264e80231..c7a03c8bf 100644 --- a/inc/Admin.php +++ b/inc/Admin.php @@ -61,7 +61,7 @@ public static function add_to_runtime( $sdk ) { * @return array */ public static function subpages() { - global $bluehost_module_container; + global $bluehost_module_container, $newfold_features; $home = array( 'bluehost#/home' => __( 'Home', 'wp-plugin-bluehost' ), @@ -72,30 +72,25 @@ public static function subpages() { $marketplace = array( 'bluehost#/marketplace' => __( 'Marketplace', 'wp-plugin-bluehost' ), ); - $performance = array( - 'bluehost#/performance' => __( 'Performance', 'wp-plugin-bluehost' ), - ); - $settings = array( + // wp-cloud adjustment + $performance = ( 'atomic' === getContext( 'platform' ) ) + ? array( + 'bluehost#/performance' => __( 'Performance', 'wp-plugin-bluehost' ), + ) + : array(); + $settings = array( 'bluehost#/settings' => __( 'Settings', 'wp-plugin-bluehost' ), ); - $staging = array( - 'bluehost#/staging' => __( 'Staging', 'wp-plugin-bluehost' ), - ); + // only add staging link if feature is enabled + $staging = $newfold_features->get('staging') + ? array( + 'bluehost#/staging' => __( 'Staging', 'wp-plugin-bluehost' ), + ) + : array(); $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, diff --git a/inc/Data.php b/inc/Data.php index 4f04c9113..3458daf09 100644 --- a/inc/Data.php +++ b/inc/Data.php @@ -19,7 +19,7 @@ final class Data { * @return array */ public static function runtime() { - global $bluehost_module_container; + global $bluehost_module_container, $newfold_features; $runtime = array( 'plugin' => array( @@ -28,6 +28,7 @@ public static function runtime() { 'assets' => BLUEHOST_PLUGIN_URL . 'assets/', 'brand' => $bluehost_module_container->plugin()->brand, ), + 'features' => $newfold_features->all(), ); return $runtime; diff --git a/src/app/data/routes.js b/src/app/data/routes.js index 7e413ed46..f31f8e3d1 100644 --- a/src/app/data/routes.js +++ b/src/app/data/routes.js @@ -137,7 +137,7 @@ export const routes = [ title: __( 'Staging', 'wp-plugin-bluehost' ), Component: Staging, Icon: WrenchScrewdriverIcon, - condition: 'atomic' !== window.NewfoldRuntime.context.platform, + condition: window.NewfoldRuntime.features.staging, }, { name: '/help',