Classic Editor - Version 0.2

Version Description

Update for Gutenberg 1.9. Remove warning and automatic deactivation when Gutenberg is not active.

Download this release

Release Info

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

Code changes from version 0.1 to 0.2

Files changed (2) hide show
  1. classic-editor.php +37 -22
  2. readme.txt +5 -2
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.1
9
  * Author: WordPress Contributors
10
  * License: GPL-2.0+
11
  * License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@@ -43,24 +43,13 @@ function classic_editor_is_gutenberg_active() {
43
  return false;
44
  }
45
 
46
- function classic_editor_gutenberg_missing_warning() {
47
- ?>
48
- <div class="error"><p>
49
- <?php _e( 'Classic Editor requires Gutenberg 1.5 or later. Please install and activate it before activating Classic Editor.', 'classic-editor' ); ?>
50
- <script>window.jQuery && jQuery( function( $ ) { $( 'div#message.updated' ).remove(); } );</script>
51
- </p></div>
52
- <?php
53
-
54
- deactivate_plugins( array( 'classic-editor/classic-editor.php' ) );
55
- }
56
-
57
  add_action( 'plugins_loaded', 'classic_editor_init_actions' );
58
  function classic_editor_init_actions() {
59
  if ( ! classic_editor_is_gutenberg_active() || ! (
60
  has_filter( 'replace_editor', 'gutenberg_init' ) ||
61
  has_filter( 'load-post.php', 'gutenberg_intercept_edit_post' ) ) ) {
62
 
63
- add_action( 'admin_notices', 'classic_editor_gutenberg_missing_warning' );
64
  return;
65
  }
66
 
@@ -68,12 +57,16 @@ function classic_editor_init_actions() {
68
 
69
  if ( $replace || isset( $_GET['classic-editor'] ) ) {
70
  // gutenberg.php
71
- remove_filter( 'replace_editor', 'gutenberg_init' );
72
  remove_action( 'load-post.php', 'gutenberg_intercept_edit_post' );
73
  remove_action( 'load-post-new.php', 'gutenberg_intercept_post_new' );
74
  remove_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
75
  remove_action( 'admin_init', 'gutenberg_redirect_demo' );
76
- remove_action( 'admin_menu', 'gutenberg_menu' );
 
 
 
 
77
 
78
  // lib/client-assets.php
79
  remove_action( 'wp_enqueue_scripts', 'gutenberg_register_scripts_and_styles', 5 );
@@ -84,28 +77,50 @@ function classic_editor_init_actions() {
84
  // lib/compat.php
85
  remove_action( 'wp_enqueue_scripts', 'gutenberg_ensure_wp_api_request', 20 );
86
  remove_action( 'admin_enqueue_scripts', 'gutenberg_ensure_wp_api_request', 20 );
 
87
  remove_filter( 'wp_editor_settings', 'gutenberg_disable_editor_settings_wpautop' );
88
  remove_filter( 'wp_refresh_nonces', 'gutenberg_add_rest_nonce_to_heartbeat_response_headers' );
89
 
90
  // lib/register.php
 
91
  remove_action( 'rest_api_init', 'gutenberg_register_rest_routes' );
 
 
92
 
93
- // Metaboxes hacks
94
- remove_action( 'do_meta_boxes', 'gutenberg_meta_box_partial_page', 1000 );
95
- remove_action( 'plugins_loaded', 'gutenberg_trick_plugins_into_registering_meta_boxes' );
 
 
 
 
 
 
 
 
 
 
96
 
97
  // add_filter( 'replace_editor', 'classic_editor_replace' );
98
  }
99
 
100
  if ( $replace ) {
 
 
 
 
 
 
101
  // lib/register.php
102
  remove_filter( 'display_post_states', 'gutenberg_add_gutenberg_post_state', 10 );
103
 
104
  // lib/plugin-compat.php
105
  remove_filter( 'rest_pre_insert_post', 'gutenberg_remove_wpcom_markdown_support' );
106
 
107
- // Keep these?
108
- // remove_filter( 'the_content', 'do_blocks', 9 );
 
 
109
  // remove_action( 'init', 'gutenberg_register_post_types' );
110
  } else {
111
  // Menus
@@ -184,7 +199,7 @@ function classic_editor_redirect_location( $location ) {
184
 
185
  /**
186
  * Add an `Add New (Classic)` submenu for Posts, Pages, etc.
187
- */
188
  function classic_editor_add_submenus() {
189
  foreach ( get_post_types( array( 'show_ui' => true ) ) as $type ) {
190
  $type_obj = get_post_type_object( $type );
@@ -214,7 +229,7 @@ function classic_editor_add_submenus() {
214
 
215
  /**
216
  * Add an `Edit (Classic)` link in the toolbar.
217
- */
218
  function classic_editor_admin_bar_menu( $wp_admin_bar ) {
219
  global $post_id, $wp_the_query;
220
  $edit_url = null;
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
43
  return false;
44
  }
45
 
 
 
 
 
 
 
 
 
 
 
 
46
  add_action( 'plugins_loaded', 'classic_editor_init_actions' );
47
  function classic_editor_init_actions() {
48
  if ( ! classic_editor_is_gutenberg_active() || ! (
49
  has_filter( 'replace_editor', 'gutenberg_init' ) ||
50
  has_filter( 'load-post.php', 'gutenberg_intercept_edit_post' ) ) ) {
51
 
52
+ // Gutenberg is not installed or activated. No need to do anything :)
53
  return;
54
  }
55
 
57
 
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 );
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' );
97
+ remove_action( 'submitpage_box', 'gutenberg_intercept_meta_box_render' );
98
+ remove_action( 'edit_page_form', 'gutenberg_intercept_meta_box_render' );
99
+ remove_action( 'edit_form_advanced', 'gutenberg_intercept_meta_box_render' );
100
+
101
+ remove_filter( 'redirect_post_location', 'gutenberg_meta_box_save_redirect' );
102
+ remove_filter( 'filter_gutenberg_meta_boxes', 'gutenberg_filter_meta_boxes' );
103
 
104
  // add_filter( 'replace_editor', 'classic_editor_replace' );
105
  }
106
 
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
199
 
200
  /**
201
  * Add an `Add New (Classic)` submenu for Posts, Pages, etc.
202
+ */
203
  function classic_editor_add_submenus() {
204
  foreach ( get_post_types( array( 'show_ui' => true ) ) as $type ) {
205
  $type_obj = get_post_type_object( $type );
229
 
230
  /**
231
  * Add an `Edit (Classic)` link in the toolbar.
232
+ */
233
  function classic_editor_admin_bar_menu( $wp_admin_bar ) {
234
  global $post_id, $wp_the_query;
235
  $edit_url = null;
readme.txt CHANGED
@@ -2,11 +2,11 @@
2
  Contributors: azaozz
3
  Requires at least: 4.9
4
  Tested up to: 4.9
5
- Stable tag: trunk
6
  License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
 
9
- Restores the Classic Editor and the old-style Edit Post screen layout (TinyMCE, Meta boxes, etc.). Supports the pluhins that extend this screen.
10
 
11
  == Description ==
12
 
@@ -26,6 +26,9 @@ 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
 
30
  = 0.1 =
31
  Initial release.
2
  Contributors: azaozz
3
  Requires at least: 4.9
4
  Tested up to: 4.9
5
+ Stable tag: 0.2
6
  License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
 
9
+ Restores the Classic Editor and the old-style Edit Post screen layout (TinyMCE, Meta boxes, etc.). Supports the plugins that extend this screen.
10
 
11
  == Description ==
12
 
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.
32
 
33
  = 0.1 =
34
  Initial release.