WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Site_Health_Auto_Updates::test_all_files_writable() public WP 5.2.0

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

Это метод класса: WP_Site_Health_Auto_Updates{}

Хуков нет.

Возвращает

Массив/true/false. The test results. False if they're not writeable.

Использование

$WP_Site_Health_Auto_Updates = new WP_Site_Health_Auto_Updates();
$WP_Site_Health_Auto_Updates->test_all_files_writable();

Заметки

  • Global. WP_Filesystem_Base. $wp_filesystem WordPress filesystem subclass.

Список изменений

С версии 5.2.0 Введена.

Код WP_Site_Health_Auto_Updates::test_all_files_writable() WP 5.5.1

wp-admin/includes/class-wp-site-health-auto-updates.php
<?php
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;
	}

	$checksums = get_core_checksums( $wp_version, 'en_US' );
	$dev       = ( false !== strpos( $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 ( 'wp-content' === substr( $file, 0, 10 ) ) {
			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',
		);
	}
}