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 选项 能够 网站 你曾经阅读了这个 Wordpress 架设的站点...
复制代码代码如下:<?php/*Plugin Name: WPJAM HTML Widget TitleDescription: 让 Widget 题目支持简略的 HT...
要害字形容:引见 性能 治理 评论 渣滓 审核 能够 网站 Akismet 编辑 如今咱们来看看评论治理性能。评论是...
将Gravatar寰球通用头像缓存的目的在于放慢网站的关上速度,由于Gravatar官网的效劳器在国外,加上伟大的GF...
讯问后果却有些出人意料,居然是超流量了,应用这么久还是第一次遇到超量的状况。 登陆cPanel后盾查看也的确...
WordPress 不只是博客, 很多时分 WordPress 还被用作为 CMS (内容治理零碎). 博主们喜爱为每个文章加上对立...