Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions classic-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ private static function is_classic( $post_id = 0 ) {
$which = get_post_meta( $post_id, 'classic-editor-remember', true );

if ( $which ) {
// The editor choice will be "remembered" when the post is opened in either Classic or Block editor.
// The editor choice will be "remembered" when the post is opened in either the classic or the block editor.
if ( 'classic-editor' === $which ) {
return true;
} elseif ( 'block-editor' === $which ) {
Expand Down Expand Up @@ -390,11 +390,11 @@ public static function settings_1() {
<div class="classic-editor-options">
<p>
<input type="radio" name="classic-editor-replace" id="classic-editor-classic" value="classic"<?php if ( $settings['editor'] === 'classic' ) echo ' checked'; ?> />
<label for="classic-editor-classic"><?php _ex( 'Classic Editor', 'Editor Name', 'classic-editor' ); ?></label>
<label for="classic-editor-classic"><?php _ex( 'Classic editor', 'Editor Name', 'classic-editor' ); ?></label>
</p>
<p>
<input type="radio" name="classic-editor-replace" id="classic-editor-block" value="block"<?php if ( $settings['editor'] !== 'classic' ) echo ' checked'; ?> />
<label for="classic-editor-block"><?php _ex( 'Block Editor', 'Editor Name', 'classic-editor' ); ?></label>
<label for="classic-editor-block"><?php _ex( 'Block editor', 'Editor Name', 'classic-editor' ); ?></label>
</p>
</div>
<script>
Expand Down Expand Up @@ -467,11 +467,11 @@ public static function network_settings() {
<td>
<p>
<input type="radio" name="classic-editor-replace" id="classic-editor-classic" value="classic"<?php if ( $editor !== 'block' ) echo ' checked'; ?> />
<label for="classic-editor-classic"><?php _ex( 'Classic Editor', 'Editor Name', 'classic-editor' ); ?></label>
<label for="classic-editor-classic"><?php _ex( 'Classic editor', 'Editor Name', 'classic-editor' ); ?></label>
</p>
<p>
<input type="radio" name="classic-editor-replace" id="classic-editor-block" value="block"<?php if ( $editor === 'block' ) echo ' checked'; ?> />
<label for="classic-editor-block"><?php _ex( 'Block Editor', 'Editor Name', 'classic-editor' ); ?></label>
<label for="classic-editor-block"><?php _ex( 'Block editor', 'Editor Name', 'classic-editor' ); ?></label>
</p>
</td>
</tr>
Expand All @@ -480,7 +480,7 @@ public static function network_settings() {
<td>
<input type="checkbox" name="classic-editor-allow-sites" id="classic-editor-allow-sites" value="allow"<?php if ( $is_checked ) echo ' checked'; ?>>
<label for="classic-editor-allow-sites"><?php _e( 'Allow site admins to change settings', 'classic-editor' ); ?></label>
<p class="description"><?php _e( 'By default the Block Editor is replaced with the Classic Editor and users cannot switch editors.', 'classic-editor' ); ?></p>
<p class="description"><?php _e( 'By default the block editor is replaced with the classic editor and users cannot switch editors.', 'classic-editor' ); ?></p>
</td>
</tr>
</table>
Expand Down Expand Up @@ -508,7 +508,7 @@ public static function save_network_settings() {

/**
* Add a hidden field in edit-form-advanced.php
* to help redirect back to the Classic Editor on saving.
* to help redirect back to the classic editor on saving.
*/
public static function add_redirect_helper() {
?>
Expand All @@ -517,7 +517,7 @@ public static function add_redirect_helper() {
}

/**
* Remember when the Classic Editor was used to edit a post.
* Remember when the classic editor was used to edit a post.
*/
public static function remember_classic_editor( $post ) {
$post_type = get_post_type( $post );
Expand All @@ -528,7 +528,7 @@ public static function remember_classic_editor( $post ) {
}

/**
* Remember when the Block Editor was used to edit a post.
* Remember when the block editor was used to edit a post.
*/
public static function remember_block_editor( $editor_settings, $post ) {
$post_type = get_post_type( $post );
Expand All @@ -549,13 +549,13 @@ private static function remember( $post_id, $editor ) {
/**
* Choose which editor to use for a post.
*
* Passes through `$which_editor` for Block Editor (it's sets to `true` but may be changed by another plugin).
* Passes through `$which_editor` for block editor (it's sets to `true` but may be changed by another plugin).
*
* @uses `use_block_editor_for_post` filter.
*
* @param boolean $use_block_editor True for Block Editor, false for Classic Editor.
* @param boolean $use_block_editor True for block editor, false for classic editor.
* @param WP_Post $post The post being edited.
* @return boolean True for Block Editor, false for Classic Editor.
* @return boolean True for block editor, false for classic editor.
*/
public static function choose_editor( $use_block_editor, $post ) {
$settings = self::get_settings();
Expand All @@ -571,7 +571,7 @@ public static function choose_editor( $use_block_editor, $post ) {
if ( empty( $post->ID ) || $post->post_status === 'auto-draft' ) {
if (
( $settings['editor'] === 'classic' && ! isset( $_GET['classic-editor__forget'] ) ) || // Add New
( isset( $_GET['classic-editor'] ) && isset( $_GET['classic-editor__forget'] ) ) // Switch to Classic Editor when no draft post.
( isset( $_GET['classic-editor'] ) && isset( $_GET['classic-editor__forget'] ) ) // Switch to classic editor when no draft post.
) {
$use_block_editor = false;
}
Expand Down Expand Up @@ -637,14 +637,14 @@ public static function add_meta_box( $post_type, $post ) {
public static function do_meta_box( $post ) {
$edit_url = get_edit_post_link( $post->ID, 'raw' );

// Switching to Block Editor.
// Switching to block editor.
$edit_url = remove_query_arg( 'classic-editor', $edit_url );
// Forget the previous value when going to a specific editor.
$edit_url = add_query_arg( 'classic-editor__forget', '', $edit_url );

?>
<p style="margin: 1em 0;">
<a href="<?php echo esc_url( $edit_url ); ?>"><?php _e( 'Switch to Block Editor', 'classic-editor' ); ?></a>
<a href="<?php echo esc_url( $edit_url ); ?>"><?php _e( 'Switch to block editor', 'classic-editor' ); ?></a>
</p>
<?php
}
Expand All @@ -668,7 +668,7 @@ public static function enqueue_block_editor_scripts() {
wp_localize_script(
'classic-editor-plugin',
'classicEditorPluginL10n',
array( 'linkText' => __( 'Switch to Classic Editor', 'classic-editor' ) )
array( 'linkText' => __( 'Switch to classic editor', 'classic-editor' ) )
);
}

Expand Down Expand Up @@ -765,7 +765,7 @@ private static function get_enabled_editors_for_post( $post ) {

/**
* Adds links to the post/page screens to edit any post or page in
* the Classic Editor or Block Editor.
* the classic editor or block editor.
*
* @param array $actions Post actions.
* @param WP_Post $post Edited post.
Expand Down Expand Up @@ -800,18 +800,18 @@ public static function add_edit_links( $actions, $post ) {
// Build the edit actions. See also: WP_Posts_List_Table::handle_row_actions().
$title = _draft_or_post_title( $post->ID );

// Link to the Block Editor.
// Link to the block editor.
$url = remove_query_arg( 'classic-editor', $edit_url );
$text = _x( 'Edit (Block Editor)', 'Editor Name', 'classic-editor' );
$text = _x( 'Edit (block editor)', 'Editor Name', 'classic-editor' );
/* translators: %s: post title */
$label = sprintf( __( 'Edit &#8220;%s&#8221; in the Block Editor', 'classic-editor' ), $title );
$label = sprintf( __( 'Edit &#8220;%s&#8221; in the block editor', 'classic-editor' ), $title );
$edit_block = sprintf( '<a href="%s" aria-label="%s">%s</a>', esc_url( $url ), esc_attr( $label ), $text );

// Link to the Classic Editor.
// Link to the classic editor.
$url = add_query_arg( 'classic-editor', '', $edit_url );
$text = _x( 'Edit (Classic Editor)', 'Editor Name', 'classic-editor' );
$text = _x( 'Edit (classic editor)', 'Editor Name', 'classic-editor' );
/* translators: %s: post title */
$label = sprintf( __( 'Edit &#8220;%s&#8221; in the Classic Editor', 'classic-editor' ), $title );
$label = sprintf( __( 'Edit &#8220;%s&#8221; in the classic editor', 'classic-editor' ), $title );
$edit_classic = sprintf( '<a href="%s" aria-label="%s">%s</a>', esc_url( $url ), esc_attr( $label ), $text );

$edit_actions = array(
Expand Down Expand Up @@ -839,11 +839,11 @@ public static function add_post_state( $post_states, $post ) {
if ( ! $editors['classic_editor'] && ! $editors['block_editor'] ) {
return $post_states;
} elseif ( $editors['classic_editor'] && ! $editors['block_editor'] ) {
// Forced to Classic Editor.
$state = '<span class="classic-editor-forced-state">' . _x( 'Classic Editor', 'Editor Name', 'classic-editor' ) . '</span>';
// Forced to classic editor.
$state = '<span class="classic-editor-forced-state">' . _x( 'classic editor', 'Editor Name', 'classic-editor' ) . '</span>';
} elseif ( ! $editors['classic_editor'] && $editors['block_editor'] ) {
// Forced to Block Editor.
$state = '<span class="classic-editor-forced-state">' . _x( 'Block Editor', 'Editor Name', 'classic-editor' ) . '</span>';
// Forced to block editor.
$state = '<span class="classic-editor-forced-state">' . _x( 'block editor', 'Editor Name', 'classic-editor' ) . '</span>';
} else {
$last_editor = get_post_meta( $post->ID, 'classic-editor-remember', true );

Expand All @@ -856,7 +856,7 @@ public static function add_post_state( $post_states, $post ) {
$is_classic = ( $settings['editor'] === 'classic' );
}

$state = $is_classic ? _x( 'Classic Editor', 'Editor Name', 'classic-editor' ) : _x( 'Block Editor', 'Editor Name', 'classic-editor' );
$state = $is_classic ? _x( 'Classic editor', 'Editor Name', 'classic-editor' ) : _x( 'Block editor', 'Editor Name', 'classic-editor' );
}

// Fix PHP 7+ warnings if another plugin returns unexpected type.
Expand Down
2 changes: 1 addition & 1 deletion js/block-editor-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
var createElement = wp.element.createElement;
var PluginMoreMenuItem = wp.editPost.PluginMoreMenuItem;
var url = wp.url.addQueryArgs( document.location.href, { 'classic-editor': '', 'classic-editor__forget': '' } );
var linkText = lodash.get( window, [ 'classicEditorPluginL10n', 'linkText' ] ) || 'Switch to Classic Editor';
var linkText = lodash.get( window, [ 'classicEditorPluginL10n', 'linkText' ] ) || 'Switch to classic editor';

return createElement(
PluginMoreMenuItem,
Expand Down
26 changes: 13 additions & 13 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ At a glance, this plugin adds the following:

In addition, the Classic Editor plugin includes several filters that let other plugins control the settings, and the editor choice per post and per post type.

By default, this plugin hides all functionality available in the new Block Editor ("Gutenberg").
By default, this plugin hides all functionality available in the new block editor ("Gutenberg").

== Changelog ==

Expand All @@ -38,11 +38,11 @@ By default, this plugin hides all functionality available in the new Block Edito
* On network installations removed the restriction for only network activation.
* Added support for network administrators to choose the default network-wide editor.
* Fixed the settings link in the warning on network About screen.
* Properly added the "Switch to Classic Editor" menu item to the Block Editor menu.
* Properly added the "Switch to classic editor" menu item to the block editor menu.

= 1.3 =
* Fixed removal of the "Try Gutenberg" dashboard widget.
* Fixed condition for displaying of the after upgrade notice on the "What's New" screen. Shown when the Classic Editor is selected and users cannot switch editors.
* Fixed condition for displaying of the after upgrade notice on the "What's New" screen. Shown when the classic editor is selected and users cannot switch editors.

= 1.2 =
* Fixed switching editors from the Add New (post) screen before a draft post is saved.
Expand All @@ -53,11 +53,11 @@ By default, this plugin hides all functionality available in the new Block Edito
* Added `classic_editor_network_default_settings` filter.

= 1.1 =
Fixed a bug where it may attempt to load the Block Editor for post types that do not support editor when users are allowed to switch editors.
Fixed a bug where it may attempt to load the block editor for post types that do not support editor when users are allowed to switch editors.

= 1.0 =
* Updated for WordPress 5.0.
* Changed all "Gutenberg" names/references to "Block Editor".
* Changed all "Gutenberg" names/references to "block editor".
* Refreshed the settings UI.
* Removed disabling of the Gutenberg plugin. This was added for testing in WordPress 4.9. Users who want to continue following the development of Gutenberg in WordPress 5.0 and beyond will not need another plugin to disable it.
* Added support for per-user settings of default editor.
Expand All @@ -72,7 +72,7 @@ Fixed a bug where it may attempt to load the Block Editor for post types that do
= 0.5 =
* Updated for Gutenberg 4.1 and WordPress 5.0-beta1.
* Removed some functionality that now exists in Gutenberg.
* Fixed redirecting back to the Classic Editor after looking at post revisions.
* Fixed redirecting back to the classic editor after looking at post revisions.

= 0.4 =
* Fixed removing of the "Try Gutenberg" call-out when the Gutenberg plugin is not activated.
Expand All @@ -94,26 +94,26 @@ Initial release.

= Default settings =

When activated this plugin will restore the previous ("classic") WordPress editor and hide the new Block Editor ("Gutenberg").
When activated this plugin will restore the previous ("classic") WordPress editor and hide the new block editor ("Gutenberg").
These settings can be changed at the Settings => Writing screen.

= Default settings for network installation =

There are two options:

* When network-activated this plugin will set the Classic Editor as default and prevent site administrators and users from changing editors.
* When network-activated this plugin will set the classic editor as default and prevent site administrators and users from changing editors.
The settings can be changed and default network-wide editor can be selected on the Network Settings screen.
* When not network-activated each site administrator will be able to activate the plugin and choose options for their users.

= Cannot find the "Switch to Classic Editor" link =
= Cannot find the "Switch to classic editor" link =

It is in the main Block Editor menu, see this [screenshot](https://ps.w.org/classic-editor/assets/screenshot-7.png?rev=2023480).
It is in the main block editor menu, see this [screenshot](https://ps.w.org/classic-editor/assets/screenshot-7.png?rev=2023480).

== Screenshots ==
1. Admin settings on the Settings -> Writing screen.
2. User settings on the Profile screen. Visible when the users are allowed to switch editors.
3. "Action links" to choose alternative editor. Visible when the users are allowed to switch editors.
4. Link to switch to the Block Editor while editing a post in the Classic Editor. Visible when the users are allowed to switch editors.
5. Link to switch to the Classic Editor while editing a post in the Block Editor. Visible when the users are allowed to switch editors.
4. Link to switch to the block editor while editing a post in the classic editor. Visible when the users are allowed to switch editors.
5. Link to switch to the classic editor while editing a post in the block editor. Visible when the users are allowed to switch editors.
6. Network settings to select the default editor for the network and allow site admins to change it.
7. The "Switch to Classic Editor" link.
7. The "Switch to classic editor" link.