Remove Specific Buttons from WP Editor TinyMCE

前端 未结 1 1534
猫巷女王i
猫巷女王i 2021-01-03 14:35

I am trying to figure out how to remove specific buttons from the TinyMCE editor. I have researched the arguments in the codex but for TinyMCE is just says array and not sur

1条回答
  •  抹茶落季
    2021-01-03 14:52

    The tinymce parameter allows you to pass configuration options directly to TinyMCE - see the docs for theme_advanced_buttons and theme_advanced_disable, and the button reference.

    To show only the bold, italic and underline buttons:

    wp_editor($value, "input...", array(
        'tinymce' => array(
            'theme_advanced_buttons1' => 'bold,italic,underline',
            'theme_advanced_buttons2' => '',
            'theme_advanced_buttons3' => ''
        )
    ));
    

    Or, to show everything except the bold, italic and underline buttons:

    wp_editor($value, "input...", array(
        'tinymce' => array(
            'theme_advanced_disable' => 'bold,italic,underline'
        )
    ));
    

    As requested, your code modified:

    add_action( 'gform_field_input', 'gforms_wp_editor', 10, 5 );
    
    function gforms_wp_editor( $input, $field, $value, $lead_id, $form_id ) {
        if( $field["cssClass"] == 'richtext' ) {
            ob_start();
            wp_editor( $value, "input_{$form_id}_{$field['id']}",
                array(
                    'media_buttons' => false,
                    'quicktags'     => false,
                    'textarea_name' => "input_{$field['id']}",
                    'tinymce'       => array(
                        'theme_advanced_disable' => 'bold,italic,underline'
                    )
                )
            );
            $input = ob_get_clean();
        }
        return $input;
    }
    

    0 讨论(0)
提交回复
热议问题