Home > Backend Development > PHP Tutorial > 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
Release: 2016-07-12 09:02:48
Original
913 people have browsed it

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' );
Copy after login

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 />
Copy after login

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' );
Copy after login


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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template