From 46cdb731a7b18f4ba15276a4e73bcf8671c767b6 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 25 Apr 2024 16:57:39 -0400 Subject: [PATCH 01/23] add staging feature class and move module registration into it --- bootstrap.php | 27 +++++-------------- includes/StagingFeature.php | 53 +++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 21 deletions(-) create mode 100644 includes/StagingFeature.php diff --git a/bootstrap.php b/bootstrap.php index 46d9b26..15434a1 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -1,31 +1,16 @@ 'staging', - 'label' => __( 'Staging', 'newfold-staging-module' ), - 'callback' => function ( Container $container ) { - if ( 'atomic' === getContext( 'platform' ) ) { - return; - } - return new Staging( $container ); - }, - 'isActive' => true, - 'isHidden' => true, - ) - ); - + 'newfold/features/filter/isEnabled/staging', + function($value) { + if ( 'atomic' === getContext( 'platform' ) ) { + $value = false; + } + return $value; } ); diff --git a/includes/StagingFeature.php b/includes/StagingFeature.php new file mode 100644 index 0000000..17073e9 --- /dev/null +++ b/includes/StagingFeature.php @@ -0,0 +1,53 @@ + 'staging', + 'label' => __( 'Staging', 'newfold-staging-module' ), + 'callback' => function ( Container $container ) { + return new Staging( $container ); + }, + 'isActive' => true, + 'isHidden' => true, + ) + ); + + } + ); + + } + } + +} \ No newline at end of file From c8b6cd23aece93ed2418cfd35c0f0cd9437776a5 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 25 Apr 2024 17:18:48 -0400 Subject: [PATCH 02/23] require features module --- bootstrap.php | 2 +- composer.json | 3 ++- composer.lock | 58 +++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/bootstrap.php b/bootstrap.php index 15434a1..c460166 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -4,7 +4,7 @@ if ( function_exists( 'add_action' ) ) { - add_action( + add_filter( 'newfold/features/filter/isEnabled/staging', function($value) { if ( 'atomic' === getContext( 'platform' ) ) { diff --git a/composer.json b/composer.json index 29437e8..6a839ca 100644 --- a/composer.json +++ b/composer.json @@ -47,6 +47,7 @@ } }, "require": { - "newfold-labs/wp-module-context": "^1.0" + "newfold-labs/wp-module-context": "^1.0", + "newfold-labs/wp-module-features": "dev-main" } } \ No newline at end of file diff --git a/composer.lock b/composer.lock index 8188a24..d611ae5 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": "9825283ccab2a4bab9d08c5ed304f60c", + "content-hash": "27083de06da1ae46c76532107e2f8eaa", "packages": [ { "name": "doctrine/inflector", @@ -156,6 +156,58 @@ }, "time": "2024-02-22T18:22:13+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": "wp-forge/helpers", "version": "2.0", @@ -806,7 +858,9 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "newfold-labs/wp-module-features": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": [], From acf3f7b0ffc59686bd89635a55e663d949160589 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Wed, 1 May 2024 15:15:56 -0400 Subject: [PATCH 03/23] use getFeature helper method to disable staging based on context --- bootstrap.php | 15 ++++++++++++++- includes/Staging.php | 1 - 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bootstrap.php b/bootstrap.php index c460166..14aa07b 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -1,9 +1,11 @@ disable(); + } + } + } + ); +} \ No newline at end of file diff --git a/includes/Staging.php b/includes/Staging.php index 7f325c9..e136465 100644 --- a/includes/Staging.php +++ b/includes/Staging.php @@ -26,7 +26,6 @@ public function __construct( Container $container ) { $this->container = $container; // Module functionality goes here - // add_action( 'rest_api_init', array( StagingApi::class, 'register_routes' ) ); add_action( 'rest_api_init', function () { From 452fa01456d5f48fbbf995ab43718f4655268057 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 7 May 2024 13:11:47 -0400 Subject: [PATCH 04/23] remove module loader registration --- includes/StagingFeature.php | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/includes/StagingFeature.php b/includes/StagingFeature.php index 17073e9..2b4dbab 100644 --- a/includes/StagingFeature.php +++ b/includes/StagingFeature.php @@ -4,7 +4,7 @@ use NewfoldLabs\WP\ModuleLoader\Container; use NewfoldLabs\WP\Module\Staging\Staging; -use function NewfoldLabs\WP\ModuleLoader\register; +use function NewfoldLabs\WP\ModuleLoader\container as getContainer; /** * Child class for a feature @@ -28,26 +28,13 @@ class StagingFeature extends \NewfoldLabs\WP\Module\Features\Feature { public function initialize() { if ( function_exists( 'add_action' ) ) { + // Register module add_action( 'plugins_loaded', function () { - - register( - array( - 'name' => 'staging', - 'label' => __( 'Staging', 'newfold-staging-module' ), - 'callback' => function ( Container $container ) { - return new Staging( $container ); - }, - 'isActive' => true, - 'isHidden' => true, - ) - ); - + new Staging( getContainer() ); } ); - } } - } \ No newline at end of file From bbd4374f350a78a80abccfa174b6776fbcb1c749 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 13 May 2024 14:18:32 -0400 Subject: [PATCH 05/23] update to release version of features module --- composer.json | 2 +- composer.lock | 66 +++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index 6a839ca..7e8a420 100644 --- a/composer.json +++ b/composer.json @@ -48,6 +48,6 @@ }, "require": { "newfold-labs/wp-module-context": "^1.0", - "newfold-labs/wp-module-features": "dev-main" + "newfold-labs/wp-module-features": "^1.1" } } \ No newline at end of file diff --git a/composer.lock b/composer.lock index d611ae5..ebdc509 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": "27083de06da1ae46c76532107e2f8eaa", + "content-hash": "f855ce68c67e58895aa8dfaf47953ef7", "packages": [ { "name": "doctrine/inflector", @@ -158,27 +158,32 @@ }, { "name": "newfold-labs/wp-module-features", - "version": "dev-main", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/newfold-labs/wp-module-features.git", - "reference": "b8642cadff5ec6909c134fa87c605b5de4d2585a" + "reference": "a6780ec96584aab97036468de5d42939978b39c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/newfold-labs/wp-module-features/zipball/b8642cadff5ec6909c134fa87c605b5de4d2585a", - "reference": "b8642cadff5ec6909c134fa87c605b5de4d2585a", + "url": "https://api.github.com/repos/newfold-labs/wp-module-features/zipball/a6780ec96584aab97036468de5d42939978b39c6", + "reference": "a6780ec96584aab97036468de5d42939978b39c6", "shasum": "" }, + "require": { + "wp-forge/wp-options": "^1.1.1" + }, "require-dev": { - "newfold-labs/wp-php-standards": "^1.2" + "newfold-labs/wp-php-standards": "^1.2.3" }, - "default-branch": true, "type": "library", "autoload": { "psr-4": { "NewfoldLabs\\WP\\Module\\Features\\": "includes" - } + }, + "files": [ + "includes/functions.php" + ] }, "scripts": { "fix": [ @@ -203,10 +208,10 @@ ], "description": "A module for providing an interface for features.", "support": { - "source": "https://github.com/newfold-labs/wp-module-features/tree/main", + "source": "https://github.com/newfold-labs/wp-module-features/tree/1.1.0", "issues": "https://github.com/newfold-labs/wp-module-features/issues" }, - "time": "2024-04-19T20:13:00+00:00" + "time": "2024-05-13T17:34:22+00:00" }, { "name": "wp-forge/helpers", @@ -251,6 +256,43 @@ "source": "https://github.com/wp-forge/helpers/tree/2.0" }, "time": "2022-01-06T13:10:47+00:00" + }, + { + "name": "wp-forge/wp-options", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/wp-forge/wp-options.git", + "reference": "511b1c5e626582dd4c3c1b5602e7a20352dabc1b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wp-forge/wp-options/zipball/511b1c5e626582dd4c3c1b5602e7a20352dabc1b", + "reference": "511b1c5e626582dd4c3c1b5602e7a20352dabc1b", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "WP_Forge\\Options\\": "includes" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Micah Wood", + "email": "micah@wpscholar.com" + } + ], + "description": "A WordPress helper class for managing plugin options.", + "support": { + "issues": "https://github.com/wp-forge/wp-options/issues", + "source": "https://github.com/wp-forge/wp-options/tree/1.1.1" + }, + "time": "2024-05-10T14:57:37+00:00" } ], "packages-dev": [ @@ -858,9 +900,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "newfold-labs/wp-module-features": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": [], From a1921af56499fcb8422d68b2d82343cbff92d7a1 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 13 May 2024 15:21:42 -0400 Subject: [PATCH 06/23] use feature hooks class for managing the hooks --- bootstrap.php | 29 ++---------------- includes/StagingFeatureHooks.php | 52 ++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 27 deletions(-) create mode 100644 includes/StagingFeatureHooks.php diff --git a/bootstrap.php b/bootstrap.php index 14aa07b..181556a 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -1,30 +1,5 @@ disable(); - } - } - } - ); -} \ No newline at end of file +new StagingFeatureHooks(); \ No newline at end of file diff --git a/includes/StagingFeatureHooks.php b/includes/StagingFeatureHooks.php new file mode 100644 index 0000000..8fa6ca1 --- /dev/null +++ b/includes/StagingFeatureHooks.php @@ -0,0 +1,52 @@ +hooks(); + } + + /** + * Add hooks. + */ + public function hooks() { + + // Filter vale based on context + add_filter( 'newfold/features/filter/isEnabled:staging', array( $this, 'filterValue' ) ); + + // Force disable based on context + add_action( 'newfold/features/action/onEnable:staging', array( $this, 'maybeDisable' ) ); + + // Check if should disable on setup + add_action( 'after_setup_theme', array( $this, 'maybeDisable' ) ); + + } + + // Feature filter based on context + function filterValue( $value ) { + if ( $this->shouldDisable() ) { + $value = false; + } + return $value; + } + + // Maybe disable + function maybeDisable() { + if ( $this->shouldDisable() ) { + disableFeature('staging'); + } + } + + // Context condition for disabling feature + function shouldDisable() { + // check for atomic context + return 'atomic' === getContext( 'platform' ); + } +} \ No newline at end of file From b67263ff65c139ee1e6a8ec270545d3645bfe58b Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 13 May 2024 16:33:20 -0400 Subject: [PATCH 07/23] require the feature class --- bootstrap.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bootstrap.php b/bootstrap.php index 181556a..c0dd2d0 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -2,4 +2,6 @@ namespace NewfoldLabs\WP\Module\Staging; +require_once( __DIR__ . '/includes/StagingFeature.php' ); + new StagingFeatureHooks(); \ No newline at end of file From db67e8595cbb7ef47f31375a50e8a5ab0f72e565 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 13 May 2024 16:55:25 -0400 Subject: [PATCH 08/23] target plugin branch with features module for tests --- .github/workflows/brand-plugin-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/brand-plugin-test.yml b/.github/workflows/brand-plugin-test.yml index c92f34d..702df3e 100644 --- a/.github/workflows/brand-plugin-test.yml +++ b/.github/workflows/brand-plugin-test.yml @@ -31,6 +31,7 @@ jobs: module-repo: ${{ github.repository }} module-branch: ${{ needs.setup.outputs.branch }} plugin-repo: 'bluehost/bluehost-wordpress-plugin' + plugin-branch: 'add/features-module' secrets: inherit hostgator: From 92b1ebdcccbfb39fa0135869e889df0db4b24a4f Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 13 May 2024 17:44:01 -0400 Subject: [PATCH 09/23] reference global wp hook methods --- includes/StagingFeatureHooks.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/StagingFeatureHooks.php b/includes/StagingFeatureHooks.php index 8fa6ca1..a0e48fb 100644 --- a/includes/StagingFeatureHooks.php +++ b/includes/StagingFeatureHooks.php @@ -19,13 +19,13 @@ public function __construct() { public function hooks() { // Filter vale based on context - add_filter( 'newfold/features/filter/isEnabled:staging', array( $this, 'filterValue' ) ); + \add_filter( 'newfold/features/filter/isEnabled:staging', array( $this, 'filterValue' ) ); // Force disable based on context - add_action( 'newfold/features/action/onEnable:staging', array( $this, 'maybeDisable' ) ); + \add_action( 'newfold/features/action/onEnable:staging', array( $this, 'maybeDisable' ) ); // Check if should disable on setup - add_action( 'after_setup_theme', array( $this, 'maybeDisable' ) ); + \add_action( 'after_setup_theme', array( $this, 'maybeDisable' ) ); } From b9d61f552e65a094401b37b8716752a2dcce4263 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 14 May 2024 10:39:50 -0400 Subject: [PATCH 10/23] add feature hooks after plugins_loaded --- includes/StagingFeatureHooks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/StagingFeatureHooks.php b/includes/StagingFeatureHooks.php index a0e48fb..1588080 100644 --- a/includes/StagingFeatureHooks.php +++ b/includes/StagingFeatureHooks.php @@ -10,7 +10,7 @@ class StagingFeatureHooks { * Constructor. */ public function __construct() { - $this->hooks(); + \add_action( 'plugins_loaded', array( $this, 'hooks' ) ); } /** From 978d4ba6beb959f34e037aceb7efcbaab8585236 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 14 May 2024 10:52:28 -0400 Subject: [PATCH 11/23] defensive code cleanup --- includes/StagingFeatureHooks.php | 70 ++++++++++++++++---------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/includes/StagingFeatureHooks.php b/includes/StagingFeatureHooks.php index 1588080..d7289f8 100644 --- a/includes/StagingFeatureHooks.php +++ b/includes/StagingFeatureHooks.php @@ -10,43 +10,45 @@ class StagingFeatureHooks { * Constructor. */ public function __construct() { - \add_action( 'plugins_loaded', array( $this, 'hooks' ) ); - } + if ( function_exists( 'add_action' ) ) { + add_action( 'plugins_loaded', array( $this, 'hooks' ) ); + } + } - /** + /** * Add hooks. */ public function hooks() { - // Filter vale based on context - \add_filter( 'newfold/features/filter/isEnabled:staging', array( $this, 'filterValue' ) ); - - // Force disable based on context - \add_action( 'newfold/features/action/onEnable:staging', array( $this, 'maybeDisable' ) ); - - // Check if should disable on setup - \add_action( 'after_setup_theme', array( $this, 'maybeDisable' ) ); - - } - - // Feature filter based on context - function filterValue( $value ) { - if ( $this->shouldDisable() ) { - $value = false; - } - return $value; - } - - // Maybe disable - function maybeDisable() { - if ( $this->shouldDisable() ) { - disableFeature('staging'); - } - } - - // Context condition for disabling feature - function shouldDisable() { - // check for atomic context - return 'atomic' === getContext( 'platform' ); - } + // Filter vale based on context + add_filter( 'newfold/features/filter/isEnabled:staging', array( $this, 'filterValue' ) ); + + // Force disable based on context + add_action( 'newfold/features/action/onEnable:staging', array( $this, 'maybeDisable' ) ); + + // Check if should disable on setup + add_action( 'after_setup_theme', array( $this, 'maybeDisable' ) ); + + } + + // Feature filter based on context + function filterValue( $value ) { + if ( $this->shouldDisable() ) { + $value = false; + } + return $value; + } + + // Maybe disable + function maybeDisable() { + if ( $this->shouldDisable() ) { + disableFeature('staging'); + } + } + + // Context condition for disabling feature + function shouldDisable() { + // check for atomic context + return 'atomic' === getContext( 'platform' ); + } } \ No newline at end of file From e1da152039df6df058cfafcec8c06708005d9d5e Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 14 May 2024 10:59:12 -0400 Subject: [PATCH 12/23] fix lint --- bootstrap.php | 4 +-- includes/Staging.php | 3 +-- includes/StagingFeature.php | 46 ++++++++++++++++---------------- includes/StagingFeatureHooks.php | 30 ++++++++++++++------- 4 files changed, 47 insertions(+), 36 deletions(-) diff --git a/bootstrap.php b/bootstrap.php index c0dd2d0..9c96129 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -2,6 +2,6 @@ namespace NewfoldLabs\WP\Module\Staging; -require_once( __DIR__ . '/includes/StagingFeature.php' ); +require_once __DIR__ . '/includes/StagingFeature.php'; -new StagingFeatureHooks(); \ No newline at end of file +new StagingFeatureHooks(); diff --git a/includes/Staging.php b/includes/Staging.php index e136465..eafd4d6 100644 --- a/includes/Staging.php +++ b/includes/Staging.php @@ -48,7 +48,7 @@ function () { // add CLI commands add_action( 'cli_init', - function() { + function () { \WP_CLI::add_command( 'newfold staging', 'NewfoldLabs\WP\Module\Staging\StagingCLI', @@ -445,5 +445,4 @@ protected function runCommand( $command, $args = null ) { return $response; } - } diff --git a/includes/StagingFeature.php b/includes/StagingFeature.php index 2b4dbab..c63e3ed 100644 --- a/includes/StagingFeature.php +++ b/includes/StagingFeature.php @@ -8,33 +8,33 @@ /** * Child class for a feature - * + * * Child classes should define a name property as the feature name for all API calls. This name will be used in the registry. * Child class naming convention is {FeatureName}Feature. */ class StagingFeature extends \NewfoldLabs\WP\Module\Features\Feature { - /** - * The feature name. - * - * @var string - */ - protected $name = 'staging'; - protected $value = true; // default to on + /** + * The feature name. + * + * @var string + */ + protected $name = 'staging'; + protected $value = true; // default to on - /** - * Initialize staging feature - * - */ - public function initialize() { - if ( function_exists( 'add_action' ) ) { + /** + * Initialize staging feature + * + */ + public function initialize() { + if ( function_exists( 'add_action' ) ) { - // Register module - add_action( - 'plugins_loaded', - function () { - new Staging( getContainer() ); - } - ); - } - } + // Register module + add_action( + 'plugins_loaded', + function () { + new Staging( getContainer() ); + } + ); + } + } } \ No newline at end of file diff --git a/includes/StagingFeatureHooks.php b/includes/StagingFeatureHooks.php index d7289f8..8cbf87b 100644 --- a/includes/StagingFeatureHooks.php +++ b/includes/StagingFeatureHooks.php @@ -4,6 +4,9 @@ use function NewfoldLabs\WP\Context\getContext; use function NewfoldLabs\WP\Module\Features\disable as disableFeature; +/** + * This class adds staging feature hooks. + **/ class StagingFeatureHooks { /** @@ -19,19 +22,20 @@ public function __construct() { * Add hooks. */ public function hooks() { - // Filter vale based on context add_filter( 'newfold/features/filter/isEnabled:staging', array( $this, 'filterValue' ) ); - // Force disable based on context add_action( 'newfold/features/action/onEnable:staging', array( $this, 'maybeDisable' ) ); - // Check if should disable on setup add_action( 'after_setup_theme', array( $this, 'maybeDisable' ) ); - } - // Feature filter based on context + /** + * Feature filter based on context. + * + * @param boolean $value the value + * @return boolean the filtered value + */ function filterValue( $value ) { if ( $this->shouldDisable() ) { $value = false; @@ -39,16 +43,24 @@ function filterValue( $value ) { return $value; } - // Maybe disable + /** + * Maybe disable the feature. + * + * @return void + */ function maybeDisable() { if ( $this->shouldDisable() ) { - disableFeature('staging'); + disableFeature( 'staging' ); } } - // Context condition for disabling feature + /** + * Context condition for disabling feature. + * + * @return boolean whether the feature should be disabled + */ function shouldDisable() { // check for atomic context return 'atomic' === getContext( 'platform' ); } -} \ No newline at end of file +} From 64716605911fe4f676f19e1ff9a745f9e4c997b6 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 14 May 2024 11:03:56 -0400 Subject: [PATCH 13/23] fix lint --- includes/StagingFeature.php | 11 ++++++++--- includes/StagingFeatureHooks.php | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/includes/StagingFeature.php b/includes/StagingFeature.php index c63e3ed..0f1d87c 100644 --- a/includes/StagingFeature.php +++ b/includes/StagingFeature.php @@ -19,11 +19,16 @@ class StagingFeature extends \NewfoldLabs\WP\Module\Features\Feature { * @var string */ protected $name = 'staging'; - protected $value = true; // default to on /** - * Initialize staging feature + * The feature value. Defaults to on. * + * @var boolean + */ + protected $value = true; + + /** + * Initialize staging feature. */ public function initialize() { if ( function_exists( 'add_action' ) ) { @@ -37,4 +42,4 @@ function () { ); } } -} \ No newline at end of file +} diff --git a/includes/StagingFeatureHooks.php b/includes/StagingFeatureHooks.php index 8cbf87b..50c53f8 100644 --- a/includes/StagingFeatureHooks.php +++ b/includes/StagingFeatureHooks.php @@ -36,7 +36,7 @@ public function hooks() { * @param boolean $value the value * @return boolean the filtered value */ - function filterValue( $value ) { + public function filterValue( $value ) { if ( $this->shouldDisable() ) { $value = false; } @@ -48,7 +48,7 @@ function filterValue( $value ) { * * @return void */ - function maybeDisable() { + public function maybeDisable() { if ( $this->shouldDisable() ) { disableFeature( 'staging' ); } @@ -59,7 +59,7 @@ function maybeDisable() { * * @return boolean whether the feature should be disabled */ - function shouldDisable() { + public function shouldDisable() { // check for atomic context return 'atomic' === getContext( 'platform' ); } From b103e5d8ed3292df85a21f17b919a90316ffa92b Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 14 May 2024 11:13:21 -0400 Subject: [PATCH 14/23] update phpcs versions --- phpcs.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 7267645..a70fc20 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,8 +1,8 @@ - - + + From 7cc9a1b6db147d935da3f9000bd7c34e85a65e43 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Wed, 15 May 2024 17:51:50 -0400 Subject: [PATCH 15/23] load file via composer rather than require_once --- bootstrap.php | 2 -- composer.json | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/bootstrap.php b/bootstrap.php index 9c96129..c89a79c 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -2,6 +2,4 @@ namespace NewfoldLabs\WP\Module\Staging; -require_once __DIR__ . '/includes/StagingFeature.php'; - new StagingFeatureHooks(); diff --git a/composer.json b/composer.json index 7e8a420..aa00840 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "NewfoldLabs\\WP\\Module\\Staging\\": "includes" }, "files": [ + "includes/StagingFeature.php", "bootstrap.php" ] }, From f553c9644fb94d6a8640623a406f3947fbf23d9f Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 20 May 2024 15:07:13 -0400 Subject: [PATCH 16/23] remove atomic detection it has been moved to a standalone module --- bootstrap.php | 5 --- composer.json | 3 +- includes/StagingFeatureHooks.php | 66 -------------------------------- 3 files changed, 1 insertion(+), 73 deletions(-) delete mode 100644 bootstrap.php delete mode 100644 includes/StagingFeatureHooks.php diff --git a/bootstrap.php b/bootstrap.php deleted file mode 100644 index c89a79c..0000000 --- a/bootstrap.php +++ /dev/null @@ -1,5 +0,0 @@ -shouldDisable() ) { - $value = false; - } - return $value; - } - - /** - * Maybe disable the feature. - * - * @return void - */ - public function maybeDisable() { - if ( $this->shouldDisable() ) { - disableFeature( 'staging' ); - } - } - - /** - * Context condition for disabling feature. - * - * @return boolean whether the feature should be disabled - */ - public function shouldDisable() { - // check for atomic context - return 'atomic' === getContext( 'platform' ); - } -} From 4ca5c99400fd7ed900464f2ef6286932dad1312b Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 20 May 2024 16:01:28 -0400 Subject: [PATCH 17/23] update to latest features module --- composer.json | 6 +++--- composer.lock | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index dad94b9..c1ac6f0 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ ] }, "require-dev": { - "newfold-labs/wp-php-standards": "^1.2" + "newfold-labs/wp-php-standards": "^1.2.2" }, "scripts": { "fix": [ @@ -48,6 +48,6 @@ }, "require": { "newfold-labs/wp-module-context": "^1.0", - "newfold-labs/wp-module-features": "^1.1" + "newfold-labs/wp-module-features": "^1.2" } -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index ebdc509..5b5b5ca 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": "f855ce68c67e58895aa8dfaf47953ef7", + "content-hash": "297ddabeed091964db43e3b8b71a1f4d", "packages": [ { "name": "doctrine/inflector", @@ -158,16 +158,16 @@ }, { "name": "newfold-labs/wp-module-features", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/newfold-labs/wp-module-features.git", - "reference": "a6780ec96584aab97036468de5d42939978b39c6" + "reference": "e46032e09a14ab76e28ca20c276a76fa0c6a9023" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/newfold-labs/wp-module-features/zipball/a6780ec96584aab97036468de5d42939978b39c6", - "reference": "a6780ec96584aab97036468de5d42939978b39c6", + "url": "https://api.github.com/repos/newfold-labs/wp-module-features/zipball/e46032e09a14ab76e28ca20c276a76fa0c6a9023", + "reference": "e46032e09a14ab76e28ca20c276a76fa0c6a9023", "shasum": "" }, "require": { @@ -208,10 +208,10 @@ ], "description": "A module for providing an interface for features.", "support": { - "source": "https://github.com/newfold-labs/wp-module-features/tree/1.1.0", + "source": "https://github.com/newfold-labs/wp-module-features/tree/1.2.0", "issues": "https://github.com/newfold-labs/wp-module-features/issues" }, - "time": "2024-05-13T17:34:22+00:00" + "time": "2024-05-20T16:52:34+00:00" }, { "name": "wp-forge/helpers", From 191492ab43e7f435ed3d4a860be3dac3d1a86265 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 21 May 2024 16:24:12 -0400 Subject: [PATCH 18/23] register feature with new filter --- bootstrap.php | 10 ++++++++++ composer.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 bootstrap.php diff --git a/bootstrap.php b/bootstrap.php new file mode 100644 index 0000000..9020789 --- /dev/null +++ b/bootstrap.php @@ -0,0 +1,10 @@ + Date: Tue, 21 May 2024 16:46:09 -0400 Subject: [PATCH 19/23] check function_exists first --- bootstrap.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bootstrap.php b/bootstrap.php index 9020789..6ea4aa2 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -2,9 +2,11 @@ namespace NewfoldLabs\WP\Module\Staging; -add_filter( - 'newfold/features/filter/register', - function( $features ) { - return array_merge( $features, array( StagingFeature::class ) ); - } -); \ No newline at end of file +if ( function_exists( 'add_filter' ) ) { + add_filter( + 'newfold/features/filter/register', + function( $features ) { + return array_merge( $features, array( StagingFeature::class ) ); + } + ); +} \ No newline at end of file From 44cc4336ee8fe859cf16321d302f8fe21af1254f Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 21 May 2024 17:15:59 -0400 Subject: [PATCH 20/23] update feature module --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 00dfc47..192dfdc 100644 --- a/composer.json +++ b/composer.json @@ -48,6 +48,6 @@ }, "require": { "newfold-labs/wp-module-context": "^1.0", - "newfold-labs/wp-module-features": "^1.2" + "newfold-labs/wp-module-features": "^1.3.0" } } diff --git a/composer.lock b/composer.lock index 5b5b5ca..245648e 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": "297ddabeed091964db43e3b8b71a1f4d", + "content-hash": "8cb5570aaacaa3fe34a9f3c140f0c447", "packages": [ { "name": "doctrine/inflector", @@ -158,16 +158,16 @@ }, { "name": "newfold-labs/wp-module-features", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/newfold-labs/wp-module-features.git", - "reference": "e46032e09a14ab76e28ca20c276a76fa0c6a9023" + "reference": "e2eb88461048a77a8df59c381bd6fe36af9277f3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/newfold-labs/wp-module-features/zipball/e46032e09a14ab76e28ca20c276a76fa0c6a9023", - "reference": "e46032e09a14ab76e28ca20c276a76fa0c6a9023", + "url": "https://api.github.com/repos/newfold-labs/wp-module-features/zipball/e2eb88461048a77a8df59c381bd6fe36af9277f3", + "reference": "e2eb88461048a77a8df59c381bd6fe36af9277f3", "shasum": "" }, "require": { @@ -208,10 +208,10 @@ ], "description": "A module for providing an interface for features.", "support": { - "source": "https://github.com/newfold-labs/wp-module-features/tree/1.2.0", + "source": "https://github.com/newfold-labs/wp-module-features/tree/1.3.0", "issues": "https://github.com/newfold-labs/wp-module-features/issues" }, - "time": "2024-05-20T16:52:34+00:00" + "time": "2024-05-21T21:05:48+00:00" }, { "name": "wp-forge/helpers", From 85b3da6b6f5f8604879b3a0d6558eb607dc72d1c Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 21 May 2024 17:23:34 -0400 Subject: [PATCH 21/23] lint fixes --- bootstrap.php | 14 +++++++------- includes/Staging.php | 24 ------------------------ includes/StagingFeature.php | 2 +- 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/bootstrap.php b/bootstrap.php index 6ea4aa2..02e1735 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -3,10 +3,10 @@ namespace NewfoldLabs\WP\Module\Staging; if ( function_exists( 'add_filter' ) ) { - add_filter( - 'newfold/features/filter/register', - function( $features ) { - return array_merge( $features, array( StagingFeature::class ) ); - } - ); -} \ No newline at end of file + add_filter( + 'newfold/features/filter/register', + function ( $features ) { + return array_merge( $features, array( StagingFeature::class ) ); + } + ); +} diff --git a/includes/Staging.php b/includes/Staging.php index eafd4d6..f19ae5e 100644 --- a/includes/Staging.php +++ b/includes/Staging.php @@ -164,30 +164,6 @@ public function getEnvironment() { return get_option( 'staging_environment', 'production' ); } - /** - * Get production screenshot URL. - * - * @param int $width Screenshot width. - * @param int $height Screenshot height. - * - * @return string - */ - public function getProductionScreenshotUrl( $width = 122, $height = 92 ) { - return ''; - } - - /** - * Get staging screenshot URL. - * - * @param int $width Screenshot width. - * @param int $height Screenshot height. - * - * @return string - */ - public function getStagingScreenshotUrl( $width = 122, $height = 92 ) { - return ''; - } - /** * Check if the current environment matches a specific value. * diff --git a/includes/StagingFeature.php b/includes/StagingFeature.php index 0f1d87c..577a4ca 100644 --- a/includes/StagingFeature.php +++ b/includes/StagingFeature.php @@ -18,7 +18,7 @@ class StagingFeature extends \NewfoldLabs\WP\Module\Features\Feature { * * @var string */ - protected $name = 'staging'; + protected $name = 'staging'; /** * The feature value. Defaults to on. From ae85ec034b3764438d53b08df409883a48435f3f Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 21 May 2024 17:27:16 -0400 Subject: [PATCH 22/23] revert removing screenshot methods --- includes/Staging.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/includes/Staging.php b/includes/Staging.php index f19ae5e..eafd4d6 100644 --- a/includes/Staging.php +++ b/includes/Staging.php @@ -164,6 +164,30 @@ public function getEnvironment() { return get_option( 'staging_environment', 'production' ); } + /** + * Get production screenshot URL. + * + * @param int $width Screenshot width. + * @param int $height Screenshot height. + * + * @return string + */ + public function getProductionScreenshotUrl( $width = 122, $height = 92 ) { + return ''; + } + + /** + * Get staging screenshot URL. + * + * @param int $width Screenshot width. + * @param int $height Screenshot height. + * + * @return string + */ + public function getStagingScreenshotUrl( $width = 122, $height = 92 ) { + return ''; + } + /** * Check if the current environment matches a specific value. * From 5e619b130a2d954cf9a12859b90200e77518ebf4 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Wed, 29 May 2024 10:17:53 -0400 Subject: [PATCH 23/23] Revert "target plugin branch with features module for tests" This reverts commit db67e8595cbb7ef47f31375a50e8a5ab0f72e565. --- .github/workflows/brand-plugin-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/brand-plugin-test.yml b/.github/workflows/brand-plugin-test.yml index 702df3e..c92f34d 100644 --- a/.github/workflows/brand-plugin-test.yml +++ b/.github/workflows/brand-plugin-test.yml @@ -31,7 +31,6 @@ jobs: module-repo: ${{ github.repository }} module-branch: ${{ needs.setup.outputs.branch }} plugin-repo: 'bluehost/bluehost-wordpress-plugin' - plugin-branch: 'add/features-module' secrets: inherit hostgator: