WP_Debug_Data::get_wp_filesystem(): array<string,
- Since
- 6.7.0
- Source
wp-admin/includes/class-wp-debug-data.php:1752
Compatibility
- WordPress
- since 6.7.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Return value
array<string,- string|array> The debug data and other information for the Info screen.
Performance profile
How much work a call to WP_Debug_Data::get_wp_filesystem() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Constant
- Instructions
- 139–180
- Plugin surface
- None
- Called by
- 1
Reads or writes the filesystem via file_exists().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 233.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- filesystemfilesystem access
file_exists()called directly - hookthird-party callbacks
apply_filters()one call below WP_Debug_Data::get_wp_filesystem() - optionoption read or write
get_option()one call below WP_Debug_Data::get_wp_filesystem()
Further down the call graph this can also reach cache, serialize, transient and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 3 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Debug_Data::get_wp_filesystem() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!file_exists() && !defined('WPMU_PLUGIN_DIR') | 139–153 | wp_upload_dir(), wp_get_font_dir(), file_exists(), wp_is_writable(), wp_is_writable(), wp_is_writable(), wp_is_writable(), get_template(), get_theme_root(), wp_is_writable(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __() |
!file_exists() && defined('WPMU_PLUGIN_DIR') && !is_dir() | 144–158 | wp_upload_dir(), wp_get_font_dir(), file_exists(), wp_is_writable(), wp_is_writable(), wp_is_writable(), wp_is_writable(), get_template(), get_theme_root(), wp_is_writable(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), is_dir(), __(), __() |
!file_exists() && defined('WPMU_PLUGIN_DIR') && is_dir() | 164–180 | wp_upload_dir(), wp_get_font_dir(), file_exists(), wp_is_writable(), wp_is_writable(), wp_is_writable(), wp_is_writable(), get_template(), get_theme_root(), wp_is_writable(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), is_dir(), wp_is_writable(), __(), __(), __(), __() |
This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 217 | 133–173 | 19 | 16 fewer instructions than PHP 8.5 |
| 8.5 | 233 | 139–180 | 19 | |
| 8.4 | 233 | 139–180 | 19 | |
| 8.3 | 233 | 139–180 | 19 | |
| 8.2 | 233 | 139–180 | 19 | |
| 8.1 | 233 | 139–180 | 19 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 234 | 139–180 | 19 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 6
- wp_upload_dir()Returns an array containing the current upload directory's path and URL.
- wp_get_font_dir()Retrieves font uploads directory information.
- wp_is_writable()Determines if a directory is writable.
- get_theme_root()Retrieves path to themes directory.
- get_template()Retrieves name of the active theme.
- __()Retrieves the translation of $text.
Used by · 1
- WP_Debug_Data::debug_data()Static function for generating site debug data when required.
Source code
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
Introduced in 6.7.0. One change between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
array to array<string,.verified against sourceAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-admin/includes/class-wp-debug-data.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.