wp/wp-admin/includes/class-wp-automatic-updater.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
    21 	 * @var array
    21 	 * @var array
    22 	 */
    22 	 */
    23 	protected $update_results = array();
    23 	protected $update_results = array();
    24 
    24 
    25 	/**
    25 	/**
    26 	 * Whether the entire automatic updater is disabled.
    26 	 * Determines whether the entire automatic updater is disabled.
    27 	 *
    27 	 *
    28 	 * @since 3.7.0
    28 	 * @since 3.7.0
    29 	 */
    29 	 */
    30 	public function is_disabled() {
    30 	public function is_disabled() {
    31 		// Background updates are disabled if you don't want file changes.
    31 		// Background updates are disabled if you don't want file changes.
    54 		 */
    54 		 */
    55 		return apply_filters( 'automatic_updater_disabled', $disabled );
    55 		return apply_filters( 'automatic_updater_disabled', $disabled );
    56 	}
    56 	}
    57 
    57 
    58 	/**
    58 	/**
    59 	 * Check for version control checkouts.
    59 	 * Checks for version control checkouts.
    60 	 *
    60 	 *
    61 	 * Checks for Subversion, Git, Mercurial, and Bazaar. It recursively looks up the
    61 	 * Checks for Subversion, Git, Mercurial, and Bazaar. It recursively looks up the
    62 	 * filesystem to the top of the drive, erring on the side of detecting a VCS
    62 	 * filesystem to the top of the drive, erring on the side of detecting a VCS
    63 	 * checkout somewhere.
    63 	 * checkout somewhere.
    64 	 *
    64 	 *
   191 		 *  - `auto_update_core`
   191 		 *  - `auto_update_core`
   192 		 *  - `auto_update_plugin`
   192 		 *  - `auto_update_plugin`
   193 		 *  - `auto_update_theme`
   193 		 *  - `auto_update_theme`
   194 		 *  - `auto_update_translation`
   194 		 *  - `auto_update_translation`
   195 		 *
   195 		 *
   196 		 * Generally speaking, plugins, themes, and major core versions are not updated
   196 		 * Since WordPress 3.7, minor and development versions of core, and translations have
   197 		 * by default, while translations and minor and development versions for core
   197 		 * been auto-updated by default. New installs on WordPress 5.6 or higher will also
   198 		 * are updated by default.
   198 		 * auto-update major versions by default. Starting in 5.6, older sites can opt-in to
       
   199 		 * major version auto-updates, and auto-updates for plugins and themes.
   199 		 *
   200 		 *
   200 		 * See the {@see 'allow_dev_auto_core_updates'}, {@see 'allow_minor_auto_core_updates'},
   201 		 * See the {@see 'allow_dev_auto_core_updates'}, {@see 'allow_minor_auto_core_updates'},
   201 		 * and {@see 'allow_major_auto_core_updates'} filters for a more straightforward way to
   202 		 * and {@see 'allow_major_auto_core_updates'} filters for a more straightforward way to
   202 		 * adjust core updates.
   203 		 * adjust core updates.
   203 		 *
   204 		 *
   292 		$this->send_email( 'manual', $item );
   293 		$this->send_email( 'manual', $item );
   293 		return true;
   294 		return true;
   294 	}
   295 	}
   295 
   296 
   296 	/**
   297 	/**
   297 	 * Update an item, if appropriate.
   298 	 * Updates an item, if appropriate.
   298 	 *
   299 	 *
   299 	 * @since 3.7.0
   300 	 * @since 3.7.0
   300 	 *
   301 	 *
   301 	 * @param string $type The type of update being checked: 'core', 'theme', 'plugin', 'translation'.
   302 	 * @param string $type The type of update being checked: 'core', 'theme', 'plugin', 'translation'.
   302 	 * @param object $item The update offer.
   303 	 * @param object $item The update offer.
   416 				// These aren't actual errors, treat it as a skipped-update instead
   417 				// These aren't actual errors, treat it as a skipped-update instead
   417 				// to avoid triggering the post-core update failure routines.
   418 				// to avoid triggering the post-core update failure routines.
   418 				return false;
   419 				return false;
   419 			}
   420 			}
   420 
   421 
   421 			// Core doesn't output this, so let's append it so we don't get confused.
   422 			// Core doesn't output this, so let's append it, so we don't get confused.
   422 			if ( is_wp_error( $upgrade_result ) ) {
   423 			if ( is_wp_error( $upgrade_result ) ) {
   423 				$skin->error( __( 'Installation failed.' ), $upgrade_result );
   424 				$upgrade_result->add( 'installation_failed', __( 'Installation failed.' ) );
       
   425 				$skin->error( $upgrade_result );
   424 			} else {
   426 			} else {
   425 				$skin->feedback( __( 'WordPress updated successfully.' ) );
   427 				$skin->feedback( __( 'WordPress updated successfully.' ) );
   426 			}
   428 			}
   427 		}
   429 		}
   428 
   430 
   774 				$body .= "\n\n";
   776 				$body .= "\n\n";
   775 
   777 
   776 				// Don't show this message if there is a newer version available.
   778 				// Don't show this message if there is a newer version available.
   777 				// Potential for confusion, and also not useful for them to know at this point.
   779 				// Potential for confusion, and also not useful for them to know at this point.
   778 				if ( 'fail' === $type && ! $newer_version_available ) {
   780 				if ( 'fail' === $type && ! $newer_version_available ) {
   779 					$body .= __( 'We tried but were unable to update your site automatically.' ) . ' ';
   781 					$body .= __( 'An attempt was made, but your site could not be updated automatically.' ) . ' ';
   780 				}
   782 				}
   781 
   783 
   782 				$body .= __( 'Updating is easy and only takes a few moments:' );
   784 				$body .= __( 'Updating is easy and only takes a few moments:' );
   783 				$body .= "\n" . network_admin_url( 'update-core.php' );
   785 				$body .= "\n" . network_admin_url( 'update-core.php' );
   784 				break;
   786 				break;
   840 
   842 
   841 		if ( 'critical' === $type && is_wp_error( $result ) ) {
   843 		if ( 'critical' === $type && is_wp_error( $result ) ) {
   842 			$body .= "\n***\n\n";
   844 			$body .= "\n***\n\n";
   843 			/* translators: %s: WordPress version. */
   845 			/* translators: %s: WordPress version. */
   844 			$body .= sprintf( __( 'Your site was running version %s.' ), get_bloginfo( 'version' ) );
   846 			$body .= sprintf( __( 'Your site was running version %s.' ), get_bloginfo( 'version' ) );
   845 			$body .= ' ' . __( 'We have some data that describes the error your site encountered.' );
   847 			$body .= ' ' . __( 'Some data that describes the error your site encountered has been put together.' );
   846 			$body .= ' ' . __( 'Your hosting company, support forum volunteers, or a friendly developer may be able to use this information to help you:' );
   848 			$body .= ' ' . __( 'Your hosting company, support forum volunteers, or a friendly developer may be able to use this information to help you:' );
   847 
   849 
   848 			// If we had a rollback and we're still critical, then the rollback failed too.
   850 			// If we had a rollback and we're still critical, then the rollback failed too.
   849 			// Loop through all errors (the main WP_Error, the update result, the rollback result) for code, data, etc.
   851 			// Loop through all errors (the main WP_Error, the update result, the rollback result) for code, data, etc.
   850 			if ( 'rollback_was_required' === $result->get_error_code() ) {
   852 			if ( 'rollback_was_required' === $result->get_error_code() ) {
  1232 		// Add a note about the support forums.
  1234 		// Add a note about the support forums.
  1233 		$body[] = __( 'If you experience any issues or need support, the volunteers in the WordPress.org support forums may be able to help.' );
  1235 		$body[] = __( 'If you experience any issues or need support, the volunteers in the WordPress.org support forums may be able to help.' );
  1234 		$body[] = __( 'https://wordpress.org/support/forums/' );
  1236 		$body[] = __( 'https://wordpress.org/support/forums/' );
  1235 		$body[] = "\n" . __( 'The WordPress Team' );
  1237 		$body[] = "\n" . __( 'The WordPress Team' );
  1236 
  1238 
       
  1239 		if ( '' !== get_option( 'blogname' ) ) {
       
  1240 			$site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
       
  1241 		} else {
       
  1242 			$site_title = parse_url( home_url(), PHP_URL_HOST );
       
  1243 		}
       
  1244 
  1237 		$body    = implode( "\n", $body );
  1245 		$body    = implode( "\n", $body );
  1238 		$to      = get_site_option( 'admin_email' );
  1246 		$to      = get_site_option( 'admin_email' );
  1239 		$subject = sprintf( $subject, wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) );
  1247 		$subject = sprintf( $subject, $site_title );
  1240 		$headers = '';
  1248 		$headers = '';
  1241 
  1249 
  1242 		$email = compact( 'to', 'subject', 'body', 'headers' );
  1250 		$email = compact( 'to', 'subject', 'body', 'headers' );
  1243 
  1251 
  1244 		/**
  1252 		/**
  1343 			}
  1351 			}
  1344 
  1352 
  1345 			$body[] = '';
  1353 			$body[] = '';
  1346 		}
  1354 		}
  1347 
  1355 
  1348 		$site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
  1356 		if ( '' !== get_bloginfo( 'name' ) ) {
       
  1357 			$site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
       
  1358 		} else {
       
  1359 			$site_title = parse_url( home_url(), PHP_URL_HOST );
       
  1360 		}
  1349 
  1361 
  1350 		if ( $failures ) {
  1362 		if ( $failures ) {
  1351 			$body[] = trim(
  1363 			$body[] = trim(
  1352 				__(
  1364 				__(
  1353 					"BETA TESTING?
  1365 					"BETA TESTING?