From 33952d50690fbc78c4ccb53e51d7528512c4be39 Mon Sep 17 00:00:00 2001 From: audrasjb Date: Thu, 27 Feb 2025 23:04:27 +0000 Subject: [PATCH] Themes: Fix inconstancies between theme and plugin editor. This updates the header area of the theme and plugin file editor screen to make them more consistent. It now displays the name of theme or plugin, the active or inactive state, and the path to the file that is selected. Props karmatosed, poena, audrasjb. Fixes #41142. Built from https://develop.svn.wordpress.org/trunk@59884 git-svn-id: http://core.svn.wordpress.org/trunk@59226 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/plugin-editor.php | 26 ++++++++++++++++++-------- wp-admin/theme-editor.php | 23 ++++++++++++++--------- wp-includes/version.php | 2 +- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php index 73017cae91..53e46ba394 100644 --- a/wp-admin/plugin-editor.php +++ b/wp-admin/plugin-editor.php @@ -85,6 +85,9 @@ if ( empty( $file ) ) { $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 @@ endif; ' . 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/wp-admin/theme-editor.php b/wp-admin/theme-editor.php index bf869f4d8a..fbb9b6bd94 100644 --- a/wp-admin/theme-editor.php +++ b/wp-admin/theme-editor.php @@ -182,12 +182,7 @@ if ( ! empty( $posted_content ) ) { $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,22 @@ if ( preg_match( '/\.css$/', $file ) && ! wp_is_block_theme() && current_user_ca

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 ) +); +?>
diff --git a/wp-includes/version.php b/wp-includes/version.php index 50c77331a1..ca7a94ea40 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59883'; +$wp_version = '6.8-alpha-59884'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.