-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheasydebug.php
59 lines (48 loc) · 1.44 KB
/
easydebug.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* Plugin Name: Easy Debug
* Description: Easily disable plugins and switch to a default theme using query strings.
* Version: 0.0.2
* Author: Jason Stallings, John Dittmar
* Author URI: http://github.com/octalmage/
*/
add_filter("pre_option_template", "easydebug_theme");
add_filter("pre_option_stylesheet", "easydebug_theme");
add_filter("pre_option_active_plugins", "easydebug_plugins");
add_filter("pre_site_option_active_sitewide_plugins", "easydebug_plugins");
function easydebug_theme($theme)
{
if ( isset($_GET["theme"]) )
{
$themes = wp_get_themes();
if ( array_key_exists($_GET["theme"], $themes) )
{
return $_GET["theme"];
}
$default_themes = array_filter(array_keys($themes), function($k)
{
return strpos($k, 'twenty') !== false;
});
$default_themes = array_intersect(array_keys($themes), $default_themes);
if ( !empty($default_themes) )
{
$index = 0;
if ( is_numeric($_GET["theme"]) )
{
$requested_index = (int) $_GET["theme"];
$index = isset($default_themes[$requested_index]) ? $requested_index : 0;
}
return $default_themes[$index];
}
}
return $theme;
}
function easydebug_plugins($plugins)
{
if ( $_GET["disableplugins"] == 1)
{
return array();
}
return $plugins;
}
?>