Automattic\WooCommerce\Admin\API

Notes::maybe_add_nonce_to_url()privateWC 1.0

Maybe add a nonce to a URL.

Method of the class: Notes{}

No Hooks.

Return

String. A fully formed URL.

Usage

// private - for code of main (parent) class only
$result = $this->maybe_add_nonce_to_url( $url, $action, $name ) : string;
$url(string) (required)
The URL needing a nonce.
$action(string)
The nonce action.
Default: ''
$name(string)
The nonce name.
Default: ''

Notes::maybe_add_nonce_to_url() code WC 9.7.1

private function maybe_add_nonce_to_url( string $url, string $action = '', string $name = '' ) : string {
	if ( empty( $action ) ) {
		return $url;
	}

	if ( empty( $name ) ) {
		// Default parameter name.
		$name = '_wpnonce';
	}

	return add_query_arg( $name, wp_create_nonce( $action ), $url );
}