*
* @since 3.7.0
*
- * @param bool $reply Whether to bail without returning the package. Default is false.
- * @param string $package The package file name.
- * @param object $this The WP_Upgrader instance.
+ * @param bool $reply Whether to bail without returning the package.
+ * Default false.
+ * @param string $package The package file name.
+ * @param WP_Upgrader $this The WP_Upgrader instance.
*/
$reply = apply_filters( 'upgrader_pre_download', false, $package, $this );
if ( false !== $reply )
$this->skin->feedback('installing_package');
- $res = apply_filters('upgrader_pre_install', true, $hook_extra);
+ /**
+ * Filter the install response before the installation has started.
+ *
+ * Returning a truthy value, or one that could be evaluated as a WP_Error
+ * will effectively short-circuit the installation, returning that value
+ * instead.
+ *
+ * @since 2.8.0
+ *
+ * @param bool|WP_Error $response Response.
+ * @param array $hook_extra Extra arguments passed to hooked filters.
+ */
+ $res = apply_filters( 'upgrader_pre_install', true, $hook_extra );
if ( is_wp_error($res) )
return $res;
else //It's only a single file, the upgrader will use the foldername of this file as the destination folder. foldername is based on zip filename.
$source = trailingslashit($source);
- //Hook ability to change the source file location..
- $source = apply_filters('upgrader_source_selection', $source, $remote_source, $this);
+ /**
+ * Filter the source file location for the upgrade package.
+ *
+ * @since 2.8.0
+ *
+ * @param string $source File source location.
+ * @param string $remote_source Remove file source location.
+ * @param WP_Upgrader $this WP_Upgrader instance.
+ */
+ $source = apply_filters( 'upgrader_source_selection', $source, $remote_source, $this );
if ( is_wp_error($source) )
return $source;
$removed = true;
if ( $wp_filesystem->exists($remote_destination) )
$removed = $wp_filesystem->delete($remote_destination, true);
- $removed = apply_filters('upgrader_clear_destination', $removed, $local_destination, $remote_destination, $hook_extra);
+
+ /**
+ * Filter whether the upgrader cleared the destination.
+ *
+ * @since 2.8.0
+ *
+ * @param bool $removed Whether the destination was cleared.
+ * @param string $local_destination The local package destination.
+ * @param string $remote_destination The remote package destination.
+ * @param array $hook_extra Extra arguments passed to hooked filters.
+ */
+ $removed = apply_filters( 'upgrader_clear_destination', $removed, $local_destination, $remote_destination, $hook_extra );
if ( is_wp_error($removed) )
return $removed;
$this->result = compact('local_source', 'source', 'source_name', 'source_files', 'destination', 'destination_name', 'local_destination', 'remote_destination', 'clear_destination', 'delete_source_dir');
- $res = apply_filters('upgrader_post_install', true, $hook_extra, $this->result);
+ /**
+ * Filter the install response after the installation has finished.
+ *
+ * @since 2.8.0
+ *
+ * @param bool $response Install response.
+ * @param array $hook_extra Extra arguments passed to hooked filters.
+ * @param array $result Installation result data.
+ */
+ $res = apply_filters( 'upgrader_post_install', true, $hook_extra, $this->result );
+
if ( is_wp_error($res) ) {
$this->result = $res;
return $res;
$this->skin->after();
if ( ! $is_multi ) {
+
+ /** This action is documented in wp-admin/includes/class-wp-upgrader.php */
do_action( 'upgrader_process_complete', $this, $hook_extra );
$this->skin->footer();
}
var $result;
var $bulk = false;
- var $show_before = '';
function upgrade_strings() {
$this->strings['up_to_date'] = __('The plugin is at the latest version.');
$this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true);
if ( !isset( $current->response[ $plugin ] ) ) {
- $this->skin->set_result(true);
+ $this->skin->set_result('up_to_date');
$this->skin->before();
$this->skin->feedback('up_to_date');
$this->skin->after();
$this->maintenance_mode(false);
+ /**
+ * Fires when the bulk upgrader process is complete.
+ *
+ * @since 3.6.0
+ *
+ * @param Plugin_Upgrader $this Plugin_Upgrader instance. In other contexts, $this, might
+ * be a Theme_Upgrader or Core_Upgrade instance.
+ * @param array $data {
+ * Array of bulk item update data.
+ *
+ * @type string $action Type of action. Default 'update'.
+ * @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'.
+ * @type bool $bulk Whether the update process is a bulk update. Default true.
+ * @type array $packages Array of plugin, theme, or core packages to update.
+ * }
+ */
do_action( 'upgrader_process_complete', $this, array(
'action' => 'update',
'type' => 'plugin',
if ( !isset( $current->response[ $theme ] ) ) {
$this->skin->before();
$this->skin->set_result(false);
- $this->skin->error('up_to_date');
+ $this->skin->error( 'up_to_date' );
$this->skin->after();
return false;
}
if ( !isset( $current->response[ $theme ] ) ) {
$this->skin->set_result(true);
$this->skin->before();
- $this->skin->feedback('up_to_date');
+ $this->skin->feedback( 'up_to_date' );
$this->skin->after();
$results[$theme] = true;
continue;
$this->maintenance_mode(false);
+ /** This action is documented in wp-admin/includes/class-wp-upgrader.php */
do_action( 'upgrader_process_complete', $this, array(
'action' => 'update',
- 'type' => 'plugin',
+ 'type' => 'theme',
'bulk' => true,
'themes' => $themes,
) );
elseif ( $parsed_args['pre_check_md5'] && ! $this->check_files() )
$partial = false;
- // If partial update is returned from the API, use that, unless we're doing a reinstall.
- // If we cross the new_bundled version number, then use the new_bundled zip.
- // Don't though if the constant is set to skip bundled items.
- // If the API returns a no_content zip, go with it. Finally, default to the full zip.
+ /*
+ * If partial update is returned from the API, use that, unless we're doing
+ * a reinstall. If we cross the new_bundled version number, then use
+ * the new_bundled zip. Don't though if the constant is set to skip bundled items.
+ * If the API returns a no_content zip, go with it. Finally, default to the full zip.
+ */
if ( $parsed_args['do_rollback'] && $current->packages->rollback )
$to_download = 'rollback';
elseif ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version && $partial )
}
if ( $try_rollback ) {
+ /** This filter is documented in wp-admin/includes/update-core.php */
apply_filters( 'update_feedback', $result );
+
+ /** This filter is documented in wp-admin/includes/update-core.php */
apply_filters( 'update_feedback', $this->strings['start_rollback'] );
$rollback_result = $this->upgrade( $current, array_merge( $parsed_args, array( 'do_rollback' => true ) ) );
}
}
+ /** This action is documented in wp-admin/includes/class-wp-upgrader.php */
do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'core' ) );
// Clear the current updates
// 3: 3.7-alpha-25000 -> 3.7-alpha-25678 -> 3.7-beta1 -> 3.7-beta2
if ( $current_is_development_version ) {
+
+ /**
+ * Filter whether to enable automatic core updates for development versions.
+ *
+ * @since 3.7.0
+ *
+ * @param bool $upgrade_dev Whether to enable automatic updates for
+ * development versions.
+ */
if ( ! apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev ) )
return false;
// else fall through to minor + major branches below
}
// 4: Minor In-branch updates (3.7.0 -> 3.7.1 -> 3.7.2 -> 3.7.4)
- if ( $current_branch == $new_branch )
+ if ( $current_branch == $new_branch ) {
+
+ /**
+ * Filter whether to enable minor automatic core updates.
+ *
+ * @since 3.7.0
+ *
+ * @param bool $upgrade_minor Whether to enable minor automatic core updates.
+ */
return apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor );
+ }
// 5: Major version updates (3.7.0 -> 3.8.0 -> 3.9.1)
- if ( version_compare( $new_branch, $current_branch, '>' ) )
+ if ( version_compare( $new_branch, $current_branch, '>' ) ) {
+
+ /**
+ * Filter whether to enable major automatic core updates.
+ *
+ * @since 3.7.0
+ *
+ * @param bool $upgrade_major Whether to enable major automatic core updates.
+ */
return apply_filters( 'allow_major_auto_core_updates', $upgrade_major );
+ }
// If we're not sure, we don't want it
return false;
* This also disables update notification emails. That may change in the future.
*
* @since 3.7.0
+ *
* @param bool $disabled Whether the updater should be disabled.
*/
return apply_filters( 'automatic_updater_disabled', $disabled );
}
/**
- * Filter whether the automatic updater should consider a filesystem location to be potentially
- * managed by a version control system.
+ * Filter whether the automatic updater should consider a filesystem
+ * location to be potentially managed by a version control system.
*
* @since 3.7.0
*
- * @param bool $checkout Whether a VCS checkout was discovered at $context or ABSPATH, or anywhere higher.
- * @param string $context The filesystem context (a path) against which filesystem status should be checked.
+ * @param bool $checkout Whether a VCS checkout was discovered at $context
+ * or ABSPATH, or anywhere higher.
+ * @param string $context The filesystem context (a path) against which
+ * filesystem status should be checked.
*/
return apply_filters( 'automatic_updates_is_vcs_checkout', $checkout, $context );
}
*
* @since 3.7.0
*
- * @param string $type The type of update being checked: 'core', 'theme', 'plugin', 'translation'.
+ * @param string $type The type of update being checked: 'core', 'theme',
+ * 'plugin', 'translation'.
* @param object $item The update offer.
- * @param string $context The filesystem context (a path) against which filesystem access and status
- * should be checked.
+ * @param string $context The filesystem context (a path) against which filesystem
+ * access and status should be checked.
*/
public function should_update( $type, $item, $context ) {
// Used to see if WP_Filesystem is set up to allow unattended updates.
* The dynamic portion of the hook name, $type, refers to the type of update
* being checked. Can be 'core', 'theme', 'plugin', or 'translation'.
*
- * Generally speaking, plugins, themes, and major core versions are not updated by default,
- * while translations and minor and development versions for core are updated by default.
+ * Generally speaking, plugins, themes, and major core versions are not updated
+ * by default, while translations and minor and development versions for core
+ * are updated by default.
*
- * See the filters allow_dev_auto_core_updates, allow_minor_auto_core_updates, and
- * allow_major_auto_core_updates more straightforward filters to adjust core updates.
+ * See the allow_dev_auto_core_updates, allow_minor_auto_core_updates, and
+ * allow_major_auto_core_updates filters for a more straightforward way to
+ * adjust core updates.
*
* @since 3.7.0
*
$notify = ! empty( $item->notify_email );
/**
- * Whether to notify the site administrator of a new core update.
+ * Filter whether to notify the site administrator of a new core update.
*
- * By default, administrators are notified when the update offer received from WordPress.org
- * sets a particular flag. This allows for discretion in if and when to notify.
+ * By default, administrators are notified when the update offer received
+ * from WordPress.org sets a particular flag. This allows some discretion
+ * in if and when to notify.
*
- * This filter only fires once per release -- if the same email address was already
- * notified of the same new version, we won't repeatedly email the administrator.
+ * This filter is only evaluated once per release. If the same email address
+ * was already notified of the same new version, WordPress won't repeatedly
+ * email the administrator.
*
- * This filter is also used on about.php to check if a plugin has disabled these notifications.
+ * This filter is also used on about.php to check if a plugin has disabled
+ * these notifications.
*
* @since 3.7.0
*
- * @param bool $notify Whether the site administrator is notified.
- * @param object $item The update offer.
+ * @param bool $notify Whether the site administrator is notified.
+ * @param object $item The update offer.
*/
if ( ! apply_filters( 'send_core_update_notification_email', $notify, $item ) )
return false;
break;
case 'theme':
$upgrader = new Theme_Upgrader( $skin );
- $context = get_theme_root( $item );
+ $context = get_theme_root( $item->theme );
break;
case 'translation':
$upgrader = new Language_Pack_Upgrader( $skin );
// Send debugging email to all development installs.
if ( ! empty( $this->update_results ) ) {
$development_version = false !== strpos( $wp_version, '-' );
+
/**
* Filter whether to send a debugging email for each automatic background update.
*
* @since 3.7.0
- * @param bool $development_version By default, emails are sent if the install is a development version.
+ *
+ * @param bool $development_version By default, emails are sent if the
+ * install is a development version.
* Return false to avoid the email.
*/
if ( apply_filters( 'automatic_updates_send_debug_email', $development_version ) )
if ( ! empty( $this->update_results['core'] ) )
$this->after_core_update( $this->update_results['core'][0] );
+
+ /**
+ * Fires after all automatic updates have run.
+ *
+ * @since 3.8.0
+ *
+ * @param array $update_results The results of all attempted updates.
+ */
+ do_action( 'automatic_updates_complete', $this->update_results );
}
// Clear the lock
* @since 3.7.0
*
* @param bool $send Whether to send the email. Default true.
- * @param string $type The type of email to send. Can be one of 'success', 'fail', 'critical'.
+ * @param string $type The type of email to send. Can be one of
+ * 'success', 'fail', 'critical'.
* @param object $core_update The update offer that was attempted.
* @param mixed $result The result for the core update. Can be WP_Error.
*/
break;
}
+ $critical_support = 'critical' === $type && ! empty( $core_update->support_email );
+ if ( $critical_support ) {
+ // Support offer if available.
+ $body .= "\n\n" . sprintf( __( "The WordPress team is willing to help you. Forward this email to %s and the team will work with you to make sure your site is working." ), $core_update->support_email );
+ } else {
+ // Add a note about the support forums.
+ $body .= "\n\n" . __( 'If you experience any issues or need support, the volunteers in the WordPress.org support forums may be able to help.' );
+ $body .= "\n" . __( 'https://wordpress.org/support/' );
+ }
+
// Updates are important!
- if ( $type != 'success' || $newer_version_available )
+ if ( $type != 'success' || $newer_version_available ) {
$body .= "\n\n" . __( 'Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.' );
+ }
- // Add a note about the support forums to all emails.
- $body .= "\n\n" . __( 'If you experience any issues or need support, the volunteers in the WordPress.org support forums may be able to help.' );
- $body .= "\n" . __( 'http://wordpress.org/support/' );
+ if ( $critical_support ) {
+ $body .= " " . __( "If you reach out to us, we'll also ensure you'll never have this problem again." );
+ }
// If things are successful and we're now on the latest, mention plugins and themes if any are out of date.
if ( $type == 'success' && ! $newer_version_available && ( get_plugin_updates() || get_theme_updates() ) ) {
$headers = '';
$email = compact( 'to', 'subject', 'body', 'headers' );
+
/**
* Filter the email sent following an automatic background core update.
*
* @param array $email {
* Array of email arguments that will be passed to wp_mail().
*
- * @type string $to The email recipient. An array of emails can be returned, as handled by wp_mail().
+ * @type string $to The email recipient. An array of emails
+ * can be returned, as handled by wp_mail().
* @type string $subject The email's subject.
* @type string $body The email message body.
* @type string $headers Any email headers, defaults to no headers.
* }
- * @param string $type The type of email being sent. Can be one of 'success', 'fail', 'manual', 'critical'.
+ * @param string $type The type of email being sent. Can be one of
+ * 'success', 'fail', 'manual', 'critical'.
* @param object $core_update The update offer that was attempted.
* @param mixed $result The result for the core update. Can be WP_Error.
*/
$email = apply_filters( 'auto_core_update_email', $email, $type, $core_update, $result );
- wp_mail( $email['to'], $email['subject'], $email['body'], $email['headers'] );
+ wp_mail( $email['to'], wp_specialchars_decode( $email['subject'] ), $email['body'], $email['headers'] );
}
/**
$body = array();
$failures = 0;
- $body[] = 'WordPress site: ' . network_home_url( '/' );
+ $body[] = sprintf( __( 'WordPress site: %s' ), network_home_url( '/' ) );
// Core
if ( isset( $this->update_results['core'] ) ) {
$result = $this->update_results['core'][0];
if ( $result->result && ! is_wp_error( $result->result ) ) {
- $body[] = sprintf( 'SUCCESS: WordPress was successfully updated to %s', $result->name );
+ $body[] = sprintf( __( 'SUCCESS: WordPress was successfully updated to %s' ), $result->name );
} else {
- $body[] = sprintf( 'FAILED: WordPress failed to update to %s', $result->name );
+ $body[] = sprintf( __( 'FAILED: WordPress failed to update to %s' ), $result->name );
$failures++;
}
$body[] = '';
continue;
$success_items = wp_list_filter( $this->update_results[ $type ], array( 'result' => true ) );
if ( $success_items ) {
- $body[] = "The following {$type}s were successfully updated:";
- foreach ( wp_list_pluck( $success_items, 'name' ) as $name )
- $body[] = ' * SUCCESS: ' . $name;
+ $messages = array(
+ 'plugin' => __( 'The following plugins were successfully updated:' ),
+ 'theme' => __( 'The following themes were successfully updated:' ),
+ 'translation' => __( 'The following translations were successfully updated:' ),
+ );
+
+ $body[] = $messages[ $type ];
+ foreach ( wp_list_pluck( $success_items, 'name' ) as $name ) {
+ $body[] = ' * ' . sprintf( __( 'SUCCESS: %s' ), $name );
+ }
}
if ( $success_items != $this->update_results[ $type ] ) {
// Failed updates
- $body[] = "The following {$type}s failed to update:";
+ $messages = array(
+ 'plugin' => __( 'The following plugins failed to update:' ),
+ 'theme' => __( 'The following themes failed to update:' ),
+ 'translation' => __( 'The following translations failed to update:' ),
+ );
+
+ $body[] = $messages[ $type ];
foreach ( $this->update_results[ $type ] as $item ) {
if ( ! $item->result || is_wp_error( $item->result ) ) {
- $body[] = ' * FAILED: ' . $item->name;
+ $body[] = ' * ' . sprintf( __( 'FAILED: %s' ), $item->name );
$failures++;
}
}
$body[] = '';
}
+ $site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
if ( $failures ) {
- $body[] = '';
- $body[] = 'BETA TESTING?';
- $body[] = '=============';
- $body[] = '';
- $body[] = 'This debugging email is sent when you are using a development version of WordPress.';
- $body[] = '';
- $body[] = 'If you think these failures might be due to a bug in WordPress, could you report it?';
- $body[] = ' * Open a thread in the support forums: http://wordpress.org/support/forum/alphabeta';
- $body[] = " * Or, if you're comfortable writing a bug report: http://core.trac.wordpress.org/";
- $body[] = '';
- $body[] = 'Thanks! -- The WordPress Team';
- $body[] = '';
- $subject = sprintf( '[%s] There were failures during background updates', get_bloginfo( 'name' ) );
+ $body[] = __( "
+BETA TESTING?
+=============
+
+This debugging email is sent when you are using a development version of WordPress.
+
+If you think these failures might be due to a bug in WordPress, could you report it?
+ * Open a thread in the support forums: https://wordpress.org/support/forum/alphabeta
+ * Or, if you're comfortable writing a bug report: http://core.trac.wordpress.org/
+
+Thanks! -- The WordPress Team" );
+
+ $subject = sprintf( __( '[%s] There were failures during background updates' ), $site_title );
} else {
- $subject = sprintf( '[%s] Background updates have finished', get_bloginfo( 'name' ) );
+ $subject = sprintf( __( '[%s] Background updates have finished' ), $site_title );
}
- $body[] = 'UPDATE LOG';
- $body[] = '==========';
+ $title = __( 'UPDATE LOG' );
+ $body[] = $title;
+ $body[] = str_repeat( '=', strlen( $title ) );
$body[] = '';
foreach ( array( 'core', 'plugin', 'theme', 'translation' ) as $type ) {
foreach ( $results as $result_type => $result ) {
if ( ! is_wp_error( $result ) )
continue;
- $body[] = ' ' . ( 'rollback' === $result_type ? 'Rollback ' : '' ) . 'Error: [' . $result->get_error_code() . '] ' . $result->get_error_message();
+
+ if ( 'rollback' === $result_type ) {
+ /* translators: 1: Error code, 2: Error message. */
+ $body[] = ' ' . sprintf( __( 'Rollback Error: [%1$s] %2$s' ), $result->get_error_code(), $result->get_error_message() );
+ } else {
+ /* translators: 1: Error code, 2: Error message. */
+ $body[] = ' ' . sprintf( __( 'Error: [%1$s] %2$s' ), $result->get_error_code(), $result->get_error_message() );
+ }
+
if ( $result->get_error_data() )
$body[] = ' ' . implode( ', ', (array) $result->get_error_data() );
}
}
}
- //echo "<h1>\n$subject\n</h1>\n";
- //echo "<pre>\n" . implode( "\n", $body ) . "\n</pre>";
+ $email = array(
+ 'to' => get_site_option( 'admin_email' ),
+ 'subject' => $subject,
+ 'body' => implode( "\n", $body ),
+ 'headers' => ''
+ );
+
+ /**
+ * Filter the debug email that can be sent following an automatic
+ * background core update.
+ *
+ * @since 3.8.0
+ *
+ * @param array $email {
+ * Array of email arguments that will be passed to wp_mail().
+ *
+ * @type string $to The email recipient. An array of emails
+ * can be returned, as handled by wp_mail().
+ * @type string $subject Email subject.
+ * @type string $body Email message body.
+ * @type string $headers Any email headers. Default empty.
+ * }
+ * @param int $failures The number of failures encountered while upgrading.
+ * @param mixed $results The results of all attempted updates.
+ */
+ $email = apply_filters( 'automatic_updates_debug_email', $email, $failures, $this->update_results );
- wp_mail( get_site_option( 'admin_email' ), $subject, implode( "\n", $body ) );
+ wp_mail( $email['to'], wp_specialchars_decode( $email['subject'] ), $email['body'], $email['headers'] );
}
}