后台编辑文章的时候添加短代码按钮,预设短代码,实现快速添加短代码
//添加短代码
add_action('admin_print_scripts', 'my_quicktags');
function my_quicktags() {
wp_enqueue_script(
'my_quicktags',
get_stylesheet_directory_uri().'/assets/js/my_quicktags.js',
array('quicktags')
);
}
//添加短代码下拉框
function wzt_select(){
echo '
<select id="short_code_select">
#模板<option value="请选择一个短代码!!!">插入短代码</option>
<option value="[secret key=\'更换文章密码\']内容[/secret]">文章密码保护</option>
</select>';
}
if (current_user_can('edit_posts') && current_user_can('edit_pages')) {
add_action('media_buttons', 'wzt_select', 11);
}
function wzt_button() {
echo '<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#short_code_select").change(function(){
send_to_editor(jQuery("#short_code_select :selected").val());
return false;
});
});
</script>';
}
add_action('admin_head', 'wzt_button');
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。