-
-
Save gschoppe/ce88a7821764ef11803a5c64350078b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
Hi @gschoppe Greg,
I came to realise that the filter of the
plugin_action_links
with theclassic_editor_addon_remove_settings_link
function does not work.To make it work, the filter needs to be replaced with an action:
add_action( 'plugins_loaded', 'classic_editor_addon_remove_settings_link' );
And the function itself can be simplified by:
You can see, the changes also in my original gist (updated of course with your changes).
What do you think about releasing this together as a plugin in the WP Plugin Repo?