Disable Gutenberg - Version 1.3

Version Description

To upgrade this plugin, remove the old version and replace with the new version. Or just click "Update" from the Plugins screen and let WordPress do it for you automatically.

Note: uninstalling the plugin from the WP Plugins screen results in the removal of all settings and data from the WP database.

Download this release

Release Info

Developer specialk
Plugin Icon 128x128 Disable Gutenberg
Version 1.3
Comparing to
See all releases

Code changes from version 1.2 to 1.3

disable-gutenberg.php CHANGED
@@ -2,16 +2,16 @@
2
  /*
3
  Plugin Name: Disable Gutenberg
4
  Plugin URI: https://perishablepress.com/disable-gutenberg/
5
- Description: Completely disable Gutenberg Editor sitewide or for specific post types.
6
  Tags: gutenberg, disable, post types, g7g
7
  Author: Jeff Starr
8
  Author URI: https://plugin-planet.com/
9
  Donate link: https://monzillamedia.com/donate.html
10
  Contributors: specialk
11
  Requires at least: 4.5
12
- Tested up to: 4.9.8
13
- Stable tag: 1.2
14
- Version: 1.2
15
  Requires PHP: 5.2
16
  Text Domain: disable-gutenberg
17
  Domain Path: /languages
@@ -51,22 +51,29 @@ if (!class_exists('DisableGutenberg')) {
51
  add_filter('plugin_action_links', array($this, 'action_links'), 10, 2);
52
  add_filter('plugin_row_meta', array($this, 'plugin_links'), 10, 2);
53
 
54
- add_action('admin_enqueue_scripts', 'disable_gutenberg_enqueue_resources_admin');
55
- add_action('admin_print_scripts', 'disable_gutenberg_print_js_vars_admin');
56
- add_action('admin_notices', 'disable_gutenberg_admin_notice');
57
- add_action('admin_init', 'disable_gutenberg_register_settings');
58
- add_action('admin_init', 'disable_gutenberg_reset_options');
59
- add_action('admin_menu', 'disable_gutenberg_menu_pages');
60
 
61
- add_filter('gutenberg_can_edit_post_type', 'disable_gutenberg', 10, 2);
62
- add_filter('admin_init', 'disable_gutenberg_disable_nag');
63
- add_action('admin_menu', 'disable_gutenberg_menu_items', 999);
 
 
 
 
 
 
 
 
64
 
65
  }
66
 
67
  function constants() {
68
 
69
- if (!defined('DISABLE_GUTENBERG_VERSION')) define('DISABLE_GUTENBERG_VERSION', '1.2');
70
  if (!defined('DISABLE_GUTENBERG_REQUIRE')) define('DISABLE_GUTENBERG_REQUIRE', '4.5');
71
  if (!defined('DISABLE_GUTENBERG_AUTHOR')) define('DISABLE_GUTENBERG_AUTHOR', 'Jeff Starr');
72
  if (!defined('DISABLE_GUTENBERG_NAME')) define('DISABLE_GUTENBERG_NAME', __('Disable Gutenberg', 'disable-gutenberg'));
2
  /*
3
  Plugin Name: Disable Gutenberg
4
  Plugin URI: https://perishablepress.com/disable-gutenberg/
5
+ Description: Disables Gutenberg and restores the Classic Editor and original Edit Post screen. Provides options to enable on specific post types, user roles, and more.
6
  Tags: gutenberg, disable, post types, g7g
7
  Author: Jeff Starr
8
  Author URI: https://plugin-planet.com/
9
  Donate link: https://monzillamedia.com/donate.html
10
  Contributors: specialk
11
  Requires at least: 4.5
12
+ Tested up to: 5.0
13
+ Stable tag: 1.3
14
+ Version: 1.3
15
  Requires PHP: 5.2
16
  Text Domain: disable-gutenberg
17
  Domain Path: /languages
51
  add_filter('plugin_action_links', array($this, 'action_links'), 10, 2);
52
  add_filter('plugin_row_meta', array($this, 'plugin_links'), 10, 2);
53
 
54
+ add_filter('page_row_actions', 'disable_gutenberg_page_row_actions', 15, 2);
55
+ add_filter('post_row_actions', 'disable_gutenberg_page_row_actions', 15, 2);
56
+ add_filter('get_edit_post_link', 'disable_gutenberg_get_edit_post_link');
57
+ add_filter('redirect_post_location', 'disable_gutenberg_redirect_post_location');
58
+ add_action('edit_form_top', 'disable_gutenberg_edit_form_top');
 
59
 
60
+ add_action('admin_enqueue_scripts', 'disable_gutenberg_enqueue_resources_admin');
61
+ add_action('admin_print_scripts', 'disable_gutenberg_print_js_vars_admin');
62
+ add_action('admin_notices', 'disable_gutenberg_admin_notice');
63
+ add_action('admin_init', 'disable_gutenberg_register_settings');
64
+ add_action('admin_init', 'disable_gutenberg_reset_options');
65
+ add_action('admin_menu', 'disable_gutenberg_menu_pages');
66
+ add_action('admin_menu', 'disable_gutenberg_add_submenus');
67
+ add_action('admin_menu', 'disable_gutenberg_menu_items', 999);
68
+ add_filter('admin_init', 'disable_gutenberg_disable_nag');
69
+
70
+ add_filter('use_block_editor_for_post_type', 'disable_gutenberg_init', 10, 2);
71
 
72
  }
73
 
74
  function constants() {
75
 
76
+ if (!defined('DISABLE_GUTENBERG_VERSION')) define('DISABLE_GUTENBERG_VERSION', '1.3');
77
  if (!defined('DISABLE_GUTENBERG_REQUIRE')) define('DISABLE_GUTENBERG_REQUIRE', '4.5');
78
  if (!defined('DISABLE_GUTENBERG_AUTHOR')) define('DISABLE_GUTENBERG_AUTHOR', 'Jeff Starr');
79
  if (!defined('DISABLE_GUTENBERG_NAME')) define('DISABLE_GUTENBERG_NAME', __('Disable Gutenberg', 'disable-gutenberg'));
inc/classic-editor.php CHANGED
@@ -1,40 +1,27 @@
1
  <?php // Classic Editor
2
 
3
- if (!defined('ABSPATH')) exit;
4
 
5
- function disable_gutenberg_is_gutenberg_active() {
6
-
7
- if (
8
- in_array('gutenberg/gutenberg.php', (array) get_option('active_plugins')) ||
9
- (is_multisite() && array_key_exists('gutenberg/gutenberg.php', (array) get_site_option('active_sitewide_plugins'))) ||
10
- has_filter('load-post.php', 'gutenberg_intercept_edit_post') ||
11
- has_filter('replace_editor', 'gutenberg_init')
12
- ) {
13
-
14
- return true;
15
-
16
- }
17
-
18
- return false;
19
-
20
- }
21
 
22
- function disable_gutenberg_init_actions() {
23
-
24
- if (!disable_gutenberg_is_gutenberg_active()) return;
25
-
26
- // Gutenberg plugin: remove the "Classic editor" row actions
27
- remove_action('admin_init', 'gutenberg_add_edit_link_filters');
28
 
29
  // gutenberg.php
30
  remove_action('admin_menu', 'gutenberg_menu');
 
31
  remove_action('admin_notices', 'gutenberg_wordpress_version_notice');
32
  remove_action('admin_init', 'gutenberg_redirect_demo');
 
33
  remove_action('admin_print_scripts-edit.php', 'gutenberg_replace_default_add_new_button');
34
 
35
  remove_filter('replace_editor', 'gutenberg_init');
 
36
  remove_filter('admin_url', 'gutenberg_modify_add_new_button_url');
37
 
 
 
 
 
38
  // lib/client-assets.php
39
  remove_action('wp_enqueue_scripts', 'gutenberg_register_scripts_and_styles', 5);
40
  remove_action('admin_enqueue_scripts', 'gutenberg_register_scripts_and_styles', 5);
@@ -43,30 +30,25 @@ function disable_gutenberg_init_actions() {
43
 
44
  // lib/compat.php
45
  remove_filter('wp_refresh_nonces', 'gutenberg_add_rest_nonce_to_heartbeat_response_headers');
46
-
47
  // lib/plugin-compat.php
48
  remove_filter('rest_pre_insert_post', 'gutenberg_remove_wpcom_markdown_support');
49
 
50
  // lib/register.php
51
- remove_action('plugins_loaded', 'gutenberg_trick_plugins_into_registering_meta_boxes');
52
  remove_action('edit_form_top', 'gutenberg_remember_classic_editor_when_saving_posts');
53
-
54
  remove_filter('redirect_post_location', 'gutenberg_redirect_to_classic_editor_when_saving_posts');
55
  remove_filter('get_edit_post_link', 'gutenberg_revisions_link_to_editor');
56
  remove_filter('wp_prepare_revision_for_js', 'gutenberg_revisions_restore');
57
  remove_filter('display_post_states', 'gutenberg_add_gutenberg_post_state');
58
-
59
  // lib/rest-api.php
60
  remove_action('rest_api_init', 'gutenberg_register_rest_routes');
61
  remove_action('rest_api_init', 'gutenberg_add_taxonomy_visibility_field');
62
-
63
  remove_filter('rest_request_after_callbacks', 'gutenberg_filter_oembed_result');
64
  remove_filter('registered_post_type', 'gutenberg_register_post_prepare_functions');
65
- remove_filter('registered_taxonomy', 'gutenberg_register_taxonomy_prepare_functions');
66
- remove_filter('rest_index', 'gutenberg_ensure_wp_json_has_theme_supports');
67
- remove_filter('rest_request_before_callbacks', 'gutenberg_handle_early_callback_checks');
68
- remove_filter('rest_user_collection_params', 'gutenberg_filter_user_collection_parameters');
69
- remove_filter('rest_request_after_callbacks', 'gutenberg_filter_request_after_callbacks');
70
 
71
  // lib/meta-box-partial-page.php
72
  remove_action('do_meta_boxes', 'gutenberg_meta_box_save', 1000);
@@ -74,12 +56,16 @@ function disable_gutenberg_init_actions() {
74
  remove_action('submitpage_box', 'gutenberg_intercept_meta_box_render');
75
  remove_action('edit_page_form', 'gutenberg_intercept_meta_box_render');
76
  remove_action('edit_form_advanced', 'gutenberg_intercept_meta_box_render');
77
-
78
  remove_filter('redirect_post_location', 'gutenberg_meta_box_save_redirect');
79
  remove_filter('filter_gutenberg_meta_boxes', 'gutenberg_filter_meta_boxes');
80
 
81
- // Keep
 
 
 
82
 
 
83
  // lib/blocks.php
84
  // remove_filter('the_content', 'do_blocks', 9);
85
 
@@ -92,8 +78,6 @@ function disable_gutenberg_init_actions() {
92
 
93
  // remove_action('init', 'gutenberg_register_post_types');
94
 
95
- add_filter('replace_editor', 'disable_gutenberg_replace');
96
-
97
  }
98
 
99
  function disable_gutenberg_replace($return) {
1
  <?php // Classic Editor
2
 
3
+ // NOTE: Removes same actions/filters as Classic Editor plugin
4
 
5
+ if (!defined('ABSPATH')) exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
+ function disable_gutenberg_remove() {
 
 
 
 
 
8
 
9
  // gutenberg.php
10
  remove_action('admin_menu', 'gutenberg_menu');
11
+ remove_action('admin_notices', 'gutenberg_build_files_notice');
12
  remove_action('admin_notices', 'gutenberg_wordpress_version_notice');
13
  remove_action('admin_init', 'gutenberg_redirect_demo');
14
+ remove_action('admin_init', 'gutenberg_add_edit_link_filters');
15
  remove_action('admin_print_scripts-edit.php', 'gutenberg_replace_default_add_new_button');
16
 
17
  remove_filter('replace_editor', 'gutenberg_init');
18
+ remove_filter('body_class', 'gutenberg_add_responsive_body_class');
19
  remove_filter('admin_url', 'gutenberg_modify_add_new_button_url');
20
 
21
+ // Keep
22
+ // remove_filter('wp_kses_allowed_html', 'gutenberg_kses_allowedtags', 10, 2); // not needed in 5.0
23
+ // remove_filter('bulk_actions-edit-wp_block', 'gutenberg_block_bulk_actions');
24
+
25
  // lib/client-assets.php
26
  remove_action('wp_enqueue_scripts', 'gutenberg_register_scripts_and_styles', 5);
27
  remove_action('admin_enqueue_scripts', 'gutenberg_register_scripts_and_styles', 5);
30
 
31
  // lib/compat.php
32
  remove_filter('wp_refresh_nonces', 'gutenberg_add_rest_nonce_to_heartbeat_response_headers');
33
+
34
  // lib/plugin-compat.php
35
  remove_filter('rest_pre_insert_post', 'gutenberg_remove_wpcom_markdown_support');
36
 
37
  // lib/register.php
 
38
  remove_action('edit_form_top', 'gutenberg_remember_classic_editor_when_saving_posts');
39
+
40
  remove_filter('redirect_post_location', 'gutenberg_redirect_to_classic_editor_when_saving_posts');
41
  remove_filter('get_edit_post_link', 'gutenberg_revisions_link_to_editor');
42
  remove_filter('wp_prepare_revision_for_js', 'gutenberg_revisions_restore');
43
  remove_filter('display_post_states', 'gutenberg_add_gutenberg_post_state');
44
+
45
  // lib/rest-api.php
46
  remove_action('rest_api_init', 'gutenberg_register_rest_routes');
47
  remove_action('rest_api_init', 'gutenberg_add_taxonomy_visibility_field');
48
+
49
  remove_filter('rest_request_after_callbacks', 'gutenberg_filter_oembed_result');
50
  remove_filter('registered_post_type', 'gutenberg_register_post_prepare_functions');
51
+ remove_filter('register_post_type_args', 'gutenberg_filter_post_type_labels');
 
 
 
 
52
 
53
  // lib/meta-box-partial-page.php
54
  remove_action('do_meta_boxes', 'gutenberg_meta_box_save', 1000);
56
  remove_action('submitpage_box', 'gutenberg_intercept_meta_box_render');
57
  remove_action('edit_page_form', 'gutenberg_intercept_meta_box_render');
58
  remove_action('edit_form_advanced', 'gutenberg_intercept_meta_box_render');
59
+
60
  remove_filter('redirect_post_location', 'gutenberg_meta_box_save_redirect');
61
  remove_filter('filter_gutenberg_meta_boxes', 'gutenberg_filter_meta_boxes');
62
 
63
+ // add_filter('replace_editor', 'disable_gutenberg_replace');
64
+
65
+ // lib/compat.php
66
+ remove_action('admin_enqueue_scripts', 'gutenberg_check_if_classic_needs_warning_about_blocks');
67
 
68
+ // Keep
69
  // lib/blocks.php
70
  // remove_filter('the_content', 'do_blocks', 9);
71
 
78
 
79
  // remove_action('init', 'gutenberg_register_post_types');
80
 
 
 
81
  }
82
 
83
  function disable_gutenberg_replace($return) {
inc/plugin-core.php CHANGED
@@ -2,33 +2,49 @@
2
 
3
  if (!defined('ABSPATH')) exit;
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  function disable_gutenberg($is_enabled, $post_type) {
6
 
 
 
 
 
7
  $options = disable_gutenberg_get_options();
8
 
9
  $disable_all = (isset($options['disable-all']) && !empty($options['disable-all'])) ? true : false;
10
 
11
- if ($disable_all) return false;
12
 
13
- foreach (disable_gutenberg_get_enabled_user_roles() as $role) {
14
-
15
- $roles = disable_gutenberg_get_current_user_roles();
16
 
17
- if (is_array($roles) && in_array($role, $roles)) return false;
18
 
19
  }
20
 
21
- foreach (disable_gutenberg_get_enabled_post_types() as $type) {
22
 
23
- if ($post_type === $type) return false;
 
 
24
 
25
  }
26
 
27
- if (disable_gutenberg_disable_templates()) return false;
28
-
29
- if (disable_gutenberg_disable_ids()) return false;
30
 
31
- return $is_enabled;
32
 
33
  }
34
 
@@ -75,7 +91,7 @@ function disable_gutenberg_get_enabled_user_roles() {
75
 
76
  preg_match('/^user-role_(.*)$/i', $key, $matches);
77
 
78
- if (isset($matches[1]) && !empty($matches[1])) $array[] = $matches[1];
79
 
80
  }
81
 
@@ -116,7 +132,7 @@ function disable_gutenberg_get_enabled_post_types() {
116
 
117
  preg_match('/^post-type_(.*)$/i', $key, $matches);
118
 
119
- if (isset($matches[1]) && !empty($matches[1])) $array[] = $matches[1];
120
 
121
  }
122
 
@@ -130,6 +146,8 @@ function disable_gutenberg_disable_templates() {
130
 
131
  $template = '';
132
 
 
 
133
  $post_id = isset($_GET['post']) ? intval($_GET['post']) : null;
134
 
135
  if (is_admin() && !empty($post_id)) {
@@ -144,7 +162,13 @@ function disable_gutenberg_disable_templates() {
144
 
145
  }
146
 
147
- return in_array($template, $excluded);
 
 
 
 
 
 
148
 
149
  }
150
 
@@ -174,7 +198,7 @@ function disable_gutenberg_disable_nag() {
174
 
175
  $disable_nag = (isset($options['disable-nag']) && !empty($options['disable-nag'])) ? true : false;
176
 
177
- if ($disable_nag) remove_filter('try_gutenberg_panel', 'wp_try_gutenberg_panel');
178
 
179
  }
180
 
@@ -189,3 +213,203 @@ function disable_gutenberg_menu_items() {
189
  if ($hide_gutenberg) remove_menu_page('gutenberg');
190
 
191
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  if (!defined('ABSPATH')) exit;
4
 
5
+ function disable_gutenberg_init($is_enabled, $post_type) {
6
+
7
+ if (disable_gutenberg($is_enabled, $post_type)) {
8
+
9
+ disable_gutenberg_remove();
10
+
11
+ return false;
12
+
13
+ }
14
+
15
+ return $is_enabled;
16
+
17
+ }
18
+
19
  function disable_gutenberg($is_enabled, $post_type) {
20
 
21
+ if (!$is_enabled) return false;
22
+
23
+ if (isset($_GET['classic-editor'])) return true;
24
+
25
  $options = disable_gutenberg_get_options();
26
 
27
  $disable_all = (isset($options['disable-all']) && !empty($options['disable-all'])) ? true : false;
28
 
29
+ if ($disable_all) return true;
30
 
31
+ foreach (disable_gutenberg_get_enabled_post_types() as $type) {
 
 
32
 
33
+ if ($post_type === $type) return true;
34
 
35
  }
36
 
37
+ foreach (disable_gutenberg_get_enabled_user_roles() as $role) {
38
 
39
+ $roles = disable_gutenberg_get_current_user_roles();
40
+
41
+ if (is_array($roles) && in_array($role, $roles)) return true;
42
 
43
  }
44
 
45
+ if (disable_gutenberg_disable_templates() || disable_gutenberg_disable_ids()) return true;
 
 
46
 
47
+ return false;
48
 
49
  }
50
 
91
 
92
  preg_match('/^user-role_(.*)$/i', $key, $matches);
93
 
94
+ if ($value && isset($matches[1]) && !empty($matches[1])) $array[] = $matches[1];
95
 
96
  }
97
 
132
 
133
  preg_match('/^post-type_(.*)$/i', $key, $matches);
134
 
135
+ if ($value && isset($matches[1]) && !empty($matches[1])) $array[] = $matches[1];
136
 
137
  }
138
 
146
 
147
  $template = '';
148
 
149
+ $disable = false;
150
+
151
  $post_id = isset($_GET['post']) ? intval($_GET['post']) : null;
152
 
153
  if (is_admin() && !empty($post_id)) {
162
 
163
  }
164
 
165
+ if (!empty($excluded) && !empty($template)) {
166
+
167
+ $disable = in_array($template, $excluded, true);
168
+
169
+ }
170
+
171
+ return $disable;
172
 
173
  }
174
 
198
 
199
  $disable_nag = (isset($options['disable-nag']) && !empty($options['disable-nag'])) ? true : false;
200
 
201
+ if ($disable_nag) remove_filter('try_gutenberg_panel', 'wp_try_gutenberg_panel'); // until WP 5.0 beta
202
 
203
  }
204
 
213
  if ($hide_gutenberg) remove_menu_page('gutenberg');
214
 
215
  }
216
+
217
+ function disable_gutenberg_is_gutenberg_active() {
218
+
219
+ $gutenberg = has_filter('replace_editor', 'gutenberg_init') ? true : false;
220
+
221
+ $block_editor = version_compare($GLOBALS['wp_version'], '5.0-beta', '>') ? true : false;
222
+
223
+ if ($gutenberg || $block_editor) return true;
224
+
225
+ return false;
226
+
227
+ }
228
+
229
+ function disable_gutenberg_post_or_page() {
230
+
231
+ global $pagenow;
232
+
233
+ $type = null;
234
+
235
+ if ($pagenow === 'edit.php') {
236
+
237
+ if (!isset($_GET['post_type'])) {
238
+
239
+ $type = 'post'; // posts @ edit.php
240
+
241
+ } elseif (isset($_GET['post_type']) && $_GET['post_type'] === 'page') {
242
+
243
+ $type = 'page'; // pages @ edit.php?post_type=page
244
+
245
+ }
246
+
247
+ } elseif ($pagenow === 'post.php' && isset($_GET['post'])) {
248
+
249
+ $post_type = get_post_type($_GET['post']);
250
+
251
+ if ($post_type === 'post') {
252
+
253
+ $type = 'post'; // post.php?post=1&action=edit
254
+
255
+ } elseif ($post_type === 'page') {
256
+
257
+ $type = 'page'; // post.php?post=1&action=edit
258
+
259
+ }
260
+
261
+ } elseif ($pagenow === 'post-new.php') {
262
+
263
+ if (!isset($_GET['post_type'])) {
264
+
265
+ $type = 'post'; // post-new.php
266
+
267
+ } elseif (isset($_GET['post_type']) && $_GET['post_type'] === 'page') {
268
+
269
+ $type = 'page'; // post-new.php?post_type=page
270
+
271
+ }
272
+
273
+ }
274
+
275
+ return $type;
276
+
277
+ }
278
+
279
+ // THANKS to Classic Editor for next several functions
280
+
281
+ function disable_gutenberg_add_submenus() {
282
+
283
+ $post_type = disable_gutenberg_post_or_page();
284
+
285
+ $is_active = disable_gutenberg_is_gutenberg_active();
286
+
287
+ $disable = ($post_type) ? disable_gutenberg($is_active, $post_type) : false;
288
+
289
+ if ($disable && version_compare(get_bloginfo('version'), '5.0-beta', '>')) return;
290
+
291
+ foreach (get_post_types(array('show_ui' => true)) as $type) {
292
+
293
+ $type_obj = get_post_type_object($type);
294
+
295
+ if (!$type_obj->show_in_menu || !post_type_supports($type, 'editor')) continue;
296
+
297
+ if ($type_obj->show_in_menu === true) {
298
+
299
+ if ('post' === $type) {
300
+
301
+ $parent_slug = 'edit.php';
302
+
303
+ } elseif ('page' === $type) {
304
+
305
+ $parent_slug = 'edit.php?post_type=page';
306
+
307
+ } else {
308
+
309
+ continue;
310
+
311
+ }
312
+
313
+ } else {
314
+
315
+ $parent_slug = $type_obj->show_in_menu;
316
+
317
+ }
318
+
319
+ $item_name = $type_obj->labels->add_new .' '. __('(Classic)', 'disable-gutenberg');
320
+
321
+ add_submenu_page($parent_slug, $type_obj->labels->add_new, $item_name, $type_obj->cap->edit_posts, 'post-new.php?post_type='. $type .'&classic-editor');
322
+
323
+ }
324
+
325
+ }
326
+
327
+ function disable_gutenberg_page_row_actions($actions, $post) {
328
+
329
+ $is_active = disable_gutenberg_is_gutenberg_active();
330
+
331
+ if (disable_gutenberg($is_active, $post->post_type)) return $actions;
332
+
333
+ if (!$is_active || array_key_exists('classic', $actions)) return $actions;
334
+
335
+ if ('trash' === $post->post_status || !post_type_supports($post->post_type, 'editor')) return $actions;
336
+
337
+ $edit_url = get_edit_post_link($post->ID, 'raw');
338
+
339
+ if (!$edit_url) return $actions;
340
+
341
+ $edit_url = add_query_arg('classic-editor', '', $edit_url);
342
+
343
+ $title = _draft_or_post_title($post->ID);
344
+
345
+ $edit_action = array(
346
+
347
+ 'classic' => sprintf(
348
+
349
+ '<a href="%s" aria-label="%s">%s</a>',
350
+
351
+ esc_url($edit_url),
352
+
353
+ esc_attr(sprintf(
354
+
355
+ __('Edit &#8220;%s&#8221; with Classic Editor', 'disable-gutenberg'),
356
+
357
+ $title
358
+
359
+ )),
360
+
361
+ __('Edit (Classic)', 'disable-gutenberg')
362
+
363
+ ),
364
+
365
+ );
366
+
367
+ $edit_offset = array_search('edit', array_keys($actions), true);
368
+
369
+ array_splice($actions, $edit_offset + 1, 0, $edit_action);
370
+
371
+ return $actions;
372
+
373
+ }
374
+
375
+ function disable_gutenberg_get_edit_post_link($url) {
376
+
377
+ global $current_screen;
378
+
379
+ if (!isset($_REQUEST['classic-editor']) && !disable_gutenberg(disable_gutenberg_is_gutenberg_active(), $current_screen->post_type)) return $url;
380
+
381
+ $url = add_query_arg('classic-editor', '', $url);
382
+
383
+ return $url;
384
+
385
+ }
386
+
387
+ function disable_gutenberg_redirect_post_location($location) {
388
+
389
+ global $current_screen;
390
+
391
+ if (!isset($_REQUEST['classic-editor']) && !disable_gutenberg(disable_gutenberg_is_gutenberg_active(), $current_screen->post_type)) return $location;
392
+
393
+ if (isset($_REQUEST['classic-editor']) || (isset($_POST['_wp_http_referer']) && strpos($_POST['_wp_http_referer'], '&classic-editor') !== false)) {
394
+
395
+ $location = add_query_arg('classic-editor', '', $location);
396
+
397
+ }
398
+
399
+ return $location;
400
+
401
+ }
402
+
403
+ function disable_gutenberg_edit_form_top() {
404
+
405
+ global $current_screen;
406
+
407
+ if (!isset($_GET['classic-editor']) && !disable_gutenberg(disable_gutenberg_is_gutenberg_active(), $current_screen->post_type)) return;
408
+
409
+ ?>
410
+
411
+ <input type="hidden" name="classic-editor" value="" />
412
+
413
+ <?php
414
+
415
+ }
inc/settings-register.php CHANGED
@@ -44,14 +44,14 @@ function disable_gutenberg_register_settings() {
44
 
45
  }
46
 
47
- add_settings_field('templates', __('Disable Templates', 'disable-gutenberg'), 'disable_gutenberg_callback_text', 'disable_gutenberg_options', 'settings_4', array('id' => 'templates', 'label' => esc_html__('Separate multiple templates with commas', 'disable-gutenberg')));
48
- add_settings_field('post-ids', __('Disable Post IDs', 'disable-gutenberg'), 'disable_gutenberg_callback_text', 'disable_gutenberg_options', 'settings_5', array('id' => 'post-ids', 'label' => esc_html__('Separate multiple post IDs with commas', 'disable-gutenberg')));
49
-
50
- add_settings_field('disable-nag', __('Disable Nag', 'disable-gutenberg'), 'disable_gutenberg_callback_checkbox', 'disable_gutenberg_options', 'settings_6', array('id' => 'disable-nag', 'label' => esc_html__('Disable "Try Gutenberg" nag', 'disable-gutenberg')));
51
- add_settings_field('hide-menu', __('Plugin Menu Item', 'disable-gutenberg'), 'disable_gutenberg_callback_checkbox', 'disable_gutenberg_options', 'settings_6', array('id' => 'hide-menu', 'label' => esc_html__('Hide this plugin&rsquo;s menu item', 'disable-gutenberg')));
52
- add_settings_field('hide-gut', __('Gutenberg Menu Item', 'disable-gutenberg'), 'disable_gutenberg_callback_checkbox', 'disable_gutenberg_options', 'settings_6', array('id' => 'hide-gut', 'label' => esc_html__('Hide the Gutenberg plugin&rsquo;s menu item', 'disable-gutenberg')));
53
- add_settings_field('reset_options', __('Reset Options', 'disable-gutenberg'), 'disable_gutenberg_callback_reset', 'disable_gutenberg_options', 'settings_6', array('id' => 'reset_options', 'label' => esc_html__('Restore default plugin options', 'disable-gutenberg')));
54
- add_settings_field('rate_plugin', __('Rate Plugin', 'disable-gutenberg'), 'disable_gutenberg_callback_rate', 'disable_gutenberg_options', 'settings_6', array('id' => 'rate_plugin', 'label' => esc_html__('Show support with a 5-star rating&nbsp;&raquo;', 'disable-gutenberg')));
55
 
56
  }
57
 
44
 
45
  }
46
 
47
+ add_settings_field('templates', __('Disable Templates', 'disable-gutenberg'), 'disable_gutenberg_callback_text', 'disable_gutenberg_options', 'settings_4', array('id' => 'templates', 'label' => esc_html__('Separate multiple templates with commas', 'disable-gutenberg')));
48
+ add_settings_field('post-ids', __('Disable Post IDs', 'disable-gutenberg'), 'disable_gutenberg_callback_text', 'disable_gutenberg_options', 'settings_5', array('id' => 'post-ids', 'label' => esc_html__('Separate multiple post IDs with commas', 'disable-gutenberg')));
49
+
50
+ add_settings_field('disable-nag', __('Disable Nag', 'disable-gutenberg'), 'disable_gutenberg_callback_checkbox', 'disable_gutenberg_options', 'settings_6', array('id' => 'disable-nag', 'label' => esc_html__('Disable "Try Gutenberg" nag', 'disable-gutenberg')));
51
+ add_settings_field('hide-menu', __('Plugin Menu Item', 'disable-gutenberg'), 'disable_gutenberg_callback_checkbox', 'disable_gutenberg_options', 'settings_6', array('id' => 'hide-menu', 'label' => esc_html__('Hide this plugin&rsquo;s menu item', 'disable-gutenberg')));
52
+ add_settings_field('hide-gut', __('Gutenberg Menu Item', 'disable-gutenberg'), 'disable_gutenberg_callback_checkbox', 'disable_gutenberg_options', 'settings_6', array('id' => 'hide-gut', 'label' => esc_html__('Hide Gutenberg plugin&rsquo;s menu item (for WP &lt; 5.0)', 'disable-gutenberg')));
53
+ add_settings_field('reset_options', __('Reset Options', 'disable-gutenberg'), 'disable_gutenberg_callback_reset', 'disable_gutenberg_options', 'settings_6', array('id' => 'reset_options', 'label' => esc_html__('Restore default plugin options', 'disable-gutenberg')));
54
+ add_settings_field('rate_plugin', __('Rate Plugin', 'disable-gutenberg'), 'disable_gutenberg_callback_rate', 'disable_gutenberg_options', 'settings_6', array('id' => 'rate_plugin', 'label' => esc_html__('Show support with a 5-star rating&nbsp;&raquo;', 'disable-gutenberg')));
55
 
56
  }
57
 
readme.txt CHANGED
@@ -2,22 +2,22 @@
2
 
3
  Plugin Name: Disable Gutenberg
4
  Plugin URI: https://perishablepress.com/disable-gutenberg/
5
- Description: Disable Gutenberg Editor and replace with Classic Editor.
6
  Tags: gutenberg, disable, post types, g7g
7
  Author: Jeff Starr
8
  Author URI: https://plugin-planet.com/
9
  Donate link: https://monzillamedia.com/donate.html
10
  Contributors: specialk
11
  Requires at least: 4.5
12
- Tested up to: 4.9.8
13
- Stable tag: 1.2
14
- Version: 1.2
15
  Requires PHP: 5.2
16
  Text Domain: disable-gutenberg
17
  Domain Path: /languages
18
  License: GPL v2 or later
19
 
20
- Disable Gutenberg Editor and replace with Classic Editor. Selectively disable for posts, pages, roles, post types, and theme templates. Hide the Gutenberg nag, menu item, and more!
21
 
22
 
23
 
@@ -26,8 +26,8 @@ Disable Gutenberg Editor and replace with Classic Editor. Selectively disable fo
26
  This plugin disables the new Gutenberg Editor and replaces it with the Classic Editor. You can disable Gutenberg completely, or selectively disable for posts, pages, roles, post types, and theme templates. Plus you can hide the Gutenberg nag, menu item, and more!
27
 
28
  > The all-in-one, COMPLETE solution handling Gutenberg.
29
-
30
  > Hide ALL traces of Gutenberg and replace with the Classic Editor.
 
31
 
32
  The Disable Gutenberg plugin restores the classic (original) WordPress editor and the "Edit Post" screen. So you can continue using plugins and theme functions that extend the Classic Editor. Supports awesome features like Meta Boxes, Quicktags, Custom Fields, and everything else the Classic Editor can do.
33
 
@@ -40,7 +40,12 @@ The Disable Gutenberg plugin restores the classic (original) WordPress editor an
40
  * NEW: Disable Gutenberg for any post/page IDs
41
  * Disable Gutenberg admin notice (nag)
42
  * Option to hide the plugin menu item
43
- * NEW: Option to hide the Gutenberg plugin menu item (settings link)
 
 
 
 
 
44
 
45
  Fully configurable, enable or disable Gutenberg and restore the Classic Editor wherever is necessary.
46
 
@@ -95,6 +100,11 @@ __If you like this plugin, please give it a 5-star rating to encourage future de
95
  [More info on installing WP plugins](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins)
96
 
97
 
 
 
 
 
 
98
  **Hide Menu Option**
99
 
100
  Disable Gutenberg provides a setting to disable the plugin's menu item. This is useful if you don't want your clients to get curious and start fiddling around.
@@ -143,6 +153,18 @@ Note: uninstalling the plugin from the WP Plugins screen results in the removal
143
  Yes. When Gutenberg is active, the plugin disables it (depending on your selected options) and replaces with the Classic Editor. Otherwise, if Gutenberg is not active, the plugin does nothing. So it's totally fine to install before Gutenberg is added to WP core, so it will be ready when the time comes.
144
 
145
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  **Got a question?**
147
 
148
  Send any questions or feedback via my [contact form](https://perishablepress.com/contact/)
@@ -171,6 +193,14 @@ Links, tweets and likes also appreciated. Thanks! :)
171
 
172
  == Changelog ==
173
 
 
 
 
 
 
 
 
 
174
  **1.2 (2018/08/14)**
175
 
176
  * Adds `rel="noopener noreferrer"` to all [blank-target links](https://perishablepress.com/wordpress-blank-target-vulnerability/)
2
 
3
  Plugin Name: Disable Gutenberg
4
  Plugin URI: https://perishablepress.com/disable-gutenberg/
5
+ Description: Disables Gutenberg and restores the Classic Editor and original Edit Post screen. Provides options to enable on specific post types, user roles, and more.
6
  Tags: gutenberg, disable, post types, g7g
7
  Author: Jeff Starr
8
  Author URI: https://plugin-planet.com/
9
  Donate link: https://monzillamedia.com/donate.html
10
  Contributors: specialk
11
  Requires at least: 4.5
12
+ Tested up to: 5.0
13
+ Stable tag: 1.3
14
+ Version: 1.3
15
  Requires PHP: 5.2
16
  Text Domain: disable-gutenberg
17
  Domain Path: /languages
18
  License: GPL v2 or later
19
 
20
+ Disable Gutenberg and restore the Classic Editor and original Edit Post screen (TinyMCE, meta boxes, et al). Selectively disable for posts, pages, roles, post types, and theme templates. Hide the Gutenberg nag, menu item, and more.
21
 
22
 
23
 
26
  This plugin disables the new Gutenberg Editor and replaces it with the Classic Editor. You can disable Gutenberg completely, or selectively disable for posts, pages, roles, post types, and theme templates. Plus you can hide the Gutenberg nag, menu item, and more!
27
 
28
  > The all-in-one, COMPLETE solution handling Gutenberg.
 
29
  > Hide ALL traces of Gutenberg and replace with the Classic Editor.
30
+ > Restores the original Edit Post screen (TinyMCE, meta boxes, et al).
31
 
32
  The Disable Gutenberg plugin restores the classic (original) WordPress editor and the "Edit Post" screen. So you can continue using plugins and theme functions that extend the Classic Editor. Supports awesome features like Meta Boxes, Quicktags, Custom Fields, and everything else the Classic Editor can do.
33
 
40
  * NEW: Disable Gutenberg for any post/page IDs
41
  * Disable Gutenberg admin notice (nag)
42
  * Option to hide the plugin menu item
43
+ * Option to hide the Gutenberg plugin menu item (settings link)
44
+ * NEW! Adds WP menu item: "Add New (Classic)"
45
+ * NEW! Adds post link to "Edit (Classic)"
46
+
47
+ > Works same way as Classic Editor plugin, but can do a LOT more!
48
+ > Lightweight and super fast, built with the WP API :)
49
 
50
  Fully configurable, enable or disable Gutenberg and restore the Classic Editor wherever is necessary.
51
 
100
  [More info on installing WP plugins](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins)
101
 
102
 
103
+ **Important**
104
+
105
+ Do not use Disable Gutenberg with other plugins (like the Classic Editor plugin) that also disable or replace Gutenberg. Why? Because it may cause loading of redundant scripts, which may in turn lead to unexpected/untested results.
106
+
107
+
108
  **Hide Menu Option**
109
 
110
  Disable Gutenberg provides a setting to disable the plugin's menu item. This is useful if you don't want your clients to get curious and start fiddling around.
153
  Yes. When Gutenberg is active, the plugin disables it (depending on your selected options) and replaces with the Classic Editor. Otherwise, if Gutenberg is not active, the plugin does nothing. So it's totally fine to install before Gutenberg is added to WP core, so it will be ready when the time comes.
154
 
155
 
156
+ **What's the difference between Classic Editor plugin?**
157
+
158
+ Classic Editor plugin enables you to disable Gutenberg across the board, and replace it with the Classic Editor. The Disable Gutenberg plugin does the exact same thing, in the exact same way, BUT it also provides more granular control over when and where Gutenberg is replaced with the Classic Editor. Disable Gutenberg plugin makes it easy to replace Gutenberg everywhere, OR you can choose to replace only for specific post types, user roles, post IDs, theme template, and more. Check out the list of features and compare them to the alternatives. It's not even close! ;)
159
+
160
+ Bottom line: both Disable Gutenberg and Classic Editor plugins are lightweight and enable you to replace Gutenberg with the Classic Editor for the entire site. The difference is that Disable Gutenberg also gives you advanced configuration options including menu hiding and more.
161
+
162
+
163
+ **Why does Classic Editor plugin have way more users?**
164
+
165
+ Because it is being promoted by the Gutenberg developers and the "official" plugin for replacing Gutenberg. That's fine, but understand that Disable Gutenberg functions the same way AND provides way more features and settings. FWIW, I use Disable Gutenberg on my sites Perishable Press, DigWP.com, Plugin Planet, and many others. 100% solid.
166
+
167
+
168
  **Got a question?**
169
 
170
  Send any questions or feedback via my [contact form](https://perishablepress.com/contact/)
193
 
194
  == Changelog ==
195
 
196
+ **1.3 (2018/10/27)**
197
+
198
+ * Refactored for WordPress 5.0 (Gutenberg merged into core)
199
+ * Ensures functionality on pre-5.0 WP versions
200
+ * Adds WP menu item: "Add New (Classic)"
201
+ * Adds post link to "Edit (Classic)"
202
+ * Tests on WordPress 5.0 (beta)
203
+
204
  **1.2 (2018/08/14)**
205
 
206
  * Adds `rel="noopener noreferrer"` to all [blank-target links](https://perishablepress.com/wordpress-blank-target-vulnerability/)