给WordPress的编辑后台添加提示框的代码实例分享,
WordPress 3.5 新添加了一个提示框功能,可以创建一个提示框,然后指向任何元素,比如下边的例子:
本文就来教你怎么创建一个这样的提示框。
首先需要添加提示框的脚本,这样才能使用提示框的 JS 方法。
1 2 3 4 5 6 | 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() 方法创建一个简单的提示框:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
function Bing_add_pointer_scripts(){
$content = '<h3>请设置主题</h3>' ;
$content .= '<p>请为新主题进行简单的配置!' ;
?>
<script type= "text/javascript" >
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' );<br />
|
ログイン後にコピー
综合代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
function Bing_add_pointer_scripts(){
$content = '<h3>请设置主题</h3>' ;
$content .= '<p>请为新主题进行简单的配置!' ;
?>
<script type= "text/javascript" >
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开发中过滤属性以及Sql语句的函数使用
- WordPress中编写自定义存储字段的相关PHP函数解析
- WordPress中创建用户角色的相关PHP函数使用详解