Skip to content

Commit

Permalink
add hooks to run act/deactivation steps when feature is en/disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
circlecube committed May 21, 2024
1 parent cf5ffd4 commit 1afaf02
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions includes/PerformanceFeatureHooks.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
<?php
namespace NewfoldLabs\WP\Module\Performance;


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

use function NewfoldLabs\WP\Module\Performance\getCacheLevel;
use function NewfoldLabs\WP\ModuleLoader\container as getContainer;
use function NewfoldLabs\WP\Context\getContext;
use function NewfoldLabs\WP\Module\Features\disable as disableFeature;
use function NewfoldLabs\WP\Module\Features\isEnabled;

/**
* This class adds performance feature hooks.
Expand All @@ -25,6 +20,7 @@ class PerformanceFeatureHooks {
public function __construct() {
if ( function_exists( 'add_action' ) ) {
add_action( 'newfold_container_set', array( $this, 'pluginHooks') );
add_action( 'plugins_loaded', array( $this, 'hooks' ) );
}
}

Expand All @@ -34,6 +30,15 @@ public function __construct() {
public function pluginHooks( Container $container ) {
register_activation_hook( $container->plugin()->file, array( $this, 'onActivation' ) );
register_deactivation_hook( $container->plugin()->file, array( $this, 'onDeactivation' ) );

}

/**
* Add hooks.
*/
public function hooks() {
add_action( 'newfold/features/action/onEnable:performance', array( $this, 'onActivation' ) );
add_action( 'newfold/features/action/onDisable:performance', array( $this, 'onDeactivation' ) );
}

/**
Expand Down

0 comments on commit 1afaf02

Please sign in to comment.