给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模板罕用函数集锦

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

在WordPress的文章编辑器中设置默许内容的办法

很多时分咱们需求在给 WordPress 文章编辑器设置默许内容,比方把罕用的扫尾或许文章留意事项放出来,本文就...

解说WordPress链接治理性能

要害字形容:性能 治理 链接 解说 能够 这个 增加 信息 网站 一个 这一次咱们来解说Wordpress链接治理性能...

管制好你的 Wordpress 侧边栏

当然 Wordpress 2.7 里有&ldquo;小工具&rdquo;选项也能管制 Widget ,然而重复试验后发现款式无奈对立,可控...

WordPress主题制造之模板文件的引入办法

get_template_part() 用来援用模板文件,相似于 get_header()、get_sidebar() 和 get_footer(),只不过这个...

WordPress评论IP地址显示为127.0.0.1的处理方法

穆童博客应用的是Wordpress顺序,上次在改换了效劳器之后不知为何一切新评论的IP地址都显示为127.0.0.1。刚...

需求提交

客服服务

亿鸽在线客服系统