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 module #22

Merged
merged 29 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c95fc5a
require features module
circlecube May 6, 2024
a05c7e2
move module registration into PerformanceFeature class and remove boo…
circlecube May 7, 2024
752b1ec
update performance feature based on context in bootstrap
circlecube May 7, 2024
971b270
remove module loader registration
circlecube May 7, 2024
ffc9ec0
set up actions for contextual feature management
circlecube May 10, 2024
8578eea
update to release version of features module
circlecube May 13, 2024
61dafb7
use feature hooks class for managing the hooks
circlecube May 13, 2024
06baa28
target plugin branch with features module for tests
circlecube May 13, 2024
be22ad1
require the feature class
circlecube May 13, 2024
8ad6dc8
reference global wp hook methods
circlecube May 13, 2024
6d8ee67
add feature hooks after plugins_loaded
circlecube May 14, 2024
b24f55a
defensive code cleanup
circlecube May 14, 2024
a870844
add lint workflow
circlecube May 14, 2024
fcfdb56
add newfold php standards package
circlecube May 14, 2024
9a37188
fix lint
circlecube May 14, 2024
a85e586
tabs
circlecube May 14, 2024
efe8f6f
fix lint
circlecube May 14, 2024
371bc7c
load file via composer rather than require_once
circlecube May 15, 2024
2202067
move container hooks into hooks class
circlecube May 15, 2024
eefe02f
remove atomic detection hooks
circlecube May 20, 2024
cf5ffd4
update to latest features module
circlecube May 20, 2024
1afaf02
add hooks to run act/deactivation steps when feature is en/disabled
circlecube May 21, 2024
727f5bf
lint fixes
circlecube May 21, 2024
0c28f91
remove whitespace
circlecube May 21, 2024
2e3710f
require PerformanceFeature file
circlecube May 21, 2024
00058b5
register feature with new filter
circlecube May 21, 2024
08f3180
check function_exists first
circlecube May 21, 2024
329a2fd
update feature module
circlecube May 21, 2024
6eeca8c
lint
circlecube May 21, 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
1 change: 1 addition & 0 deletions .github/workflows/brand-plugin-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Lint
on:
push:
branches:
- '**'
paths:
- '**.php'
pull_request:
types: [opened, edited, reopened, ready_for_review]
paths:
- '**.php'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

jobs:
phpcs:
name: Run PHP Code Sniffer
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v3

# User PHP 7.4 here for compatibility with the WordPress codesniffer rules.
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
tools: composer, cs2pr

- uses: technote-space/get-diff-action@v6
with:
SUFFIX_FILTER: .php

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
if: "!! env.GIT_DIFF"

- name: Cache Composer vendor directory
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
if: "!! env.GIT_DIFF"

- name: Validate composer.json and composer.lock
run: composer validate
if: "!! env.GIT_DIFF"

- name: Install dependencies
run: composer install --no-progress --optimize-autoloader --prefer-dist
if: "!! env.GIT_DIFF"

- name: Detecting PHP Code Standards Violations
run: vendor/bin/phpcs --standard=phpcs.xml -s ${{ env.GIT_DIFF }}
if: "!! env.GIT_DIFF"
77 changes: 2 additions & 75 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,78 +1,5 @@
<?php

use NewfoldLabs\WP\Module\Performance\CacheTypes\Browser;
use NewfoldLabs\WP\Module\Performance\CacheTypes\Cloudflare;
use NewfoldLabs\WP\Module\Performance\CacheTypes\File;
use NewfoldLabs\WP\Module\Performance\CacheTypes\Skip404;
use NewfoldLabs\WP\Module\Performance\Performance;
use NewfoldLabs\WP\Module\Performance\ResponseHeaderManager;
use NewfoldLabs\WP\ModuleLoader\Container;
namespace NewfoldLabs\WP\Module\Performance;

use function NewfoldLabs\WP\Module\Performance\getCacheLevel;
use function NewfoldLabs\WP\ModuleLoader\register;
use function NewfoldLabs\WP\Context\getContext;

if ( function_exists( 'add_action' ) ) {

add_action(
'plugins_loaded',
function () {
register(
[
'name' => 'performance',
'label' => __( 'Performance', 'newfold' ),
'callback' => function ( Container $container ) {
if ( 'atomic' === getContext( 'platform' ) ) {
return;
}
new Performance( $container );
},
'isActive' => true,
'isHidden' => true,
]
);

}
);

add_action(
'newfold_container_set',
function ( Container $container ) {
if ( 'atomic' === getContext( 'platform' ) ) {
return;
}

register_activation_hook(
$container->plugin()->file,
function () use ( $container ) {

Skip404::onActivation();
File::onActivation();
Browser::onActivation();

// Add headers to .htaccess
$responseHeaderManager = new ResponseHeaderManager();
$responseHeaderManager->addHeader( 'X-Newfold-Cache-Level', absint( getCacheLevel() ) );

}
);

register_deactivation_hook(
$container->plugin()->file,
function () use ( $container ) {

Skip404::onDeactivation();
File::onDeactivation();
Browser::onDeactivation();

// Remove all headers from .htaccess
$responseHeaderManager = new ResponseHeaderManager();
$responseHeaderManager->removeAllHeaders();

}
);

}
);

}
new PerformanceFeatureHooks();
14 changes: 12 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"NewfoldLabs\\WP\\Module\\Performance\\": "includes"
},
"files": [
"includes/PerformanceFeature.php",
"includes/functions.php",
"bootstrap.php"
]
Expand All @@ -28,8 +29,17 @@
],
"require": {
"newfold-labs/wp-module-context": "^1.0",
"wp-forge/collection": "^1.0",
"wp-forge/collection": "^1.0.2",
"wp-forge/wp-htaccess-manager": "^1.0",
"wpscholar/url": "^1.2"
"wpscholar/url": "^1.2.2",
"newfold-labs/wp-module-features": "^1.2"
},
"require-dev": {
"newfold-labs/wp-php-standards": "^1.2.3"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
Loading
Loading