From e1da152039df6df058cfafcec8c06708005d9d5e Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 14 May 2024 10:59:12 -0400 Subject: [PATCH] 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 +}