| 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 | if( |
| | 213 | |
| | 214 | // If we're deliberatly trying to bypass loading plugins |
| | 215 | isset( $_GET['_wp_dont_load_plugins'] ) |
| | 216 | |
| | 217 | // Through the Dashboard |
| | 218 | && is_admin() |
| | 219 | |
| | 220 | // And a user is logged in (no use setting if a user isn't logged in) |
| | 221 | && isset( $_COOKIE[LOGGED_IN_COOKIE] ) |
| | 222 | ) { |
| | 223 | |
| | 224 | // Our cookie lasts 10 minutes so if somehow it was set it gets de-activated. |
| | 225 | $cookie_to_expire = time() + 600; |
| | 226 | |
| | 227 | // Set a cookie for the user so they have time to de-activate the plugin. |
| | 228 | setcookie( |
| | 229 | '_wp_dont_load_plugins', |
| | 230 | |
| | 231 | // Store something that makes this unique so it can't be done by somebody else. |
| | 232 | md5( $_COOKIE[LOGGED_IN_COOKIE] ), |
| | 233 | |
| | 234 | // Expire time. |
| | 235 | $cookie_to_expire |
| | 236 | ); |
| | 237 | |
| | 238 | // Throw a message if we set this and the cookie was set (first time). |
| | 239 | add_action( 'admin_notices', 'wp_plugins_not_loaded_notice' ); |
| | 240 | |
| | 241 | // Don't load plugins... |
| | 242 | |
| | 243 | } elseif( |
| | 244 | |
| | 245 | // If our cookie is set. |
| | 246 | isset( $_COOKIE['_wp_dont_load_plugins'] ) |
| | 247 | |
| | 248 | // And our login details match (just to make this cookie hard to duplicate). |
| | 249 | && $_COOKIE['_wp_dont_load_plugins'] == md5( $_COOKIE[LOGGED_IN_COOKIE] ) |
| | 250 | |
| | 251 | // Only for the Dashboards. |
| | 252 | && is_admin() |
| | 253 | |
| | 254 | // And we're not trying to turn this off. |
| | 255 | && ! isset( $_GET['_wp_load_plugins'] ) |
| | 256 | ) { |
| | 257 | |
| | 258 | // Throw a message if the cookie is active. |
| | 259 | add_action( 'admin_notices', 'wp_plugins_not_loaded_notice' ); |
| | 260 | |
| | 261 | // Don't load plugins... |
| | 262 | |
| | 263 | } elseif( |
| | 264 | |
| | 265 | // We want to start loading plugins again. |
| | 266 | isset( $_GET['_wp_load_plugins'] ) |
| | 267 | |
| | 268 | // Activated through the Dashboard. |
| | 269 | && is_admin() |
| | 270 | |
| | 271 | ) { |
| | 272 | |
| | 273 | // Remove the cookie. |
| | 274 | setcookie( |
| | 275 | '_wp_dont_load_plugins', |
| | 276 | |
| | 277 | // No value |
| | 278 | false, |
| | 279 | |
| | 280 | // Expire |
| | 281 | time() - 3600 |
| | 282 | ); |
| | 283 | |
| | 284 | // Don't load plugins... |
| | 285 | |
| | 286 | } else { |
| | 287 | |
| | 288 | // Load active plugins. |
| | 289 | foreach ( wp_get_active_and_valid_plugins() as $plugin ) { |
| | 290 | wp_register_plugin_realpath( $plugin ); |
| | 291 | include_once( $plugin ); |
| | 292 | } |
| | 293 | |
| | 294 | unset( $plugin ); |
| | 295 | |