PluginProbe
Disable Gutenberg / trunk
Disable Gutenberg vtrunk
trunk 1.1 1.2 1.3 1.3.1 1.4 1.5 1.5.1 1.5.2 1.6 1.7 1.8 1.8.1 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.5.1 2.6 2.7 2.8 2.8.1 All 39 releases
disable-gutenberg / disable-gutenberg.php

disable-gutenberg.php in Disable Gutenberg trunk, at disable-gutenberg.php

272 lines 8.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Disable Gutenberg
4 Plugin URI: https://perishablepress.com/disable-gutenberg/
5 Description: Disables Gutenberg Block Editor and restores the Classic Editor and original Edit Post screen. Provides options to enable on specific post types, user roles, and more.
6 Tags: classic editor, block editor, editor, gutenberg
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.9
12 Tested up to: 7.1
13 Stable tag: 3.3.2
14 Version: 3.3.2
15 Requires PHP: 5.6.20
16 Text Domain: disable-gutenberg
17 Domain Path: /languages
18 License: GPL v2 or later
19 */
20
21 /*
22 This program is free software; you can redistribute it and/or
23 modify it under the terms of the GNU General Public License
24 as published by the Free Software Foundation; either version
25 2 of the License, or (at your option) any later version.
26
27 This program is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU General Public License for more details.
31
32 You should have received a copy of the GNU General Public License
33 with this program. If not, visit: https://www.gnu.org/licenses/
34
35 Copyright 2018-2026 Monzilla Media. All rights reserved.
36 */
37
38 if (!defined('ABSPATH')) die();
39
40 if (!class_exists('DisableGutenberg')) {
41
42 class DisableGutenberg {
43
44 function __construct() {
45
46 $this->constants();
47 $this->includes();
48
49 register_activation_hook(__FILE__, 'disable_gutenberg_dismiss_notice_activate');
50
51 add_action('admin_init', array($this, 'check_version'));
52 add_action('init', array($this, 'load_i18n'));
53 add_filter('plugin_action_links', array($this, 'action_links'), 10, 2);
54 add_filter('plugin_row_meta', array($this, 'plugin_links'), 10, 2);
55 add_filter('admin_footer_text', array($this, 'footer_text'), 10, 1);
56
57 add_action('admin_enqueue_scripts', 'disable_gutenberg_admin_enqueue_scripts');
58 add_action('admin_print_scripts', 'disable_gutenberg_admin_print_scripts');
59 add_action('admin_notices', 'disable_gutenberg_admin_notice');
60 add_action('admin_init', 'disable_gutenberg_register_settings');
61 add_action('admin_init', 'disable_gutenberg_reset_options');
62 add_action('admin_menu', 'disable_gutenberg_menu_pages');
63 add_action('admin_menu', 'disable_gutenberg_menu_items', 999);
64 add_action('admin_init', 'disable_gutenberg_acf_enable_meta');
65 add_action('admin_init', 'disable_gutenberg_privacy_notice');
66 add_action('admin_init', 'disable_gutenberg_dismiss_notice_save');
67 add_action('admin_init', 'disable_gutenberg_dismiss_notice_version');
68 add_filter('admin_init', 'disable_gutenberg_disable_nag');
69 add_filter('admin_init', 'disable_gutenberg_init');
70
71 add_filter('wp_enqueue_scripts', 'disable_gutenberg_wp_enqueue_scripts', 100);
72
73 add_action('admin_print_styles', 'disable_gutenberg_safari_18_temp_fix');
74
75 }
76
77 function constants() {
78
79 if (!defined('DISABLE_GUTENBERG_VERSION')) define('DISABLE_GUTENBERG_VERSION', '3.3.2');
80 if (!defined('DISABLE_GUTENBERG_REQUIRE')) define('DISABLE_GUTENBERG_REQUIRE', '4.9');
81 if (!defined('DISABLE_GUTENBERG_AUTHOR')) define('DISABLE_GUTENBERG_AUTHOR', 'Jeff Starr');
82 if (!defined('DISABLE_GUTENBERG_NAME')) define('DISABLE_GUTENBERG_NAME', 'Disable Gutenberg');
83 if (!defined('DISABLE_GUTENBERG_HOME')) define('DISABLE_GUTENBERG_HOME', esc_url('https://perishablepress.com/disable-gutenberg/'));
84 if (!defined('DISABLE_GUTENBERG_URL')) define('DISABLE_GUTENBERG_URL', plugin_dir_url(__FILE__));
85 if (!defined('DISABLE_GUTENBERG_DIR')) define('DISABLE_GUTENBERG_DIR', plugin_dir_path(__FILE__));
86 if (!defined('DISABLE_GUTENBERG_FILE')) define('DISABLE_GUTENBERG_FILE', plugin_basename(__FILE__));
87 if (!defined('DISABLE_GUTENBERG_SLUG')) define('DISABLE_GUTENBERG_SLUG', basename(dirname(__FILE__)));
88
89 }
90
91 function includes() {
92
93 require_once DISABLE_GUTENBERG_DIR .'inc/classic-editor.php';
94 require_once DISABLE_GUTENBERG_DIR .'inc/plugin-core.php';
95 require_once DISABLE_GUTENBERG_DIR .'inc/plugin-frontend.php';
96 require_once DISABLE_GUTENBERG_DIR .'inc/settings-reset.php';
97
98 if (is_admin()) {
99
100 require_once DISABLE_GUTENBERG_DIR .'inc/resources-enqueue.php';
101 require_once DISABLE_GUTENBERG_DIR .'inc/settings-display.php';
102 require_once DISABLE_GUTENBERG_DIR .'inc/settings-register.php';
103
104 if (version_compare($GLOBALS['wp_version'], '5.0-beta', '>')) {
105
106 require_once DISABLE_GUTENBERG_DIR .'inc/plugin-features.php';
107
108 }
109
110 }
111
112 }
113
114 function options() {
115
116 $options = array(
117
118 'disable-all' => 1,
119 'disable-nag' => 1,
120 'hide-menu' => 0,
121 'hide-gut' => 0,
122 'templates' => '',
123 'post-ids' => '',
124 'acf-enable' => 0,
125 'links-enable' => 0,
126 'whitelist-id' => '',
127 'whitelist-slug' => '',
128 'whitelist-title' => '',
129 'whitelist' => 0,
130 'styles-enable' => 0,
131 'classic-widgets' => 1,
132
133 );
134
135 $types = disable_gutenberg_get_post_types();
136
137 foreach($types as $type) {
138
139 extract($type); // name label
140
141 $options['post-type_'. $name] = 1;
142
143 }
144
145 $roles = disable_gutenberg_get_user_roles();
146
147 foreach($roles as $type) {
148
149 extract($type); // name label
150
151 $options['user-role_'. $name] = 1;
152
153 }
154
155 return apply_filters('disable_gutenberg_options', $options);
156
157 }
158
159 function action_links($links, $file) {
160
161 if (($file === DISABLE_GUTENBERG_FILE) && (current_user_can('manage_options'))) {
162
163 $settings = '<a href="'. admin_url('options-general.php?page=disable-gutenberg') .'">'. esc_html__('Settings', 'disable-gutenberg') .'</a>';
164
165 array_unshift($links, $settings);
166
167 }
168
169 return $links;
170
171 }
172
173 function plugin_links($links, $file) {
174
175 if ($file === DISABLE_GUTENBERG_FILE) {
176
177 $home_href = 'https://perishablepress.com/disable-gutenberg/';
178 $home_title = esc_attr__('Plugin Homepage', 'disable-gutenberg');
179 $home_text = esc_html__('Homepage', 'disable-gutenberg');
180
181 $links[] = '<a target="_blank" rel="noopener noreferrer" href="'. $home_href .'" title="'. $home_title .'">'. $home_text .'</a>';
182
183 $rate_href = 'https://wordpress.org/support/plugin/'. DISABLE_GUTENBERG_SLUG .'/reviews/?rate=5#new-post';
184 $rate_title = esc_attr__('Click here to rate and review this plugin at WordPress.org', 'disable-gutenberg');
185 $rate_text = esc_html__('Rate this plugin', 'disable-gutenberg') .'&nbsp;&raquo;';
186
187 $links[] = '<a target="_blank" rel="noopener noreferrer" href="'. $rate_href .'" title="'. $rate_title .'">'. $rate_text .'</a>';
188
189 }
190
191 return $links;
192
193 }
194
195 function footer_text($text) {
196
197 $screen_id = disable_gutenberg_get_current_screen_id();
198
199 $ids = array('settings_page_disable-gutenberg');
200
201 if ($screen_id && apply_filters('disable_gutenberg_admin_footer_text', in_array($screen_id, $ids))) {
202
203 $text = __('Like this plugin? Give it a', 'disable-gutenberg');
204
205 $text .= ' <a target="_blank" rel="noopener noreferrer" href="https://wordpress.org/support/plugin/disable-gutenberg/reviews/?rate=5#new-post">';
206
207 $text .= __('�
208
209
210
211
212 rating&nbsp;&raquo;', 'disable-gutenberg') .'</a>';
213
214 }
215
216 return $text;
217
218 }
219
220 function check_version() {
221
222 $wp_version = get_bloginfo('version');
223
224 if (isset($_GET['activate']) && $_GET['activate'] == 'true') {
225
226 if (version_compare($wp_version, DISABLE_GUTENBERG_REQUIRE, '<')) {
227
228 if (is_plugin_active(DISABLE_GUTENBERG_FILE)) {
229
230 deactivate_plugins(DISABLE_GUTENBERG_FILE);
231
232 $msg = '<strong>'. DISABLE_GUTENBERG_NAME .'</strong> '. esc_html__('requires WordPress ', 'disable-gutenberg') . DISABLE_GUTENBERG_REQUIRE;
233 $msg .= esc_html__(' or higher, and has been deactivated. ', 'disable-gutenberg');
234 $msg .= esc_html__('Please return to the', 'disable-gutenberg') .' <a href="'. admin_url('plugins.php') .'">';
235 $msg .= esc_html__('WordPress Admin Area', 'disable-gutenberg') .'</a> '. esc_html__('to upgrade WordPress and try again.', 'disable-gutenberg');
236
237 wp_die($msg);
238
239 }
240
241 }
242
243 }
244
245 }
246
247 function load_i18n() {
248
249 load_plugin_textdomain('disable-gutenberg', false, dirname(DISABLE_GUTENBERG_FILE) .'/languages/');
250
251 }
252
253 function __clone() {
254
255 _doing_it_wrong(__FUNCTION__, esc_html__('Sorry, pal!', 'disable-gutenberg'), DISABLE_GUTENBERG_VERSION);
256
257 }
258
259 function __wakeup() {
260
261 _doing_it_wrong(__FUNCTION__, esc_html__('Sorry, pal!', 'disable-gutenberg'), DISABLE_GUTENBERG_VERSION);
262
263 }
264
265 }
266
267 global $DisableGutenberg;
268
269 $DisableGutenberg = new DisableGutenberg();
270
271 }
272