From 250d0ca8654e08933feb9e9f912b17a3c339d279 Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Thu, 5 Dec 2024 09:51:54 +0100 Subject: [PATCH] Make the theme and plugin file editor more consistent Update the header area of the theme and plugin file editors to be more consistent. Display the name of theme or plugin, the active or inactive state, and the path to the file that is selected (including the file name). --- src/wp-admin/plugin-editor.php | 26 ++++++++++++++++++-------- src/wp-admin/theme-editor.php | 24 +++++++++++++++--------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/wp-admin/plugin-editor.php b/src/wp-admin/plugin-editor.php index 73017cae91153..53e46ba394d3b 100644 --- a/src/wp-admin/plugin-editor.php +++ b/src/wp-admin/plugin-editor.php @@ -85,6 +85,9 @@ $file = validate_file_to_edit( $file, $plugin_files ); $real_file = WP_PLUGIN_DIR . '/' . $file; +$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_files[0] ); +$plugin_name = $plugin_data['Name']; + // Handle fallback editing of file when JavaScript is not available. $edit_error = null; $posted_content = null; @@ -220,23 +223,30 @@ ' . esc_html( $file ) . '' ); + /* translators: %s: Plugin name. */ + printf( __( 'Editing %s (active)' ), '' . esc_html( $plugin_name ) . '' ); } else { - /* translators: %s: Plugin file name. */ - printf( __( 'Browsing %s (active)' ), '' . esc_html( $file ) . '' ); + /* translators: %s: Plugin name. */ + printf( __( 'Browsing %s (active)' ), '' . esc_html( $plugin_name ) . '' ); } } else { if ( is_writable( $real_file ) ) { - /* translators: %s: Plugin file name. */ - printf( __( 'Editing %s (inactive)' ), '' . esc_html( $file ) . '' ); + /* translators: %s: Plugin name. */ + printf( __( 'Editing %s (inactive)' ), '' . esc_html( $plugin_name ) . '' ); } else { - /* translators: %s: Plugin file name. */ - printf( __( 'Browsing %s (inactive)' ), '' . esc_html( $file ) . '' ); + /* translators: %s: Plugin name. */ + printf( __( 'Browsing %s (inactive)' ), '' . esc_html( $plugin_name ) . '' ); } } ?> +' . __( 'File: %s' ) . '', + esc_html( $file ) +); +?>
diff --git a/src/wp-admin/theme-editor.php b/src/wp-admin/theme-editor.php index bf869f4d8a886..4559000244d68 100644 --- a/src/wp-admin/theme-editor.php +++ b/src/wp-admin/theme-editor.php @@ -182,12 +182,7 @@ $content = esc_textarea( $content ); } -$file_description = get_file_description( $relative_file ); -$file_show = array_search( $file, array_filter( $allowed_files ), true ); -$description = esc_html( $file_description ); -if ( $file_description !== $file_show ) { - $description .= ' (' . esc_html( $file_show ) . ')'; -} +$file_show = array_search( $file, array_filter( $allowed_files ), true ); ?>

@@ -235,12 +230,23 @@

display( 'Name' ); - if ( $description ) { - echo ': ' . $description; + if ( wp_get_theme()->get( 'Name' ) === $theme->display( 'Name' ) ) { + /* translators: %s: Theme name. */ + printf( __( 'Editing %s (active)' ), '' . $theme->display( 'Name' ) . '' ); + } else { + /* translators: %s: Theme name. */ + printf( __( 'Editing %s (inactive)' ), '' . $theme->display( 'Name' ) . '' ); } + ?>

+' . __( 'File: %s' ) . '', + esc_html( $file_show ) +); +?>