动态地将数组添加到函数中的style_formats数组中

时间:2016-05-21 10:23:12

标签: php arrays wordpress

我想使用动态数组向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,
),

0 个答案:

没有答案