Home  >  Article  >  Backend Development  >  Sharing code examples for adding prompt boxes to the WordPress editing backend, _PHP tutorial

Sharing code examples for adding prompt boxes to the WordPress editing backend, _PHP tutorial

WBOY
WBOYOriginal
2016-07-12 09:02:48873browse

Sharing code examples for adding prompt boxes to the WordPress editing backend,

WordPress 3.5 has added a new prompt box function, which allows you to create a prompt box and point it to any element, such as Example below:

This article will teach you how to create such a prompt box.

First you need to add the script of the prompt box20151225145502025.png (579×337) so that you can use the JS method of the prompt box.

//挂载提示框脚本
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' );

Then use the pointer() method to create a simple tooltip:

/**
  *WordPress 后台添加提示框
  *http://www.endskin.com/admin-help-box/
*/
function Bing_add_pointer_scripts(){
  $content = '<h3>请设置主题</h3>';
  $content .= '<p>请为新主题进行简单的配置!';
&#63;>  
  <script type="text/javascript">
  //<![CDATA[
  jQuery(document).ready(function($){
    $('#menu-appearance').pointer({//可以指向任何元素
      content: '<&#63;php echo $content; &#63;>',
      position: {
        edge: 'left',
        align: 'center'
      },
      close: function(){
        //提示框打开之后做的事情
      }
    }).pointer('open');
  });
  //]]>
  </script>
<&#63;php
}
add_action( 'admin_print_footer_scripts', 'Bing_add_pointer_scripts' );<br />

Comprehensive code:

/**
  *WordPress 后台添加提示框
  *http://www.endskin.com/admin-help-box/
*/
function Bing_add_pointer_scripts(){
  $content = '<h3>请设置主题</h3>';
  $content .= '<p>请为新主题进行简单的配置!';
&#63;>  
  <script type="text/javascript">
  //<![CDATA[
  jQuery(document).ready(function($){
    $('#menu-appearance').pointer({//可以指向任何元素
      content: '<&#63;php echo $content; &#63;>',
      position: {
        edge: 'left',
        align: 'center'
      },
      close: function(){
        //提示框打开之后做的事情
      }
    }).pointer('open');
  });
  //]]>
  </script>
<&#63;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' );


Articles you may be interested in:

  • WordPress code to determine whether the user is logged in
  • Detailed explanation of the function of reminding to install plug-ins and hiding plug-ins in WordPress
  • Detailed explanation of the use of filter attributes and Sql statement functions in WordPress development
  • Analysis of relevant PHP functions for writing custom storage fields in WordPress
  • Detailed explanation of the use of relevant PHP functions for creating user roles in WordPress

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1084525.htmlTechArticle Share the code example of adding a prompt box to the WordPress editing background. WordPress 3.5 has added a new prompt box function, which can Create a tooltip and point it to any element, like this...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn