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 | } elseif( |
| 242 | |
| 243 | // If our cookie is set. |
| 244 | isset( $_COOKIE['_wp_dont_load_plugins'] ) |
| 245 | |
| 246 | // And our login details match (just to make this cookie hard to duplicate). |
| 247 | && $_COOKIE['_wp_dont_load_plugins'] == md5( $_COOKIE[LOGGED_IN_COOKIE] ) |
| 248 | |
| 249 | // Only for the dashboardDashboard. |
| 250 | && is_admin() |
| 251 | |
| 252 | // And we're not trying to turn this off. |
| 253 | && ! isset( $_GET['_wp_load_plugins'] ) |
| 254 | ) { |
| 255 | |
| 256 | // Throw a message if the cookie is active. |
| 257 | add_action( 'admin_notices', 'wp_plugins_not_loaded_notice' ); |
| 258 | |
| 259 | } elseif( |
| 260 | |
| 261 | // We want to start loading plugins again. |
| 262 | isset( $_GET['_wp_load_plugins'] ) |
| 263 | |
| 264 | // Activated through the Dashboard. |
| 265 | && is_admin() |
| 266 | |
| 267 | ) { |
| 268 | |
| 269 | // Remove the cookie. |
| 270 | setcookie( |
| 271 | '_wp_dont_load_plugins', |
| 272 | |
| 273 | // No value |
| 274 | false, |
| 275 | |
| 276 | // Expire |
| 277 | time() - 3600 |
| 278 | ); |
| 279 | |
| 280 | } else { |
| 281 | |
| 282 | // Load active plugins. |
| 283 | foreach ( wp_get_active_and_valid_plugins() as $plugin ) { |
| 284 | wp_register_plugin_realpath( $plugin ); |
| 285 | include_once( $plugin ); |
| 286 | } |
| 287 | |