senlin / classic-editor-addon

This free "Classic Editor Addon" plugin makes sure that Gutenberg cannot be accidentally activated even while the "Classic Editor" plugin is active.
GNU General Public License v3.0
19 stars 5 forks source link

Filter for when classic editor is mu-plugin #11

Closed senlin closed 2 years ago

senlin commented 2 years ago

A user sent a message pointing out some difficulty for when the Classic Editor plugin has been installed as a mu-plugin (or inside a custom plugin). Original message here.

Long story short, he suggests adding a filter:

add_filter( 'option_active_plugins', function( $plugins ){
    foreach( (array) debug_backtrace() as $item ) {
        if( array_key_exists( 'function', $item ) && $item['function'] == 'cea_depends_on_ce' ) {
            $plugins[] = 'classic-editor/classic-editor.php';
            break;
        }
    }

    return $plugins;
});