LoginSignup
1
4

More than 5 years have passed since last update.

Wordpressのビジュアルエディタのボタンを編集

Posted at

Wordpressの管理画面のカスタマイズ方法を備忘録として記載。

functions.php

/* ビジュアルエディタのボタンを削除
* ---------------------------------------- */
//1段目
function remove_tinymce_buttons( $buttons ) {
  $remove = array(
    // 'formatselect', // フォーマット
    // 'bold',         // 太字
    'italic',       // イタリック
    // 'bullist',      // 番号なしリスト
    'numlist',      // 番号付きリスト
    'blockquote',   // 引用
    'alignleft',    // 左寄せ
    'aligncenter',  // 中央揃え
    'alignright',   // 右寄せ
    // 'link',         // リンクの挿入/編集
    // 'unlink',       // リンクの削除
    'wp_more',      // 「続きを読む」タグを挿入
    // 'wp_adv',       // ツールバー切り替え
    'dfw'           // 集中執筆モード
  ); // ここに削除したいものを記述
  return array_diff($buttons, $remove);
}
add_filter( 'mce_buttons', 'remove_tinymce_buttons' );

//2段目
function remove_tinymce_buttons_2( $buttons ) {
  $remove = array(
    'strikethrough', // 打ち消し
    'hr',            // 横ライン
    'forecolor',     // テキスト色
    'pastetext',     // テキストとしてペースト
    'removeformat',  // 書式設定をクリア
    'charmap',       // 特殊文字
    'outdent',       // インデントを減らす
    'indent',        // インデントを増やす
    'undo',          // 取り消し
    'redo',          // やり直し
    'wp_help'        // キーボードショートカット
  ); // ここに削除したいものを記述
  return array_diff($buttons, $remove);
}
add_filter( 'mce_buttons_2', 'remove_tinymce_buttons_2' );
functions.php

/* ビジュアルエディタの指定できるフォーマットを変更
* ---------------------------------------- */

add_filter( 'tiny_mce_before_init', 'custom_tiny_mce_formats' );
function custom_tiny_mce_formats( $settings ){
  $settings[ 'block_formats' ] = '段落=p;見出し1=h2;見出し2=h3;見出し3=h4;';
  return $settings;
}

参考:
https://www.nxworld.net/wordpress/wp-custom-visual-editor.html

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4