手机
当前位置:查字典教程网 >编程开发 >php教程 >给WordPress的编辑后台添加提示框的代码实例分享
给WordPress的编辑后台添加提示框的代码实例分享
摘要:WordPress3.5新添加了一个提示框功能,可以创建一个提示框,然后指向任何元素,比如下边的例子:本文就来教你怎么创建一个这样的提示框。...

WordPress 3.5 新添加了一个提示框功能,可以创建一个提示框,然后指向任何元素,比如下边的例子:

本文就来教你怎么创建一个这样的提示框。

首先需要添加提示框

给WordPress的编辑后台添加提示框的代码实例分享1

的脚本,这样才能使用提示框的 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的编辑后台添加提示框的代码实例分享】相关文章:

PHP教程:清除wordpress里恶意代码

十天学会php之第八天

删除无限级目录与文件代码共享

递归实现php数组转xml的代码分享

php curl 上传文件代码实例

PHP Hash算法:Times33算法代码实例

php数组合并与拆分实例分析

PHP中isset与array_key_exists的区别实例分析

php编写批量生成不重复的卡号密码代码

PHP树的代码,可以嵌套任意层

精品推荐
分类导航