Remove unneeded translations

This commit is contained in:
Alex P. 2025-07-15 20:07:26 +03:00
parent 65d958254d
commit fc9ca6fe60
No known key found for this signature in database
GPG key ID: 68E4DCB139B18520
23 changed files with 43 additions and 120 deletions

View file

@ -444,9 +444,7 @@ class OrderEndpoint {
} }
$response = $this->request( $url, $args ); $response = $this->request( $url, $args );
if ( is_wp_error( $response ) ) { if ( is_wp_error( $response ) ) {
$error = new RuntimeException( $error = new RuntimeException( 'Could not retrieve order.' );
__( 'Could not retrieve order.', 'woocommerce-paypal-payments' )
);
$this->logger->warning( $error->getMessage() ); $this->logger->warning( $error->getMessage() );
throw $error; throw $error;
@ -456,7 +454,7 @@ class OrderEndpoint {
if ( 404 === $status_code || empty( $response['body'] ) ) { if ( 404 === $status_code || empty( $response['body'] ) ) {
$error = new RuntimeException( $error = new RuntimeException(
__( 'Could not retrieve order.', 'woocommerce-paypal-payments' ), 'Could not retrieve order.',
404 404
); );
$this->logger->warning( $this->logger->warning(

View file

@ -113,9 +113,7 @@ class WebhookEndpoint {
$response = $this->request( $url, $args ); $response = $this->request( $url, $args );
if ( is_wp_error( $response ) ) { if ( is_wp_error( $response ) ) {
throw new RuntimeException( throw new RuntimeException( 'Not able to create a webhook.' );
__( 'Not able to create a webhook.', 'woocommerce-paypal-payments' )
);
} }
$json = json_decode( $response['body'] ); $json = json_decode( $response['body'] );
@ -151,9 +149,7 @@ class WebhookEndpoint {
$response = $this->request( $url, $args ); $response = $this->request( $url, $args );
if ( is_wp_error( $response ) ) { if ( is_wp_error( $response ) ) {
throw new RuntimeException( throw new RuntimeException( 'Not able to load webhooks list.' );
__( 'Not able to load webhooks list.', 'woocommerce-paypal-payments' )
);
} }
$json = json_decode( $response['body'] ); $json = json_decode( $response['body'] );
@ -195,9 +191,7 @@ class WebhookEndpoint {
$response = $this->request( $url, $args ); $response = $this->request( $url, $args );
if ( $response instanceof WP_Error ) { if ( $response instanceof WP_Error ) {
throw new RuntimeException( throw new RuntimeException( 'Not able to delete the webhook.' );
__( 'Not able to delete the webhook.', 'woocommerce-paypal-payments' )
);
} }
$status_code = (int) wp_remote_retrieve_response_code( $response ); $status_code = (int) wp_remote_retrieve_response_code( $response );
@ -250,9 +244,7 @@ class WebhookEndpoint {
$response = $this->request( $url, $args ); $response = $this->request( $url, $args );
if ( is_wp_error( $response ) ) { if ( is_wp_error( $response ) ) {
throw new RuntimeException( throw new RuntimeException( 'Not able to simulate webhook.' );
__( 'Not able to simulate webhook.', 'woocommerce-paypal-payments' )
);
} }
$json = json_decode( $response['body'] ); $json = json_decode( $response['body'] );
$status_code = (int) wp_remote_retrieve_response_code( $response ); $status_code = (int) wp_remote_retrieve_response_code( $response );
@ -312,9 +304,7 @@ class WebhookEndpoint {
); );
$response = $this->request( $url, $args ); $response = $this->request( $url, $args );
if ( is_wp_error( $response ) ) { if ( is_wp_error( $response ) ) {
$error = new RuntimeException( $error = new RuntimeException( 'Not able to verify webhook event.' );
__( 'Not able to verify webhook event.', 'woocommerce-paypal-payments' )
);
$this->logger->log( $this->logger->log(
'warning', 'warning',
$error->getMessage(), $error->getMessage(),
@ -340,9 +330,7 @@ class WebhookEndpoint {
public function verify_current_request_for_webhook( Webhook $webhook ): bool { public function verify_current_request_for_webhook( Webhook $webhook ): bool {
if ( ! $webhook->id() ) { if ( ! $webhook->id() ) {
$error = new RuntimeException( $error = new RuntimeException( 'Not a valid webhook to verify.' );
__( 'Not a valid webhook to verify.', 'woocommerce-paypal-payments' )
);
$this->logger->log( 'warning', $error->getMessage(), array( 'webhook' => $webhook ) ); $this->logger->log( 'warning', $error->getMessage(), array( 'webhook' => $webhook ) );
throw $error; throw $error;
} }
@ -369,11 +357,7 @@ class WebhookEndpoint {
$error = new RuntimeException( $error = new RuntimeException(
sprintf( sprintf(
// translators: %s is the headers key. 'Not a valid webhook event. Header %s is missing',
__(
'Not a valid webhook event. Header %s is missing',
'woocommerce-paypal-payments'
),
$key $key
) )
); );

View file

@ -62,8 +62,7 @@ class AuthorizationStatus {
if ( ! in_array( $status, self::VALID_STATUS, true ) ) { if ( ! in_array( $status, self::VALID_STATUS, true ) ) {
throw new RuntimeException( throw new RuntimeException(
sprintf( sprintf(
// translators: %s is the current status. '%s is not a valid status',
__( '%s is not a valid status', 'woocommerce-paypal-payments' ),
$status $status
) )
); );

View file

@ -51,8 +51,7 @@ class OrderStatus {
if ( ! in_array( $status, self::VALID_STATUS, true ) ) { if ( ! in_array( $status, self::VALID_STATUS, true ) ) {
throw new RuntimeException( throw new RuntimeException(
sprintf( sprintf(
// translators: %s is the current status. '%s is not a valid status',
__( '%s is not a valid status', 'woocommerce-paypal-payments' ),
$status $status
) )
); );

View file

@ -51,8 +51,7 @@ class PayerTaxInfo {
if ( ! in_array( $type, self::VALID_TYPES, true ) ) { if ( ! in_array( $type, self::VALID_TYPES, true ) ) {
throw new RuntimeException( throw new RuntimeException(
sprintf( sprintf(
// translators: %s is the current type. '%s is not a valid tax type.',
__( '%s is not a valid tax type.', 'woocommerce-paypal-payments' ),
$type $type
) )
); );

View file

@ -50,9 +50,7 @@ class PaymentToken {
*/ */
public function __construct( string $id, stdClass $source, string $type = self::TYPE_PAYMENT_METHOD_TOKEN ) { public function __construct( string $id, stdClass $source, string $type = self::TYPE_PAYMENT_METHOD_TOKEN ) {
if ( ! in_array( $type, self::get_valid_types(), true ) ) { if ( ! in_array( $type, self::get_valid_types(), true ) ) {
throw new RuntimeException( throw new RuntimeException( 'Not a valid payment source type.' );
__( 'Not a valid payment source type.', 'woocommerce-paypal-payments' )
);
} }
$this->id = $id; $this->id = $id;
$this->type = $type; $this->type = $type;

View file

@ -245,8 +245,7 @@ class AmountFactory {
if ( ! isset( $item->value ) || ! is_numeric( $item->value ) ) { if ( ! isset( $item->value ) || ! is_numeric( $item->value ) ) {
throw new RuntimeException( throw new RuntimeException(
sprintf( sprintf(
// translators: %s is the current breakdown key. 'No value given for breakdown %s',
__( 'No value given for breakdown %s', 'woocommerce-paypal-payments' ),
$key $key
) )
); );
@ -254,8 +253,7 @@ class AmountFactory {
if ( ! isset( $item->currency_code ) ) { if ( ! isset( $item->currency_code ) ) {
throw new RuntimeException( throw new RuntimeException(
sprintf( sprintf(
// translators: %s is the current breakdown key. 'No currency given for breakdown %s',
__( 'No currency given for breakdown %s', 'woocommerce-paypal-payments' ),
$key $key
) )
); );

View file

@ -45,15 +45,11 @@ class AuthorizationFactory {
*/ */
public function from_paypal_response( \stdClass $data ): Authorization { public function from_paypal_response( \stdClass $data ): Authorization {
if ( ! isset( $data->id ) ) { if ( ! isset( $data->id ) ) {
throw new RuntimeException( throw new RuntimeException( 'Does not contain an id.' );
__( 'Does not contain an id.', 'woocommerce-paypal-payments' )
);
} }
if ( ! isset( $data->status ) ) { if ( ! isset( $data->status ) ) {
throw new RuntimeException( throw new RuntimeException( 'Does not contain status.' );
__( 'Does not contain status.', 'woocommerce-paypal-payments' )
);
} }
$reason = $data->status_details->reason ?? null; $reason = $data->status_details->reason ?? null;

View file

@ -78,7 +78,7 @@ class CaptureFactory {
$amount = $this->amount_factory->from_paypal_response( $data->amount ); $amount = $this->amount_factory->from_paypal_response( $data->amount );
if ( null === $amount ) { if ( null === $amount ) {
throw new RuntimeException( __( 'Invalid capture amount data.', 'woocommerce-paypal-payments' ) ); throw new RuntimeException( 'Invalid capture amount data.' );
} }
return new Capture( return new Capture(

View file

@ -179,19 +179,13 @@ class ItemFactory {
*/ */
public function from_paypal_response( \stdClass $data ): Item { public function from_paypal_response( \stdClass $data ): Item {
if ( ! isset( $data->name ) ) { if ( ! isset( $data->name ) ) {
throw new RuntimeException( throw new RuntimeException( 'No name for item given' );
__( 'No name for item given', 'woocommerce-paypal-payments' )
);
} }
if ( ! isset( $data->quantity ) || ! is_numeric( $data->quantity ) ) { if ( ! isset( $data->quantity ) || ! is_numeric( $data->quantity ) ) {
throw new RuntimeException( throw new RuntimeException( 'No quantity for item given' );
__( 'No quantity for item given', 'woocommerce-paypal-payments' )
);
} }
if ( ! isset( $data->unit_amount->value ) || ! isset( $data->unit_amount->currency_code ) ) { if ( ! isset( $data->unit_amount->value ) || ! isset( $data->unit_amount->currency_code ) ) {
throw new RuntimeException( throw new RuntimeException( 'No money values for item given' );
__( 'No money values for item given', 'woocommerce-paypal-payments' )
);
} }
$unit_amount = new Money( (float) $data->unit_amount->value, $data->unit_amount->currency_code ); $unit_amount = new Money( (float) $data->unit_amount->value, $data->unit_amount->currency_code );

View file

@ -114,9 +114,7 @@ class OrderFactory {
*/ */
private function validate_order_id( \stdClass $order_data ): void { private function validate_order_id( \stdClass $order_data ): void {
if ( ! isset( $order_data->id ) ) { if ( ! isset( $order_data->id ) ) {
throw new RuntimeException( throw new RuntimeException( 'Order does not contain an id.' );
__( 'Order does not contain an id.', 'woocommerce-paypal-payments' )
);
} }
} }

View file

@ -27,9 +27,7 @@ class PaymentTokenFactory {
*/ */
public function from_paypal_response( $data ): PaymentToken { public function from_paypal_response( $data ): PaymentToken {
if ( ! isset( $data->id ) ) { if ( ! isset( $data->id ) ) {
throw new RuntimeException( throw new RuntimeException( 'No id for payment token given' );
__( 'No id for payment token given', 'woocommerce-paypal-payments' )
);
} }
return new PaymentToken( return new PaymentToken(

View file

@ -57,24 +57,16 @@ class PlanFactory {
*/ */
public function from_paypal_response( stdClass $data ): Plan { public function from_paypal_response( stdClass $data ): Plan {
if ( ! isset( $data->id ) ) { if ( ! isset( $data->id ) ) {
throw new RuntimeException( throw new RuntimeException( 'No id for given plan' );
__( 'No id for given plan', 'woocommerce-paypal-payments' )
);
} }
if ( ! isset( $data->name ) ) { if ( ! isset( $data->name ) ) {
throw new RuntimeException( throw new RuntimeException( 'No name for plan given' );
__( 'No name for plan given', 'woocommerce-paypal-payments' )
);
} }
if ( ! isset( $data->product_id ) ) { if ( ! isset( $data->product_id ) ) {
throw new RuntimeException( throw new RuntimeException( 'No product id for given plan' );
__( 'No product id for given plan', 'woocommerce-paypal-payments' )
);
} }
if ( ! isset( $data->billing_cycles ) ) { if ( ! isset( $data->billing_cycles ) ) {
throw new RuntimeException( throw new RuntimeException( 'No billing cycles for given plan' );
__( 'No billing cycles for given plan', 'woocommerce-paypal-payments' )
);
} }
$billing_cycles = array(); $billing_cycles = array();

View file

@ -28,14 +28,10 @@ class ProductFactory {
*/ */
public function from_paypal_response( stdClass $data ): Product { public function from_paypal_response( stdClass $data ): Product {
if ( ! isset( $data->id ) ) { if ( ! isset( $data->id ) ) {
throw new RuntimeException( throw new RuntimeException( 'No id for product given' );
__( 'No id for product given', 'woocommerce-paypal-payments' )
);
} }
if ( ! isset( $data->name ) ) { if ( ! isset( $data->name ) ) {
throw new RuntimeException( throw new RuntimeException( 'No name for product given' );
__( 'No name for product given', 'woocommerce-paypal-payments' )
);
} }
return new Product( return new Product(

View file

@ -224,9 +224,7 @@ class PurchaseUnitFactory {
*/ */
public function from_paypal_response( \stdClass $data ): ?PurchaseUnit { public function from_paypal_response( \stdClass $data ): ?PurchaseUnit {
if ( ! isset( $data->reference_id ) || ! is_string( $data->reference_id ) ) { if ( ! isset( $data->reference_id ) || ! is_string( $data->reference_id ) ) {
throw new RuntimeException( throw new RuntimeException( 'No reference ID given.' );
__( 'No reference ID given.', 'woocommerce-paypal-payments' )
);
} }
$amount_data = $data->amount ?? null; $amount_data = $data->amount ?? null;

View file

@ -77,7 +77,7 @@ class RefundFactory {
$amount = $this->amount_factory->from_paypal_response( $data->amount ); $amount = $this->amount_factory->from_paypal_response( $data->amount );
if ( null === $amount ) { if ( null === $amount ) {
throw new RuntimeException( __( 'Invalid refund amount data.', 'woocommerce-paypal-payments' ) ); throw new RuntimeException( 'Invalid refund amount data.' );
} }
return new Refund( return new Refund(

View file

@ -36,9 +36,7 @@ class ReturnUrlFactory {
} }
} }
throw new RuntimeException( throw new RuntimeException( 'Product URL is required but not provided in the request data.' );
__( 'Product URL is required but not provided in the request data.', 'woocommerce-paypal-payments' )
);
case 'pay-now': case 'pay-now':
if ( ! empty( $request_data['order_id'] ) ) { if ( ! empty( $request_data['order_id'] ) ) {
$order = wc_get_order( $request_data['order_id'] ); $order = wc_get_order( $request_data['order_id'] );
@ -47,9 +45,7 @@ class ReturnUrlFactory {
} }
} }
throw new RuntimeException( throw new RuntimeException( 'The order ID is invalid.' );
__( 'The order ID is invalid.', 'woocommerce-paypal-payments' )
);
default: default:
return wc_get_checkout_url(); return wc_get_checkout_url();
} }

View file

@ -97,14 +97,10 @@ class ShippingFactory {
*/ */
public function from_paypal_response( \stdClass $data ): Shipping { public function from_paypal_response( \stdClass $data ): Shipping {
if ( ! isset( $data->name->full_name ) ) { if ( ! isset( $data->name->full_name ) ) {
throw new RuntimeException( throw new RuntimeException( 'No name was given for shipping.' );
__( 'No name was given for shipping.', 'woocommerce-paypal-payments' )
);
} }
if ( ! isset( $data->address ) ) { if ( ! isset( $data->address ) ) {
throw new RuntimeException( throw new RuntimeException( 'No address was given for shipping.' );
__( 'No address was given for shipping.', 'woocommerce-paypal-payments' )
);
} }
$contact_phone = null; $contact_phone = null;
$contact_email = null; $contact_email = null;

View file

@ -40,14 +40,10 @@ class WebhookEventFactory {
*/ */
public function from_paypal_response( $data ): WebhookEvent { public function from_paypal_response( $data ): WebhookEvent {
if ( ! isset( $data->id ) ) { if ( ! isset( $data->id ) ) {
throw new RuntimeException( throw new RuntimeException( 'ID for webhook event not found.' );
__( 'ID for webhook event not found.', 'woocommerce-paypal-payments' )
);
} }
if ( ! isset( $data->event_type ) ) { if ( ! isset( $data->event_type ) ) {
throw new RuntimeException( throw new RuntimeException( 'Event type for webhook event not found.' );
__( 'Event type for webhook event not found.', 'woocommerce-paypal-payments' )
);
} }
$create_time = ( isset( $data->create_time ) ) ? $create_time = ( isset( $data->create_time ) ) ?

View file

@ -59,19 +59,13 @@ class WebhookFactory {
*/ */
public function from_paypal_response( $data ): Webhook { public function from_paypal_response( $data ): Webhook {
if ( ! isset( $data->id ) ) { if ( ! isset( $data->id ) ) {
throw new RuntimeException( throw new RuntimeException( 'No id for webhook given.' );
__( 'No id for webhook given.', 'woocommerce-paypal-payments' )
);
} }
if ( ! isset( $data->url ) ) { if ( ! isset( $data->url ) ) {
throw new RuntimeException( throw new RuntimeException( 'No URL for webhook given.' );
__( 'No URL for webhook given.', 'woocommerce-paypal-payments' )
);
} }
if ( ! isset( $data->event_types ) ) { if ( ! isset( $data->event_types ) ) {
throw new RuntimeException( throw new RuntimeException( 'No event types for webhook given.' );
__( 'No event types for webhook given.', 'woocommerce-paypal-payments' )
);
} }
return new Webhook( return new Webhook(

View file

@ -173,9 +173,7 @@ class ApproveOrderEndpoint implements EndpointInterface {
try { try {
$data = $this->request_data->read_request( self::nonce() ); $data = $this->request_data->read_request( self::nonce() );
if ( ! isset( $data['order_id'] ) ) { if ( ! isset( $data['order_id'] ) ) {
throw new RuntimeException( throw new RuntimeException( 'No order id given' );
__( 'No order id given', 'woocommerce-paypal-payments' )
);
} }
$order = $this->api_endpoint->order( $data['order_id'] ); $order = $this->api_endpoint->order( $data['order_id'] );

View file

@ -111,9 +111,7 @@ class ApproveSubscriptionEndpoint implements EndpointInterface {
public function handle_request(): bool { public function handle_request(): bool {
$data = $this->request_data->read_request( $this->nonce() ); $data = $this->request_data->read_request( $this->nonce() );
if ( ! isset( $data['order_id'] ) ) { if ( ! isset( $data['order_id'] ) ) {
throw new RuntimeException( throw new RuntimeException( 'No order id given' );
__( 'No order id given', 'woocommerce-paypal-payments' )
);
} }
$order = $this->order_endpoint->order( $data['order_id'] ); $order = $this->order_endpoint->order( $data['order_id'] );

View file

@ -47,9 +47,7 @@ class RequestData {
|| ! wp_verify_nonce( $json['nonce'], $nonce ) || ! wp_verify_nonce( $json['nonce'], $nonce )
) { ) {
remove_filter( 'nonce_user_logged_out', array( $this, 'nonce_fix' ), 100 ); remove_filter( 'nonce_user_logged_out', array( $this, 'nonce_fix' ), 100 );
throw new RuntimeException( throw new RuntimeException( 'Could not validate nonce.' );
__( 'Could not validate nonce.', 'woocommerce-paypal-payments' )
);
} }
$this->dequeue_nonce_fix(); $this->dequeue_nonce_fix();