Making WordPress.org

Changeset 15003


Ignore:
Timestamp:
07/25/2026 12:01:49 PM (14 hours ago)
Author:
obenland
Message:

wporg-login: Add argument schemas to registration REST endpoints.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions-registration.php

    r14602 r15003  
    230230 * Fetches a pending user record from the database by username or Email.
    231231 *
    232  * @param string|int $who The username, email address, or user ID.
     232 * @param string|int|array $who The username, email address, user ID, or an
     233 *                              existing pending user record.
     234 * @return array|false The pending user record, or false if not found.
    233235 */
    234236function wporg_get_pending_user( $who ) {
     
    236238
    237239        // Is it a pending user object already?
    238         if ( is_array( $who ) && isset( $who['pending_id'] ) ) {
    239                 return $who;
     240        if ( is_array( $who ) ) {
     241                if ( empty( $who['pending_id'] ) ) {
     242                        return false;
     243                }
     244                $who = (int) $who['pending_id'];
    240245        }
    241246
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions-restapi.php

    r14995 r15003  
    66                'callback'            => 'wporg_login_rest_username_exists',
    77                'permission_callback' => '__return_true',
     8                'args'                => array(
     9                        'login' => array(
     10                                'type'              => 'string',
     11                                'sanitize_callback' => 'sanitize_text_field',
     12                        ),
     13                ),
    814        ) );
    915        register_rest_route( 'wporg/v1', '/username-available/?', array(
     
    1117                'callback'            => 'wporg_login_rest_username_exists',
    1218                'permission_callback' => '__return_true',
     19                'args'                => array(
     20                        'login' => array(
     21                                'type'              => 'string',
     22                                'sanitize_callback' => 'sanitize_text_field',
     23                        ),
     24                ),
    1325        ) );
    1426
     
    1729                'callback'            => 'wporg_login_rest_email_in_use',
    1830                'permission_callback' => '__return_true',
     31                'args'                => array(
     32                        'email' => array(
     33                                'type'              => 'string',
     34                                'sanitize_callback' => 'sanitize_text_field',
     35                        ),
     36                ),
    1937        ) );
    2038        register_rest_route( 'wporg/v1', '/email-in-use/?', array(
     
    2240                'callback'            => 'wporg_login_rest_email_in_use',
    2341                'permission_callback' => '__return_true',
     42                'args'                => array(
     43                        'email' => array(
     44                                'type'              => 'string',
     45                                'sanitize_callback' => 'sanitize_text_field',
     46                        ),
     47                ),
    2448        ) );
    2549
     
    2852                'callback'            => 'wporg_login_rest_resend_confirmation_email',
    2953                'permission_callback' => '__return_true',
     54                'args'                => array(
     55                        'account' => array(
     56                                'type'              => 'string',
     57                                'required'          => true,
     58                                'sanitize_callback' => 'sanitize_text_field',
     59                        ),
     60                ),
    3061        ) );
    3162}
Note: See TracChangeset for help on using the changeset viewer.