Introduce wp_validate_action( $action = '' ), a helper function that checks $_REQUEST for action and returns it, or empty string if not present. If $action is passed, it checks to make sure they match before returning it, or an empty string. Strings are always returned to avoid returning multiple types.

Implementing this removes 27 uses of direct superglobal access in the admin.

For more reading:
https://codeclimate.com/github/WordPress/WordPress/wp-admin/edit-comments.php

See #33837.


git-svn-id: https://develop.svn.wordpress.org/trunk@34059 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-09-11 21:07:45 +00:00
parent 9805723e3d
commit 33953cb392
12 changed files with 44 additions and 16 deletions

View File

@@ -28,7 +28,7 @@ nocache_headers();
/** This action is documented in wp-admin/admin.php */
do_action( 'admin_init' );
$action = empty( $_REQUEST['action'] ) ? '' : $_REQUEST['action'];
$action = wp_validate_action();
if ( ! wp_validate_auth_cookie() ) {
if ( empty( $action ) ) {