Skip to content

Commit

Permalink
fix internationalization according to wp standards (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlHandy authored Oct 12, 2024
1 parent 5eeae09 commit 6599212
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions includes/class-kalpa-mmg-checkout-activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* This file contains the Kalpa_MMG_Checkout_Activator class and activation function.
*
* @package Kalpa_Kalpa_MMG_Checkout_Main
* @package Kalpa_MMG_Checkout_Main
* @since 1.0.0
*/

Expand All @@ -18,7 +18,7 @@
* This class defines all code necessary to run during the plugin's activation.
*
* @since 1.0.0
* @package Kalpa_Kalpa_MMG_Checkout_Main
* @package Kalpa_MMG_Checkout_Main
* @author Kalpa Services Inc. <[email protected]>
*/
class Kalpa_MMG_Checkout_Activator {
Expand Down
2 changes: 1 addition & 1 deletion includes/class-kalpa-mmg-checkout-deactivator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* This file contains the Kalpa_MMG_Checkout_Deactivator class and deactivation function.
*
* @package Kalpa_Kalpa_MMG_Checkout_Main
* @package Kalpa_MMG_Checkout_Main
* @since 1.0.0
*/

Expand Down
4 changes: 2 additions & 2 deletions includes/class-kalpa-mmg-checkout-dependency-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private static function is_localhost() {
public static function woocommerce_missing_notice() {
?>
<div class="error">
<p><?php esc_html_e( 'MMG Checkout requires WooCommerce to be installed and active. Please install and activate WooCommerce to use this plugin.', 'mmg-checkout' ); ?></p>
<p><?php esc_html_e( 'MMG Checkout requires WooCommerce to be installed and active. Please install and activate WooCommerce to use this plugin.', 'kalpa-mmg-checkout' ); ?></p>
</div>
<?php
}
Expand All @@ -98,7 +98,7 @@ public static function woocommerce_missing_notice() {
public static function mbstring_missing_notice() {
?>
<div class="error">
<p><?php esc_html_e( 'MMG Checkout requires the mbstring PHP extension to be installed and active on the server. Please install and activate mbstring to use this plugin.', 'mmg-checkout' ); ?></p>
<p><?php esc_html_e( 'MMG Checkout requires the mbstring PHP extension to be installed and active on the server. Please install and activate mbstring to use this plugin.', 'kalpa-mmg-checkout' ); ?></p>
</div>
<?php
}
Expand Down
8 changes: 4 additions & 4 deletions includes/class-kalpa-mmg-checkout-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ private function generate_unique_callback_url() {
*/
public function enqueue_scripts() {
if ( is_checkout_pay_page() ) {
wp_enqueue_script( 'mmg-checkout', plugin_dir_url( __DIR__ ) . 'admin/js/mmg-checkout.js', array( 'jquery' ), '3.0', true );
wp_enqueue_script( 'kalpa-mmg-checkout', plugin_dir_url( __DIR__ ) . 'admin/js/mmg-checkout.js', array( 'jquery' ), '3.0', true );
wp_localize_script(
'mmg-checkout',
'kalpa-mmg-checkout',
'mmg_checkout_params',
array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
Expand All @@ -134,7 +134,7 @@ public function enqueue_scripts() {
}

wp_localize_script(
'wc-mmg-payments-blocks',
'kalpa-mmg-payment-blocks',
'mmgCheckoutData',
array(
'title' => isset( $gateway_settings['title'] ) ? $gateway_settings['title'] : 'MMG Checkout',
Expand Down Expand Up @@ -412,7 +412,7 @@ public function handle_error_payment() {
$order->update_status( 'failed', "Payment failed. Error Code: {$error_code}, Message: {$error_message}" );

// Redirect to the order page with an error message.
wc_add_notice( __( 'Payment failed. Please try again or contact support.', 'mmg-checkout' ), 'error' );
wc_add_notice( __( 'Payment failed. Please try again or contact support.', 'kalpa-mmg-checkout' ), 'error' );
wp_safe_redirect( $order->get_checkout_payment_url() );
exit;
}
Expand Down
4 changes: 2 additions & 2 deletions includes/class-kalpa-mmg-checkout-payments-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public function is_active() {
*/
public function get_payment_method_script_handles() {
wp_register_script(
'wc-mmg-payments-blocks',
'kalpa-mmg-payment-blocks',
plugins_url( 'admin/js/mmg-checkout-blocks.js', __DIR__ ),
array( 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n' ),
filemtime( plugin_dir_path( __DIR__ ) . 'admin/js/mmg-checkout-blocks.js' ),
true
);
return array( 'wc-mmg-payments-blocks' );
return array( 'kalpa-mmg-payment-blocks' );
}

/**
Expand Down
36 changes: 18 additions & 18 deletions includes/class-kalpa-mmg-checkout-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* This class handles the settings page for the MMG Checkout plugin.
*
* @package Kalpa_Kalpa_MMG_Checkout_Main
* @package Kalpa_MMG_Checkout_Main
*/

if ( ! defined( 'ABSPATH' ) ) {
Expand All @@ -29,33 +29,33 @@ public function __construct() {
* Add admin menu.
*/
public function add_admin_menu() {
add_options_page( 'MMG Checkout Settings', 'MMG Checkout', 'manage_options', 'mmg-checkout-settings', array( $this, 'settings_page' ) );
add_options_page( 'MMG Checkout Settings', 'MMG Checkout', 'manage_options', 'kalpa-mmg-checkout-settings', array( $this, 'settings_page' ) );
}

/**
* Register settings.
*/
public function register_settings() {
register_setting( 'mmg_checkout_settings', 'mmg_mode', array( 'sanitize_callback' => array( $this, 'sanitize_mode' ) ) );
register_setting( 'kalpa_mmg_checkout_settings', 'mmg_mode', array( 'sanitize_callback' => array( $this, 'sanitize_mode' ) ) );

// Live credentials.
register_setting( 'mmg_checkout_settings', 'mmg_live_client_id', array( 'sanitize_callback' => 'sanitize_text_field' ) );
register_setting( 'mmg_checkout_settings', 'mmg_live_merchant_id', array( 'sanitize_callback' => 'sanitize_text_field' ) );
register_setting( 'mmg_checkout_settings', 'mmg_live_secret_key', array( 'sanitize_callback' => 'sanitize_text_field' ) );
register_setting( 'mmg_checkout_settings', 'mmg_live_rsa_public_key', array( 'sanitize_callback' => array( $this, 'sanitize_multiline_field' ) ) );
register_setting( 'mmg_checkout_settings', 'mmg_live_rsa_private_key', array( 'sanitize_callback' => array( $this, 'sanitize_multiline_field' ) ) );
register_setting( 'mmg_checkout_settings', 'mmg_live_checkout_url', array( 'sanitize_callback' => 'esc_url' ) );
register_setting( 'kalpa_mmg_checkout_settings', 'mmg_live_client_id', array( 'sanitize_callback' => 'sanitize_text_field' ) );
register_setting( 'kalpa_mmg_checkout_settings', 'mmg_live_merchant_id', array( 'sanitize_callback' => 'sanitize_text_field' ) );
register_setting( 'kalpa_mmg_checkout_settings', 'mmg_live_secret_key', array( 'sanitize_callback' => 'sanitize_text_field' ) );
register_setting( 'kalpa_mmg_checkout_settings', 'mmg_live_rsa_public_key', array( 'sanitize_callback' => array( $this, 'sanitize_multiline_field' ) ) );
register_setting( 'kalpa_mmg_checkout_settings', 'mmg_live_rsa_private_key', array( 'sanitize_callback' => array( $this, 'sanitize_multiline_field' ) ) );
register_setting( 'kalpa_mmg_checkout_settings', 'mmg_live_checkout_url', array( 'sanitize_callback' => 'esc_url' ) );

// Demo credentials.
register_setting( 'mmg_checkout_settings', 'mmg_demo_client_id', array( 'sanitize_callback' => 'sanitize_text_field' ) );
register_setting( 'mmg_checkout_settings', 'mmg_demo_merchant_id', array( 'sanitize_callback' => 'sanitize_text_field' ) );
register_setting( 'mmg_checkout_settings', 'mmg_demo_secret_key', array( 'sanitize_callback' => 'sanitize_text_field' ) );
register_setting( 'mmg_checkout_settings', 'mmg_demo_rsa_public_key', array( 'sanitize_callback' => array( $this, 'sanitize_multiline_field' ) ) );
register_setting( 'mmg_checkout_settings', 'mmg_demo_rsa_private_key', array( 'sanitize_callback' => array( $this, 'sanitize_multiline_field' ) ) );
register_setting( 'mmg_checkout_settings', 'mmg_demo_checkout_url', array( 'sanitize_callback' => 'esc_url' ) );
register_setting( 'kalpa_mmg_checkout_settings', 'mmg_demo_client_id', array( 'sanitize_callback' => 'sanitize_text_field' ) );
register_setting( 'kalpa_mmg_checkout_settings', 'mmg_demo_merchant_id', array( 'sanitize_callback' => 'sanitize_text_field' ) );
register_setting( 'kalpa_mmg_checkout_settings', 'mmg_demo_secret_key', array( 'sanitize_callback' => 'sanitize_text_field' ) );
register_setting( 'kalpa_mmg_checkout_settings', 'mmg_demo_rsa_public_key', array( 'sanitize_callback' => array( $this, 'sanitize_multiline_field' ) ) );
register_setting( 'kalpa_mmg_checkout_settings', 'mmg_demo_rsa_private_key', array( 'sanitize_callback' => array( $this, 'sanitize_multiline_field' ) ) );
register_setting( 'kalpa_mmg_checkout_settings', 'mmg_demo_checkout_url', array( 'sanitize_callback' => 'esc_url' ) );

// Common settings.
register_setting( 'mmg_checkout_settings', 'mmg_merchant_name', array( 'sanitize_callback' => 'sanitize_text_field' ) );
register_setting( 'kalpa_mmg_checkout_settings', 'mmg_merchant_name', array( 'sanitize_callback' => 'sanitize_text_field' ) );
}

/**
Expand All @@ -73,8 +73,8 @@ public function settings_page() {
</div>
<form method="post" action="options.php" id="mmg-checkout-settings-form">
<?php
settings_fields( 'mmg_checkout_settings' );
do_settings_sections( 'mmg_checkout_settings' );
settings_fields( 'kalpa_mmg_checkout_settings' );
do_settings_sections( 'kalpa_mmg_checkout_settings' );
?>
<table class="form-table">
<tr valign="top">
Expand Down
8 changes: 4 additions & 4 deletions kalpa-mmg-checkout.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php
/**
* Plugin Name: MMG Checkout for WooCommerce
* Plugin Name: MMG Checkout for WooCommerce
*
* @package MMG Checkout for WooCommerce
* @package MMG Checkout for WooCommerce
* @author Kalpa Services Inc.
* @copyright 2024 Kalpa Services Inc.
* @license GPL-2.0-or-later
*
* @wordpress-plugin
* Plugin Name: MMG Checkout for WooCommerce
* Plugin Name: MMG Checkout for WooCommerce
* Plugin URI: https://mmg-plugin.kalpa.dev
* Description: Enables MMG Checkout for WooCommerce flow for registered MMG Merchants to receive E-Commerce payments from MMG customers.
* Version: 2.1.7
Expand Down Expand Up @@ -82,7 +82,7 @@ function ( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment
* @return array The updated array of query variables.
*/
function mmg_query_vars( $vars ) {
$vars[] = 'mmg-checkout';
$vars[] = 'mmg-checkout'; // changing this will cause a breaking change for existing users.
$vars[] = 'callback_key';
return $vars;
}
Expand Down

0 comments on commit 6599212

Please sign in to comment.