Remove fix_actve_plugins(). Props hakre. fixes #11750

git-svn-id: http://svn.automattic.com/wordpress/trunk@12848 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-01-26 18:39:12 +00:00
parent 3ffb57a4f8
commit 5d2365a499
7 changed files with 39 additions and 41 deletions

View File

@ -258,8 +258,8 @@ function get_plugins($plugin_folder = '') {
* @param string $plugin Base plugin path from plugins directory. * @param string $plugin Base plugin path from plugins directory.
* @return bool True, if in the active plugins list. False, not in the list. * @return bool True, if in the active plugins list. False, not in the list.
*/ */
function is_plugin_active($plugin) { function is_plugin_active( $plugin ) {
return in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ); return in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ) );
} }
/** /**
@ -286,9 +286,9 @@ function is_plugin_active($plugin) {
* @param string $redirect Optional. URL to redirect to. * @param string $redirect Optional. URL to redirect to.
* @return WP_Error|null WP_Error on invalid file or null on success. * @return WP_Error|null WP_Error on invalid file or null on success.
*/ */
function activate_plugin($plugin, $redirect = '') { function activate_plugin( $plugin, $redirect = '' ) {
$current = get_option('active_plugins'); $current = get_option( 'active_plugins', array() );
$plugin = plugin_basename(trim($plugin)); $plugin = plugin_basename( trim( $plugin ) );
$valid = validate_plugin($plugin); $valid = validate_plugin($plugin);
if ( is_wp_error($valid) ) if ( is_wp_error($valid) )
@ -322,13 +322,10 @@ function activate_plugin($plugin, $redirect = '') {
* @param string|array $plugins Single plugin or list of plugins to deactivate. * @param string|array $plugins Single plugin or list of plugins to deactivate.
* @param bool $silent Optional, default is false. Prevent calling deactivate hook. * @param bool $silent Optional, default is false. Prevent calling deactivate hook.
*/ */
function deactivate_plugins($plugins, $silent= false) { function deactivate_plugins( $plugins, $silent = false ) {
$current = get_option('active_plugins'); $current = get_option( 'active_plugins', array() );
if ( !is_array($plugins) ) foreach ( (array) $plugins as $plugin ) {
$plugins = array($plugins);
foreach ( $plugins as $plugin ) {
$plugin = plugin_basename($plugin); $plugin = plugin_basename($plugin);
if ( ! is_plugin_active($plugin) ) if ( ! is_plugin_active($plugin) )
continue; continue;
@ -475,26 +472,32 @@ function delete_plugins($plugins, $redirect = '' ) {
return true; return true;
} }
/**
* validate active plugins
*
* validate all active plugins, deactivates invalid and
* returns an array of deactived ones.
*
* @since unknown
* @return array invalid plugins, plugin as key, error as value
*/
function validate_active_plugins() { function validate_active_plugins() {
$check_plugins = apply_filters( 'active_plugins', get_option('active_plugins') ); $plugins = apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) );
// Sanity check. If the active plugin list is not an array, make it an // validate vartype: array
// empty array. if ( !is_array( $plugins ) ) {
if ( !is_array($check_plugins) ) {
update_option('active_plugins', array()); update_option('active_plugins', array());
return; return;
} }
//Invalid is any plugin that is deactivated due to error.
$invalid = array(); $invalid = array();
// If a plugin file does not exist, remove it from the list of active // invalid plugins get deactivated
// plugins. foreach ( $plugins as $plugin ) {
foreach ( $check_plugins as $check_plugin ) { $result = validate_plugin( $plugin );
$result = validate_plugin($check_plugin);
if ( is_wp_error( $result ) ) { if ( is_wp_error( $result ) ) {
$invalid[$check_plugin] = $result; $invalid[$plugin] = $result;
deactivate_plugins( $check_plugin, true); deactivate_plugins( $plugin, true );
} }
} }
return $invalid; return $invalid;

View File

@ -208,7 +208,7 @@ foreach ( $plugin_files as $plugin_file ) :
<div id="documentation"><label for="docs-list"><?php _e('Documentation:') ?></label> <?php echo $docs_select ?> <input type="button" class="button" value="<?php esc_attr_e( 'Lookup' ) ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&amp;locale=<?php echo urlencode( get_locale() ) ?>&amp;version=<?php echo urlencode( $wp_version ) ?>&amp;redirect=true'); }" /></div> <div id="documentation"><label for="docs-list"><?php _e('Documentation:') ?></label> <?php echo $docs_select ?> <input type="button" class="button" value="<?php esc_attr_e( 'Lookup' ) ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&amp;locale=<?php echo urlencode( get_locale() ) ?>&amp;version=<?php echo urlencode( $wp_version ) ?>&amp;redirect=true'); }" /></div>
<?php endif; ?> <?php endif; ?>
<?php if ( is_writeable($real_file) ) : ?> <?php if ( is_writeable($real_file) ) : ?>
<?php if ( in_array($file, (array) get_option('active_plugins')) ) { ?> <?php if ( in_array( $file, (array) get_option( 'active_plugins', array() ) ) ) { ?>
<p><?php _e('<strong>Warning:</strong> Making changes to active plugins is not recommended. If your changes cause a fatal error, the plugin will be automatically deactivated.'); ?></p> <p><?php _e('<strong>Warning:</strong> Making changes to active plugins is not recommended. If your changes cause a fatal error, the plugin will be automatically deactivated.'); ?></p>
<?php } ?> <?php } ?>
<p class="submit"> <p class="submit">

View File

@ -113,7 +113,7 @@ if ( !empty($action) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
require_once( 'admin-header.php' ); require_once( 'admin-header.php' );
$url = 'plugins.php?action=upgrade-selected&amp;plugins=' . urlencode( join( ',', $plugins ) ); $url = 'plugins.php?action=upgrade-selected&amp;plugins=' . urlencode( join( ',', $plugins ) );
$title = __( 'Upgrade Plugins' ); $title = __( 'Upgrade Plugins' );
$nonce = 'bulk-manage-plugins'; $nonce = 'bulk-manage-plugins';
@ -283,9 +283,9 @@ add_contextual_help($current_screen, $help);
if ( is_multisite() && is_super_admin() ) { if ( is_multisite() && is_super_admin() ) {
$menu_perms = get_site_option('menu_items', array()); $menu_perms = get_site_option('menu_items', array());
if ( !$menu_perms['plugins'] ) { if ( empty($menu_perms['plugins']) )
add_action( 'admin_notices', '_admin_notice_multisite_activate_plugins_page' ); add_action( 'admin_notices', '_admin_notice_multisite_activate_plugins_page' );
} unset($menu_perms);
} }
$title = __('Manage Plugins'); $title = __('Manage Plugins');

View File

@ -404,7 +404,7 @@ function wp_plugins_to_load() {
if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) )
$plugins[] = ABSPATH . 'my-hacks.php'; $plugins[] = ABSPATH . 'my-hacks.php';
$active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) ); $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) );
if ( !is_array( $active_plugins ) || defined( 'WP_INSTALLING' ) ) if ( !is_array( $active_plugins ) || defined( 'WP_INSTALLING' ) )
return $plugins; return $plugins;
foreach ( $active_plugins as $plugin ) { foreach ( $active_plugins as $plugin ) {

View File

@ -110,4 +110,11 @@ function get_user_details( $username ) {
return get_user_by('login', $username); return get_user_by('login', $username);
} }
/**
* @deprecated 3.0
*/
function clear_global_post_cache( $post_id ) {
_deprecated_function( __FUNCTION__, '3.0', 'clean_post_cache' );
}
?> ?>

View File

@ -725,11 +725,6 @@ function get_blog_post( $blog_id, $post_id ) {
return $post; return $post;
} }
// deprecated, see clean_post_cache()
function clear_global_post_cache( $post_id ) {
return;
}
function add_user_to_blog( $blog_id, $user_id, $role ) { function add_user_to_blog( $blog_id, $user_id, $role ) {
switch_to_blog($blog_id); switch_to_blog($blog_id);
@ -1986,13 +1981,6 @@ function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) {
return false; return false;
} }
function fix_active_plugins( $value ) {
if ( false == is_array( $value ) )
$value = array();
return $value;
}
add_filter( "option_active_plugins", "fix_active_plugins" );
if ( !function_exists('rss_gc') ) : if ( !function_exists('rss_gc') ) :
function rss_gc() { function rss_gc() {
global $wpdb; global $wpdb;

View File

@ -112,7 +112,7 @@ function wp_update_plugins() {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
$plugins = get_plugins(); $plugins = get_plugins();
$active = get_option( 'active_plugins' ); $active = get_option( 'active_plugins', array() );
$current = get_site_transient( 'update_plugins' ); $current = get_site_transient( 'update_plugins' );
if ( ! is_object($current) ) if ( ! is_object($current) )
$current = new stdClass; $current = new stdClass;
@ -147,7 +147,7 @@ function wp_update_plugins() {
$current->last_checked = time(); $current->last_checked = time();
set_site_transient( 'update_plugins', $current ); set_site_transient( 'update_plugins', $current );
$to_send = (object)compact('plugins', 'active'); $to_send = (object) compact('plugins', 'active');
$options = array( $options = array(
'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3), 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),