Automattic\WooCommerce\Internal\StockNotifications\Emails

EmailActionController::validate_and_maybe_process_request │ public │ WC 1.0

Checks request parameters and processes the notification based on the action type.

Метод класса: EmailActionController{}

Хуков нет.

Возвращает

void. Ничего (null).

Использование

$EmailActionController = new EmailActionController();
$EmailActionController->validate_and_maybe_process_request( $notification_id, $email_link_action_key, $action ): void;
$notification_id(int) (обязательный)
The ID of the notification to process.
$email_link_action_key(строка) (обязательный)
The action key from the email link.
$action(строка)
The action to perform: 'verify' or 'unsubscribe'.
По умолчанию: ''

Код EmailActionController::validate_and_maybe_process_request() WC 11.2.2

public function validate_and_maybe_process_request( int $notification_id, string $email_link_action_key, string $action = '' ): void {
	if ( empty( $email_link_action_key ) || empty( $notification_id ) ) {
		return;
	}

	// An empty $action means the caller omitted the routing argument — a
	// programming error, not a mis-routed email. Return silently so the
	// debug branch in the switch is reserved for genuinely-unknown
	// tokens arriving in the wild.
	if ( '' === $action ) {
		return;
	}

	$notification = $this->get_notification_to_be_processed( $notification_id );

	if ( ! $notification ) {
		return;
	}

	switch ( $action ) {
		case self::ACTION_VERIFY:
			$this->process_verification_action( $notification, $email_link_action_key );
			break;
		case self::ACTION_UNSUBSCRIBE:
			$this->process_unsubscribe_action( $notification, $email_link_action_key );
			break;
		default:
			// Unknown action — silently drop in production, log in debug so
			// mis-routed email links surface during alpha testing rather
			// than no-op'ing invisibly.
			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
				wc_get_logger()->debug(
					sprintf(
						'Unknown email_link_action "%s" for notification %d',
						$action,
						$notification->get_id()
					),
					array( 'source' => 'stock-notifications' )
				);
			}
			break;
	}//end switch
}