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