forked from atwellpub/WordPress-Fast-Ajax-Mu-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fast-ajax.php
41 lines (31 loc) · 1.06 KB
/
fast-ajax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
define('FAST_AJAX' , true );
/**
* Enable Fast Ajax
*/
add_filter( 'option_active_plugins', 'ajax_disable_plugins' );
function ajax_disable_plugins($plugins){
/* load all plugins if not in ajax mode */
if ( !defined( 'DOING_AJAX' ) ) {
return $plugins;
}
/* load all plugins if fast_ajax is set to false */
if ( !isset($_REQUEST['fast_ajax']) || !$_REQUEST['fast_ajax'] ) {
return $plugins;
}
/* disable all plugins if none are told to load by the load_plugins array */
if ( !isset($_REQUEST['load_plugins']) || !$_REQUEST['load_plugins'] ) {
return array();
}
/* convert json */
if (!is_array($_REQUEST['load_plugins']) && $_REQUEST['load_plugins']) {
$_REQUEST['load_plugins'] = json_decode($_REQUEST['load_plugins'],true);
}
/* unset plugins not included in the load_plugins array */
foreach ($plugins as $key => $plugin_path) {
if (!in_array($plugin_path, $_REQUEST['load_plugins'] )) {
unset($plugins[$key]);
}
}
return $plugins;
}