wp_update_plugins [ WordPress Function ]
| Uses: |
|
| Returns: |
|
| Defined at: |
|
Check plugin versions against the latest versions hosted on WordPress.org.
The WordPress version, PHP version, and Locale is sent along with a list of all plugins installed. Checks against the WordPress server at api.wordpress.org. Will only check if WordPress isn't installing.
Source
<?php
function wp_update_plugins() {
include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
if ( defined('WP_INSTALLING') )
return false;
// If running blog-side, bail unless we've not checked in the last 12 hours
if ( !function_exists( 'get_plugins' ) )
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
$plugins = get_plugins();
$active = get_option( 'active_plugins', array() );
$current = get_site_transient( 'update_plugins' );
if ( ! is_object($current) )
$current = new stdClass;
$new_option = new stdClass;
$new_option->last_checked = time();
// Check for update on a different schedule, depending on the page.
switch ( current_filter() ) {
case 'load-update-core.php' :
$timeout = 60; // 1 min
break;
case 'load-plugins.php' :
case 'load-update.php' :
$timeout = 3600; // 1 hour
break;
default :
$timeout = 43200; // 12 hours
}
$time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
if ( $time_not_changed ) {
$plugin_changed = false;
foreach ( $plugins as $file => $p ) {
$new_option->checked[ $file ] = $p['Version'];
if ( !isset( $current->checked[ $file ] ) || strval($current->checked[ $file ]) !== strval($p['Version']) )
$plugin_changed = true;
}
if ( isset ( $current->response ) && is_array( $current->response ) ) {
foreach ( $current->response as $plugin_file => $update_details ) {
if ( ! isset($plugins[ $plugin_file ]) ) {
$plugin_changed = true;
break;
}
}
}
// Bail if we've checked recently and if nothing has changed
if ( ! $plugin_changed )
return false;
}
// Update last_checked for current to prevent multiple blocking requests if request hangs
$current->last_checked = time();
set_site_transient( 'update_plugins', $current );
$to_send = (object) compact('plugins', 'active');
$options = array(
'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
'body' => array( 'plugins' => serialize( $to_send ) ),
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
);
$raw_response = wp_remote_post('http://api.wordpress.org/plugins/update-check/1.0/', $options);
if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) )
return false;
$response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
if ( is_array( $response ) )
$new_option->response = $response;
else
$new_option->response = array();
set_site_transient( 'update_plugins', $new_option );
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- PHPXRef 0.7 : WordPress : Function Reference: wp_update_plugins()
Function and Method Cross Reference. wp_update_plugins(). Defined at: /wp- includes/update.php -> line 122. Referenced 2 times: /wp-includes/update.php ...
phpxref.ftwr.co.uk - [wp-hackers] wp_update_plugins hook?
Nov 12, 2008 ... Previous message: [wp-hackers] wp_update_plugins hook? Next message: [wp- hackers] wp_update_plugins hook? Messages sorted by: ...
lists.automattic.com - WordPress › Support » wp_update_plugins
[resolved] wp_update_plugins (3 posts). miowebdesigns. Member Posted 7 months ago #. Can I comment out. wp_update_plugins. in the update.php file to get ...
wordpress.org - wp_update_plugins (WordPress Function) - WPSeek.com
WordPress lookup for wp_update_plugins, a WordPress Function. wpseek.com is a WordPress-centric search tool for developers and theme authors.
wpseek.com