Make WordPress Core


Ignore:
Timestamp:
09/11/2015 09:07:45 PM (10 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/network/users.php

    r34025 r34059  
    175175require_once( ABSPATH . 'wp-admin/admin-header.php' );
    176176
    177 if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) {
     177$action = wp_validate_action();
     178if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $action ) ) {
    178179    ?>
    179180    <div id="message" class="updated notice is-dismissible"><p>
    180181        <?php
    181         switch ( $_REQUEST['action'] ) {
     182        switch ( $action ) {
    182183            case 'delete':
    183184                _e( 'User deleted.' );
Note: See TracChangeset for help on using the changeset viewer.