Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Code Example in admin_action_{action} Hook Documentation #1802

Open
PARTHVATALIYA opened this issue Nov 26, 2024 · 1 comment
Open
Labels
[Status] To do Issue marked as Todo

Comments

@PARTHVATALIYA
Copy link

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}" );
}
@PARTHVATALIYA PARTHVATALIYA added the [Status] To do Issue marked as Todo label Nov 26, 2024
Copy link

Heads up @WordPress/docs-issues-coordinators, we have a new issue open. Time to use 'em labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] To do Issue marked as Todo
Projects
None yet
Development

No branches or pull requests

1 participant