| 212 | | // Load active plugins. |
| 213 | | foreach ( wp_get_active_and_valid_plugins() as $plugin ) { |
| 214 | | wp_register_plugin_realpath( $plugin ); |
| 215 | | include_once( $plugin ); |
| | 212 | |
| | 213 | // Load active plugins if we aren't trying to stop them from loading. |
| | 214 | if( |
| | 215 | |
| | 216 | // Only load plugins if we don't pass plugins.php?dontloadplugins. |
| | 217 | ! isset( $_GET['dontloadplugins'] ) |
| | 218 | |
| | 219 | // And our 2 minute cookie isn't set. |
| | 220 | && ! isset( $_COOKIE['wp_dont_load_plugins'] ) |
| | 221 | |
| | 222 | // Or, if we're disabling the cookie, go ahead and load the plugin |
| | 223 | // and remove the cookie. |
| | 224 | || isset( $_GET['loadtheplugins'] ) |
| | 225 | ) { |
| | 226 | |
| | 227 | // Make sure our cookie is removed. |
| | 228 | if( isset( $_COOKIE['wp_dont_load_plugins'] ) ) { |
| | 229 | setcookie( 'wp_dont_load_plugins', '', time() - 3600 ); |
| | 230 | } |
| | 231 | |
| | 232 | // Load active plugins. |
| | 233 | foreach ( wp_get_active_and_valid_plugins() as $plugin ) { |
| | 234 | wp_register_plugin_realpath( $plugin ); |
| | 235 | include_once( $plugin ); |
| | 236 | } |
| | 237 | unset( $plugin ); |
| | 238 | |
| | 239 | } else { |
| | 240 | |
| | 241 | // Our cookie lasts 10 minutes and re-activates the plugins. |
| | 242 | $cookie_to_expire = time() + 600; |
| | 243 | |
| | 244 | // Set a cookie for the user so they have time to de-activate the plugin. |
| | 245 | setcookie( |
| | 246 | 'wp_dont_load_plugins', |
| | 247 | |
| | 248 | // Store the time it will expire so we can use that. |
| | 249 | $cookie_to_expire, |
| | 250 | |
| | 251 | // Expire time. |
| | 252 | $cookie_to_expire |
| | 253 | ); |
| | 254 | |
| | 255 | // Throw a message if we don't load plugins. |
| | 256 | add_action( 'admin_notices', 'wp_plugins_not_loaded_notice' ); |