CG
(@du-bist-der-lenz)
最新バージョンでも、「段落メニュー」と連動できていて問題は見られませんでした。

TinyMCE廻りはバージョン4.3で変更があったんでしたかね。
CG (@du-bist-der-lenz)さん
ご返信ありがとうございます。
私もここまでは確認が出来ております。
実際に適用をしようとすると、
入力済みの文字にスタイルに変化が起きず。
テキストエディタで確認をすると
やはりh2などが適用されておりません。
こんにちは
どのようなコードを書いたのか具体的に教えていただけますか。
ちなみに下記のようなコードでスタイルフォーマットに h2 を追加することはできると思います。
function my_mce_before_init_insert_formats( $init_array ) {
$style_formats = array(
array(
'title' => '見出し2',
'block' => 'h2',
'classes' => 'midashi2',
),
);
$init_array['style_formats'] = json_encode( $style_formats );
return $init_array;
}
add_filter( 'tiny_mce_before_init', 'my_mce_before_init_insert_formats' );
ishitakaさん、ご返信ありがとうございます。
具体的なコードは下記となります。
// Callback function to filter the MCE settings
function my_mce_before_init_insert_formats( $init_array ) {
// Define the style_formats array
$style_formats = array(
// Each array child is a format with it's own settings
array(
'title' => '.translation',
'block' => 'h2',
'classes' => 'translation',
'wrapper' => true,
),
array(
'title' => '⇠.rtl',
'block' => 'blockquote',
'classes' => 'rtl',
'wrapper' => true,
),
array(
'title' => '.ltr⇢',
'block' => 'blockquote',
'classes' => 'ltr',
'wrapper' => true,
),
);
// Insert the array, JSON ENCODED, into 'style_formats'
$init_array['style_formats'] = json_encode( $style_formats );
return $init_array;
}
// Attach callback to 'tiny_mce_before_init'
add_filter( 'tiny_mce_before_init', 'my_mce_before_init_insert_formats' );
下記ページのコード最初のblockの部分をh2に変更いたしました。
https://codex.wordpress.org/TinyMCE_Custom_Styles
ドロップダウンメニューには表示されるのですが、
h2の部分を選択をしても、文章に適用がされないような状況です。
ishitakaさん
上記にて改善いたしました。
ありがとうございます。
大変助かりました。
wrapper – State that tells that the current format is a container format for block elements. For example a div wrapper or blockquote.
ブロック要素のcontainerだったらtrue
h2にはブロック要素がいれられないので、falseにする必要があったということでしょうか。
h2 はブロック要素なので本来であれば wrapper は true なのかも知れませんが・・・よく分かりません (^^;
ishitakaさん
熟練の勘ということですね!
本当にありがとうございます。