### Eclipse Workspace Patch 1.0
#P wordpress-trunk
|
|
|
258 | 258 | * @param string $plugin Base plugin path from plugins directory. |
259 | 259 | * @return bool True, if in the active plugins list. False, not in the list. |
260 | 260 | */ |
261 | | function is_plugin_active($plugin) { |
262 | | return in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ); |
| 261 | function is_plugin_active( $plugin ) { |
| 262 | return in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ) ); |
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
… |
… |
|
286 | 286 | * @param string $redirect Optional. URL to redirect to. |
287 | 287 | * @return WP_Error|null WP_Error on invalid file or null on success. |
288 | 288 | */ |
289 | | function activate_plugin($plugin, $redirect = '') { |
290 | | $current = get_option('active_plugins'); |
291 | | $plugin = plugin_basename(trim($plugin)); |
| 289 | function activate_plugin( $plugin, $redirect = '' ) { |
| 290 | $current = get_option( 'active_plugins', array() ); |
| 291 | $plugin = plugin_basename( trim( $plugin ) ); |
292 | 292 | |
293 | 293 | $valid = validate_plugin($plugin); |
294 | 294 | if ( is_wp_error($valid) ) |
… |
… |
|
322 | 322 | * @param string|array $plugins Single plugin or list of plugins to deactivate. |
323 | 323 | * @param bool $silent Optional, default is false. Prevent calling deactivate hook. |
324 | 324 | */ |
325 | | function deactivate_plugins($plugins, $silent= false) { |
326 | | $current = get_option('active_plugins'); |
| 325 | function deactivate_plugins( $plugins, $silent = false ) { |
| 326 | $current = get_option( 'active_plugins', array() ); |
327 | 327 | |
328 | | if ( !is_array($plugins) ) |
329 | | $plugins = array($plugins); |
330 | | |
331 | | foreach ( $plugins as $plugin ) { |
| 328 | foreach ( (array) $plugins as $plugin ) { |
332 | 329 | $plugin = plugin_basename($plugin); |
333 | 330 | if( ! is_plugin_active($plugin) ) |
334 | 331 | continue; |
… |
… |
|
475 | 472 | return true; |
476 | 473 | } |
477 | 474 | |
| 475 | /** |
| 476 | * validate active plugins |
| 477 | * |
| 478 | * validate all active plugins, deactivates invalid and |
| 479 | * returns an array of deactived ones. |
| 480 | * |
| 481 | * @since unknown |
| 482 | * @return array invalid plugins, plugin as key, error as value |
| 483 | */ |
478 | 484 | function validate_active_plugins() { |
479 | | $check_plugins = apply_filters( 'active_plugins', get_option('active_plugins') ); |
| 485 | $plugins = apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ); |
480 | 486 | |
481 | | // Sanity check. If the active plugin list is not an array, make it an |
482 | | // empty array. |
483 | | if ( !is_array($check_plugins) ) { |
| 487 | // validate vartype: array |
| 488 | if ( !is_array( $plugins ) ) { |
484 | 489 | update_option('active_plugins', array()); |
485 | 490 | return; |
486 | 491 | } |
487 | 492 | |
488 | | //Invalid is any plugin that is deactivated due to error. |
489 | 493 | $invalid = array(); |
490 | 494 | |
491 | | // If a plugin file does not exist, remove it from the list of active |
492 | | // plugins. |
493 | | foreach ( $check_plugins as $check_plugin ) { |
494 | | $result = validate_plugin($check_plugin); |
| 495 | // invalid plugins get deactivated |
| 496 | foreach ( $plugins as $plugin ) { |
| 497 | $result = validate_plugin( $plugin ); |
495 | 498 | if ( is_wp_error( $result ) ) { |
496 | | $invalid[$check_plugin] = $result; |
497 | | deactivate_plugins( $check_plugin, true); |
| 499 | $invalid[$plugin] = $result; |
| 500 | deactivate_plugins( $plugin, true ); |
498 | 501 | } |
499 | 502 | } |
500 | 503 | return $invalid; |