Exclude cache plugins from MU plugin
This commit is contained in:
parent
1be0c0946c
commit
c2f4e4e8e8
@ -22,16 +22,6 @@ if (
|
|||||||
|
|
||||||
$request_uri = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
|
$request_uri = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
|
||||||
|
|
||||||
// Check if AJAX comment request
|
|
||||||
if (
|
|
||||||
get_option( 'fictioneer_enable_fast_ajax_comments' ) &&
|
|
||||||
( defined( 'DOING_AJAX' ) && DOING_AJAX ) &&
|
|
||||||
strpos( $_REQUEST['action'] ?? '', 'fictioneer_ajax' ) === 0 &&
|
|
||||||
strpos( $_REQUEST['action'] ?? '', '_comment' ) !== false
|
|
||||||
) {
|
|
||||||
add_filter( 'option_active_plugins', 'fictioneer_exclude_plugins' );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check REST Request
|
// Check REST Request
|
||||||
if ( strpos( $request_uri, 'wp-json/fictioneer/' ) !== false ) {
|
if ( strpos( $request_uri, 'wp-json/fictioneer/' ) !== false ) {
|
||||||
add_filter( 'option_active_plugins', 'fictioneer_exclude_plugins' );
|
add_filter( 'option_active_plugins', 'fictioneer_exclude_plugins' );
|
||||||
@ -63,3 +53,50 @@ function fictioneer_exclude_plugins( $plugins ) {
|
|||||||
// Continue filter
|
// Continue filter
|
||||||
return $plugins;
|
return $plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if AJAX comment request
|
||||||
|
if (
|
||||||
|
get_option( 'fictioneer_enable_fast_ajax_comments' ) &&
|
||||||
|
( defined( 'DOING_AJAX' ) && DOING_AJAX ) &&
|
||||||
|
strpos( $_REQUEST['action'] ?? '', 'fictioneer_ajax' ) === 0 &&
|
||||||
|
strpos( $_REQUEST['action'] ?? '', '_comment' ) !== false
|
||||||
|
) {
|
||||||
|
add_filter( 'option_active_plugins', 'fictioneer_exclude_plugins_while_commenting' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters the list of active plugins when commenting
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @param array $plugins An array of active plugin paths.
|
||||||
|
*
|
||||||
|
* @return array Filtered array of active plugins.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function fictioneer_exclude_plugins_while_commenting( $plugins ) {
|
||||||
|
// Setup
|
||||||
|
$allow_list = array(
|
||||||
|
'w3-total-cache/w3-total-cache.php', // W3 Total Cache
|
||||||
|
'wp-super-cache/wp-cache.php', // WP Super Cache
|
||||||
|
'wp-rocket/wp-rocket.php', // WP Rocket
|
||||||
|
'litespeed-cache/litespeed-cache.php', // LiteSpeed Cache
|
||||||
|
'wp-fastest-cache/wpFastestCache.php', // WP Fastest Cache
|
||||||
|
'cache-enabler/cache-enabler.php', // Cache Enabler
|
||||||
|
'hummingbird-performance/wp-hummingbird.php', // Hummingbird – Optimize Speed, Enable Cache
|
||||||
|
'wp-optimize/wp-optimize.php', // WP-Optimize - Clean, Compress, Cache
|
||||||
|
'sg-cachepress/sg-cachepress.php', // SG Optimizer (SiteGround)
|
||||||
|
'breeze/breeze.php', // Breeze (by Cloudways)
|
||||||
|
'nitropack/nitropack.php' // NitroPack
|
||||||
|
);
|
||||||
|
|
||||||
|
// Remove not allowed plugins
|
||||||
|
foreach ( $plugins as $index => $plugin ) {
|
||||||
|
if ( ! in_array( $plugin, $allow_list ) ) {
|
||||||
|
unset( $plugins[ $index ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Continue filter
|
||||||
|
return $plugins;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user