diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index cc4d9cb61..b501c2a3e 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -99,7 +99,7 @@ function get_plugin_data( $plugin_file ) { function get_plugins($plugin_folder = '') { if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') ) - $cached_plugins = array(); + $cache_plugins = array(); if ( isset($cache_plugins[ $plugin_folder ]) ) return $cache_plugins[ $plugin_folder ]; diff --git a/wp-includes/cron.php b/wp-includes/cron.php index 08fbb0ea8..6eff54a31 100644 --- a/wp-includes/cron.php +++ b/wp-includes/cron.php @@ -133,6 +133,7 @@ function wp_cron() { function wp_get_schedules() { $schedules = array( 'hourly' => array( 'interval' => 3600, 'display' => __('Once Hourly') ), + 'twicedaily' => array( 'interval' => 43200, 'display' => __('Twice Daily') ), 'daily' => array( 'interval' => 86400, 'display' => __('Once Daily') ), ); return array_merge( apply_filters( 'cron_schedules', array() ), $schedules ); diff --git a/wp-includes/update.php b/wp-includes/update.php index 1cdba0534..beeee9fcf 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -90,22 +90,17 @@ function wp_update_plugins() { if ( !function_exists('fsockopen') || defined('WP_INSTALLING') ) return false; - $current = get_option( 'update_plugins' ); - - $time_not_changed = isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ); - // If running blog-side, bail unless we've not checked in the last 12 hours - if ( !function_exists( 'get_plugins' ) ) { - if ( $time_not_changed ) - return false; + if ( !function_exists( 'get_plugins' ) ) require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); - } $plugins = get_plugins(); $active = get_option( 'active_plugins' ); + $current = get_option( 'update_plugins' ); $new_option = ''; $new_option->last_checked = time(); + $time_not_changed = isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ); $plugin_changed = false; foreach ( $plugins as $file => $p ) { @@ -160,9 +155,19 @@ function wp_update_plugins() { update_option( 'update_plugins', $new_option ); } -if ( defined( 'WP_ADMIN' ) && WP_ADMIN ) - add_action( 'admin_init', 'wp_update_plugins' ); -else - add_action( 'init', 'wp_update_plugins' ); + +function _maybe_update_plugins() { + $current = get_option( 'update_plugins' ); + if ( isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ) ) + return; + wp_update_plugins(); +} + +add_action( 'load-plugins.php', 'wp_update_plugins' ); +add_action( 'admin_init', '_maybe_update_plugins' ); +add_action( 'wp_update_plugins', 'wp_update_plugins' ); + +if ( !wp_next_scheduled('wp_update_plugins') ) + wp_schedule_event(time(), 'twicedaily', 'wp_update_plugins'); ?>