WordPress 3.5 新增加了一个提醒框性能,能够创立一个提醒框,而后指向任何元素,比方下边的例子:
本文就来教你怎样创立一个这样的提醒框。
首先需求增加提醒框的脚本,这样能力应用提醒框的 JS 办法。
//挂载提醒框脚本
function Bing_admin_pointer_enqueue_scripts(){
wp_enqueue_style( 'wp-pointer' );
wp_enqueue_script( 'wp-pointer' );
}
add_action( 'admin_enqueue_scripts', 'Bing_admin_pointer_enqueue_scripts' );
而后应用 pointer() 办法创立一个简略的提醒框:
/**
*WordPress 后盾增加提醒框
*http://www.endskin.com/admin-help-box/
*/
function Bing_add_pointer_scripts(){
$content = '<h3>请设置主题</h3>';
$content .= '<p>请为新主题进行简略的配置!';
?>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function($){
$('#menu-appearance').pointer({//能够指向任何元素
content: '<?php echo $content; ?>',
position: {
edge: 'left',
align: 'center'
},
close: function(){
//提醒框关上之后做的事件
}
}).pointer('open');
});
//]]>
</script>
<?php
}
add_action( 'admin_print_footer_scripts', 'Bing_add_pointer_scripts' );
综合代码:
/**
*WordPress 后盾增加提醒框
*http://www.endskin.com/admin-help-box/
*/
function Bing_add_pointer_scripts(){
$content = '<h3>请设置主题</h3>';
$content .= '<p>请为新主题进行简略的配置!';
?>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function($){
$('#menu-appearance').pointer({//能够指向任何元素
content: '<?php echo $content; ?>',
position: {
edge: 'left',
align: 'center'
},
close: function(){
//提醒框关上之后做的事件
}
}).pointer('open');
});
//]]>
</script>
<?php
}
add_action( 'admin_print_footer_scripts', 'Bing_add_pointer_scripts' );
//挂载提醒框脚本
function Bing_admin_pointer_enqueue_scripts(){
wp_enqueue_style( 'wp-pointer' );
wp_enqueue_script( 'wp-pointer' );
}
add_action( 'admin_enqueue_scripts', 'Bing_admin_pointer_enqueue_scripts' );
以上就是安达网络工作室关于《给WordPress的编辑后台添加提示框的代码实例分享》的一些看法。更多内容请查看本栏目更多内容!
前言 Wordpress这款开源顺序的后盾门路齐全曾经暴露了,很容易遭到黑客的入侵。其它很多开源顺序都是能够修...
2015必备wordpress插件列表。为了加强wordpress站点,一些优秀无效的收费wordpress 插件是必不可少的。 Wo...
七牛云存储是由七牛提供的在线存储效劳,经过云端接口向企业客户提供网上有限存储空间,和传统的云存储效劳...
共性化登陆界面的办法有两种,第一种是交换登陆背景,这个算是小型共性化吧: 在/wp-admin/images找到login...
本文实例讲述了Wordpress分类,标签,分页显示及翻页呈现404谬误的处理办法。分享给大家供大家参考。详细剖析...
函数is_singular()检测后果为true,当上面其一前往true时:is_single()、is_page()、is_attachment()。 假如...