WP_Debug_Data::get_wp_filesystem(): array

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Gets the file system section of the debug data.

Return

array

Source

private static function get_wp_filesystem(): array {
	$upload_dir                     = wp_upload_dir();
	$fonts_dir_exists               = file_exists( wp_get_font_dir()['basedir'] );
	$is_writable_abspath            = wp_is_writable( ABSPATH );
	$is_writable_wp_content_dir     = wp_is_writable( WP_CONTENT_DIR );
	$is_writable_upload_dir         = wp_is_writable( $upload_dir['basedir'] );
	$is_writable_wp_plugin_dir      = wp_is_writable( WP_PLUGIN_DIR );
	$is_writable_template_directory = wp_is_writable( get_theme_root( get_template() ) );
	$is_writable_fonts_dir          = $fonts_dir_exists ? wp_is_writable( wp_get_font_dir()['basedir'] ) : false;

	$fields = array(
		'wordpress'  => array(
			'label' => __( 'The main WordPress directory' ),
			'value' => ( $is_writable_abspath ? __( 'Writable' ) : __( 'Not writable' ) ),
			'debug' => ( $is_writable_abspath ? 'writable' : 'not writable' ),
		),
		'wp-content' => array(
			'label' => __( 'The wp-content directory' ),
			'value' => ( $is_writable_wp_content_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
			'debug' => ( $is_writable_wp_content_dir ? 'writable' : 'not writable' ),
		),
		'uploads'    => array(
			'label' => __( 'The uploads directory' ),
			'value' => ( $is_writable_upload_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
			'debug' => ( $is_writable_upload_dir ? 'writable' : 'not writable' ),
		),
		'plugins'    => array(
			'label' => __( 'The plugins directory' ),
			'value' => ( $is_writable_wp_plugin_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
			'debug' => ( $is_writable_wp_plugin_dir ? 'writable' : 'not writable' ),
		),
		'themes'     => array(
			'label' => __( 'The themes directory' ),
			'value' => ( $is_writable_template_directory ? __( 'Writable' ) : __( 'Not writable' ) ),
			'debug' => ( $is_writable_template_directory ? 'writable' : 'not writable' ),
		),
		'fonts'      => array(
			'label' => __( 'The fonts directory' ),
			'value' => $fonts_dir_exists
				? ( $is_writable_fonts_dir ? __( 'Writable' ) : __( 'Not writable' ) )
				: __( 'Does not exist' ),
			'debug' => $fonts_dir_exists
				? ( $is_writable_fonts_dir ? 'writable' : 'not writable' )
				: 'does not exist',
		),
	);

	// Add more filesystem checks.
	if ( defined( 'WPMU_PLUGIN_DIR' ) && is_dir( WPMU_PLUGIN_DIR ) ) {
		$is_writable_wpmu_plugin_dir = wp_is_writable( WPMU_PLUGIN_DIR );

		$fields['mu-plugins'] = array(
			'label' => __( 'The must use plugins directory' ),
			'value' => ( $is_writable_wpmu_plugin_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
			'debug' => ( $is_writable_wpmu_plugin_dir ? 'writable' : 'not writable' ),
		);
	}

	return array(
		'label'       => __( 'Filesystem Permissions' ),
		'description' => __( 'Shows whether WordPress is able to write to the directories it needs access to.' ),
		'fields'      => $fields,
	);
}

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.