给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 让 PHP 更盛行了 而不是框架

Tiobe Index(编程言语世界排名指数),是一个显示各种编程言语的绝对盛行趋向的排名,开端于 2001 年,每...

WordPress 插件间接将效劳器文件导入媒体库

WordPress 的 Media 库治理器只能从客户端抉择文件上传,Dion Hulse 开发了一个 Add From Server 插件,支...

WordPress中主动激活插件的完成办法

有一个一劳永逸的办法能够使wordpress博主当前上传插件都不必再手动激活,wordpress主动激活,办法很简略,...

WordPress完成网站投稿者也能够上传图片的办法

本文实例讲述了WordPress完成网站投稿者也能够上传图片的办法。分享给大家供大家参考。详细剖析如下: Word...

WordPress提醒require_once() Failed opening required的处理办法

本文实例讲述了WordPress提醒require_once() Failed opening required的处理办法。 一、成绩: 明天进我的w...

wordpress全局变量$wpdb初始化并申明为全局变量的办法

首先从wordpress顺序index.php动手: 复制代码代码如下:define('WP_USE_THEMES', true); /** Loads the Wor...

需求提交

客服服务

亿鸽在线客服系统