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 7.6.8 7.6.9 7.7.0 7.8.0 7.8.1 7.8.10 7.8.11 7.8.12 7.8.13 7.8.14 7.8.15 7.8.16 7.8.17 7.8.18 7.8.2 7.8.3 7.8.4 7.8.5 7.8.5.1 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1 7.9.10 7.9.11 7.9.2 7.9.3 7.9.4 7.9.5 7.9.6 7.9.7 7.9.8 7.9.9 8.0.0 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.1.0 8.1.1 8.1.2 8.1.3 8.1.4 8.2.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.2.0 3.3.0 3.4.0 3.5.0 3.6.1 3.7.0 3.8.0 3.9.0 3.9.1 3.9.2 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.9.0 4.9.1 4.9.2 4.9.3 5.0.0
admin-site-enhancements / classes / class-disable-gutenberg.php
admin-site-enhancements / classes Last commit date
class-activation.php 4 months ago class-admin-menu-organizer.php 4 months ago class-admin-menu-svg-icon-mask.php 4 months ago class-auto-publish-posts-with-missed-schedule.php 4 months ago class-avif-upload.php 4 months ago class-captcha-protection.php 4 months ago class-change-login-url.php 4 months ago class-cleanup-admin-bar.php 4 months ago class-common-methods.php 4 months ago class-content-duplication.php 4 months ago class-content-order.php 4 months ago class-custom-admin-footer-text.php 4 months ago class-custom-body-class.php 4 months ago class-custom-css.php 4 months ago class-custom-nav-menu-items-in-new-tab.php 4 months ago class-deactivation.php 4 months ago class-disable-author-archives.php 4 months ago class-disable-comments.php 4 months ago class-disable-dashboard-widgets.php 4 months ago class-disable-embeds.php 4 months ago class-disable-feeds.php 4 months ago class-disable-gutenberg.php 4 months ago class-disable-rest-api.php 4 months ago class-disable-smaller-components.php 4 months ago class-disable-updates.php 4 months ago class-disable-xml-rpc.php 4 months ago class-display-system-summary.php 4 months ago class-email-address-obfuscator.php 4 months ago class-email-delivery.php 4 months ago class-enhance-list-tables.php 4 months ago class-external-permalinks.php 4 months ago class-heartbeat-control.php 4 months ago class-hide-admin-bar.php 4 months ago class-hide-admin-notices.php 4 months ago class-image-sizes-panel.php 4 months ago class-image-upload-control.php 4 months ago class-insert-head-body-footer-code.php 4 months ago class-last-login-column.php 4 months ago class-limit-login-attempts.php 4 months ago class-login-id-type.php 4 months ago class-login-logout-menu.php 4 months ago class-maintenance-mode.php 4 months ago class-manage-ads-appads-txt.php 4 months ago class-manage-robots-txt.php 4 months ago class-media-files-visibility-control.php 4 months ago class-media-replacement.php 4 months ago class-multiple-user-roles.php 4 months ago class-obfuscate-author-slugs.php 4 months ago class-open-external-links-in-new-tab.php 4 months ago class-password-protection.php 4 months ago class-redirect-after-login.php 4 months ago class-redirect-after-logout.php 4 months ago class-redirect-fourofour.php 4 months ago class-registration-date-column.php 4 months ago class-revisions-control.php 4 months ago class-search-engines-visibility.php 4 months ago class-settings-fields-render.php 4 months ago class-settings-sanitization.php 4 months ago class-settings-sections-fields.php 4 months ago class-show-custom-taxonomy-filters.php 4 months ago class-site-identity-on-login-page.php 4 months ago class-svg-upload.php 4 months ago class-various-admin-ui-enhancements.php 4 months ago class-view-admin-as-role.php 4 months ago class-wider-admin-menu.php 4 months ago class-wp-config-transformer.php 4 months ago
class-disable-gutenberg.php
190 lines
1 <?php
2
3 namespace ASENHA\Classes;
4
5 /**
6 * Class for Disable Gutenberg module
7 *
8 * @since 6.9.5
9 */
10 class Disable_Gutenberg {
11 /**
12 * Disable Gutenberg in wp-admin for some or all post types
13 *
14 * @since 2.8.0
15 */
16 public function disable_gutenberg_for_post_types_admin() {
17 // Get current page's post type from WP core globals and query parameters
18 global $pagenow, $typenow;
19 $post_type = null;
20 if ( 'edit.php' === $pagenow ) {
21 // on the list table screen, $typenow returns correct post type
22 $post_type = $typenow;
23 } elseif ( 'post.php' === $pagenow ) {
24 // on the edit screen, $typenow is empty, so we detect it
25 $post_type = ( isset( $_GET['post'] ) ? get_post_type( $_GET['post'] ) : 'post' );
26 } elseif ( 'post-new.php' === $pagenow ) {
27 // on the add new screen, best to get post type from GET parameter
28 $post_type = ( isset( $_GET['post_type'] ) ? $_GET['post_type'] : 'post' );
29 } else {
30 }
31 // Check if Gutenberg feature is enabled for the site
32 // Before/after WP v5.0.0 via feature plugin
33 $gutenberg = function_exists( 'gutenberg_register_scripts_and_styles' );
34 // Since WP v5.0.0, gutenberg is in core
35 $block_editor = has_action( 'enqueue_block_assets' );
36 // Gutenberg feature is not enabled for the site
37 if ( !$gutenberg && false === $block_editor ) {
38 return;
39 // do nothing
40 }
41 // Assemble single-dimensional array of post types for which Gutenberg should be disabled
42 $options = get_option( ASENHA_SLUG_U );
43 $disable_gutenberg_type = 'only-on';
44 $disable_gutenberg_for = $options['disable_gutenberg_for'];
45 $post_types_for_disable_gutenberg = array();
46 foreach ( $disable_gutenberg_for as $post_type_slug => $is_gutenberg_disabled ) {
47 if ( $is_gutenberg_disabled ) {
48 $post_types_for_disable_gutenberg[] = $post_type_slug;
49 }
50 }
51 // Selectively disable Gutenberg
52 if ( 'only-on' == $disable_gutenberg_type && in_array( $post_type, $post_types_for_disable_gutenberg ) || 'except-on' == $disable_gutenberg_type && !in_array( $post_type, $post_types_for_disable_gutenberg ) || 'all-post-types' == $disable_gutenberg_type ) {
53 // For WP v5.0.0 upwards
54 add_filter( 'use_block_editor_for_post_type', '__return_false', 100 );
55 // If Gutenberg feature plugin is activated
56 if ( $gutenberg ) {
57 add_filter( 'gutenberg_can_edit_post_type', '__return_false', 100 );
58 $this->remove_all_gutenberg_hooks();
59 }
60 }
61 }
62
63 /**
64 * Remove Gutenberg hooks added via feature plugin.
65 *
66 * @link https://plugins.trac.wordpress.org/browser/classic-editor/tags/1.6.2/classic-editor.php#L138
67 * @since 2.8.0
68 */
69 public function remove_all_gutenberg_hooks() {
70 remove_action( 'admin_menu', 'gutenberg_menu' );
71 remove_action( 'admin_init', 'gutenberg_redirect_demo' );
72 // Gutenberg 5.3+
73 remove_action( 'wp_enqueue_scripts', 'gutenberg_register_scripts_and_styles' );
74 remove_action( 'admin_enqueue_scripts', 'gutenberg_register_scripts_and_styles' );
75 remove_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
76 remove_action( 'rest_api_init', 'gutenberg_register_rest_widget_updater_routes' );
77 remove_action( 'admin_print_styles', 'gutenberg_block_editor_admin_print_styles' );
78 remove_action( 'admin_print_scripts', 'gutenberg_block_editor_admin_print_scripts' );
79 remove_action( 'admin_print_footer_scripts', 'gutenberg_block_editor_admin_print_footer_scripts' );
80 remove_action( 'admin_footer', 'gutenberg_block_editor_admin_footer' );
81 remove_action( 'admin_enqueue_scripts', 'gutenberg_widgets_init' );
82 remove_action( 'admin_notices', 'gutenberg_build_files_notice' );
83 remove_filter( 'load_script_translation_file', 'gutenberg_override_translation_file' );
84 remove_filter( 'block_editor_settings', 'gutenberg_extend_block_editor_styles' );
85 remove_filter( 'default_content', 'gutenberg_default_demo_content' );
86 remove_filter( 'default_title', 'gutenberg_default_demo_title' );
87 remove_filter( 'block_editor_settings', 'gutenberg_legacy_widget_settings' );
88 remove_filter( 'rest_request_after_callbacks', 'gutenberg_filter_oembed_result' );
89 // Previously used, compat for older Gutenberg versions.
90 remove_filter( 'wp_refresh_nonces', 'gutenberg_add_rest_nonce_to_heartbeat_response_headers' );
91 remove_filter( 'get_edit_post_link', 'gutenberg_revisions_link_to_editor' );
92 remove_filter( 'wp_prepare_revision_for_js', 'gutenberg_revisions_restore' );
93 remove_action( 'rest_api_init', 'gutenberg_register_rest_routes' );
94 remove_action( 'rest_api_init', 'gutenberg_add_taxonomy_visibility_field' );
95 remove_filter( 'registered_post_type', 'gutenberg_register_post_prepare_functions' );
96 remove_action( 'do_meta_boxes', 'gutenberg_meta_box_save' );
97 remove_action( 'submitpost_box', 'gutenberg_intercept_meta_box_render' );
98 remove_action( 'submitpage_box', 'gutenberg_intercept_meta_box_render' );
99 remove_action( 'edit_page_form', 'gutenberg_intercept_meta_box_render' );
100 remove_action( 'edit_form_advanced', 'gutenberg_intercept_meta_box_render' );
101 remove_filter( 'redirect_post_location', 'gutenberg_meta_box_save_redirect' );
102 remove_filter( 'filter_gutenberg_meta_boxes', 'gutenberg_filter_meta_boxes' );
103 remove_filter( 'body_class', 'gutenberg_add_responsive_body_class' );
104 remove_filter( 'admin_url', 'gutenberg_modify_add_new_button_url' );
105 // old
106 remove_action( 'admin_enqueue_scripts', 'gutenberg_check_if_classic_needs_warning_about_blocks' );
107 remove_filter( 'register_post_type_args', 'gutenberg_filter_post_type_labels' );
108 }
109
110 /**
111 * Disable Gutenberg styles and scripts on the front end for all or some post types
112 *
113 * @since 2.8.0
114 */
115 public function disable_gutenberg_for_post_types_frontend() {
116 global $post;
117 if ( is_numeric( $post ) ) {
118 $post = get_post( (int) $post );
119 }
120 if ( !is_object( $post ) || !property_exists( $post, 'post_type' ) ) {
121 return;
122 }
123 $post_type = $post->post_type;
124 // Assemble single-dimensional array of post types for which Gutenberg should be disabled
125 $options = get_option( ASENHA_SLUG_U );
126 $disable_gutenberg_type = 'only-on';
127 $disable_gutenberg_for = $options['disable_gutenberg_for'];
128 $post_types_for_disable_gutenberg = array();
129 foreach ( $disable_gutenberg_for as $post_type_slug => $is_gutenberg_disabled ) {
130 if ( $is_gutenberg_disabled ) {
131 $post_types_for_disable_gutenberg[] = $post_type_slug;
132 }
133 }
134 // Selectively disable for the selected post types
135 if ( 'only-on' == $disable_gutenberg_type && in_array( $post_type, $post_types_for_disable_gutenberg ) || 'except-on' == $disable_gutenberg_type && !in_array( $post_type, $post_types_for_disable_gutenberg ) || 'all-post-types' == $disable_gutenberg_type ) {
136 global $wp_styles;
137 // As needed, exclude some block styles from dequeuing
138 $keep_enqueued = array();
139 // e.g. array( 'wp-block-navigation' );
140 foreach ( $wp_styles->queue as $handle ) {
141 // For all stye handles that starts with 'wp-block', e.g. 'wp-block-library', 'wp-block-library-theme'
142 if ( false !== strpos( $handle, 'wp-block' ) ) {
143 if ( !in_array( $handle, $keep_enqueued ) ) {
144 wp_dequeue_style( $handle );
145 wp_deregister_style( $handle );
146 }
147 }
148 }
149 // Additional dequeuing
150 wp_dequeue_style( 'core-block-supports' );
151 wp_deregister_style( 'core-block-supports' );
152 wp_dequeue_style( 'global-styles' );
153 // theme.json
154 wp_deregister_style( 'global-styles' );
155 // theme.json
156 wp_dequeue_style( 'classic-theme-styles' );
157 // classic theme
158 wp_deregister_style( 'classic-theme-styles' );
159 // classic theme
160 wp_dequeue_style( 'wp-block-library' );
161 wp_deregister_style( 'wp-block-library' );
162 }
163 // wp_deregister_style( 'wp-block-library' );
164 }
165
166 /**
167 * Temporary fix for Safari 18 negative horizontal margin on floats.
168 * [TODO] Remove when Safari 18 implements a fix on their end.
169 *
170 * @link https://wordpress.org/support/topic/safari-18-0-breaking-classic-editor/
171 * @link https://plugins.trac.wordpress.org/changeset/3158976/classic-editor/trunk/classic-editor.php
172 */
173 public function safari_18_fix() {
174 global $current_screen;
175 if ( isset( $current_screen->base ) && 'post' === $current_screen->base ) {
176 $clear = ( is_rtl() ? 'right' : 'left' );
177 ?>
178 <style id="classic-editor-safari-18-temp-fix">
179 _::-webkit-full-page-media, _:future, :root #post-body #postbox-container-2 {
180 clear: <?php
181 echo $clear;
182 ?>;
183 }
184 </style>
185 <?php
186 }
187 }
188
189 }
190