Heim  >  Artikel  >  Backend-Entwicklung  >  [WORDPRESS系列]在正题的 function.php 中给 WordPress 编辑器添加自定义按钮(Quicktags)

[WORDPRESS系列]在正题的 function.php 中给 WordPress 编辑器添加自定义按钮(Quicktags)

WBOY
WBOYOriginal
2016-06-13 12:18:21929Durchsuche

[WORDPRESS系列]在主题的 function.php 中给 WordPress 编辑器添加自定义按钮(Quicktags)
参考资料:
http://www.ssdn2007.com/wordpress-add-quicktags-button-in-function-php.html
http://codex.wordpress.org.cn/Quicktags_API

http://yusi123.com/460.html

functions.php 代码

<?php// 给editor添加更多默认按纽function enable_more_buttons($buttons) {	$buttons[] = 'hr';	$buttons[] = 'fontselect';	$buttons[] = 'sup';	$buttons[] = 'del';	$buttons[] = 'cleanup';	$buttons[] = 'styleselect';	 	// 更多按钮自行添加吧...	 	return $buttons;}//add_filter("mce_buttons", "enable_more_buttons"); //默认将新添加的按钮追加在工具栏的第一行//add_filter("mce_buttons_2", "enable_more_buttons");  //添加到工具栏的第二行add_filter("mce_buttons_3", "enable_more_buttons");  //添加到工具栏的第三行// 将editor的默认视图改成文本add_filter('wp_default_editor', create_function('', 'return "html";')); // 默认是add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );// 编辑器添加默认内容function insertPreContent($content) {        if(!is_feed() && !is_home()) { 			$content.= "这里的预定义内容在编辑器可见";        }        return $content;}add_filter ('default_content', 'insertPreContent');// 添加自定义editor 按纽add_action('admin_print_scripts', 'my_quicktags');function my_quicktags() {    wp_enqueue_script(        'my_quicktags',        get_stylesheet_directory_uri().'/js/my_quicktags.js',        array('quicktags')    );};?>

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn