mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
Theme Editor: ensure that files named index.php in theme subfolders are not labeled as "Main Index Template"
Props MikeHansenMe, wonderboymusic, bravokeyl, Shelob9. Fixes #27201. git-svn-id: https://develop.svn.wordpress.org/trunk@34658 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -51,18 +51,21 @@ $wp_file_descriptions = array(
|
||||
*
|
||||
* @global array $wp_file_descriptions
|
||||
* @param string $file Filesystem path or filename
|
||||
* @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist
|
||||
* @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist.
|
||||
* Appends 'Page Template' to basename of $file if the file is a page template
|
||||
*/
|
||||
function get_file_description( $file ) {
|
||||
global $wp_file_descriptions;
|
||||
global $wp_file_descriptions, $allowed_files;
|
||||
|
||||
if ( isset( $wp_file_descriptions[basename( $file )] ) ) {
|
||||
return $wp_file_descriptions[basename( $file )];
|
||||
}
|
||||
elseif ( file_exists( $file ) && is_file( $file ) ) {
|
||||
$template_data = implode( '', file( $file ) );
|
||||
if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ))
|
||||
return sprintf( __( '%s Page Template' ), _cleanup_header_comment($name[1]) );
|
||||
$relative_pathinfo = pathinfo( $file );
|
||||
$file_path = $allowed_files[ $file ];
|
||||
if ( isset( $wp_file_descriptions[ basename( $file ) ] ) && '.' === $relative_pathinfo['dirname'] ) {
|
||||
return $wp_file_descriptions[ basename( $file ) ];
|
||||
} elseif ( file_exists( $file_path ) && is_file( $file_path ) ) {
|
||||
$template_data = implode( '', file( $file_path ) );
|
||||
if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) ) {
|
||||
return sprintf( __( '%s Page Template' ), _cleanup_header_comment( $name[1] ) );
|
||||
}
|
||||
}
|
||||
|
||||
return trim( basename( $file ) );
|
||||
|
||||
Reference in New Issue
Block a user