php 从wordpress wysiwyg删除按钮

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 从wordpress wysiwyg删除按钮相关的知识,希望对你有一定的参考价值。

/**
 * Removes buttons from the first row of the tiny mce editor
 *
 *
 * @param    array    $buttons    The default array of buttons
 * @return   array                The updated array of buttons that exludes some items
 */
add_filter( 'mce_buttons', 'jivedig_remove_tiny_mce_buttons_from_editor');
function jivedig_remove_tiny_mce_buttons_from_editor( $buttons ) {
    $remove_buttons = array(
        'bold',
        'italic',
        'strikethrough',
        'bullist',
        'numlist',
        'blockquote',
        'hr', // horizontal line
        'alignleft',
        'aligncenter',
        'alignright',
        'link',
        'unlink',
        'wp_more', // read more link
        'spellchecker',
        'dfw', // distraction free writing mode
        'wp_adv', // kitchen sink toggle (if removed, kitchen sink will always display)
    );
    foreach ( $buttons as $button_key => $button_value ) {
        if ( in_array( $button_value, $remove_buttons ) ) {
            unset( $buttons[ $button_key ] );
        }
    }
    return $buttons;
}
/**
 * Removes buttons from the second row (kitchen sink) of the tiny mce editor
 *
 *
 * @param    array    $buttons    The default array of buttons in the kitchen sink
 * @return   array                The updated array of buttons that exludes some items
 */
add_filter( 'mce_buttons_2', 'jivedig_remove_tiny_mce_buttons_from_kitchen_sink');
function jivedig_remove_tiny_mce_buttons_from_kitchen_sink( $buttons ) {
    $remove_buttons = array(
        'formatselect', // format dropdown menu for <p>, headings, etc
        'underline',
        'alignjustify',
        'forecolor', // text color
        'pastetext', // paste as text
        'removeformat', // clear formatting
        'charmap', // special characters
        'outdent',
        'indent',
        'undo',
        'redo',
        'wp_help', // keyboard shortcuts
    );
    foreach ( $buttons as $button_key => $button_value ) {
        if ( in_array( $button_value, $remove_buttons ) ) {
            unset( $buttons[ $button_key ] );
        }
    }
    return $buttons;
}

以上是关于php 从wordpress wysiwyg删除按钮的主要内容,如果未能解决你的问题,请参考以下文章

php 防止Wordpress在p标签中包装图像和iframe(默认WYSIWYG和高级自定义字段Wordpress WYSIWYG插件)

PHP 添加按钮到WordPress wysiwyg编辑器

php 将样式添加到Wordpress WYSIWYG编辑器

php ACF Pro - 从WYSIWYG编辑器中的图像中删除p标签

php ACF Pro - 从WYSIWYG编辑器中的图像中删除p标签

scss WordPress WYSIWYG布局模板