Editor: Change the Text editor label to Code.

Rename the 'Text' tab of the classic editor to 'Code', mimicking the labels used in the block editor: "Visual editor" and "Code editor".
 
Update code comment and Help documentation to reference the editor using the new label.

Props lukecavanagh, ctienshi, travel_girl, audrasjb, sabernhardt, joedolson, rseigel, mark-k, sergeybiryukov, presskopp, giuriani, afercia, knutsp, audrasjb, sukhendu2002.
Fixes #38061.

git-svn-id: https://develop.svn.wordpress.org/trunk@59696 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe Dolson 2025-01-23 23:52:04 +00:00
parent e12e1f9753
commit 9548718a44
7 changed files with 19 additions and 19 deletions

View File

@ -162,7 +162,7 @@
if ( wpLink.isMCE() ) {
wpLink.mceRefresh( url, text );
} else {
// For the Text editor the "Link text" field is always shown.
// For the Code editor the "Link text" field is always shown.
if ( ! inputs.wrap.hasClass( 'has-text-field' ) ) {
inputs.wrap.addClass( 'has-text-field' );
}

View File

@ -559,7 +559,7 @@ window.autosave = function() {
});
} else {
// Make sure the Text editor is selected.
// Make sure the Code editor is selected.
$( '#content-html' ).trigger( 'click' );
$( '#content' ).trigger( 'focus' );

View File

@ -22,7 +22,7 @@ window.wp = window.wp || {};
$$ = tinymce.$;
/**
* Handles onclick events for the Visual/Text tabs.
* Handles onclick events for the Visual/Code tabs.
*
* @since 4.3.0
*
@ -62,7 +62,7 @@ window.wp = window.wp || {};
}
/**
* Switches the editor between Visual and Text mode.
* Switches the editor between Visual and Code mode.
*
* @since 2.5.0
*
@ -838,7 +838,7 @@ window.wp = window.wp || {};
}
}
// Restore the selection when the editor is initialized. Needed when the Text editor is the default.
// Restore the selection when the editor is initialized. Needed when the Code editor is the default.
$( document ).on( 'tinymce-editor-init.keep-scroll-position', function( event, editor ) {
if ( editor.$( '.mce_SELRES_start' ).length ) {
focusHTMLBookmarkInVisualEditor( editor );
@ -1203,7 +1203,7 @@ window.wp = window.wp || {};
/**
* Initialize TinyMCE and/or Quicktags. For use with wp_enqueue_editor() (PHP).
*
* Intended for use with an existing textarea that will become the Text editor tab.
* Intended for use with an existing textarea that will become the Code editor tab.
* The editor width will be the width of the textarea container, height will be adjustable.
*
* Settings for both TinyMCE and Quicktags can be passed on initialization, and are "filtered"
@ -1246,7 +1246,7 @@ window.wp = window.wp || {};
};
}
// Add wrap and the Visual|Text tabs.
// Add wrap and the Visual|Code tabs.
if ( settings.tinymce && settings.quicktags ) {
var $textarea = $( '#' + id );
@ -1293,7 +1293,7 @@ window.wp = window.wp || {};
.append( $button.attr({
id: id + '-html',
'class': 'wp-switch-editor switch-html'
}).text( window.tinymce.translate( 'Text' ) ) )
}).text( window.tinymce.translate( 'Code' ) ) )
).append( $editorContainer )
);

View File

@ -283,9 +283,9 @@ if ( 'post' === $post_type ) {
);
$title_and_editor = '<p>' . __( '<strong>Title</strong> &mdash; Enter a title for your post. After you enter a title, you&#8217;ll see the permalink below, which you can edit.' ) . '</p>';
$title_and_editor .= '<p>' . __( '<strong>Post editor</strong> &mdash; Enter the text for your post. There are two modes of editing: Visual and Text. Choose the mode by clicking on the appropriate tab.' ) . '</p>';
$title_and_editor .= '<p>' . __( '<strong>Post editor</strong> &mdash; Enter the text for your post. There are two modes of editing: Visual and Code. Choose the mode by clicking on the appropriate tab.' ) . '</p>';
$title_and_editor .= '<p>' . __( 'Visual mode gives you an editor that is similar to a word processor. Click the Toolbar Toggle button to get a second row of controls.' ) . '</p>';
$title_and_editor .= '<p>' . __( 'The Text mode allows you to enter HTML along with your post text. Note that &lt;p&gt; and &lt;br&gt; tags are converted to line breaks when switching to the Text editor to make it less cluttered. When you type, a single line break can be used instead of typing &lt;br&gt;, and two line breaks instead of paragraph tags. The line breaks are converted back to tags automatically.' ) . '</p>';
$title_and_editor .= '<p>' . __( 'The Code mode allows you to enter HTML along with your post text. Note that &lt;p&gt; and &lt;br&gt; tags are converted to line breaks when switching to the Code editor to make it less cluttered. When you type, a single line break can be used instead of typing &lt;br&gt;, and two line breaks instead of paragraph tags. The line breaks are converted back to tags automatically.' ) . '</p>';
$title_and_editor .= '<p>' . __( 'You can insert media files by clicking the button above the post editor and following the directions. You can align or edit images using the inline formatting toolbar available in Visual mode.' ) . '</p>';
$title_and_editor .= '<p>' . __( 'You can enable distraction-free writing mode using the icon to the right. This feature is not available for old browsers or devices with small screens, and requires that the full-height editor be enabled in Screen Options.' ) . '</p>';
$title_and_editor .= '<p>' . sprintf(
@ -314,7 +314,7 @@ if ( 'post' === $post_type ) {
);
} elseif ( 'page' === $post_type ) {
$about_pages = '<p>' . __( 'Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the &#8220;Parent&#8221; of the other, creating a group of pages.' ) . '</p>' .
'<p>' . __( 'Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. This screen also has the distraction-free writing space, available in both the Visual and Text modes via the Fullscreen buttons. The Page editor mostly works the same as the Post editor, but there are some Page-specific features in the Page Attributes box.' ) . '</p>';
'<p>' . __( 'Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. This screen also has the distraction-free writing space, available in both the Visual and Code modes via the Fullscreen buttons. The Page editor mostly works the same as the Post editor, but there are some Page-specific features in the Page Attributes box.' ) . '</p>';
get_current_screen()->add_help_tab(
array(

View File

@ -54,7 +54,7 @@ final class _WP_Editors {
* @type string|int $tabindex Tabindex value to use. Default empty.
* @type string $tabfocus_elements The previous and next element ID to move the focus to
* when pressing the Tab key in TinyMCE. Default ':prev,:next'.
* @type string $editor_css Intended for extra styles for both Visual and Text editors.
* @type string $editor_css Intended for extra styles for both Visual and Code editors.
* Should include `<style>` tags, and can use "scoped". Default empty.
* @type string $editor_class Extra classes to add to the editor textarea element. Default empty.
* @type bool $teeny Whether to output the minimal editor config. Examples include
@ -184,7 +184,7 @@ final class _WP_Editors {
if ( self::$this_quicktags ) {
$default_editor = $set['default_editor'] ? $set['default_editor'] : wp_default_editor();
// 'html' is used for the "Text" editor tab.
// 'html' is used for the "Code" editor tab.
if ( 'html' !== $default_editor ) {
$default_editor = 'tinymce';
}
@ -194,7 +194,7 @@ final class _WP_Editors {
$buttons .= '<button type="button" id="' . $editor_id_attr . '-tmce"' . $html_active . ' class="wp-switch-editor switch-tmce"' .
' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Visual', 'Name for the Visual editor tab' ) . "</button>\n";
$buttons .= '<button type="button" id="' . $editor_id_attr . '-html"' . $tmce_active . ' class="wp-switch-editor switch-html"' .
' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Text', 'Name for the Text editor tab (formerly HTML)' ) . "</button>\n";
' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Code', 'Name for the Code editor tab (formerly Text)' ) . "</button>\n";
} else {
$default_editor = 'tinymce';
}
@ -272,7 +272,7 @@ final class _WP_Editors {
'id="' . $editor_id_attr . '">%s</textarea></div>'
);
// Prepare the content for the Visual or Text editor, only when TinyMCE is used (back-compat).
// Prepare the content for the Visual or Code editor, only when TinyMCE is used (back-compat).
if ( self::$this_tinymce ) {
add_filter( 'the_editor_content', 'format_for_editor', 10, 2 );
}
@ -627,7 +627,7 @@ final class _WP_Editors {
);
/**
* Filters the list of teenyMCE buttons (Text tab).
* Filters the list of teenyMCE buttons (Code tab).
*
* @since 2.7.0
* @since 3.3.0 The `$editor_id` parameter was added.
@ -1396,7 +1396,7 @@ final class _WP_Editors {
'Apply' => __( 'Apply' ), // Tooltip for the 'apply' button in the inline link dialog.
'Link options' => __( 'Link options' ), // Tooltip for the 'link options' button in the inline link dialog.
'Visual' => _x( 'Visual', 'Name for the Visual editor tab' ), // Editor switch tab label.
'Text' => _x( 'Text', 'Name for the Text editor tab (formerly HTML)' ), // Editor switch tab label.
'Code' => _x( 'Code', 'Name for the Code editor tab (formerly Text)' ), // Editor switch tab label.
'Add Media' => array( __( 'Add Media' ), 'accessM' ), // Tooltip for the 'Add Media' button in the block editor Classic block.
// Shortcuts help modal.

View File

@ -3792,7 +3792,7 @@ function user_can_richedit() {
* Finds out which editor should be displayed by default.
*
* Works out which of the editors to display as the current editor for a
* user. The 'html' setting is for the "Text" editor tab.
* user. The 'html' setting is for the "Code" editor tab.
*
* @since 2.5.0
*

View File

@ -557,7 +557,7 @@ class WP_Widget_Text extends WP_Widget {
<div hidden class="wp-pointer paste-html-pointer wp-pointer-top">
<div class="wp-pointer-content">
<h3><?php _e( 'Did you just paste HTML?' ); ?></h3>
<p><?php _e( 'Hey there, looks like you just pasted HTML into the &#8220;Visual&#8221; tab of the Text widget. You may want to paste your code into the &#8220;Text&#8221; tab instead. Alternately, try out the new &#8220;Custom HTML&#8221; widget!' ); ?></p>
<p><?php _e( 'Hey there, looks like you just pasted HTML into the &#8220;Visual&#8221; tab of the Text widget. You may want to paste your code into the &#8220;Code&#8221; tab instead. Alternately, try out the new &#8220;Custom HTML&#8221; widget!' ); ?></p>
<div class="wp-pointer-buttons">
<a class="close" href="#"><?php _e( 'Dismiss' ); ?></a>
</div>