Changeset 56069 for trunk/src/wp-admin/includes/file.php
- Timestamp:
- 06/27/2023 04:06:16 PM (3 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/includes/file.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/file.php
r55990 r56069 128 128 * @since 2.6.0 129 129 * @since 4.9.0 Added the `$exclusions` parameter. 130 * 131 * @param string $folder Optional. Full path to folder. Default empty. 132 * @param int $levels Optional. Levels of folders to follow, Default 100 (PHP Loop limit). 133 * @param string[] $exclusions Optional. List of folders and files to skip. 130 * @since 6.3.0 Added the `$include_hidden` parameter. 131 * 132 * @param string $folder Optional. Full path to folder. Default empty. 133 * @param int $levels Optional. Levels of folders to follow, Default 100 (PHP Loop limit). 134 * @param string[] $exclusions Optional. List of folders and files to skip. 135 * @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files. 136 * Default false. 134 137 * @return string[]|false Array of files on success, false on failure. 135 138 */ 136 function list_files( $folder = '', $levels = 100, $exclusions = array() ) {139 function list_files( $folder = '', $levels = 100, $exclusions = array(), $include_hidden = false ) { 137 140 if ( empty( $folder ) ) { 138 141 return false; … … 157 160 158 161 // Skip hidden and excluded files. 159 if ( '.' === $file[0]|| in_array( $file, $exclusions, true ) ) {162 if ( ( ! $include_hidden && '.' === $file[0] ) || in_array( $file, $exclusions, true ) ) { 160 163 continue; 161 164 } 162 165 163 166 if ( is_dir( $folder . $file ) ) { 164 $files2 = list_files( $folder . $file, $levels - 1 );167 $files2 = list_files( $folder . $file, $levels - 1, array(), $include_hidden ); 165 168 if ( $files2 ) { 166 169 $files = array_merge( $files, $files2 );
Note: See TracChangeset
for help on using the changeset viewer.