From 11ddb327773b932a4264d18daca56df23f2f64c7 Mon Sep 17 00:00:00 2001 From: Remy Chauveau Date: Tue, 17 Dec 2024 00:17:48 +0100 Subject: [PATCH] Comply to WP plugin guide line --- .github/workflows/buildzip.yml | 4 +- README.md | 6 +-- includes/api/admin-refund.php | 4 +- includes/api/admin-save-wallet.php | 4 +- includes/controllers/Orders.php | 6 +-- includes/controllers/Refund.php | 4 +- includes/controllers/i18n.php | 50 ++++++++--------- .../gateway/xprcheckout-gateway.php | 54 +++++++++---------- xprcheckout.php | 22 ++++---- 9 files changed, 77 insertions(+), 77 deletions(-) diff --git a/.github/workflows/buildzip.yml b/.github/workflows/buildzip.yml index e3953de..db707d4 100644 --- a/.github/workflows/buildzip.yml +++ b/.github/workflows/buildzip.yml @@ -28,7 +28,7 @@ jobs: uses: thedoctor0/zip-release@0.7.1 with: type: 'zip' - filename: 'xprcheckout_gateway.zip' + filename: 'xprcheckout_webauth_gateway.zip' directory: '.' exclusions: '*.git* /*node_modules/* .editorconfig /*applications/*' - name: Generate JSON manifest @@ -37,5 +37,5 @@ jobs: uses: ncipollo/release-action@v1.12.0 with: tag: '${{ github.ref_name }}' - artifacts: "xprcheckout_gateway.zip,info.json" + artifacts: "xprcheckout_webauth_gateway.zip,info.json" token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/README.md b/README.md index c8a40f3..447dc05 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -=== XPRCheckout - WebAuth Gateway for Woocommerce === +=== XPRCheckout - WebAuth Gateway for e-commerce === Requires at least: 6.0 Tested up to: 6.7 Requires PHP: 7.0 @@ -6,8 +6,8 @@ Stable tag: ##VERSION_TAG## License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html -# XPRCheckout - WebAuth Gateway for Woocommerce -*A WebAuth-Enabled Gateway for WooCommerce* +# XPRCheckout - WebAuth Gateway for e-commerce +*A WebAuth-Enabled Gateway for e-commerce* ## The basic scope diff --git a/includes/api/admin-refund.php b/includes/api/admin-refund.php index 619329f..d420f85 100644 --- a/includes/api/admin-refund.php +++ b/includes/api/admin-refund.php @@ -26,7 +26,7 @@ function xprcheckout_register_payments_with_orders_routes() function admin_only_permission_check($request) { if (!is_user_logged_in()) { - return new WP_Error('rest_forbidden', __('You must be logged in to access this endpoint.','xprcheckout_gateway'), ['status' => 403]); + return new WP_Error('rest_forbidden', __('You must be logged in to access this endpoint.','xprcheckout_webauth_gateway'), ['status' => 403]); } // Get the current user @@ -37,7 +37,7 @@ function admin_only_permission_check($request) { return true; } -return new WP_Error('rest_forbidden', __('You do not have permission to access this endpoint.','xprcheckout_gateway'), ['status' => 403]); +return new WP_Error('rest_forbidden', __('You do not have permission to access this endpoint.','xprcheckout_webauth_gateway'), ['status' => 403]); } diff --git a/includes/api/admin-save-wallet.php b/includes/api/admin-save-wallet.php index 200eb58..c1a1586 100644 --- a/includes/api/admin-save-wallet.php +++ b/includes/api/admin-save-wallet.php @@ -49,7 +49,7 @@ function xprcheckout_register_save_wallet_config_routes() function admin_only_save_wallet_permission_check($request) { if (!is_user_logged_in()) { - return new WP_Error('rest_forbidden', __('You must be logged in to access this endpoint.','xprcheckout_gateway'), ['status' => 403]); + return new WP_Error('rest_forbidden', __('You must be logged in to access this endpoint.','xprcheckout_webauth_gateway'), ['status' => 403]); } // Get the current user @@ -60,7 +60,7 @@ function admin_only_save_wallet_permission_check($request) { return true; } -return new WP_Error('rest_forbidden', __('You do not have permission to access this endpoint.','xprcheckout_gateway'), ['status' => 403]); +return new WP_Error('rest_forbidden', __('You do not have permission to access this endpoint.','xprcheckout_webauth_gateway'), ['status' => 403]); } diff --git a/includes/controllers/Orders.php b/includes/controllers/Orders.php index 2750dfd..88e6768 100644 --- a/includes/controllers/Orders.php +++ b/includes/controllers/Orders.php @@ -122,9 +122,9 @@ public function mutateOrdersColumnsHeader($columns) foreach ($columns as $column_name => $column_info) { $new_columns[$column_name] = $column_info; if ('order_status' === $column_name) { - $new_columns['transactionId'] = __('Transaction', 'xprcheckout_gateway'); // title - $new_columns['network'] = __('Mainnet/testnet', 'xprcheckout_gateway'); // title - $new_columns['paid_token'] = __('Received tokens', 'xprcheckout_gateway'); // title + $new_columns['transactionId'] = __('Transaction', 'xprcheckout_webauth_gateway'); // title + $new_columns['network'] = __('Mainnet/testnet', 'xprcheckout_webauth_gateway'); // title + $new_columns['paid_token'] = __('Received tokens', 'xprcheckout_webauth_gateway'); // title } } return $new_columns; diff --git a/includes/controllers/Refund.php b/includes/controllers/Refund.php index 580a767..ae60b89 100644 --- a/includes/controllers/Refund.php +++ b/includes/controllers/Refund.php @@ -69,7 +69,7 @@ public function registerMetabox() { add_meta_box( 'woocommerce-xprcheckout-payment', - __('XPRCheckout payment', 'xprcheckout_gateway'), + __('XPRCheckout payment', 'xprcheckout_webauth_gateway'), [$this, 'renderMetabox'], 'woocommerce_page_wc-orders', 'advanced', @@ -78,7 +78,7 @@ public function registerMetabox() ); add_meta_box( 'woocommerce-xprcheckout-payment', - __('XPRCheckout payment', 'xprcheckout_gateway'), + __('XPRCheckout payment', 'xprcheckout_webauth_gateway'), [$this, 'renderMetabox'], 'shop_order', 'advanced', diff --git a/includes/controllers/i18n.php b/includes/controllers/i18n.php index d7633b4..17a333d 100644 --- a/includes/controllers/i18n.php +++ b/includes/controllers/i18n.php @@ -45,14 +45,14 @@ private function registerActions() */ function initTextDomain() { - load_plugin_textdomain('xprcheckout_gateway'); + load_plugin_textdomain('xprcheckout_webauth_gateway'); } /** * Retrieves public-facing translated strings. * * Provides an array of translated strings that are likely to be used in public-facing interfaces - * related to the xprcheckout_gateway payment gateway. Uses the plugin's text domain for translations. + * related to the xprcheckout_webauth_gateway payment gateway. Uses the plugin's text domain for translations. * * @return array Associative array of public-facing translated strings. */ @@ -60,32 +60,32 @@ public static function getPublicTranslations() { return [ - "payInviteTitle" => __('Pay with WebAuth', 'xprcheckout_gateway'), - "payInviteText" => __('Connect your WebAuth wallet to start the payment flow.', 'xprcheckout_gateway'), - "payInviteButtonLabel" => __('Connect WebAuth', 'xprcheckout_gateway'), - "orderStatusTitle" => __("Payment succesfull", 'xprcheckout_gateway'), - "orderStatusText" => __("This order is marked as complete", 'xprcheckout_gateway'), - "selectTokenDialogTitle" => __("Select token", 'xprcheckout_gateway'), - "selectTokenDialogText" => __("Select the token you want to pay with.", 'xprcheckout_gateway'), - "selectTokenDialogConnectedAs" => __("Connected as", 'xprcheckout_gateway'), - "selectTokenDialogChangeAccountLabel" => __("change account ?", 'xprcheckout_gateway'), - "selectTokenPayButtonLabel" => __("Pay", 'xprcheckout_gateway'), - "selectTokenPayProcessingLabel" => __("Fetching tokens rates", 'xprcheckout_gateway'), + "payInviteTitle" => __('Pay with WebAuth', 'xprcheckout_webauth_gateway'), + "payInviteText" => __('Connect your WebAuth wallet to start the payment flow.', 'xprcheckout_webauth_gateway'), + "payInviteButtonLabel" => __('Connect WebAuth', 'xprcheckout_webauth_gateway'), + "orderStatusTitle" => __("Payment succesfull", 'xprcheckout_webauth_gateway'), + "orderStatusText" => __("This order is marked as complete", 'xprcheckout_webauth_gateway'), + "selectTokenDialogTitle" => __("Select token", 'xprcheckout_webauth_gateway'), + "selectTokenDialogText" => __("Select the token you want to pay with.", 'xprcheckout_webauth_gateway'), + "selectTokenDialogConnectedAs" => __("Connected as", 'xprcheckout_webauth_gateway'), + "selectTokenDialogChangeAccountLabel" => __("change account ?", 'xprcheckout_webauth_gateway'), + "selectTokenPayButtonLabel" => __("Pay", 'xprcheckout_webauth_gateway'), + "selectTokenPayProcessingLabel" => __("Fetching tokens rates", 'xprcheckout_webauth_gateway'), - "paymentProcessingLabel" => __("Waiting for transaction to complete", 'xprcheckout_gateway'), - "paymentFailureDialogTitle" => __("Something wrong with your transfer.", 'xprcheckout_gateway'), - "paymentFailureDialogText" => __("The transfer fail. The issue came from the chain side, but do not worry, no tokens have been transferred. Please retry or save your order to pay it later.", 'xprcheckout_gateway'), + "paymentProcessingLabel" => __("Waiting for transaction to complete", 'xprcheckout_webauth_gateway'), + "paymentFailureDialogTitle" => __("Something wrong with your transfer.", 'xprcheckout_webauth_gateway'), + "paymentFailureDialogText" => __("The transfer fail. The issue came from the chain side, but do not worry, no tokens have been transferred. Please retry or save your order to pay it later.", 'xprcheckout_webauth_gateway'), - "invalidOrderDialogTitle" => __("No order found.", 'xprcheckout_gateway'), - "invalidOrderDialogText" => __("Not order has been found at the given url. ", 'xprcheckout_gateway'), + "invalidOrderDialogTitle" => __("No order found.", 'xprcheckout_webauth_gateway'), + "invalidOrderDialogText" => __("Not order has been found at the given url. ", 'xprcheckout_webauth_gateway'), - "verifyPaymentDialogTitle" => __("Payment verification", 'xprcheckout_gateway'), - "verifyPaymentDialogText" => __("Please wait while we check payment information.", 'xprcheckout_gateway'), - "verifyPaymentDialogProcessLabel" => __("Verifying payment", 'xprcheckout_gateway'), - "verifySuccessPaymentDialogTitle" => __("Payment verified", 'xprcheckout_gateway'), - "verifySuccessPaymentDialogText" => __("Great, your payment has be verified, order is now completed! ", 'xprcheckout_gateway'), - "verifyFailurePaymentDialogTitle" => __("Payment verification failed", 'xprcheckout_gateway'), - "verifyFailurePaymentDialogText" => __("Your payment could'nt been verified , order is pending! ", 'xprcheckout_gateway'), + "verifyPaymentDialogTitle" => __("Payment verification", 'xprcheckout_webauth_gateway'), + "verifyPaymentDialogText" => __("Please wait while we check payment information.", 'xprcheckout_webauth_gateway'), + "verifyPaymentDialogProcessLabel" => __("Verifying payment", 'xprcheckout_webauth_gateway'), + "verifySuccessPaymentDialogTitle" => __("Payment verified", 'xprcheckout_webauth_gateway'), + "verifySuccessPaymentDialogText" => __("Great, your payment has be verified, order is now completed! ", 'xprcheckout_webauth_gateway'), + "verifyFailurePaymentDialogTitle" => __("Payment verification failed", 'xprcheckout_webauth_gateway'), + "verifyFailurePaymentDialogText" => __("Your payment could'nt been verified , order is pending! ", 'xprcheckout_webauth_gateway'), ]; } } diff --git a/includes/woocommerce/gateway/xprcheckout-gateway.php b/includes/woocommerce/gateway/xprcheckout-gateway.php index 4f6f904..d2b8aad 100644 --- a/includes/woocommerce/gateway/xprcheckout-gateway.php +++ b/includes/woocommerce/gateway/xprcheckout-gateway.php @@ -40,9 +40,9 @@ protected function setup_properties() { $this->id = 'xprcheckout'; $this->icon = apply_filters('woocommerce_cod_icon', ''); - $this->title = __('XPR Checkout', 'xprcheckout_gateway'); - $this->method_title = __('XPR Checkout', 'xprcheckout_gateway'); - $this->method_description = __('Provides a Webauth wallet Payment Gateway for your customer.', 'xprcheckout_gateway'); + $this->title = __('XPR Checkout', 'xprcheckout_webauth_gateway'); + $this->method_title = __('XPR Checkout', 'xprcheckout_webauth_gateway'); + $this->method_description = __('Provides a Webauth wallet Payment Gateway for your customer.', 'xprcheckout_webauth_gateway'); $this->has_fields = false; } @@ -53,75 +53,75 @@ public function init_form_fields() { $this->form_fields = array( 'enabled' => array( - 'title' => __('Enable/Disable', 'xprcheckout_gateway'), + 'title' => __('Enable/Disable', 'xprcheckout_webauth_gateway'), 'type' => 'checkbox', - 'label' => __('Enable Webauth Payment', 'xprcheckout_gateway'), + 'label' => __('Enable Webauth Payment', 'xprcheckout_webauth_gateway'), 'default' => 'yes' ), 'network' => array( - 'title' => __('Select network', 'xprcheckout_gateway'), + 'title' => __('Select network', 'xprcheckout_webauth_gateway'), 'type' => 'select', 'options' => [ 'mainnet' => 'Mainnet', 'testnet' => 'Testnet', ], - 'label' => __('Select network', 'xprcheckout_gateway'), + 'label' => __('Select network', 'xprcheckout_webauth_gateway'), 'default' => 'testnet', 'value' ), 'registered' => array( - 'title' => __('Register store ', 'xprcheckout_gateway'), + 'title' => __('Register store ', 'xprcheckout_webauth_gateway'), 'type' => 'xprcheckout_register', - 'description' => __('Register you store nearby the smart contract', 'xprcheckout_gateway'), + 'description' => __('Register you store nearby the smart contract', 'xprcheckout_webauth_gateway'), 'desc_tip' => true, ), 'title' => array( - 'title' => __('Title', 'xprcheckout_gateway'), + 'title' => __('Title', 'xprcheckout_webauth_gateway'), 'type' => 'text', 'default' => 'Pay with WebAuth', - 'description' => __('This controls the title which the user sees during checkout.', 'xprcheckout_gateway'), + 'description' => __('This controls the title which the user sees during checkout.', 'xprcheckout_webauth_gateway'), 'desc_tip' => true, ), 'description' => array( - 'title' => __('Description', 'xprcheckout_gateway'), + 'title' => __('Description', 'xprcheckout_webauth_gateway'), 'type' => 'textarea', - 'description' => __('This controls the title which the user sees during checkout.', 'xprcheckout_gateway'), - 'default' => __('Pay securely with with multiple crypto currencies through WebAuth with zero gas fee', 'xprcheckout_gateway'), + 'description' => __('This controls the title which the user sees during checkout.', 'xprcheckout_webauth_gateway'), + 'default' => __('Pay securely with with multiple crypto currencies through WebAuth with zero gas fee', 'xprcheckout_webauth_gateway'), 'desc_tip' => true, ), 'wallet' => array( - 'title' => __('Mainnet account', 'xprcheckout_gateway'), + 'title' => __('Mainnet account', 'xprcheckout_webauth_gateway'), 'type' => 'hidden', - 'description' => __('Set the destination account on mainnet where pay token will be paid. Used only when "Use testnet" option is disabled', 'xprcheckout_gateway'), + 'description' => __('Set the destination account on mainnet where pay token will be paid. Used only when "Use testnet" option is disabled', 'xprcheckout_webauth_gateway'), 'desc_tip' => true, ), 'appName' => array( - 'title' => __('dApp Name', 'xprcheckout_gateway'), + 'title' => __('dApp Name', 'xprcheckout_webauth_gateway'), 'type' => 'text', - 'description' => __('The application name displayed in the webauth modal', 'xprcheckout_gateway'), - 'default' => __('My awesome store', 'xprcheckout_gateway'), + 'description' => __('The application name displayed in the webauth modal', 'xprcheckout_webauth_gateway'), + 'default' => __('My awesome store', 'xprcheckout_webauth_gateway'), 'desc_tip' => true, ), /*'appLogo' => array( - 'title' => __('dApp Logo', 'xprcheckout_gateway'), + 'title' => __('dApp Logo', 'xprcheckout_webauth_gateway'), 'type' => 'text', - 'description' => __('The application logo displayed in the webauth modal', 'xprcheckout_gateway'), + 'description' => __('The application logo displayed in the webauth modal', 'xprcheckout_webauth_gateway'), 'desc_tip' => true, ),*/ 'allowedTokens' => array( - 'title' => __('Allowed Tokens', 'xprcheckout_gateway'), + 'title' => __('Allowed Tokens', 'xprcheckout_webauth_gateway'), 'type' => 'text', - 'description' => __('Accepted tokens as payment for transfer, will be displayed in the payments process flow. Specify a uppercase only, coma separated, tokens list', 'xprcheckout_gateway'), - 'default' => __('XPR,XUSDC', 'xprcheckout_gateway'), + 'description' => __('Accepted tokens as payment for transfer, will be displayed in the payments process flow. Specify a uppercase only, coma separated, tokens list', 'xprcheckout_webauth_gateway'), + 'default' => __('XPR,XUSDC', 'xprcheckout_webauth_gateway'), 'desc_tip' => true, ), 'currencyApi' => array( - 'title' => __('Free api key ', 'xprcheckout_gateway'), + 'title' => __('Free api key ', 'xprcheckout_webauth_gateway'), 'type' => 'text', - 'description' => __('We provide limited one. You can register yours for free here.', 'xprcheckout_gateway'), + 'description' => __('We provide limited one. You can register yours for free here.', 'xprcheckout_webauth_gateway'), 'desc_tip' => false, ), ); @@ -337,7 +337,7 @@ public function generate_hidden_html($key, $data) function xprcheckout_redirect_on_new_order($order) { - if(WC()->session->chosen_payment_method == 'xprcheckout_gateway'){ + if(WC()->session->chosen_payment_method == 'xprcheckout_webauth_gateway'){ $this->xprcheckout_redirect_to_payment_page(); } diff --git a/xprcheckout.php b/xprcheckout.php index 3906b8f..cee9943 100644 --- a/xprcheckout.php +++ b/xprcheckout.php @@ -1,13 +1,13 @@
-

+

Install Woocommerce

@@ -163,13 +163,13 @@ function xprcheckout_redirect_to_payment (){ } add_action( 'template_redirect', 'xprcheckout_redirect_to_payment' ); -add_action( 'woocommerce_blocks_loaded', 'xprcheckout_gateway_block_support'); -function xprcheckout_gateway_block_support(){ +add_action( 'woocommerce_blocks_loaded', 'xprcheckout_webauth_gateway_block_support'); +function xprcheckout_webauth_gateway_block_support(){ require_once XPRCHECKOUT_ROOT_DIR . 'includes/supports/block-support.php'; } -add_action( 'woocommerce_blocks_payment_method_type_registration', 'xprcheckout_gateway_block_method_type_registration'); -function xprcheckout_gateway_block_method_type_registration ($payment_method_registry){ +add_action( 'woocommerce_blocks_payment_method_type_registration', 'xprcheckout_webauth_gateway_block_method_type_registration'); +function xprcheckout_webauth_gateway_block_method_type_registration ($payment_method_registry){ $payment_method_registry->register( new WC_XPRCheckoutBlocksSupport() ); }