我想使用动态数组向wordpress添加自定义样式。
我的问题是如何动态地将两个数组添加到'my_mce_before_init_insert_formats'函数中的style_formats数组中?
function my_mce_before_init_insert_formats( $init_array ) {
$style_formats = array(
array(
'title' => '.translation',
'block' => 'blockquote',
'classes' => 'translation',
'wrapper' => true,
),
//add arrays here dynamically
);
$init_array['style_formats'] = json_encode( $style_formats );
return $init_array;
}
//arrays to add dynamically
array(
'title' => '⇠.rtl',
'block' => 'blockquote',
'classes' => 'rtl',
'wrapper' => true,
),
array(
'title' => '.ltr⇢',
'block' => 'blockquote',
'classes' => 'ltr',
'wrapper' => true,
),