diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php
index 171d8b6..eb1ef29 100644
a
|
b
|
final class WP_Theme implements ArrayAccess { |
985 | 985 | */ |
986 | 986 | public function get_files( $type = null, $depth = 0, $search_parent = false ) { |
987 | 987 | // get and cache all theme files to start with. |
988 | | $label = sanitize_key( 'files_' . $this->cache_hash . '-' . $this->get( 'Version' ) ); |
989 | | $transient_key = substr( $label, 0, 29 ) . md5( $label ); |
| 988 | $transient_key = $this->get_files_transient_key(); |
| 989 | |
| 990 | $all_files = false; |
| 991 | |
| 992 | if ( defined( 'WP_DEBUG' ) && ! WP_DEBUG ) { |
| 993 | $all_files = get_transient( $transient_key ); |
| 994 | } |
990 | 995 | |
991 | | $all_files = get_transient( $transient_key ); |
992 | 996 | if ( false === $all_files ) { |
993 | 997 | $all_files = (array) self::scandir( $this->get_stylesheet_directory(), null, -1 ); |
994 | 998 | |
… |
… |
final class WP_Theme implements ArrayAccess { |
996 | 1000 | $all_files += (array) self::scandir( $this->get_template_directory(), null, -1 ); |
997 | 1001 | } |
998 | 1002 | |
999 | | set_transient( $transient_key, $all_files, HOUR_IN_SECONDS ); |
| 1003 | if ( defined( 'WP_DEBUG' ) && ! WP_DEBUG ) { |
| 1004 | set_transient( $transient_key, $all_files, HOUR_IN_SECONDS ); |
| 1005 | } |
1000 | 1006 | } |
1001 | 1007 | |
1002 | 1008 | // Filter $all_files by $type & $depth. |
… |
… |
final class WP_Theme implements ArrayAccess { |
1110 | 1116 | } |
1111 | 1117 | |
1112 | 1118 | /** |
| 1119 | * Clear the cache of files in the theme's directory. |
| 1120 | * |
| 1121 | * @since 4.9.1 |
| 1122 | * |
| 1123 | * @return bool True if successful, false otherwise. |
| 1124 | */ |
| 1125 | public function clear_files_caches() { |
| 1126 | $transient_key = $this->get_files_transient_key(); |
| 1127 | return delete_transient( $transient_key ); |
| 1128 | } |
| 1129 | |
| 1130 | /** |
1113 | 1131 | * Scans a directory for files of a certain extension. |
1114 | 1132 | * |
1115 | 1133 | * @since 3.4.0 |
… |
… |
final class WP_Theme implements ArrayAccess { |
1495 | 1513 | // Don't mark up; Do translate. |
1496 | 1514 | return strnatcasecmp( $a->display( 'Name', false, true ), $b->display( 'Name', false, true ) ); |
1497 | 1515 | } |
| 1516 | |
| 1517 | /** |
| 1518 | * Return a transient key used to cache the files in the theme's directory |
| 1519 | * |
| 1520 | * @since 4.9.1 |
| 1521 | * @return string The transient key used into WP_Theme::get_files. |
| 1522 | */ |
| 1523 | private function get_files_transient_key() { |
| 1524 | $label = sanitize_key( 'files_' . $this->cache_hash . '-' . $this->get( 'Version' ) ); |
| 1525 | return substr( $label, 0, 29 ) . md5( $label ); |
| 1526 | } |
1498 | 1527 | } |