Function Reference/add contextual help

来自WordPress中文文档
跳转至: 导航搜索

includeonlydiv style=clear:both; background-color:#FFFFFF; border:1px solid #FFFFFF; color:#c00; padding:7px; margin:0.5em auto 0.5em auto; vertical-align:middle;This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists. See also onlyincludecodewp-includes/deprecated.php/code/onlyinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Template Description

Link to the source code on http://core.trac.wordpress.org/browser/.

Parameters

  1. filename
  2. (option) path to codetag/code (version) or codetrunk/code. This option is only used for a new function.br /Default: codetrunk/code -- trunk is the latest bleeding edge development version of WordPress.

Usage

Link to the stable version: pre检查到模板循环:模板:Trac/pre

Link to trunk: pre检查到模板循环:模板:Trac/pre

/div

wordpress.org.cn./div/includeonlynoinclude

Description

This Template is used by Codex:Template Messages.

Usage

pre 检查到模板循环:模板:Message /pre

Result

检查到模板循环:模板:Message

/noinclude


Use add_help_tab() instead.

Description

This function is used to add HTML to the Contextual Help tab for a specific admin page.

Usage

%%% <?php add_contextual_help( $screen, $help ); ?> %%%

Parameters

tt$screen/tt
(string) (required) The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
Default: Nonenoinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Notes

This template is for standardizing how parameters look in the Function Reference and in Template Tags. Here is an example of this template being called: prenowiki检查到模板循环:模板:Parameter/nowiki/pre 检查到模板循环:模板:Parameter

The usage of this template is below: prenowiki检查到模板循环:模板:Parameter/nowiki/pre Let's take a closer look at the parameters..

name
The name of the parameter.
datatype
The datatype that should be given for this parameter when called.
  • string
  • integer
  • boolean
  • mixed
description
A short description of the parameter.
importance
Set this parameter to optional if the parameter is optional. Otherwise, do not declare this parameter—it defaults to required.
  • required
  • optional
default
If this parameter is optional, ttdefault/tt is the value that will be used if the parameter is not declared.

wordpress.org.cn /div /noinclude

tt$help/tt
(string) (required) An arbitrary string containing HTML for help text.
Default: Nonenoinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Notes

This template is for standardizing how parameters look in the Function Reference and in Template Tags. Here is an example of this template being called: prenowiki检查到模板循环:模板:Parameter/nowiki/pre 检查到模板循环:模板:Parameter

The usage of this template is below: prenowiki检查到模板循环:模板:Parameter/nowiki/pre Let's take a closer look at the parameters..

name
The name of the parameter.
datatype
The datatype that should be given for this parameter when called.
  • string
  • integer
  • boolean
  • mixed
description
A short description of the parameter.
importance
Set this parameter to optional if the parameter is optional. Otherwise, do not declare this parameter—it defaults to required.
  • required
  • optional
default
If this parameter is optional, ttdefault/tt is the value that will be used if the parameter is not declared.

wordpress.org.cn /div /noinclude

Example

Default Usage

This example shows how you would add contextual help to an admin page you've created with the add_theme_page() function. Here, we will assume that your page has a slug of 'my_theme_options' and exists under the Appearance tab, which has a slug of 'appearance_page'. To keep things organized, we can use the 'admin_init' hook to declare a function with our custom contextual help.

<?php 
function add_my_contextual_help() {
    $text = __("<p>This is a help text for 'my_theme_options' page (a subpage of 'appearance_page').</p>");
    add_contextual_help( 'appearance_page_my_theme_options', $text ); 
}
add_action( 'admin_init', 'add_my_contextual_help' );
?>

Finding the Screen Name

If you need to find the current screen name (for the $screen parameter) then you can use this function. Just put it in your functions.php file and then browse to the page you wish to find the screen name. It will then be printed across the top of your admin screen. This is very useful for people who create custom administration menus (typically advanced premium themes) and aren't quite sure what the screen name would be.

<?php
function check_current_screen() {
    if( !is_admin() ) return;
    global $current_screen;
    print_r( $current_screen );
}
add_action( 'admin_notices', 'check_current_screen' );
?>

Notes

When using this function to add contextual help to an admin page created by a plugin or theme, it is important to remember that the add_*_page() set of functions build and return custom hook names - which are needed in order to use add_contextual_help().

This page hook name is usually made up of two page slugs separated by an underscore - the slug for the current page (as defined in your add_*_page() function), an underscore, and the slug for the parent page.

For example, if you created a new "theme_options" subpage under the Admin > Appearance menu (which itself has a slug of "appearance_page"), your page hook would be "appearance_page_theme_options".

To modify or add to the hard-coded help text for default WordPress admin pages, you have to use the gettext filter hook.

Change Log

Source File

add_contextual_help() is located in onlyincludecodewp-admin/includes/template.php/code/onlyinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Template Description

Link to the source code on http://core.trac.wordpress.org/browser/.

Parameters

  1. filename
  2. (option) path to codetag/code (version) or codetrunk/code. This option is only used for a new function.br /Default: codetrunk/code -- trunk is the latest bleeding edge development version of WordPress.

Usage

Link to the stable version: pre检查到模板循环:模板:Trac/pre

Link to trunk: pre检查到模板循环:模板:Trac/pre

/div

wordpress.org.cn.

Related

Topics

Functions

Resources