Skip to content

Commit cfed08e

Browse files
committed
Release: v2.11.1
1 parent 8f65d90 commit cfed08e

File tree

3 files changed

+42
-37
lines changed

3 files changed

+42
-37
lines changed

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
*** WooCommerce API Manager PHP Library for Plugins and Themes Changelog ***
22

3+
2025.06.09 - version 2.11.1
4+
* Fix: Correctly output HTML links in API error messages
5+
* Fix: Improve translatable activation information output
6+
37
2025.06.04 - version 2.11.0
48
* New: Update the terminology in labels and text matching the latest API Manager version
59

examples/wc-api-manager-example.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626

2727
// Load the WC_AM_Client client class if it exists.
28-
if ( ! class_exists( 'WC_AM_Client_2_11_0' ) ) {
28+
if ( ! class_exists( 'WC_AM_Client_2_11_1' ) ) {
2929
/**
3030
* This library does not use Composer autoloading to support a wider range of implementations.
3131
*
@@ -37,7 +37,7 @@
3737
}
3838

3939
// Instantiate the WC_AM_Client class object if the WC_AM_Client class is loaded.
40-
if ( class_exists( 'WC_AM_Client_2_11_0' ) ) {
40+
if ( class_exists( 'WC_AM_Client_2_11_1' ) ) {
4141
/**
4242
* This file is only an example that includes a plugin header, and this code is used to instantiate the client object.
4343
*
@@ -69,7 +69,7 @@
6969
*
7070
* @NOTE Replace the dummy values with your own.
7171
*/
72-
$wcam_lib = new WC_AM_Client_2_11_0( __FILE__, 123, null, '1.0', 'theme', 'https://example.org/example-theme', __( 'Example WordPress Plugin', 'example-textdomain' ), 'example-textdomain' );
72+
$wcam_lib = new WC_AM_Client_2_11_1( __FILE__, 123, null, '1.0', 'theme', 'https://example.org/example-theme', __( 'Example WordPress Plugin', 'example-textdomain' ), 'example-textdomain' );
7373

7474
/**
7575
* Plugin example (default menu).
@@ -80,13 +80,13 @@
8080
*/
8181

8282
// If the Product ID is not set the customer will see a form field when activating the API Key that requires the Product ID along with a form field for the API Key.
83-
$wcam_lib = new WC_AM_Client_2_11_0( __FILE__, '', null, '1.2.3', 'plugin', 'https://example.org/example-plugin', __( 'Example WordPress Plugin', 'example-textdomain' ), 'example-textdomain' );
83+
$wcam_lib = new WC_AM_Client_2_11_1( __FILE__, '', null, '1.2.3', 'plugin', 'https://example.org/example-plugin', __( 'Example WordPress Plugin', 'example-textdomain' ), 'example-textdomain' );
8484

8585
// Setting the Product ID below will eliminate the required form field for the customer to enter the Product ID, so the customer will only be required to enter the API Key.
86-
$wcam_lib = new WC_AM_Client_2_11_0( __FILE__, 456, null, '1.2.3', 'plugin', 'https://example.org/example-plugin', __( 'Example WordPress Plugin', 'example-textdomain' ), 'example-textdomain' );
86+
$wcam_lib = new WC_AM_Client_2_11_1( __FILE__, 456, null, '1.2.3', 'plugin', 'https://example.org/example-plugin', __( 'Example WordPress Plugin', 'example-textdomain' ), 'example-textdomain' );
8787

8888
// If you offer the product as a variable product where the customer can switch to another product with a different Product ID, then do not set the Product ID here, but you may pass a product parent ID instead (generally not recommended unless you are using subscription switches and not setting a product ID or letting the customer enter it).
89-
$wcam_lib = new WC_AM_Client_2_11_0( __FILE__, null, 789, '1.2.3', 'plugin', 'https://example.org/example-plugin', __( 'Example WordPress Plugin', 'example-textdomain' ), 'example-textdomain' );
89+
$wcam_lib = new WC_AM_Client_2_11_1( __FILE__, null, 789, '1.2.3', 'plugin', 'https://example.org/example-plugin', __( 'Example WordPress Plugin', 'example-textdomain' ), 'example-textdomain' );
9090

9191
/**
9292
* Custom top level or top level submenu.
@@ -99,7 +99,7 @@
9999
* @see add_options_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null );
100100
* @see add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $icon_url = '', $position = null );
101101
*
102-
* Then pass the custom menu settings as an array to the WC_AM_Client_2_11_0 class as shown in the example below.
102+
* Then pass the custom menu settings as an array to the WC_AM_Client_2_11_1 class as shown in the example below.
103103
*/
104104

105105
$wcam_lib_custom_menu = array(
@@ -109,13 +109,13 @@
109109
'menu_title' => __( 'Example API Key', 'example-textdomain' ),
110110
);
111111

112-
$wcam_lib = new WC_AM_Client_2_11_0( __FILE__, 123, null, '1.2.3', 'plugin', 'https://example.org/example-plugin', __( 'Example WordPress Plugin', 'example-textdomain' ), 'example-textdomain', $wcam_lib_custom_menu );
112+
$wcam_lib = new WC_AM_Client_2_11_1( __FILE__, 123, null, '1.2.3', 'plugin', 'https://example.org/example-plugin', __( 'Example WordPress Plugin', 'example-textdomain' ), 'example-textdomain', $wcam_lib_custom_menu );
113113

114114
/**
115115
* Suppress the inactive notice.
116116
*
117-
* When your plugin or theme is activated, the WC_AM_Client_2_11_0 class will display a notice in the admin area if the plugin or theme has not been activated.
117+
* When your plugin or theme is activated, the WC_AM_Client_2_11_1 class will display a notice in the admin area if the plugin or theme has not been activated.
118118
* You can disable this by setting the last argument passed to the client constructor to false.
119119
*/
120-
$wcam_lib = new WC_AM_Client_2_11_0( __FILE__, 123, null, '1.2.3', 'plugin', 'https://example.org/example-plugin', __( 'Example WordPress Plugin', 'example-textdomain' ), 'example-textdomain', null, false );
120+
$wcam_lib = new WC_AM_Client_2_11_1( __FILE__, 123, null, '1.2.3', 'plugin', 'https://example.org/example-plugin', __( 'Example WordPress Plugin', 'example-textdomain' ), 'example-textdomain', null, false );
121121
}

wc-am-client.php

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @link https://kestrelwp.com/developers
1818
*
19-
* @version 2.11.0
19+
* @version 2.11.1
2020
* @author Kestrel
2121
* @copyright Copyright (c) 2013-2025 Kestrel
2222
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
@@ -25,13 +25,13 @@
2525

2626
defined( 'ABSPATH' ) || exit;
2727

28-
if ( ! class_exists( 'WC_AM_Client_2_11_0' ) ) {
28+
if ( ! class_exists( 'WC_AM_Client_2_11_1' ) ) {
2929
/**
3030
* API Manager for WooCommerce client class.
3131
*
3232
* @since 1.0.0
3333
*/
34-
class WC_AM_Client_2_11_0 {
34+
class WC_AM_Client_2_11_1 {
3535

3636
/** @var string API URL. */
3737
private $api_url = '';
@@ -439,13 +439,14 @@ public function auto_update_message( $html, $plugin_file, $plugin_data ) {
439439
if ( $this->wc_am_plugin_name === $plugin_file ) {
440440

441441
if ( ! $this->get_api_key_status() || ! $this->get_api_key_status( true ) ) {
442+
/* translators: Context: Software product (eg. WordPress plugin or theme) auto-updates are unavailable. */
442443
return esc_html__( 'Auto-updates unavailable.', $this->text_domain ); // phpcs:ignore
443444
}
444445

445446
$auto_updates = (array) get_site_option( 'auto_update_plugins', array() );
446447
$html = array();
447448

448-
if ( ! empty( $plugin_data['auto-update-forced'] ) ) {
449+
if ( isset( $plugin_data['auto-update-forced'] ) ) {
449450
if ( $plugin_data['auto-update-forced'] ) {
450451
// Forced on.
451452
$text = __( 'Auto-updates enabled', $this->text_domain ); // phpcs:ignore
@@ -772,47 +773,47 @@ public function get_api_key_status( $live = false ) {
772773
}
773774

774775
/**
775-
* Display activation error returned by shop or local server.
776+
* Displays activation data returned by shop or local server.
776777
*
777778
* @since 2.9
779+
* @internal
780+
*
781+
* @return void
778782
*/
779783
public function wc_am_activation_info() {
780784

781785
$result_error = get_option( 'wc_am_' . $this->product_id . '_activate_error' );
782786
$live_status = $this->license_key_status();
783-
$line_break = wp_kses_post( '<br>' );
784787

785-
if ( ! empty( $live_status ) && isset( $live_status['success'] ) && $live_status['success'] === false ) {
786-
echo esc_html( 'Error: ' . $live_status['data']['error'] );
788+
if ( ! empty( $live_status ) && isset( $live_status['success'], $live_status['data']['error'] ) && $live_status['success'] === false ) {
789+
/* translators: Placeholder: %1$s - Opening <strong> HTML tag, %2$s - Closing </strong> HTML link tag, %3$s - Error message */
790+
echo wp_kses_post( sprintf( __( '%1$sError:%2$s %3$s', $this->text_domain ), '<strong style="color:#b32d2e;">', '</strong>', $live_status['data']['error'] ) ) . '<br><br>'; // phpcs:ignore
787791
}
788792

789793
if ( $this->get_api_key_status() ) {
790794
$result_success = get_option( 'wc_am_' . $this->product_id . '_activate_success' );
791795

792796
if ( ! empty( $live_status ) && isset( $live_status['status_check'] ) && $live_status['success'] === 'active' ) {
793-
echo esc_html( 'Activations purchased: ' . $live_status['data']['total_activations_purchased'], $this->text_domain ); // phpcs:ignore
794-
echo $line_break; // phpcs:ignore
795-
echo esc_html( 'Total activations: ' . $live_status['data']['total_activations'], $this->text_domain ); // phpcs:ignore
796-
echo $line_break; // phpcs:ignore
797-
echo esc_html( 'Activations remaining: ' . $live_status['data']['activations_remaining'], $this->text_domain ); // phpcs:ignore
797+
/* translators: Placeholder: %s - license activations purchased count */
798+
echo esc_html( sprintf( __( 'Activations purchased: %s', $this->text_domain ), $live_status['data']['total_activations_purchased'] ) ); // phpcs:ignore
799+
/* translators: Placeholder: %s - total license activations count */
800+
echo esc_html( sprintf( __( 'Total activations: %s', $this->text_domain ), $live_status['data']['total_activations'] ) ); // phpcs:ignore
801+
/* translators: Placeholder: %s - total license activations remaining count */
802+
echo esc_html( sprintf( __( 'Activations remaining: %s', $this->text_domain ), $live_status['data']['activations_remaining'] ) ); // phpcs:ignore
798803
} elseif ( ! empty( $result_success ) ) {
799-
echo esc_html( $result_success );
800-
} else {
801-
echo '';
804+
echo esc_html( $result_success ) . '<br>';
802805
}
803806
} elseif ( ! $this->get_api_key_status() && ! empty( $live_status ) && isset( $live_status['status_check'] ) && $live_status['status_check'] === 'inactive' ) {
804-
805-
echo esc_html( 'Activations purchased: ' . $live_status['data']['total_activations_purchased'], $this->text_domain ); // phpcs:ignore
806-
echo $line_break; // phpcs:ignore
807-
echo esc_html( 'Total activations: ' . $live_status['data']['total_activations'], $this->text_domain ); // phpcs:ignore
808-
echo $line_break; // phpcs:ignore
809-
echo esc_html( 'Activations remaining: ' . $live_status['data']['activations_remaining'], $this->text_domain ); // phpcs:ignore
807+
/* translators: Placeholder: %s - total license activations purchased count */
808+
echo esc_html( sprintf( __( 'Activations purchased: %s', $this->text_domain ), $live_status['data']['total_activations_purchased'] ) ) . '<br>'; // phpcs:ignore
809+
/* translators: Placeholder: %s - total license activations count */
810+
echo esc_html( sprintf( __( 'Total activations: %s', $this->text_domain ), $live_status['data']['total_activations'] ) ) . '<br>'; // phpcs:ignore
811+
/* translators: Placeholder: %s - total license activations remaining count */
812+
echo esc_html( sprintf( __( 'Activations remaining: %s', $this->text_domain ), $live_status['data']['activations_remaining'] ) ) . '<br>'; // phpcs:ignore
810813
} elseif ( ! $this->get_api_key_status() && ! empty( $result_error ) ) {
811-
echo esc_html__( 'Previous activation attempt errors:', $this->text_domain ); // phpcs:ignore
812-
echo $line_break; // phpcs:ignore
813-
wp_kses_post( print_r( $result_error ) ); // phpcs:ignore
814-
} else {
815-
echo '';
814+
/* translators: Context: List of errors for a license activation failure */
815+
echo esc_html__( 'Previous activation attempt errors:', $this->text_domain ) . '<br>'; // phpcs:ignore
816+
echo wp_kses_post( print_r( $result_error, true ) ); // phpcs:ignore
816817
}
817818
}
818819

0 commit comments

Comments
 (0)