diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-admin/theme-editor.php --- a/wp/wp-admin/theme-editor.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-admin/theme-editor.php Fri Sep 05 18:40:08 2025 +0200 @@ -50,13 +50,16 @@ get_current_screen()->set_help_sidebar( '

' . __( 'For more information:' ) . '

' . '

' . __( 'Documentation on Theme Development' ) . '

' . - '

' . __( 'Documentation on Editing Themes' ) . '

' . - '

' . __( 'Documentation on Editing Files' ) . '

' . + '

' . __( 'Documentation on Editing Themes' ) . '

' . + '

' . __( 'Documentation on Editing Files' ) . '

' . '

' . __( 'Documentation on Template Tags' ) . '

' . - '

' . __( 'Support' ) . '

' + '

' . __( 'Support forums' ) . '

' ); -wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) ); +$action = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : ''; +$theme = ! empty( $_REQUEST['theme'] ) ? sanitize_text_field( $_REQUEST['theme'] ) : ''; +$file = ! empty( $_REQUEST['file'] ) ? sanitize_text_field( $_REQUEST['file'] ) : ''; +$error = ! empty( $_REQUEST['error'] ); if ( $theme ) { $stylesheet = $theme; @@ -161,15 +164,19 @@ $f = fopen( $file, 'r' ); $content = fread( $f, filesize( $file ) ); - if ( '.php' === substr( $file, strrpos( $file, '.' ) ) ) { + if ( str_ends_with( $file, '.php' ) ) { $functions = wp_doc_link_parse( $content ); - $docs_select = ''; + $docs_select .= ''; + + foreach ( $functions as $function ) { + $docs_select .= ''; + } + + $docs_select .= ''; } - $docs_select .= ''; } $content = esc_textarea( $content ); @@ -185,31 +192,44 @@

- -
-

-
- -
-

-
get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() ); ?>
-
- + 'message', + 'dismissible' => true, + 'additional_classes' => array( 'updated' ), + ) + ); +} elseif ( is_wp_error( $edit_error ) ) { + $error_code = esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() ); + $message = '

' . __( 'There was an error while trying to update the file. You may need to fix something and try updating again.' ) . '

+
' . $error_code . '
'; + wp_admin_notice( + $message, + array( + 'type' => 'error', + 'id' => 'message', + ) + ); +} - -
-

-

- built-in CSS editor.' ), - esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) ) - ); - ?> -

-
- +if ( preg_match( '/\.css$/', $file ) && ! wp_is_block_theme() && current_user_can( 'customize' ) ) { + $message = '

' . __( 'Did you know?' ) . '

' . sprintf( + /* translators: %s: Link to Custom CSS section in the Customizer. */ + __( 'There is no need to change your CSS here — you can edit and live preview CSS changes in the built-in CSS editor.' ), + esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) ) + ) . '

'; + wp_admin_notice( + $message, + array( + 'type' => 'info', + 'id' => 'message', + ) + ); +} +?>
@@ -217,7 +237,8 @@ display( 'Name' ); if ( $description ) { - echo ': ' . $description;} + echo ': ' . $description; + } ?>
@@ -244,7 +265,12 @@ errors() ) { - echo '

' . __( 'This theme is broken.' ) . ' ' . $theme->errors()->get_error_message() . '

'; + wp_admin_notice( + '' . __( 'This theme is broken.' ) . ' ' . $theme->errors()->get_error_message(), + array( + 'additional_classes' => array( 'error' ), + ) + ); } ?> @@ -276,7 +302,12 @@

' . __( 'File does not exist! Please double check the name and try again.' ) . '

'; + wp_admin_notice( + __( 'File does not exist! Please double check the name and try again.' ), + array( + 'additional_classes' => array( 'error' ), + ) + ); else : ?>
@@ -293,39 +324,48 @@
- +
- get_stylesheet() === get_template() ) : ?> -
-

- - - - -

-
- + get_stylesheet() === get_template() ) : + $message = ( is_writable( $file ) ) ? '' . __( 'Caution:' ) . ' ' : ''; + $message .= __( 'This is a file in your current parent theme.' ); + wp_admin_notice( + $message, + array( + 'type' => 'warning', + 'additional_classes' => array( 'inline' ), + ) + ); + endif; + ?>
- +

- +

Changing File Permissions for more information.' ), - __( 'https://wordpress.org/support/article/changing-file-permissions/' ) + __( 'https://developer.wordpress.org/advanced-administration/server/file-permissions/' ) ); ?>

- +
@@ -337,7 +377,7 @@