PluginProbe
Disable Gutenberg / trunk
Disable Gutenberg vtrunk
trunk 1.0.6 1.0.7 1.0.8 1.0.9
auto-disable-editor / auto-disable-editor.php

auto-disable-editor.php in Disable Gutenberg trunk, at auto-disable-editor.php

131 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @wordpress-plugin
4 * Plugin Name: Disable Gutenberg
5 * Plugin URI: https://wordpress.org/plugins/auto-disable-editor
6 * Description: Auto Disable Gutenberg will help to enable classic editor. its will disable new gutenberg block plugin.
7 * Version: 1.0.9
8 * Author: CodePopular
9 * Author URI: https://www.codepopular.com
10 * License: GPL-2.0+
11 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
12 * Text Domain: auto-disable-editor
13 * Requires at least: 4.0
14 * Tested up to: 7.0.2
15 * Requires PHP: 5.6
16 @coypright: -2024 CodePopular (support: info@codepopular.com)
17 */
18
19
20
21 // Exit if accessed directly
22 if ( !defined( 'ABSPATH' ) ) {
23 echo "can't access directly";
24 exit();
25 }
26
27 if ( ! defined( 'ADE_PLUGIN_DIR_PATH' ) ) {
28 define( 'ADE_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__) );
29 }
30
31
32 if ( ! defined( 'ADE_PLUGIN_URL' ) ) {
33 define( 'ADE_PLUGIN_URL', plugin_dir_url(__FILE__) );
34 }
35
36
37
38
39 // main plugin class
40 class CodePopular_disable_gutenberg
41 {
42 static function init()
43 {
44 if (is_admin()) {
45 add_filter('install_plugins_table_api_args_featured', array(__CLASS__, 'featured_plugins_tab'));
46 }
47
48
49 } // init
50
51
52 // add our plugins to recommended list
53 static function plugins_api_result($res, $action, $args) {
54 remove_filter('plugins_api_result', array(__CLASS__, 'plugins_api_result'), 10, 1);
55
56 $res = self::add_plugin_favs('wp-maximum-upload-file-size', $res);
57 $res = self::add_plugin_favs('unlimited-theme-addons', $res);
58
59 return $res;
60 } // plugins_api_result
61
62
63 // helper function for adding plugins to fav list
64 static function featured_plugins_tab($args) {
65 add_filter('plugins_api_result', array(__CLASS__, 'plugins_api_result'), 10, 3);
66
67 return $args;
68 } // featured_plugins_tab
69
70
71 // add single plugin to list of favs
72 static function add_plugin_favs($plugin_slug, $res) {
73 if (!empty($res->plugins) && is_array($res->plugins)) {
74 foreach ($res->plugins as $plugin) {
75 if (is_object($plugin) && !empty($plugin->slug) && $plugin->slug == $plugin_slug) {
76 return $res;
77 }
78 } // foreach
79 }
80
81 if ($plugin_info = get_transient('wf-plugin-info-' . $plugin_slug)) {
82 array_unshift($res->plugins, $plugin_info);
83 } else {
84 $plugin_info = plugins_api('plugin_information', array(
85 'slug' => $plugin_slug,
86 'is_ssl' => is_ssl(),
87 'fields' => array(
88 'banners' => true,
89 'reviews' => true,
90 'downloaded' => true,
91 'active_installs' => true,
92 'icons' => true,
93 'short_description' => true,
94 )
95 ));
96 if (!is_wp_error($plugin_info)) {
97 $res->plugins[] = $plugin_info;
98 set_transient('wf-plugin-info-' . $plugin_slug, $plugin_info, DAY_IN_SECONDS * 7);
99 }
100 }
101
102 return $res;
103 } // add_plugin_favs
104 } // class Wp_auto_disable_gutenburg
105
106
107
108
109 // Disable Gutenberg
110
111 if (version_compare($GLOBALS['wp_version'], '5.0-beta', '>')) {
112
113 // WP > 5 beta
114 add_filter('use_block_editor_for_post_type', '__return_false', 10);
115
116 } else {
117
118 // WP < 5 beta
119 add_filter('gutenberg_can_edit_post_type', '__return_false', 10);
120
121 }
122
123 add_action('init', array('CodePopular_disable_gutenberg', 'init'));
124
125
126 if (is_admin()) {
127 require_once ADE_PLUGIN_DIR_PATH . 'Admin/admin.php';
128 }
129
130
131