constants();
$this->includes();
add_action('admin_init', array($this, 'check_version'));
add_action('plugins_loaded', array($this, 'load_i18n'));
add_filter('plugin_action_links', array($this, 'action_links'), 10, 2);
add_filter('plugin_row_meta', array($this, 'plugin_links'), 10, 2);
add_action('admin_enqueue_scripts', 'disable_gutenberg_admin_enqueue_scripts');
add_action('admin_print_scripts', 'disable_gutenberg_admin_print_scripts');
add_action('admin_notices', 'disable_gutenberg_admin_notice');
add_action('admin_init', 'disable_gutenberg_register_settings');
add_action('admin_init', 'disable_gutenberg_reset_options');
add_action('admin_menu', 'disable_gutenberg_menu_pages');
add_action('admin_menu', 'disable_gutenberg_menu_items', 999);
add_action('admin_init', 'disable_gutenberg_acf_enable_meta');
add_action('admin_init', 'disable_gutenberg_privacy_notice');
add_filter('admin_init', 'disable_gutenberg_disable_nag');
add_filter('admin_init', 'disable_gutenberg_init');
add_filter('wp_enqueue_scripts', 'disable_gutenberg_wp_enqueue_scripts', 100);
}
function constants() {
if (!defined('DISABLE_GUTENBERG_VERSION')) define('DISABLE_GUTENBERG_VERSION', '1.8.1');
if (!defined('DISABLE_GUTENBERG_REQUIRE')) define('DISABLE_GUTENBERG_REQUIRE', '4.9');
if (!defined('DISABLE_GUTENBERG_AUTHOR')) define('DISABLE_GUTENBERG_AUTHOR', 'Jeff Starr');
if (!defined('DISABLE_GUTENBERG_NAME')) define('DISABLE_GUTENBERG_NAME', __('Disable Gutenberg', 'disable-gutenberg'));
if (!defined('DISABLE_GUTENBERG_HOME')) define('DISABLE_GUTENBERG_HOME', esc_url('https://perishablepress.com/disable-gutenberg/'));
if (!defined('DISABLE_GUTENBERG_URL')) define('DISABLE_GUTENBERG_URL', plugin_dir_url(__FILE__));
if (!defined('DISABLE_GUTENBERG_DIR')) define('DISABLE_GUTENBERG_DIR', plugin_dir_path(__FILE__));
if (!defined('DISABLE_GUTENBERG_FILE')) define('DISABLE_GUTENBERG_FILE', plugin_basename(__FILE__));
if (!defined('DISABLE_GUTENBERG_SLUG')) define('DISABLE_GUTENBERG_SLUG', basename(dirname(__FILE__)));
}
function includes() {
require_once DISABLE_GUTENBERG_DIR .'inc/classic-editor.php';
require_once DISABLE_GUTENBERG_DIR .'inc/plugin-core.php';
if (is_admin()) {
require_once DISABLE_GUTENBERG_DIR .'inc/resources-enqueue.php';
require_once DISABLE_GUTENBERG_DIR .'inc/settings-display.php';
require_once DISABLE_GUTENBERG_DIR .'inc/settings-register.php';
require_once DISABLE_GUTENBERG_DIR .'inc/settings-reset.php';
if (version_compare($GLOBALS['wp_version'], '5.0-beta', '>')) {
require_once DISABLE_GUTENBERG_DIR .'inc/plugin-features.php';
}
} else {
require_once DISABLE_GUTENBERG_DIR .'inc/plugin-frontend.php';
}
}
function options() {
$options = array(
'disable-all' => 1,
'disable-nag' => 1,
'hide-menu' => 0,
'hide-gut' => 0,
'templates' => '',
'post-ids' => '',
'acf-enable' => 0,
'links-enable' => 0,
'whitelist-id' => '',
'whitelist-slug' => '',
'whitelist-title' => '',
'whitelist' => 0,
'styles-enable' => 0,
);
$types = disable_gutenberg_get_post_types();
foreach($types as $type) {
extract($type); // name label
$options['post-type_'. $name] = 1;
}
$roles = disable_gutenberg_get_user_roles();
foreach($roles as $type) {
extract($type); // name label
$options['user-role_'. $name] = 1;
}
return apply_filters('disable_gutenberg_options', $options);
}
function action_links($links, $file) {
if (($file === DISABLE_GUTENBERG_FILE) && (current_user_can('manage_options'))) {
$settings = ''. esc_html__('Settings', 'disable-gutenberg') .'';
array_unshift($links, $settings);
}
return $links;
}
function plugin_links($links, $file) {
if ($file === DISABLE_GUTENBERG_FILE) {
$home_href = 'https://perishablepress.com/disable-gutenberg/';
$home_title = esc_attr__('Plugin Homepage', 'disable-gutenberg');
$home_text = esc_html__('Homepage', 'disable-gutenberg');
$links[] = ''. $home_text .'';
$rate_href = 'https://wordpress.org/support/plugin/'. DISABLE_GUTENBERG_SLUG .'/reviews/?rate=5#new-post';
$rate_title = esc_attr__('Click here to rate and review this plugin on WordPress.org', 'disable-gutenberg');
$rate_text = esc_html__('Rate this plugin', 'disable-gutenberg') .' »';
$links[] = ''. $rate_text .'';
}
return $links;
}
function check_version() {
$wp_version = get_bloginfo('version');
if (isset($_GET['activate']) && $_GET['activate'] == 'true') {
if (version_compare($wp_version, DISABLE_GUTENBERG_REQUIRE, '<')) {
if (is_plugin_active(DISABLE_GUTENBERG_FILE)) {
deactivate_plugins(DISABLE_GUTENBERG_FILE);
$msg = ''. DISABLE_GUTENBERG_NAME .' '. esc_html__('requires WordPress ', 'disable-gutenberg') . DISABLE_GUTENBERG_REQUIRE;
$msg .= esc_html__(' or higher, and has been deactivated! ', 'disable-gutenberg');
$msg .= esc_html__('Please return to the', 'disable-gutenberg') .' ';
$msg .= esc_html__('WP Admin Area', 'disable-gutenberg') .' '. esc_html__('to upgrade WordPress and try again.', 'disable-gutenberg');
wp_die($msg);
}
}
}
}
function load_i18n() {
load_plugin_textdomain('disable-gutenberg', false, DISABLE_GUTENBERG_DIR .'languages/');
}
function __clone() {
_doing_it_wrong(__FUNCTION__, esc_html__('Sorry, pal!', 'disable-gutenberg'), DISABLE_GUTENBERG_VERSION);
}
function __wakeup() {
_doing_it_wrong(__FUNCTION__, esc_html__('Sorry, pal!', 'disable-gutenberg'), DISABLE_GUTENBERG_VERSION);
}
}
global $DisableGutenberg;
$DisableGutenberg = new DisableGutenberg();
}