wp/wp-admin/includes/class-wp-site-health-auto-updates.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
    39 			$this->test_accepts_minor_updates(),
    39 			$this->test_accepts_minor_updates(),
    40 		);
    40 		);
    41 
    41 
    42 		$tests = array_filter( $tests );
    42 		$tests = array_filter( $tests );
    43 		$tests = array_map(
    43 		$tests = array_map(
    44 			function( $test ) {
    44 			static function( $test ) {
    45 				$test = (object) $test;
    45 				$test = (object) $test;
    46 
    46 
    47 				if ( empty( $test->severity ) ) {
    47 				if ( empty( $test->severity ) ) {
    48 					$test->severity = 'warning';
    48 					$test->severity = 'warning';
    49 				}
    49 				}
   154 	 *
   154 	 *
   155 	 * @since 5.2.0
   155 	 * @since 5.2.0
   156 	 *
   156 	 *
   157 	 * @return array|false The test results. False if the auto-updates failed.
   157 	 * @return array|false The test results. False if the auto-updates failed.
   158 	 */
   158 	 */
   159 	function test_if_failed_update() {
   159 	public function test_if_failed_update() {
   160 		$failed = get_site_option( 'auto_core_update_failed' );
   160 		$failed = get_site_option( 'auto_core_update_failed' );
   161 
   161 
   162 		if ( ! $failed ) {
   162 		if ( ! $failed ) {
   163 			return false;
   163 			return false;
   164 		}
   164 		}
   224 		$check_dirs = array_unique( $check_dirs );
   224 		$check_dirs = array_unique( $check_dirs );
   225 
   225 
   226 		// Search all directories we've found for evidence of version control.
   226 		// Search all directories we've found for evidence of version control.
   227 		foreach ( $vcs_dirs as $vcs_dir ) {
   227 		foreach ( $vcs_dirs as $vcs_dir ) {
   228 			foreach ( $check_dirs as $check_dir ) {
   228 			foreach ( $check_dirs as $check_dir ) {
   229 				// phpcs:ignore
   229 				// phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition,Squiz.PHP.DisallowMultipleAssignments
   230 				if ( $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ) ) {
   230 				if ( $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ) ) {
   231 					break 2;
   231 					break 2;
   232 				}
   232 				}
   233 			}
   233 			}
   234 		}
   234 		}
   270 	 *
   270 	 *
   271 	 * @since 5.2.0
   271 	 * @since 5.2.0
   272 	 *
   272 	 *
   273 	 * @return array The test results.
   273 	 * @return array The test results.
   274 	 */
   274 	 */
   275 	function test_check_wp_filesystem_method() {
   275 	public function test_check_wp_filesystem_method() {
   276 		// Make sure the `request_filesystem_credentials()` function is available during our REST API call.
   276 		// Make sure the `request_filesystem_credentials()` function is available during our REST API call.
   277 		if ( ! function_exists( 'request_filesystem_credentials' ) ) {
   277 		if ( ! function_exists( 'request_filesystem_credentials' ) ) {
   278 			require_once ABSPATH . '/wp-admin/includes/file.php';
   278 			require_once ABSPATH . '/wp-admin/includes/file.php';
   279 		}
   279 		}
   280 
   280 
   290 				'severity'    => 'fail',
   290 				'severity'    => 'fail',
   291 			);
   291 			);
   292 		}
   292 		}
   293 
   293 
   294 		return array(
   294 		return array(
   295 			'description' => __( "Your installation of WordPress doesn't require FTP credentials to perform updates." ),
   295 			'description' => __( 'Your installation of WordPress does not require FTP credentials to perform updates.' ),
   296 			'severity'    => 'pass',
   296 			'severity'    => 'pass',
   297 		);
   297 		);
   298 	}
   298 	}
   299 
   299 
   300 	/**
   300 	/**
   304 	 *
   304 	 *
   305 	 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
   305 	 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
   306 	 *
   306 	 *
   307 	 * @return array|false The test results. False if they're not writeable.
   307 	 * @return array|false The test results. False if they're not writeable.
   308 	 */
   308 	 */
   309 	function test_all_files_writable() {
   309 	public function test_all_files_writable() {
   310 		global $wp_filesystem;
   310 		global $wp_filesystem;
   311 
   311 
   312 		require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
   312 		require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
   313 
   313 
   314 		$skin    = new Automatic_Upgrader_Skin;
   314 		$skin    = new Automatic_Upgrader_Skin;
   389 	 *
   389 	 *
   390 	 * @since 5.2.0
   390 	 * @since 5.2.0
   391 	 *
   391 	 *
   392 	 * @return array|false The test results. False if it isn't a development version.
   392 	 * @return array|false The test results. False if it isn't a development version.
   393 	 */
   393 	 */
   394 	function test_accepts_dev_updates() {
   394 	public function test_accepts_dev_updates() {
   395 		require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
   395 		require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
   396 		// Only for dev versions.
   396 		// Only for dev versions.
   397 		if ( false === strpos( $wp_version, '-' ) ) {
   397 		if ( false === strpos( $wp_version, '-' ) ) {
   398 			return false;
   398 			return false;
   399 		}
   399 		}
   427 	 *
   427 	 *
   428 	 * @since 5.2.0
   428 	 * @since 5.2.0
   429 	 *
   429 	 *
   430 	 * @return array The test results.
   430 	 * @return array The test results.
   431 	 */
   431 	 */
   432 	function test_accepts_minor_updates() {
   432 	public function test_accepts_minor_updates() {
   433 		if ( defined( 'WP_AUTO_UPDATE_CORE' ) && false === WP_AUTO_UPDATE_CORE ) {
   433 		if ( defined( 'WP_AUTO_UPDATE_CORE' ) && false === WP_AUTO_UPDATE_CORE ) {
   434 			return array(
   434 			return array(
   435 				'description' => sprintf(
   435 				'description' => sprintf(
   436 					/* translators: %s: Name of the constant used. */
   436 					/* translators: %s: Name of the constant used. */
   437 					__( 'WordPress security and maintenance releases are blocked by %s.' ),
   437 					__( 'WordPress security and maintenance releases are blocked by %s.' ),