From fc9ca6fe60ffbf99e5d06acddabaa1cc39880dce Mon Sep 17 00:00:00 2001 From: "Alex P." Date: Tue, 15 Jul 2025 20:07:26 +0300 Subject: [PATCH] Remove unneeded translations --- .../src/Endpoint/OrderEndpoint.php | 6 ++-- .../src/Endpoint/WebhookEndpoint.php | 30 +++++-------------- .../src/Entity/AuthorizationStatus.php | 3 +- .../src/Entity/OrderStatus.php | 3 +- .../src/Entity/PayerTaxInfo.php | 3 +- .../src/Entity/PaymentToken.php | 4 +-- .../src/Factory/AmountFactory.php | 6 ++-- .../src/Factory/AuthorizationFactory.php | 8 ++--- .../src/Factory/CaptureFactory.php | 2 +- .../src/Factory/ItemFactory.php | 12 ++------ .../src/Factory/OrderFactory.php | 4 +-- .../src/Factory/PaymentTokenFactory.php | 4 +-- .../src/Factory/PlanFactory.php | 16 +++------- .../src/Factory/ProductFactory.php | 8 ++--- .../src/Factory/PurchaseUnitFactory.php | 4 +-- .../src/Factory/RefundFactory.php | 2 +- .../src/Factory/ReturnUrlFactory.php | 8 ++--- .../src/Factory/ShippingFactory.php | 8 ++--- .../src/Factory/WebhookEventFactory.php | 8 ++--- .../src/Factory/WebhookFactory.php | 12 ++------ .../src/Endpoint/ApproveOrderEndpoint.php | 4 +-- .../Endpoint/ApproveSubscriptionEndpoint.php | 4 +-- .../ppcp-button/src/Endpoint/RequestData.php | 4 +-- 23 files changed, 43 insertions(+), 120 deletions(-) diff --git a/modules/ppcp-api-client/src/Endpoint/OrderEndpoint.php b/modules/ppcp-api-client/src/Endpoint/OrderEndpoint.php index cb37eeb71..7c62ef1a9 100644 --- a/modules/ppcp-api-client/src/Endpoint/OrderEndpoint.php +++ b/modules/ppcp-api-client/src/Endpoint/OrderEndpoint.php @@ -444,9 +444,7 @@ class OrderEndpoint { } $response = $this->request( $url, $args ); if ( is_wp_error( $response ) ) { - $error = new RuntimeException( - __( 'Could not retrieve order.', 'woocommerce-paypal-payments' ) - ); + $error = new RuntimeException( 'Could not retrieve order.' ); $this->logger->warning( $error->getMessage() ); throw $error; @@ -456,7 +454,7 @@ class OrderEndpoint { if ( 404 === $status_code || empty( $response['body'] ) ) { $error = new RuntimeException( - __( 'Could not retrieve order.', 'woocommerce-paypal-payments' ), + 'Could not retrieve order.', 404 ); $this->logger->warning( diff --git a/modules/ppcp-api-client/src/Endpoint/WebhookEndpoint.php b/modules/ppcp-api-client/src/Endpoint/WebhookEndpoint.php index 3df4c3def..1156dfd86 100644 --- a/modules/ppcp-api-client/src/Endpoint/WebhookEndpoint.php +++ b/modules/ppcp-api-client/src/Endpoint/WebhookEndpoint.php @@ -113,9 +113,7 @@ class WebhookEndpoint { $response = $this->request( $url, $args ); if ( is_wp_error( $response ) ) { - throw new RuntimeException( - __( 'Not able to create a webhook.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'Not able to create a webhook.' ); } $json = json_decode( $response['body'] ); @@ -151,9 +149,7 @@ class WebhookEndpoint { $response = $this->request( $url, $args ); if ( is_wp_error( $response ) ) { - throw new RuntimeException( - __( 'Not able to load webhooks list.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'Not able to load webhooks list.' ); } $json = json_decode( $response['body'] ); @@ -195,9 +191,7 @@ class WebhookEndpoint { $response = $this->request( $url, $args ); if ( $response instanceof WP_Error ) { - throw new RuntimeException( - __( 'Not able to delete the webhook.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'Not able to delete the webhook.' ); } $status_code = (int) wp_remote_retrieve_response_code( $response ); @@ -250,9 +244,7 @@ class WebhookEndpoint { $response = $this->request( $url, $args ); if ( is_wp_error( $response ) ) { - throw new RuntimeException( - __( 'Not able to simulate webhook.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'Not able to simulate webhook.' ); } $json = json_decode( $response['body'] ); $status_code = (int) wp_remote_retrieve_response_code( $response ); @@ -312,9 +304,7 @@ class WebhookEndpoint { ); $response = $this->request( $url, $args ); if ( is_wp_error( $response ) ) { - $error = new RuntimeException( - __( 'Not able to verify webhook event.', 'woocommerce-paypal-payments' ) - ); + $error = new RuntimeException( 'Not able to verify webhook event.' ); $this->logger->log( 'warning', $error->getMessage(), @@ -340,9 +330,7 @@ class WebhookEndpoint { public function verify_current_request_for_webhook( Webhook $webhook ): bool { if ( ! $webhook->id() ) { - $error = new RuntimeException( - __( 'Not a valid webhook to verify.', 'woocommerce-paypal-payments' ) - ); + $error = new RuntimeException( 'Not a valid webhook to verify.' ); $this->logger->log( 'warning', $error->getMessage(), array( 'webhook' => $webhook ) ); throw $error; } @@ -369,11 +357,7 @@ class WebhookEndpoint { $error = new RuntimeException( sprintf( - // translators: %s is the headers key. - __( - 'Not a valid webhook event. Header %s is missing', - 'woocommerce-paypal-payments' - ), + 'Not a valid webhook event. Header %s is missing', $key ) ); diff --git a/modules/ppcp-api-client/src/Entity/AuthorizationStatus.php b/modules/ppcp-api-client/src/Entity/AuthorizationStatus.php index 1275cd878..d771995ca 100644 --- a/modules/ppcp-api-client/src/Entity/AuthorizationStatus.php +++ b/modules/ppcp-api-client/src/Entity/AuthorizationStatus.php @@ -62,8 +62,7 @@ class AuthorizationStatus { if ( ! in_array( $status, self::VALID_STATUS, true ) ) { throw new RuntimeException( sprintf( - // translators: %s is the current status. - __( '%s is not a valid status', 'woocommerce-paypal-payments' ), + '%s is not a valid status', $status ) ); diff --git a/modules/ppcp-api-client/src/Entity/OrderStatus.php b/modules/ppcp-api-client/src/Entity/OrderStatus.php index 387830dd3..92106417e 100644 --- a/modules/ppcp-api-client/src/Entity/OrderStatus.php +++ b/modules/ppcp-api-client/src/Entity/OrderStatus.php @@ -51,8 +51,7 @@ class OrderStatus { if ( ! in_array( $status, self::VALID_STATUS, true ) ) { throw new RuntimeException( sprintf( - // translators: %s is the current status. - __( '%s is not a valid status', 'woocommerce-paypal-payments' ), + '%s is not a valid status', $status ) ); diff --git a/modules/ppcp-api-client/src/Entity/PayerTaxInfo.php b/modules/ppcp-api-client/src/Entity/PayerTaxInfo.php index cb3bff074..e3917ba30 100644 --- a/modules/ppcp-api-client/src/Entity/PayerTaxInfo.php +++ b/modules/ppcp-api-client/src/Entity/PayerTaxInfo.php @@ -51,8 +51,7 @@ class PayerTaxInfo { if ( ! in_array( $type, self::VALID_TYPES, true ) ) { throw new RuntimeException( sprintf( - // translators: %s is the current type. - __( '%s is not a valid tax type.', 'woocommerce-paypal-payments' ), + '%s is not a valid tax type.', $type ) ); diff --git a/modules/ppcp-api-client/src/Entity/PaymentToken.php b/modules/ppcp-api-client/src/Entity/PaymentToken.php index 1598d65c7..65796d6b8 100644 --- a/modules/ppcp-api-client/src/Entity/PaymentToken.php +++ b/modules/ppcp-api-client/src/Entity/PaymentToken.php @@ -50,9 +50,7 @@ class PaymentToken { */ public function __construct( string $id, stdClass $source, string $type = self::TYPE_PAYMENT_METHOD_TOKEN ) { if ( ! in_array( $type, self::get_valid_types(), true ) ) { - throw new RuntimeException( - __( 'Not a valid payment source type.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'Not a valid payment source type.' ); } $this->id = $id; $this->type = $type; diff --git a/modules/ppcp-api-client/src/Factory/AmountFactory.php b/modules/ppcp-api-client/src/Factory/AmountFactory.php index fb4fd0785..fdcdfd8a9 100644 --- a/modules/ppcp-api-client/src/Factory/AmountFactory.php +++ b/modules/ppcp-api-client/src/Factory/AmountFactory.php @@ -245,8 +245,7 @@ class AmountFactory { if ( ! isset( $item->value ) || ! is_numeric( $item->value ) ) { throw new RuntimeException( sprintf( - // translators: %s is the current breakdown key. - __( 'No value given for breakdown %s', 'woocommerce-paypal-payments' ), + 'No value given for breakdown %s', $key ) ); @@ -254,8 +253,7 @@ class AmountFactory { if ( ! isset( $item->currency_code ) ) { throw new RuntimeException( sprintf( - // translators: %s is the current breakdown key. - __( 'No currency given for breakdown %s', 'woocommerce-paypal-payments' ), + 'No currency given for breakdown %s', $key ) ); diff --git a/modules/ppcp-api-client/src/Factory/AuthorizationFactory.php b/modules/ppcp-api-client/src/Factory/AuthorizationFactory.php index d16aee2fb..3b6d32194 100644 --- a/modules/ppcp-api-client/src/Factory/AuthorizationFactory.php +++ b/modules/ppcp-api-client/src/Factory/AuthorizationFactory.php @@ -45,15 +45,11 @@ class AuthorizationFactory { */ public function from_paypal_response( \stdClass $data ): Authorization { if ( ! isset( $data->id ) ) { - throw new RuntimeException( - __( 'Does not contain an id.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'Does not contain an id.' ); } if ( ! isset( $data->status ) ) { - throw new RuntimeException( - __( 'Does not contain status.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'Does not contain status.' ); } $reason = $data->status_details->reason ?? null; diff --git a/modules/ppcp-api-client/src/Factory/CaptureFactory.php b/modules/ppcp-api-client/src/Factory/CaptureFactory.php index e7c5be7d5..7f479f30e 100644 --- a/modules/ppcp-api-client/src/Factory/CaptureFactory.php +++ b/modules/ppcp-api-client/src/Factory/CaptureFactory.php @@ -78,7 +78,7 @@ class CaptureFactory { $amount = $this->amount_factory->from_paypal_response( $data->amount ); if ( null === $amount ) { - throw new RuntimeException( __( 'Invalid capture amount data.', 'woocommerce-paypal-payments' ) ); + throw new RuntimeException( 'Invalid capture amount data.' ); } return new Capture( diff --git a/modules/ppcp-api-client/src/Factory/ItemFactory.php b/modules/ppcp-api-client/src/Factory/ItemFactory.php index 3861b4c9d..0d9250c8f 100644 --- a/modules/ppcp-api-client/src/Factory/ItemFactory.php +++ b/modules/ppcp-api-client/src/Factory/ItemFactory.php @@ -179,19 +179,13 @@ class ItemFactory { */ public function from_paypal_response( \stdClass $data ): Item { if ( ! isset( $data->name ) ) { - throw new RuntimeException( - __( 'No name for item given', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No name for item given' ); } if ( ! isset( $data->quantity ) || ! is_numeric( $data->quantity ) ) { - throw new RuntimeException( - __( 'No quantity for item given', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No quantity for item given' ); } if ( ! isset( $data->unit_amount->value ) || ! isset( $data->unit_amount->currency_code ) ) { - throw new RuntimeException( - __( 'No money values for item given', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No money values for item given' ); } $unit_amount = new Money( (float) $data->unit_amount->value, $data->unit_amount->currency_code ); diff --git a/modules/ppcp-api-client/src/Factory/OrderFactory.php b/modules/ppcp-api-client/src/Factory/OrderFactory.php index 8846216ce..5fc910932 100644 --- a/modules/ppcp-api-client/src/Factory/OrderFactory.php +++ b/modules/ppcp-api-client/src/Factory/OrderFactory.php @@ -114,9 +114,7 @@ class OrderFactory { */ private function validate_order_id( \stdClass $order_data ): void { if ( ! isset( $order_data->id ) ) { - throw new RuntimeException( - __( 'Order does not contain an id.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'Order does not contain an id.' ); } } diff --git a/modules/ppcp-api-client/src/Factory/PaymentTokenFactory.php b/modules/ppcp-api-client/src/Factory/PaymentTokenFactory.php index e1bbbc7ed..114245ae4 100644 --- a/modules/ppcp-api-client/src/Factory/PaymentTokenFactory.php +++ b/modules/ppcp-api-client/src/Factory/PaymentTokenFactory.php @@ -27,9 +27,7 @@ class PaymentTokenFactory { */ public function from_paypal_response( $data ): PaymentToken { if ( ! isset( $data->id ) ) { - throw new RuntimeException( - __( 'No id for payment token given', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No id for payment token given' ); } return new PaymentToken( diff --git a/modules/ppcp-api-client/src/Factory/PlanFactory.php b/modules/ppcp-api-client/src/Factory/PlanFactory.php index bbf332d10..9580696b1 100644 --- a/modules/ppcp-api-client/src/Factory/PlanFactory.php +++ b/modules/ppcp-api-client/src/Factory/PlanFactory.php @@ -57,24 +57,16 @@ class PlanFactory { */ public function from_paypal_response( stdClass $data ): Plan { if ( ! isset( $data->id ) ) { - throw new RuntimeException( - __( 'No id for given plan', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No id for given plan' ); } if ( ! isset( $data->name ) ) { - throw new RuntimeException( - __( 'No name for plan given', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No name for plan given' ); } if ( ! isset( $data->product_id ) ) { - throw new RuntimeException( - __( 'No product id for given plan', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No product id for given plan' ); } if ( ! isset( $data->billing_cycles ) ) { - throw new RuntimeException( - __( 'No billing cycles for given plan', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No billing cycles for given plan' ); } $billing_cycles = array(); diff --git a/modules/ppcp-api-client/src/Factory/ProductFactory.php b/modules/ppcp-api-client/src/Factory/ProductFactory.php index a34602a21..85eeb98cb 100644 --- a/modules/ppcp-api-client/src/Factory/ProductFactory.php +++ b/modules/ppcp-api-client/src/Factory/ProductFactory.php @@ -28,14 +28,10 @@ class ProductFactory { */ public function from_paypal_response( stdClass $data ): Product { if ( ! isset( $data->id ) ) { - throw new RuntimeException( - __( 'No id for product given', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No id for product given' ); } if ( ! isset( $data->name ) ) { - throw new RuntimeException( - __( 'No name for product given', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No name for product given' ); } return new Product( diff --git a/modules/ppcp-api-client/src/Factory/PurchaseUnitFactory.php b/modules/ppcp-api-client/src/Factory/PurchaseUnitFactory.php index 6cbcc4f68..e0be1954d 100644 --- a/modules/ppcp-api-client/src/Factory/PurchaseUnitFactory.php +++ b/modules/ppcp-api-client/src/Factory/PurchaseUnitFactory.php @@ -224,9 +224,7 @@ class PurchaseUnitFactory { */ public function from_paypal_response( \stdClass $data ): ?PurchaseUnit { if ( ! isset( $data->reference_id ) || ! is_string( $data->reference_id ) ) { - throw new RuntimeException( - __( 'No reference ID given.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No reference ID given.' ); } $amount_data = $data->amount ?? null; diff --git a/modules/ppcp-api-client/src/Factory/RefundFactory.php b/modules/ppcp-api-client/src/Factory/RefundFactory.php index 6911b490a..e9cbbe542 100644 --- a/modules/ppcp-api-client/src/Factory/RefundFactory.php +++ b/modules/ppcp-api-client/src/Factory/RefundFactory.php @@ -77,7 +77,7 @@ class RefundFactory { $amount = $this->amount_factory->from_paypal_response( $data->amount ); if ( null === $amount ) { - throw new RuntimeException( __( 'Invalid refund amount data.', 'woocommerce-paypal-payments' ) ); + throw new RuntimeException( 'Invalid refund amount data.' ); } return new Refund( diff --git a/modules/ppcp-api-client/src/Factory/ReturnUrlFactory.php b/modules/ppcp-api-client/src/Factory/ReturnUrlFactory.php index 9eafa8ba5..cba03352f 100644 --- a/modules/ppcp-api-client/src/Factory/ReturnUrlFactory.php +++ b/modules/ppcp-api-client/src/Factory/ReturnUrlFactory.php @@ -36,9 +36,7 @@ class ReturnUrlFactory { } } - throw new RuntimeException( - __( 'Product URL is required but not provided in the request data.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'Product URL is required but not provided in the request data.' ); case 'pay-now': if ( ! empty( $request_data['order_id'] ) ) { $order = wc_get_order( $request_data['order_id'] ); @@ -47,9 +45,7 @@ class ReturnUrlFactory { } } - throw new RuntimeException( - __( 'The order ID is invalid.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'The order ID is invalid.' ); default: return wc_get_checkout_url(); } diff --git a/modules/ppcp-api-client/src/Factory/ShippingFactory.php b/modules/ppcp-api-client/src/Factory/ShippingFactory.php index 610c27e81..36779fd2c 100644 --- a/modules/ppcp-api-client/src/Factory/ShippingFactory.php +++ b/modules/ppcp-api-client/src/Factory/ShippingFactory.php @@ -97,14 +97,10 @@ class ShippingFactory { */ public function from_paypal_response( \stdClass $data ): Shipping { if ( ! isset( $data->name->full_name ) ) { - throw new RuntimeException( - __( 'No name was given for shipping.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No name was given for shipping.' ); } if ( ! isset( $data->address ) ) { - throw new RuntimeException( - __( 'No address was given for shipping.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No address was given for shipping.' ); } $contact_phone = null; $contact_email = null; diff --git a/modules/ppcp-api-client/src/Factory/WebhookEventFactory.php b/modules/ppcp-api-client/src/Factory/WebhookEventFactory.php index 30db85516..df256b2df 100644 --- a/modules/ppcp-api-client/src/Factory/WebhookEventFactory.php +++ b/modules/ppcp-api-client/src/Factory/WebhookEventFactory.php @@ -40,14 +40,10 @@ class WebhookEventFactory { */ public function from_paypal_response( $data ): WebhookEvent { if ( ! isset( $data->id ) ) { - throw new RuntimeException( - __( 'ID for webhook event not found.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'ID for webhook event not found.' ); } if ( ! isset( $data->event_type ) ) { - throw new RuntimeException( - __( 'Event type for webhook event not found.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'Event type for webhook event not found.' ); } $create_time = ( isset( $data->create_time ) ) ? diff --git a/modules/ppcp-api-client/src/Factory/WebhookFactory.php b/modules/ppcp-api-client/src/Factory/WebhookFactory.php index 372817458..4a53efc92 100644 --- a/modules/ppcp-api-client/src/Factory/WebhookFactory.php +++ b/modules/ppcp-api-client/src/Factory/WebhookFactory.php @@ -59,19 +59,13 @@ class WebhookFactory { */ public function from_paypal_response( $data ): Webhook { if ( ! isset( $data->id ) ) { - throw new RuntimeException( - __( 'No id for webhook given.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No id for webhook given.' ); } if ( ! isset( $data->url ) ) { - throw new RuntimeException( - __( 'No URL for webhook given.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No URL for webhook given.' ); } if ( ! isset( $data->event_types ) ) { - throw new RuntimeException( - __( 'No event types for webhook given.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No event types for webhook given.' ); } return new Webhook( diff --git a/modules/ppcp-button/src/Endpoint/ApproveOrderEndpoint.php b/modules/ppcp-button/src/Endpoint/ApproveOrderEndpoint.php index 8749fb4ba..f4ff90218 100644 --- a/modules/ppcp-button/src/Endpoint/ApproveOrderEndpoint.php +++ b/modules/ppcp-button/src/Endpoint/ApproveOrderEndpoint.php @@ -173,9 +173,7 @@ class ApproveOrderEndpoint implements EndpointInterface { try { $data = $this->request_data->read_request( self::nonce() ); if ( ! isset( $data['order_id'] ) ) { - throw new RuntimeException( - __( 'No order id given', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No order id given' ); } $order = $this->api_endpoint->order( $data['order_id'] ); diff --git a/modules/ppcp-button/src/Endpoint/ApproveSubscriptionEndpoint.php b/modules/ppcp-button/src/Endpoint/ApproveSubscriptionEndpoint.php index d89a0a1af..ba737d328 100644 --- a/modules/ppcp-button/src/Endpoint/ApproveSubscriptionEndpoint.php +++ b/modules/ppcp-button/src/Endpoint/ApproveSubscriptionEndpoint.php @@ -111,9 +111,7 @@ class ApproveSubscriptionEndpoint implements EndpointInterface { public function handle_request(): bool { $data = $this->request_data->read_request( $this->nonce() ); if ( ! isset( $data['order_id'] ) ) { - throw new RuntimeException( - __( 'No order id given', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'No order id given' ); } $order = $this->order_endpoint->order( $data['order_id'] ); diff --git a/modules/ppcp-button/src/Endpoint/RequestData.php b/modules/ppcp-button/src/Endpoint/RequestData.php index a6716e77c..465700979 100644 --- a/modules/ppcp-button/src/Endpoint/RequestData.php +++ b/modules/ppcp-button/src/Endpoint/RequestData.php @@ -47,9 +47,7 @@ class RequestData { || ! wp_verify_nonce( $json['nonce'], $nonce ) ) { remove_filter( 'nonce_user_logged_out', array( $this, 'nonce_fix' ), 100 ); - throw new RuntimeException( - __( 'Could not validate nonce.', 'woocommerce-paypal-payments' ) - ); + throw new RuntimeException( 'Could not validate nonce.' ); } $this->dequeue_nonce_fix();