Classic Editor - Version 0.3

Version Description

Updated the option from a checkbox to couple of radio buttons, seems clearer. Thanks to @designsimply for the label text suggestions. Some general updates and cleanup.

Download this release

Release Info

Developer azaozz
Plugin Icon 128x128 Classic Editor
Version 0.3
Comparing to
See all releases

Code changes from version 0.2 to 0.3

Files changed (5) hide show
  1. classic-editor.php +43 -25
  2. readme.txt +4 -0
  3. screenshot-1.png +0 -0
  4. screenshot-2.png +0 -0
  5. screenshot-3.png +0 -0
classic-editor.php CHANGED
@@ -5,7 +5,7 @@
5
  * Plugin Name: Classic Editor
6
  * Plugin URI: https://wordpress.org
7
  * Description: Enables the WordPress classic editor and the old-style Edit Post screen layout (TinyMCE, meta boxes, etc.). Supports the older plugins that extend this screen.
8
- * Version: 0.2
9
  * Author: WordPress Contributors
10
  * License: GPL-2.0+
11
  * License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@@ -34,7 +34,7 @@ if ( ! defined( 'ABSPATH' ) ) {
34
  * @return bool Whether the Gutenberg plugin is active.
35
  */
36
  function classic_editor_is_gutenberg_active() {
37
- if ( in_array( 'gutenberg/gutenberg.php', (array) get_option( 'active_plugins', array() ) ) ||
38
  ( is_multisite() && array_key_exists( 'gutenberg/gutenberg.php', (array) get_site_option( 'active_sitewide_plugins' ) ) ) ) {
39
 
40
  return true;
@@ -58,16 +58,11 @@ function classic_editor_init_actions() {
58
  if ( $replace || isset( $_GET['classic-editor'] ) ) {
59
  // gutenberg.php
60
  remove_action( 'admin_menu', 'gutenberg_menu' );
61
- remove_action( 'load-post.php', 'gutenberg_intercept_edit_post' );
62
- remove_action( 'load-post-new.php', 'gutenberg_intercept_post_new' );
63
  remove_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
64
  remove_action( 'admin_init', 'gutenberg_redirect_demo' );
65
 
66
  remove_filter( 'replace_editor', 'gutenberg_init' );
67
 
68
- // lib/blocks.php
69
- remove_filter( 'wp_insert_post_data', 'gutenberg_wpautop_insert_post_data' );
70
-
71
  // lib/client-assets.php
72
  remove_action( 'wp_enqueue_scripts', 'gutenberg_register_scripts_and_styles', 5 );
73
  remove_action( 'admin_enqueue_scripts', 'gutenberg_register_scripts_and_styles', 5 );
@@ -75,22 +70,28 @@ function classic_editor_init_actions() {
75
  remove_action( 'admin_enqueue_scripts', 'gutenberg_common_scripts_and_styles' );
76
 
77
  // lib/compat.php
78
- remove_action( 'wp_enqueue_scripts', 'gutenberg_ensure_wp_api_request', 20 );
79
- remove_action( 'admin_enqueue_scripts', 'gutenberg_ensure_wp_api_request', 20 );
80
-
81
- remove_filter( 'wp_editor_settings', 'gutenberg_disable_editor_settings_wpautop' );
82
  remove_filter( 'wp_refresh_nonces', 'gutenberg_add_rest_nonce_to_heartbeat_response_headers' );
83
 
84
  // lib/register.php
85
  remove_action( 'plugins_loaded', 'gutenberg_trick_plugins_into_registering_meta_boxes' );
86
- remove_action( 'rest_api_init', 'gutenberg_register_rest_routes' );
87
- remove_action( 'rest_api_init', 'gutenberg_register_rest_api_post_revisions' );
88
  remove_action( 'edit_form_top', 'gutenberg_remember_classic_editor_when_saving_posts' );
89
 
90
  remove_filter( 'redirect_post_location', 'gutenberg_redirect_to_classic_editor_when_saving_posts' );
91
  remove_filter( 'get_edit_post_link', 'gutenberg_revisions_link_to_editor' );
92
  remove_filter( 'wp_prepare_revision_for_js', 'gutenberg_revisions_restore' );
93
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  // lib/meta-box-partial-page.php
95
  remove_action( 'do_meta_boxes', 'gutenberg_meta_box_save', 1000 );
96
  remove_action( 'submitpost_box', 'gutenberg_intercept_meta_box_render' );
@@ -107,20 +108,26 @@ function classic_editor_init_actions() {
107
  if ( $replace ) {
108
  // gutenberg.php
109
  remove_filter( 'admin_url', 'gutenberg_modify_add_new_button_url' );
110
-
111
- // lib/blocks.php
112
- // remove_filter( 'the_content', 'do_blocks', 9 );
113
 
114
  // lib/register.php
115
- remove_filter( 'display_post_states', 'gutenberg_add_gutenberg_post_state', 10 );
116
 
117
  // lib/plugin-compat.php
118
  remove_filter( 'rest_pre_insert_post', 'gutenberg_remove_wpcom_markdown_support' );
119
 
120
  // Keep
121
- // remove_filter( 'rest_index', 'gutenberg_ensure_wp_json_has_permalink_structure' );
 
 
 
 
 
 
 
122
  // add_filter( 'the_content', 'wpautop' );
123
  // remove_filter( 'the_content', 'gutenberg_wpautop', 8 );
 
124
  // remove_action( 'init', 'gutenberg_register_post_types' );
125
  } else {
126
  // Menus
@@ -139,6 +146,9 @@ function classic_editor_init_actions() {
139
 
140
  // Gutenberg plugin: remove the "Classic editor" row actions.
141
  remove_action( 'admin_init', 'gutenberg_add_edit_link_filters' );
 
 
 
142
  }
143
 
144
  function classic_editor_admin_init() {
@@ -158,17 +168,25 @@ function classic_editor_admin_init() {
158
  * Output HTML for the settings.
159
  */
160
  function classic_editor_settings() {
161
- $no_replace = get_option( 'classic-editor-replace' ) === 'no-replace';
162
 
163
  ?>
164
- <p id="classic-editor-options" style="margin: 0;"><label>
165
- <input type="checkbox" name="classic-editor-replace" value="no-replace"<?php if ( $no_replace ) echo ' checked'; ?> />
166
- <?php _e( 'Do not replace the editor. Add alternate links to the Posts and Pages screens for editing with the Classic editor.', 'classic-editor' ); ?>
167
- </label></p>
 
 
 
 
 
 
 
 
168
  <script>
169
  jQuery( 'document' ).ready( function( $ ) {
170
  if ( window.location.hash === '#classic-editor-options' ) {
171
- $( '#classic-editor-options' ).closest( 'td' ).css( 'border', '1px solid #aaa' );
172
  }
173
  } );
174
  </script>
@@ -333,7 +351,7 @@ function classic_editor_add_edit_links( $actions, $post ) {
333
  register_activation_hook( __FILE__, 'classic_editor_activate' );
334
  function classic_editor_activate() {
335
  if ( ! get_option( 'classic-editor-replace' ) ) {
336
- update_option( 'classic-editor-replace', 'no-replace' );
337
  }
338
  }
339
 
5
  * Plugin Name: Classic Editor
6
  * Plugin URI: https://wordpress.org
7
  * Description: Enables the WordPress classic editor and the old-style Edit Post screen layout (TinyMCE, meta boxes, etc.). Supports the older plugins that extend this screen.
8
+ * Version: 0.3
9
  * Author: WordPress Contributors
10
  * License: GPL-2.0+
11
  * License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
34
  * @return bool Whether the Gutenberg plugin is active.
35
  */
36
  function classic_editor_is_gutenberg_active() {
37
+ if ( in_array( 'gutenberg/gutenberg.php', (array) get_option( 'active_plugins' ) ) ||
38
  ( is_multisite() && array_key_exists( 'gutenberg/gutenberg.php', (array) get_site_option( 'active_sitewide_plugins' ) ) ) ) {
39
 
40
  return true;
58
  if ( $replace || isset( $_GET['classic-editor'] ) ) {
59
  // gutenberg.php
60
  remove_action( 'admin_menu', 'gutenberg_menu' );
 
 
61
  remove_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
62
  remove_action( 'admin_init', 'gutenberg_redirect_demo' );
63
 
64
  remove_filter( 'replace_editor', 'gutenberg_init' );
65
 
 
 
 
66
  // lib/client-assets.php
67
  remove_action( 'wp_enqueue_scripts', 'gutenberg_register_scripts_and_styles', 5 );
68
  remove_action( 'admin_enqueue_scripts', 'gutenberg_register_scripts_and_styles', 5 );
70
  remove_action( 'admin_enqueue_scripts', 'gutenberg_common_scripts_and_styles' );
71
 
72
  // lib/compat.php
 
 
 
 
73
  remove_filter( 'wp_refresh_nonces', 'gutenberg_add_rest_nonce_to_heartbeat_response_headers' );
74
 
75
  // lib/register.php
76
  remove_action( 'plugins_loaded', 'gutenberg_trick_plugins_into_registering_meta_boxes' );
 
 
77
  remove_action( 'edit_form_top', 'gutenberg_remember_classic_editor_when_saving_posts' );
78
 
79
  remove_filter( 'redirect_post_location', 'gutenberg_redirect_to_classic_editor_when_saving_posts' );
80
  remove_filter( 'get_edit_post_link', 'gutenberg_revisions_link_to_editor' );
81
  remove_filter( 'wp_prepare_revision_for_js', 'gutenberg_revisions_restore' );
82
 
83
+ // lib/rest-api.php
84
+ remove_action( 'rest_api_init', 'gutenberg_register_rest_routes' );
85
+ remove_action( 'rest_api_init', 'gutenberg_add_taxonomy_visibility_field' );
86
+
87
+ remove_filter( 'rest_request_after_callbacks', 'gutenberg_filter_oembed_result' );
88
+ remove_filter( 'registered_post_type', 'gutenberg_register_post_prepare_functions' );
89
+ remove_filter( 'registered_taxonomy', 'gutenberg_register_taxonomy_prepare_functions' );
90
+ remove_filter( 'rest_index', 'gutenberg_ensure_wp_json_has_theme_supports' );
91
+ remove_filter( 'rest_request_before_callbacks', 'gutenberg_handle_early_callback_checks' );
92
+ remove_filter( 'rest_user_collection_params', 'gutenberg_filter_user_collection_parameters' );
93
+ remove_filter( 'rest_request_after_callbacks', 'gutenberg_filter_request_after_callbacks' );
94
+
95
  // lib/meta-box-partial-page.php
96
  remove_action( 'do_meta_boxes', 'gutenberg_meta_box_save', 1000 );
97
  remove_action( 'submitpost_box', 'gutenberg_intercept_meta_box_render' );
108
  if ( $replace ) {
109
  // gutenberg.php
110
  remove_filter( 'admin_url', 'gutenberg_modify_add_new_button_url' );
111
+ remove_action( 'admin_print_scripts-edit.php', 'gutenberg_replace_default_add_new_button' );
 
 
112
 
113
  // lib/register.php
114
+ remove_filter( 'display_post_states', 'gutenberg_add_gutenberg_post_state' );
115
 
116
  // lib/plugin-compat.php
117
  remove_filter( 'rest_pre_insert_post', 'gutenberg_remove_wpcom_markdown_support' );
118
 
119
  // Keep
120
+
121
+ // lib/blocks.php
122
+ // remove_filter( 'the_content', 'do_blocks', 9 );
123
+
124
+ // Continue to disable wpautop inside TinyMCE for posts that were started in Gutenberg.
125
+ // remove_filter( 'wp_editor_settings', 'gutenberg_disable_editor_settings_wpautop' );
126
+
127
+ // Keep the tweaks to the PHP wpautop.
128
  // add_filter( 'the_content', 'wpautop' );
129
  // remove_filter( 'the_content', 'gutenberg_wpautop', 8 );
130
+
131
  // remove_action( 'init', 'gutenberg_register_post_types' );
132
  } else {
133
  // Menus
146
 
147
  // Gutenberg plugin: remove the "Classic editor" row actions.
148
  remove_action( 'admin_init', 'gutenberg_add_edit_link_filters' );
149
+
150
+ // Remove the "Try Gutenberg" dashboard widget.
151
+ remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' );
152
  }
153
 
154
  function classic_editor_admin_init() {
168
  * Output HTML for the settings.
169
  */
170
  function classic_editor_settings() {
171
+ $replace = get_option( 'classic-editor-replace' ) !== 'no-replace';
172
 
173
  ?>
174
+ <p id="classic-editor-options" style="margin: 0;">
175
+ <input type="radio" name="classic-editor-replace" id="classic-editor-replace" value="replace"<?php if ( $replace ) echo ' checked'; ?> />
176
+ <label for="classic-editor-replace">
177
+ <?php _e( 'Replace the Gutenberg editor with the Classic editor.', 'classic-editor' ); ?>
178
+ </label>
179
+ <br>
180
+
181
+ <input type="radio" name="classic-editor-replace" id="classic-editor-no-replace" value="no-replace"<?php if ( ! $replace ) echo ' checked'; ?> />
182
+ <label for="classic-editor-no-replace">
183
+ <?php _e( 'Use the Gutenberg editor by default and include optional links back to the Classic editor.', 'classic-editor' ); ?>
184
+ </label>
185
+ </p>
186
  <script>
187
  jQuery( 'document' ).ready( function( $ ) {
188
  if ( window.location.hash === '#classic-editor-options' ) {
189
+ $( '#classic-editor-options' ).closest( 'td' ).addClass( 'highlight' );
190
  }
191
  } );
192
  </script>
351
  register_activation_hook( __FILE__, 'classic_editor_activate' );
352
  function classic_editor_activate() {
353
  if ( ! get_option( 'classic-editor-replace' ) ) {
354
+ update_option( 'classic-editor-replace', 'replace' );
355
  }
356
  }
357
 
readme.txt CHANGED
@@ -26,6 +26,10 @@ The modes can be changed from the Settings -> Writing screen. See the screenshot
26
  The current release is intended for testing with the [Gutenberg plugin](https://wordpress.org/plugins/gutenberg/) version 1.5 or newer.
27
 
28
  == Changelog ==
 
 
 
 
29
  = 0.2 =
30
  Update for Gutenberg 1.9.
31
  Remove warning and automatic deactivation when Gutenberg is not active.
26
  The current release is intended for testing with the [Gutenberg plugin](https://wordpress.org/plugins/gutenberg/) version 1.5 or newer.
27
 
28
  == Changelog ==
29
+ = 0.3 =
30
+ Updated the option from a checkbox to couple of radio buttons, seems clearer. Thanks to @designsimply for the label text suggestions.
31
+ Some general updates and cleanup.
32
+
33
  = 0.2 =
34
  Update for Gutenberg 1.9.
35
  Remove warning and automatic deactivation when Gutenberg is not active.
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file