A WordPress-centric search engine for devs and theme authors



wp_is_authorize_application_password_request_valid ›

Since5.6.0
Deprecatedn/a
wp_is_authorize_application_password_request_valid ( $request, $user )
Parameters: (2)
  • (array) $request { The array of request data. All arguments are optional and may be empty. @type string $app_name The suggested name of the application. @type string $success_url The url the user will be redirected to after approving the application. @type string $reject_url The url the user will be redirected to after rejecting the application. }
    Required: Yes
  • (WP_User) $user The user authorizing the application.
    Required: Yes
Returns:
  • (bool|WP_Error) True if the request is valid, a WP_Error object contains errors if not.
Defined at:
Codex:

Checks if the Authorize Application Password request is valid.



Source

function wp_is_authorize_application_password_request_valid( $request, $user ) {
	$error = new WP_Error();

	if ( ! empty( $request['success_url'] ) ) {
		$scheme = wp_parse_url( $request['success_url'], PHP_URL_SCHEME );

		if ( 'http' === $scheme ) {
			$error->add(
				'invalid_redirect_scheme',
				__( 'The success url must be served over a secure connection.' )
			);
		}
	}

	if ( ! empty( $request['reject_url'] ) ) {
		$scheme = wp_parse_url( $request['reject_url'], PHP_URL_SCHEME );

		if ( 'http' === $scheme ) {
			$error->add(
				'invalid_redirect_scheme',
				__( 'The rejection url must be served over a secure connection.' )
			);
		}
	}

	/**
	 * Fires before application password errors are returned.
	 *
	 * @since 5.6.0
	 *
	 * @param WP_Error $error   The error object.
	 * @param array    $request The array of request data.
	 * @param WP_User  $user    The user authorizing the application.
	 */
	do_action( 'wp_authorize_application_password_request_errors', $error, $request, $user );

	if ( $error->has_errors() ) {
		return $error;
	}

	return true;
}