Update AJAX MU plugin
This commit is contained in:
parent
51ef4fae54
commit
acde99ad35
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Fictioneer Fast AJAX
|
||||
* Description: Skips plugins and theme initialization for faster requests.
|
||||
* Version: 1.0
|
||||
* 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
|
||||
if ( ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if fast AJAX is activated
|
||||
if ( ! isset( $_REQUEST['fcn_fast_ajax'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if action is set and allowed
|
||||
if (
|
||||
! isset( $_REQUEST['action'] ) ||
|
||||
strpos( $_REQUEST['action'], 'fictioneer_ajax' ) !== 0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
function fictioneer_exclude_plugins( $plugins ) {
|
||||
// Setup
|
||||
$allow_list = array(
|
||||
'fictioneer-email-subscriptions/fictioneer-email-subscriptions.php'
|
||||
);
|
||||
|
||||
// Remove not allowed plugins
|
||||
foreach ( $plugins as $index => $plugin ) {
|
||||
if ( ! in_array( $plugin, $allow_list ) ) {
|
||||
unset( $plugins[ $index ] );
|
||||
}
|
||||
}
|
||||
|
||||
// Continue filter
|
||||
return $plugins;
|
||||
}
|
||||
add_filter( 'option_active_plugins', 'fictioneer_exclude_plugins' );
|
55
mu-plugins/fictioneer_fast_requests.php
Normal file
55
mu-plugins/fictioneer_fast_requests.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Fictioneer Fast Requests
|
||||
* Description: Skips plugins for faster requests.
|
||||
* Version: 1.0
|
||||
* 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
|
||||
if (
|
||||
( defined( 'DOING_AJAX' ) && DOING_AJAX ) &&
|
||||
isset( $_REQUEST['fcn_fast_ajax'] ) &&
|
||||
isset( $_REQUEST['action'] ) &&
|
||||
strpos( $_REQUEST['action'], 'fictioneer_ajax' ) === 0
|
||||
) {
|
||||
add_filter( 'option_active_plugins', 'fictioneer_exclude_plugins' );
|
||||
}
|
||||
|
||||
$request_uri = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
|
||||
|
||||
// Check REST Request
|
||||
if ( strpos( $request_uri, 'wp-json/fictioneer_rest/v1/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(
|
||||
'fictioneer-email-subscriptions/fictioneer-email-subscriptions.php'
|
||||
);
|
||||
|
||||
// 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