Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Classic Editor Addon by SO WP & Greg Schoppe - Classic Editor plugin doesn't remove Gutenberg by default. With this addon function we set the option that controls this from no-replace to replace and we remove the Settings link from the main Plugins page. We also suppress the Nag screen that will appear in WordPress 4.9.6
<?php
/**
* Plugin Name: Classic Editor Addon
* Plugin Author: Pieter Bos (https://so-wp.com) and Greg Schoppe (https://gschoppe.com)
* Description: The Classic Editor plugin doesn't remove Gutenberg by default. with this function we set the option that controls this from no-replace to replace and we remove the Settings link from the main Plugins page
*/
function classic_editor_addon_hardcode_replace( $value ) {
return 'replace';
}
function classic_editor_addon_remove_settings_link( $links, $file ) {
if ( $file === 'classic-editor/classic-editor.php' && current_user_can( 'manage_options' ) ) {
array_shift( $links );
}
return $links;
}
function classic_editor_addon_init() {
/**
* Remove the Try Gutenberg Panel, slated for WordPress 4.9.6
*/
remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' );
if ( function_exists( 'classic_editor_init_actions' ) ) {
/**
* Change the default option of "no-replace" to "replace",
* which means the checkbox will be unticked and the bloody plugin
* does what it says from the get-go (L336).
*/
add_filter( 'pre_option_classic-editor-replace', 'classic_editor_addon_hardcode_replace' );
/**
* Remove Settings link to the settings from the Plugins screen (L277).
*/
add_filter( 'plugin_action_links', 'classic_editor_addon_remove_settings_link', 10, 2 );
}
}
add_action( 'plugins_loaded', 'classic_editor_addon_init', 1, 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment