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

put back the caching admin bar item and dynamically set the performance settings link… #29

Merged
Merged
Changes from 1 commit
Commits
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
20 changes: 5 additions & 15 deletions includes/Performance.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

namespace NewfoldLabs\WP\Module\Performance;

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

/**
Expand Down Expand Up @@ -72,10 +69,7 @@ public function __construct( Container $container ) {
$cacheManager = new CacheManager( $container );
$cachePurger = new CachePurgingService( $cacheManager->getInstances() );

// Ensure that purgeable cache types are enabled before showing the UI.
if ( $cachePurger->canPurge() ) {
add_action( 'admin_bar_menu', array( $this, 'adminBarMenu' ), 100 );
}
add_action( 'admin_bar_menu', array( $this, 'adminBarMenu' ), 100 );

$container->set( 'cachePurger', $cachePurger );

Expand Down Expand Up @@ -105,10 +99,8 @@ function () {

/**
* Add hooks.
*
* @param Container $container the container
*/
public function hooks( Container $container ) {
public function hooks() {

add_action( 'admin_init', array( $this, 'registerSettings' ), 11 );

Expand Down Expand Up @@ -149,11 +141,9 @@ function () {
* @hooked action_scheduler_retention_period
* @see ActionScheduler_QueueCleaner::delete_old_actions()
*
* @param int $retention_period Minimum scheduled age in seconds of the actions to be deleted.
*
* @return int New retention period in seconds.
*/
public function nfd_asr_default( $retention_period ) {
public function nfd_asr_default() {
return 5 * constant( 'DAY_IN_SECONDS' );
}

Expand Down Expand Up @@ -254,7 +244,6 @@ public function adminBarMenu( \WP_Admin_Bar $wp_admin_bar ) {
}

if ( current_user_can( 'manage_options' ) ) {

$wp_admin_bar->add_node(
array(
'id' => 'nfd_purge_menu',
Expand Down Expand Up @@ -282,12 +271,13 @@ public function adminBarMenu( \WP_Admin_Bar $wp_admin_bar ) {
);
}

$brand = $this->container->get( 'plugin' )['id'];
$wp_admin_bar->add_node(
array(
'id' => 'nfd_purge_menu-cache_settings',
'title' => __( 'Cache Settings', 'newfold-module-performance' ),
'parent' => 'nfd_purge_menu',
'href' => admin_url( 'options-general.php#' . Performance::SETTINGS_ID ),
'href' => admin_url( "admin.php?page=$brand#/performance" ),
)
);
}
Expand Down
Loading