首页    >    新闻资讯    >   TinyMCE中创建自定义下拉菜单

TinyMCE中创建自定义下拉菜单

这段代码可以帮你创建一个自定义的下拉菜单。在TinyMCE的可视化编辑器中修改要创建的内容,就可以插入自定义的HTML元素。使用这段代码,即使你对HTML或者代码一点了解没有,也可以在TinyMCE修改。

function themeit_mce_buttons_2( $buttons ) { array_unshift( $buttons, 'styleselect' ); return $buttons; } add_filter( 'mce_buttons_2', 'themeit_mce_buttons_2' ); function themeit_tiny_mce_before_init( $settings ) { $settings['theme_advanced_blockformats'] = 'p,a,div,span,h1,h2,h3,h4,h5,h6,tr,'; $style_formats = array( array( 'title' => 'Button', 'inline' => 'span', 'classes' => 'button' ), array( 'title' => 'Green Button', 'inline' => 'span', 'classes' => 'button button-green' ), array( 'title' => 'Rounded Button', 'inline' => 'span', 'classes' => 'button button-rounded' ), array( 'title' => 'Other Options' ), array( 'title' => '½ Col.', 'block' => 'div', 'classes' => 'one-half' ), array( 'title' => '½ Col. Last', 'block' => 'div', 'classes' => 'one-half last' ), array( 'title' => 'Callout Box', 'block' => 'div', 'classes' => 'callout-box' ), array( 'title' => 'Highlight', 'inline' => 'span', 'classes' => 'highlight' ) ); $settings['style_formats'] = json_encode( $style_formats ); return $settings; } add_filter( 'tiny_mce_before_init', 'themeit_tiny_mce_before_init' );

分类:新闻资讯

标签:, , ,

* 版权声明:作者WordPress啦! 转载请注明出处。