Automattic\WooCommerce\Internal\StockNotifications\Frontend
MyAccountEndpoint::get_action_url
Build the nonce-protected URL a row action link points at.
Same shape as the other My Account action links (cancel order, resend set-password): a GET back to the endpoint carrying the action, the id, and a scoped nonce.
Method of the class: MyAccountEndpoint{}
No Hooks.
Returns
string. The action URL.
Usage
$result = MyAccountEndpoint::get_action_url( $action, $notification_id, $page ): string;
- $action(string) (required)
- One of the
ACTION_*values. - $notification_id(int) (required)
- The notification id.
- $page(int)
- 1-indexed page the link is rendered on.
Default:1
MyAccountEndpoint::get_action_url() MyAccountEndpoint::get action url code WC 11.2.1
public static function get_action_url( string $action, int $notification_id, int $page = 1 ): string {
$args = array(
self::ACTION_FIELD => $action,
'notification_id' => $notification_id,
);
// Carried so the redirect afterwards returns the customer to the page they acted from.
if ( $page > 1 ) {
$args['notifications_page'] = $page;
}
$url = add_query_arg( $args, self::get_endpoint_url() );
return wp_nonce_url( $url, self::get_nonce_action( $action, $notification_id ) );
}