给WordPress的编辑后盾增加提醒框的代码实例分享

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 提示框 后台 PHP编程
版权声明:本文为 安达网络工作室 转载文章,如有侵权请联系我们及时删除。
相关文章
wordpress动态化首页及去除url中的index.html

应用wordpass博客顺序的冤家都晓得他的默许首页是index.php,但是地球人都晓得index.html的太首页可以进步网...

基于wordpress主题制造的详细完成步骤

代码如下:<?php/*在根目录 -> wp-content -> themes 下创立mytheme文件夹用来寄存创立新主题模板 在mythem...

wordpress模板罕用函数集锦

根本模板文件 style.css : CSS(款式表)文件index.php : 主页模板archive.php : Archive/Category模板404.ph...

wordpress编辑器中增加链接性能主动退出nofollow的办法

由于偶然加一些站外链接,普通都是nofollow,独自写入很费事,所以揣摩从编辑器动手,经过这个插件(http:/...

WordPress中发送HTML邮件的办法

办法一,用filter发送HTML邮件 发邮件用的函数是wp_mail(),wp_mail()则基于弱小的邮件类phpMailer,所以发...

查看本人或他人的WordPress版本默许为wp-login.php

明天在修正网站的时分,不小心把最新版Wordpress3.5.1的wp-includes目录下的functions.php笼罩出来了,招致...

需求提交

客服服务

亿鸽在线客服系统