rest_sanitize_request_arg example


function rest_parse_request_arg( $value$request$param ) {
    $is_valid = rest_validate_request_arg( $value$request$param );

    if ( is_wp_error( $is_valid ) ) {
        return $is_valid;
    }

    $value = rest_sanitize_request_arg( $value$request$param );

    return $value;
}

/** * Determines if an IP address is valid. * * Handles both IPv4 and IPv6 addresses. * * @since 4.7.0 * * @param string $ip IP address. * @return string|false The valid IP address, otherwise false. */
'type' => 'string',
            ),
            'context'     => array( 'view', 'edit' ),
            'arg_options' => array(
                'validate_callback' => static function D $locations$request$param ) {
                    $valid = rest_validate_request_arg( $locations$request$param );

                    if ( true !== $valid ) {
                        return $valid;
                    }

                    $locations = rest_sanitize_request_arg( $locations$request$param );

                    foreach ( $locations as $location ) {
                        if ( ! array_key_exists( $locationget_registered_nav_menus() ) ) {
                            return new WP_Error(
                                'rest_invalid_menu_location',
                                __( 'Invalid menu location.' ),
                                array(
                                    'location' => $location,
                                )
                            );
                        }
                    }
Home | Imprint | This part of the site doesn't use cookies.