function wpupdate_cron() { include 'includes/wp-update-class.php'; include 'includes/wp-update-functions.php'; $wpupdate = new WP_Update(); $plugins = wpupdate_get_plugins(); foreach ((array) $plugins as $plugin_file => $plugin_info) { $result = $wpupdate->checkPluginUpdate($plugin_file, false, false); if (is_array($result['Errors']) && in_array('Not Cached', $result['Errors'])) { //We want to force an update on this item $result = $wpupdate->checkPluginUpdate($plugin_file, true, true); } } //Now that we've updated every plugins details, we want to update the notices, this will also have the effect of sending the email if theres new updates. $wpupdate->updateNotifications(); }
?> </h2> <?php $file = $_GET['url']; $fileinfo = pathinfo($file); $fileinfo['name'] = $fileinfo['basename']; $filename = wpupdate_url_to_file($file); $messages = $wp_update->installItemFromZip($filename, $fileinfo, 'wp-content/wpupdate/'); unlink($filename); //Once installed, Delete the zip echo '<div class="installLog">'; foreach ($messages as $message) { echo $message . '<br />'; } echo '</div>'; $plugins = wpupdate_get_plugins(ABSPATH . 'wp-content/wpupdate/'); if (1 == count($plugins)) { foreach ($plugins as $pluginFile => $plugin) { //We want the first one from the array. $newdata = $plugin; $newdata['Folder'] = dirname($pluginFile); break; } } else { foreach ($plugins as $pluginFile => $plugin) { //We want the first one from the array. if ($plugin['Name'] != $installedInfo['Name']) { continue; } $newdata = $plugin; $newdata['Folder'] = dirname($pluginFile);
/** * Updates the notifications to display when an admin is logged in if there is an update available * Also emails administrator if email alerts are enabled. * * @param null * @return null */ function updateNotifications() { $previous = get_option('wpupdate_notifications'); $new = array(); //Check for the current updates. $plugins = wpupdate_get_plugins(); foreach ((array) $plugins as $plugin_file => $plugin_info) { $plugin = $this->checkPluginUpdate($plugin_file); if (isset($plugin['Update']) && $plugin['Update']) { $new[$plugin_file] = $plugin; } } //Next, Clear any updates which have been installed if (is_array($previous) && count($previous) > 0) { foreach ($previous as $plugin_file => $plugin_info) { if (!isset($new[$plugin_file])) { array_splice($previous, array_search($plugin_file, $previous), 1); } else { //Item exists. if ($previous[$plugin_file]['HideUpdate'] && $previous[$plugin_file]['Version'] == $new[$plugin_file]['Version']) { //Only honour it if the versions are the same $new[$plugin_file]['HideUpdate'] = true; } else { $new[$plugin_file]['HideUpdate'] = false; } } } } update_option('wpupdate_notifications', $new); //Now $previous contains the updates that were available last time, $new contains those which are available this time. if ($new !== $previous) { $enabled = get_option('update_email_enable'); $email = get_option('update_email_email'); if ($enabled && !empty($email)) { $updatedPlugins = array(); foreach ($new as $plugin_file => $plugin_info) { if (true == $plugin_info['HideUpdate']) { continue; } $updatedPlugins[] = $plugin_info['PluginInfo']['Name'] . ' ' . $plugin_info['PluginInfo']['Version'] . "\n"; } if (count($updatedPlugins) > 0) { $message = sprintf(__('You have %d update(s) available for install.'), count($updatedPlugins)); $message .= "\n\n"; $message .= implode("\n", $updatedPlugins); $message .= "\n\n"; $message .= __('Wordpress Admin page') . ': ' . get_bloginfo('wpurl') . '/wp-admin/plugins.php'; $subject = get_bloginfo('name') . ': ' . __('New Updates available for install'); wp_mail($email, $subject, $message); } //End if plugins } //end if enabled } //end if changes. }
<div class="wrap"> <h2><?php _e('Plugin Management'); ?> </h2> <p><?php _e('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.'); ?> </p> <?php if (get_option('active_plugins')) { $current_plugins = get_option('active_plugins'); } $inactive = get_option('deactivated_plugins'); $plugins = wpupdate_get_plugins(); if (empty($plugins)) { echo '<p>'; _e("Couldn’t open plugins directory or there are no plugins available."); // TODO: make more helpful echo '</p>'; } else { ?> <table class="widefat plugins"> <thead> <tr> <th><?php _e('Plugin'); ?> </th> <th style="text-align: center"><?php