Making WordPress.org

Opened 3 weeks ago

Closed 3 weeks ago

#7889 closed defect (bug) (fixed)

Incorrect Code Example in admin_action_{action} Hook Documentation

Reported by: jdahir0789's profile jdahir0789 Owned by:
Milestone: Priority: normal
Component: Developer Hub Keywords:
Cc:

Description

Issue Description
The code example provided in the admin_action_{action} hook documentation does not match the actual implementation found in the WordPress core files.

URL of the Page with the Issue
https://developer.wordpress.org/reference/hooks/admin_action__requestaction

Section of Page with the issue
https://developer.wordpress.org/reference/hooks/admin_action__requestaction/#source

Why is this a problem?
The inaccurate code example can mislead developers into implementing the hook incorrectly, potentially causing issues in their WordPress sites or plugins. Clear and accurate examples are essential for helping developers understand how to use hooks properly.

Suggested Fix
Replace the current code example with the accurate implementation as found in wp-admin/admin.php between lines 408-420. Below is the correct code:

if ( ! empty( $_REQUEST['action'] ) ) {
	$action = $_REQUEST['action'];

	/**
	 * Fires when an 'action' request variable is sent.
	 *
	 * The dynamic portion of the hook name, `$action`, refers to
	 * the action derived from the `GET` or `POST` request.
	 *
	 * @since 2.6.0
	 */
	do_action( "admin_action_{$action}" );
}

Change History (1)

#1 @dd32
3 weeks ago

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

It looks like https://developer.wordpress.org/reference/hooks/admin_action__requestaction/ is a duplicate of https://developer.wordpress.org/reference/hooks/admin_action_action/ (Of which there was a user-contributed note from @lovor 3 years ago pointing out this duplication).

I'm just going to delete the former in preference of the later. I'm guessing the parser isn't cleaning up some old entries properly.

Note: See TracTickets for help on using tickets.