Title: WP_Site_Health_Auto_Updates::test_all_files_writable
Published: May 7, 2019
Last modified: August 20, 2026

---

# WP_Site_Health_Auto_Updates::test_all_files_writable(): array|false

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_all_files_writable/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_all_files_writable/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_all_files_writable/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_all_files_writable/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_all_files_writable/?output_format=md#wp--skip-link--target)

Checks if core files are writable by the web user/group.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_all_files_writable/?output_format=md#return)󠁿

 array|false The test results if at least some of WordPress core files are writeable,
or if a list of the checksums could not be retrieved from WordPress.org.
 False 
if the core files are not writeable.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_all_files_writable/?output_format=md#source)󠁿

    ```php
    public function test_all_files_writable() {
    	global $wp_filesystem;

    	require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z

    	$skin    = new Automatic_Upgrader_Skin();
    	$success = $skin->request_filesystem_credentials( false, ABSPATH );

    	if ( ! $success ) {
    		return false;
    	}

    	WP_Filesystem();

    	if ( 'direct' !== $wp_filesystem->method ) {
    		return false;
    	}

    	// Make sure the `get_core_checksums()` function is available during our REST API call.
    	if ( ! function_exists( 'get_core_checksums' ) ) {
    		require_once ABSPATH . 'wp-admin/includes/update.php';
    	}

    	$checksums = get_core_checksums( $wp_version, 'en_US' );
    	$dev       = ( str_contains( $wp_version, '-' ) );
    	// Get the last stable version's files and test against that.
    	if ( ! $checksums && $dev ) {
    		$checksums = get_core_checksums( (float) $wp_version - 0.1, 'en_US' );
    	}

    	// There aren't always checksums for development releases, so just skip the test if we still can't find any.
    	if ( ! $checksums && $dev ) {
    		return false;
    	}

    	if ( ! $checksums ) {
    		$description = sprintf(
    			/* translators: %s: WordPress version. */
    			__( "Couldn't retrieve a list of the checksums for WordPress %s." ),
    			$wp_version
    		);
    		$description .= ' ' . __( 'This could mean that connections are failing to WordPress.org.' );
    		return array(
    			'description' => $description,
    			'severity'    => 'warning',
    		);
    	}

    	$unwritable_files = array();
    	foreach ( array_keys( $checksums ) as $file ) {
    		if ( str_starts_with( $file, 'wp-content' ) ) {
    			continue;
    		}
    		if ( ! file_exists( ABSPATH . $file ) ) {
    			continue;
    		}
    		if ( ! is_writable( ABSPATH . $file ) ) {
    			$unwritable_files[] = $file;
    		}
    	}

    	if ( $unwritable_files ) {
    		if ( count( $unwritable_files ) > 20 ) {
    			$unwritable_files   = array_slice( $unwritable_files, 0, 20 );
    			$unwritable_files[] = '...';
    		}
    		return array(
    			'description' => __( 'Some files are not writable by WordPress:' ) . ' <ul><li>' . implode( '</li><li>', $unwritable_files ) . '</li></ul>',
    			'severity'    => 'fail',
    		);
    	} else {
    		return array(
    			'description' => __( 'All of your WordPress files are writable.' ),
    			'severity'    => 'pass',
    		);
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-wp-site-health-auto-updates.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-admin/includes/class-wp-site-health-auto-updates.php#L328)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-admin/includes/class-wp-site-health-auto-updates.php#L328-L404)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_all_files_writable/?output_format=md#related)󠁿

| Uses | Description | 
| [get_core_checksums()](https://developer.wordpress.org/reference/functions/get_core_checksums/)`wp-admin/includes/update.php` |

Gets and caches the checksums for the given version of WordPress.

  | 
| [WP_Filesystem()](https://developer.wordpress.org/reference/functions/wp_filesystem/)`wp-admin/includes/file.php` |

Initializes and connects the WordPress Filesystem Abstraction classes.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  |

[Show 1 more](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_all_files_writable/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_all_files_writable/?output_format=md#)

| Used by | Description | 
| [WP_Site_Health_Auto_Updates::run_tests()](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/run_tests/)`wp-admin/includes/class-wp-site-health-auto-updates.php` |

Runs tests to determine if auto-updates can run.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_all_files_writable/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.2.0](https://developer.wordpress.org/reference/since/5.2.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_site_health_auto_updates%2Ftest_all_files_writable%2F)
before being able to contribute a note or feedback.