Disable functionality of WYSIWYG editor

Support General Disable functionality of WYSIWYG editor

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6241
    BLAQBLAQ
    Participant

    I've found this option for disable functionality of the WYSIWYG editor:
    https://metabox.io/docs/filters/#section-wysiwyg-filters

    How exactly do I use that function? For e.g. you want to disable the "Add Media"-button.

    I'm thankful for any help! Cheers.

    #6244
    Anh TranAnh Tran
    Keymaster

    Hi,

    I think the easier way to change the wysiwyg is using options parameter. Using filter is the last method you should think about. Of course this will work. I'll demonstrate both methods here:

    If you want to disable "Add Media" button, use this code:

    array(
        'type'    => 'wysiwyg',
        'name'    => 'Editor',
        'id'      => 'test_editor',
        'options' => array(
            'media_buttons' => false,
        ),
    ),

    If you want to disable the text mode), use this code:

    array(
        'type'    => 'wysiwyg',
        'name'    => 'Editor',
        'id'      => 'test_editor',
        'options' => array(
            'media_buttons' => false,
            'quicktags'     => false,
        ),
    ),

    If you want to disable visual mode, use this code:

    array(
        'type'    => 'wysiwyg',
        'name'    => 'Editor',
        'id'      => 'test_editor',
        'options' => array(
            'media_buttons' => false,
            'tinymce'       => false,
        ),
    ),

    Using filter is similar:

    add_filter( 'rwmb_wysiwyg_settings', function ( $settings ) {
        $settings['media_buttons'] = false;
        // $settings['tinymce']       = false;
        $settings['quicktags']     = false;
    
        return $settings;
    } );

    Note that using filter affects all wysiwyg fields. That's why it's more preferable to use field settings instead.

    #6250
    BLAQBLAQ
    Participant

    That was exactly what I was searching for. Thanks!

    For any options, I've found the Function Reference https://codex.wordpress.org/Function_Reference/wp_editor

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Disable functionality of WYSIWYG editor’ is closed to new replies.