Automattic\WooCommerce\Admin\API
Notes::maybe_add_nonce_to_url
Maybe add a nonce to a URL.
Method of the class: Notes{}
No Hooks.
Returns
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() Notes::maybe add nonce to url code WC 10.4.3
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 );
}