Skip to content

Instantly share code, notes, and snippets.

@senlin
Last active February 3, 2019 03:13
Show Gist options
  • Save senlin/691c5f06459857f57247dc92f7ec1406 to your computer and use it in GitHub Desktop.
Save senlin/691c5f06459857f57247dc92f7ec1406 to your computer and use it in GitHub Desktop.
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, we remove the Settings link from the main Plugins page and we hide the Settings from the Settings > Writing screen. We also suppress the Nag screen tha…
<?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() {
remove_filter( 'plugin_action_links', 'classic_editor_add_settings_link' );
}
function classic_editor_hide_settings() {
?>
<style>
#classic-editor-options{display:none;}
</style>
<?php
}
function classic_editor_addon_init() {
/**
* Remove the Try Gutenberg Panel, slated for WordPress 4.9.8
*/
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 plugin
* does what it says from the get-go (L336).
*/
add_filter( 'pre_option_classic-editor-replace', 'classic_editor_addon_hardcode_replace' );
/**
* Remove link to the settings from the Plugins screen (L277).
*/
add_action( 'plugins_loaded', 'classic_editor_addon_remove_settings_link' );
/**
* Hide the Settings of the plugin on the Settings > Writing screen
*/
add_action( 'admin_footer', 'classic_editor_hide_settings' );
}
}
add_action( 'plugins_loaded', 'classic_editor_addon_init', 1, 0 );
@senlin
Copy link
Author

senlin commented Jul 9, 2018

Available as official plugin now: https://github.com/senlin/classic-editor-addon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment