2023-08-21 11:40:14 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Plugin Name: Fictioneer Fast Requests
|
|
|
|
* Description: Skips plugins for faster requests.
|
2024-05-07 14:39:01 +02:00
|
|
|
* Version: 1.1.0
|
2023-08-21 11:40:14 +02:00
|
|
|
* Author: Tetrakern
|
|
|
|
* Author URI: https://github.com/Tetrakern
|
|
|
|
* Donate link: https://ko-fi.com/tetrakern
|
|
|
|
* License: GNU General Public License v3.0 or later
|
|
|
|
* License URI: http://www.gnu.org/licenses/gpl.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Check if AJAX request
|
2024-05-07 14:39:01 +02:00
|
|
|
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['fcn_fast_ajax'] ) ) {
|
2023-08-21 11:40:14 +02:00
|
|
|
add_filter( 'option_active_plugins', 'fictioneer_exclude_plugins' );
|
|
|
|
}
|
|
|
|
|
|
|
|
$request_uri = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
|
|
|
|
|
2023-08-24 02:37:15 +02:00
|
|
|
// Check REST Request
|
|
|
|
if ( strpos( $request_uri, 'wp-json/fictioneer/' ) !== false ) {
|
|
|
|
add_filter( 'option_active_plugins', 'fictioneer_exclude_plugins' );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filters the list of active plugins
|
|
|
|
*
|
|
|
|
* @since 1.0.0
|
|
|
|
*
|
|
|
|
* @param array $plugins An array of active plugin paths.
|
|
|
|
*
|
|
|
|
* @return array Filtered array of active plugins.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_exclude_plugins( $plugins ) {
|
|
|
|
// Setup
|
|
|
|
$allow_list = array(
|
2024-05-07 15:16:16 +02:00
|
|
|
// 'plugin-name/plugin-name.php' // Example!
|
2023-08-24 02:37:15 +02:00
|
|
|
);
|
|
|
|
|
2024-05-07 15:16:16 +02:00
|
|
|
// Remove not allowed plugins, but allow all Fictioneer ones
|
|
|
|
foreach ( $plugins as $index => $plugin ) {
|
|
|
|
if ( ! in_array( $plugin, $allow_list ) && strpos( $plugin, 'fictioneer' ) === false ) {
|
|
|
|
unset( $plugins[ $index ] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Continue filter
|
|
|
|
return $plugins;
|
2023-08-24 02:37:15 +02:00
|
|
|
}
|
|
|
|
|
2023-08-23 13:00:19 +02:00
|
|
|
// Check if AJAX comment request
|
2024-05-07 16:06:47 +02:00
|
|
|
if (
|
|
|
|
get_option( 'fictioneer_enable_fast_ajax_comments' ) &&
|
|
|
|
defined( 'DOING_AJAX' ) && DOING_AJAX &&
|
|
|
|
isset( $_REQUEST['fcn_fast_comment_ajax'] )
|
|
|
|
) {
|
2023-08-24 02:37:15 +02:00
|
|
|
add_filter( 'option_active_plugins', 'fictioneer_exclude_plugins_while_commenting' );
|
2023-08-21 11:40:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-08-24 02:37:15 +02:00
|
|
|
* Filters the list of active plugins when commenting
|
2023-08-21 11:40:14 +02:00
|
|
|
*
|
|
|
|
* @since 1.0.0
|
|
|
|
*
|
|
|
|
* @param array $plugins An array of active plugin paths.
|
|
|
|
*
|
|
|
|
* @return array Filtered array of active plugins.
|
|
|
|
*/
|
|
|
|
|
2023-08-24 02:37:15 +02:00
|
|
|
function fictioneer_exclude_plugins_while_commenting( $plugins ) {
|
2023-08-21 11:40:14 +02:00
|
|
|
// Setup
|
|
|
|
$allow_list = array(
|
2023-08-24 02:37:15 +02:00
|
|
|
'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
|
2023-08-24 12:22:43 +02:00
|
|
|
'hummingbird-performance/wp-hummingbird.php', // Hummingbird
|
2023-08-24 02:37:15 +02:00
|
|
|
'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
|
2023-08-21 11:40:14 +02:00
|
|
|
);
|
|
|
|
|
2023-08-24 12:22:43 +02:00
|
|
|
// Filter and continue
|
|
|
|
return array_intersect( $plugins, $allow_list );
|
2023-08-21 11:40:14 +02:00
|
|
|
}
|