WordPress.org

Make WordPress Core

Opened 4 months ago

Closed 4 months ago

#48395 closed defect (bug) (fixed)

PHPDoc correction for add_help_tab() in wp-admin/includes/class-wp-screen.php

Reported by: atachibana Owned by: SergeyBiryukov
Milestone: 5.4 Priority: normal
Severity: minor Version:
Component: Administration Keywords: has-patch
Focuses: docs Cc:

Description

Enhanced missing information of Codex for add_help_tab() in wp-admin/includes/class-wp-screen.php:

  • Function description
  • Parameter description

Codex: https://codex.wordpress.org/Class_Reference/WP_Screen/add_help_tab
Code Reference: https://developer.wordpress.org/reference/classes/wp_screen/add_help_tab/

This is the action of inline docs and Codex migration initiatives.

Index: class-wp-screen.php
===================================================================
--- class-wp-screen.php	(revision 46561)
+++ class-wp-screen.php	(working copy)
@@ -594,8 +594,14 @@
 
 	/**
 	 * Add a help tab to the contextual help for the screen.
-	 * Call this on the load-$pagenow hook for the relevant screen.
 	 *
+	 * Call this on the load-$pagenow hook for the relevant screen,
+	 * or fetch the $current_screen object or use get_current_screen()
+	 * and then call the method from the object.
+	 *
+	 * You may need to filter $current_screen using an if or switch statement
+	 * to prevent new help tabs from being added to ALL admin screens.
+	 *
 	 * @since 3.3.0
 	 * @since 4.4.0 The `$priority` argument was added.
 	 *
@@ -603,7 +609,7 @@
 	 *     Array of arguments used to display the help tab.
 	 *
 	 *     @type string $title    Title for the tab. Default false.
-	 *     @type string $id       Tab ID. Must be HTML-safe. Default false.
+	 *     @type string $id       Tab ID. Must be HTML-safe and should be unique for this menu. It is NOT allowed to contain any empty spaces. Default false.
 	 *     @type string $content  Optional. Help tab content in plain text or HTML. Default empty string.
 	 *     @type string $callback Optional. A callback to generate the tab content. Default false.
 	 *     @type int    $priority Optional. The priority of the tab, used for ordering. Default 10.

Attachments (1)

48395.diff (1.4 KB) - added by atachibana 4 months ago.

Download all attachments as: .zip

Change History (4)

@atachibana
4 months ago

#1 @atachibana
4 months ago

  • Keywords has-patch added

#2 @SergeyBiryukov
4 months ago

  • Milestone changed from Awaiting Review to 5.4
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#3 @SergeyBiryukov
4 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 46590:

Docs: Improve documentation for WP_Screen::add_help_tab().

Props atachibana.
Fixes #48395.

Note: See TracTickets for help on using tickets.