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

Add feature via Features Module #26

Merged
merged 24 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
46cdb73
add staging feature class and move module registration into it
circlecube Apr 25, 2024
c8b6cd2
require features module
circlecube Apr 25, 2024
079390d
Merge branch 'main' into add/staging-feature
circlecube Apr 25, 2024
acf3f7b
use getFeature helper method to disable staging based on context
circlecube May 1, 2024
452fa01
remove module loader registration
circlecube May 7, 2024
bbd4374
update to release version of features module
circlecube May 13, 2024
a1921af
use feature hooks class for managing the hooks
circlecube May 13, 2024
b67263f
require the feature class
circlecube May 13, 2024
db67e85
target plugin branch with features module for tests
circlecube May 13, 2024
92b1ebd
reference global wp hook methods
circlecube May 13, 2024
b9d61f5
add feature hooks after plugins_loaded
circlecube May 14, 2024
978d4ba
defensive code cleanup
circlecube May 14, 2024
e1da152
fix lint
circlecube May 14, 2024
6471660
fix lint
circlecube May 14, 2024
b103e5d
update phpcs versions
circlecube May 14, 2024
7cc9a1b
load file via composer rather than require_once
circlecube May 15, 2024
f553c96
remove atomic detection
circlecube May 20, 2024
4ca5c99
update to latest features module
circlecube May 20, 2024
191492a
register feature with new filter
circlecube May 21, 2024
1702b13
check function_exists first
circlecube May 21, 2024
44cc433
update feature module
circlecube May 21, 2024
85b3da6
lint fixes
circlecube May 21, 2024
ae85ec0
revert removing screenshot methods
circlecube May 21, 2024
5e619b1
Revert "target plugin branch with features module for tests"
circlecube May 29, 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
32 changes: 6 additions & 26 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
<?php

use NewfoldLabs\WP\ModuleLoader\Container;
use NewfoldLabs\WP\Module\Staging\Staging;
use function NewfoldLabs\WP\ModuleLoader\register;
use function NewfoldLabs\WP\Context\getContext;

if ( function_exists( 'add_action' ) ) {

add_action(
'plugins_loaded',
function () {

register(
array(
'name' => 'staging',
'label' => __( 'Staging', 'newfold-staging-module' ),
'callback' => function ( Container $container ) {
if ( 'atomic' === getContext( 'platform' ) ) {
return;
}
return new Staging( $container );
},
'isActive' => true,
'isHidden' => true,
)
);
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 ) );
}
);

}
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
]
},
"require-dev": {
"newfold-labs/wp-php-standards": "^1.2"
"newfold-labs/wp-php-standards": "^1.2.2"
},
"scripts": {
"fix": [
Expand All @@ -47,6 +47,7 @@
}
},
"require": {
"newfold-labs/wp-module-context": "^1.0"
"newfold-labs/wp-module-context": "^1.0",
"newfold-labs/wp-module-features": "^1.3.0"
}
}
}
96 changes: 95 additions & 1 deletion composer.lock

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

4 changes: 1 addition & 3 deletions includes/Staging.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -49,7 +48,7 @@ function () {
// add CLI commands
add_action(
'cli_init',
function() {
function () {
\WP_CLI::add_command(
'newfold staging',
'NewfoldLabs\WP\Module\Staging\StagingCLI',
Expand Down Expand Up @@ -446,5 +445,4 @@ protected function runCommand( $command, $args = null ) {

return $response;
}

}
45 changes: 45 additions & 0 deletions includes/StagingFeature.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace NewfoldLabs\WP\Module\Staging;

use NewfoldLabs\WP\ModuleLoader\Container;
use NewfoldLabs\WP\Module\Staging\Staging;
use function NewfoldLabs\WP\ModuleLoader\container as getContainer;

/**
* 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';

/**
* The feature value. Defaults to on.
*
* @var boolean
*/
protected $value = true;

/**
* Initialize staging feature.
*/
public function initialize() {
if ( function_exists( 'add_action' ) ) {

// Register module
add_action(
'plugins_loaded',
function () {
new Staging( getContainer() );
}
);
}
}
}
4 changes: 2 additions & 2 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<ruleset name="Staging-Module">
<rule ref="Newfold"/>
<config name="testVersion" value="7.0-"/>
<config name="minimum_supported_wp_version" value="5.9"/>
<config name="testVersion" value="7.3-"/>
<config name="minimum_supported_wp_version" value="6.3"/>
<rule ref="WordPress-Core">
<exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid"/>
<exclude name="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase"/>
Expand Down
Loading