Skip to content

Commit

Permalink
Make migration failure instructions more detailed and specific to plu…
Browse files Browse the repository at this point in the history
…gin or theme.
  • Loading branch information
toddlahman committed Nov 29, 2019
1 parent 2f7e1fa commit 90db857
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Example Code to add to Plugins and Themes
*/

// Load WC_AM_Client class if it exists.
if ( ! class_exists( 'WC_AM_Client_2_7' ) ) {
if ( ! class_exists( 'WC_AM_Client_2_7_2' ) ) {
// Uncomment next line if this is a plugin
require_once( plugin_dir_path( __FILE__ ) . 'wc-am-client.php' );

Expand All @@ -45,7 +45,7 @@ if ( ! class_exists( 'WC_AM_Client_2_7' ) ) {
}

// Instantiate WC_AM_Client class object if the WC_AM_Client class is loaded.
if ( class_exists( 'WC_AM_Client_2_7' ) ) {
if ( class_exists( 'WC_AM_Client_2_7_2' ) ) {
/**
* This file is only an example that includes a plugin header, and this code used to instantiate the client object. The variable $wcam_lib
* can be used to access the public properties from the WC_AM_Client class, but $wcam_lib must have a unique name. To find data saved by
Expand All @@ -72,10 +72,10 @@ if ( class_exists( 'WC_AM_Client_2_7' ) ) {
*/

// Example of empty string product_id.
//$wcam_lib = new WC_AM_Client_2_7( __FILE__, '', '1.0', 'plugin', 'http://wc/', 'Simple Comments - Simple' );
//$wcam_lib = new WC_AM_Client_2_7_2( __FILE__, '', '1.0', 'plugin', 'http://wc/', 'Simple Comments - Simple' );

// Preferred positive integer product_id.
$wcam_lib = new WC_AM_Client_2_7( __FILE__, 132967, '1.0', 'plugin', 'http://wc/', 'Simple Comments - Simple' );
$wcam_lib = new WC_AM_Client_2_7_2( __FILE__, 132967, '1.0', 'plugin', 'http://wc/', 'Simple Comments - Simple' );
}
```

Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
*** WooCommerce API Manager PHP Library for Plugins and Themes Changelog ***

2019.11.29 - version 2.7.2
* Tweak: Make migration failure instructions more detailed and specific to plugin or theme.
* Tweak: Format 'plugin' or 'theme' string to lower case to insure proper string format.

2019.09.04 - version 2.7.1
* Tweak: Changed the Plugin header file name to match directory name.

Expand Down
8 changes: 4 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Example Code to add to Plugins and Themes
*/

// Load WC_AM_Client class if it exists.
if ( ! class_exists( 'WC_AM_Client_2_7' ) ) {
if ( ! class_exists( 'WC_AM_Client_2_7_2' ) ) {
// Uncomment next line if this is a plugin
require_once( plugin_dir_path( __FILE__ ) . 'wc-am-client.php' );

Expand All @@ -45,7 +45,7 @@ if ( ! class_exists( 'WC_AM_Client_2_7' ) ) {
}

// Instantiate WC_AM_Client class object if the WC_AM_Client class is loaded.
if ( class_exists( 'WC_AM_Client_2_7' ) ) {
if ( class_exists( 'WC_AM_Client_2_7_2' ) ) {
/**
* This file is only an example that includes a plugin header, and this code used to instantiate the client object. The variable $wcam_lib
* can be used to access the public properties from the WC_AM_Client class, but $wcam_lib must have a unique name. To find data saved by
Expand All @@ -72,10 +72,10 @@ if ( class_exists( 'WC_AM_Client_2_7' ) ) {
*/

// Example of empty string product_id.
//$wcam_lib = new WC_AM_Client_2_7( __FILE__, '', '1.0', 'plugin', 'http://wc/', 'Simple Comments - Simple' );
//$wcam_lib = new WC_AM_Client_2_7_2( __FILE__, '', '1.0', 'plugin', 'http://wc/', 'Simple Comments - Simple' );

// Preferred positive integer product_id.
$wcam_lib = new WC_AM_Client_2_7( __FILE__, 132967, '1.0', 'plugin', 'http://wc/', 'Simple Comments - Simple' );
$wcam_lib = new WC_AM_Client_2_7_2( __FILE__, 132967, '1.0', 'plugin', 'http://wc/', 'Simple Comments - Simple' );
}
```

Expand Down
16 changes: 11 additions & 5 deletions wc-am-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* but are not limited to, the working concept, function, and behavior of this software,
* the logical code structure and expression as written.
*
* @version 2.7
* @version 2.7.2
* @author Todd Lahman LLC https://www.toddlahman.com/
* @copyright Copyright (c) Todd Lahman LLC ([email protected])
* @package WooCommerce API Manager plugin and theme library
Expand All @@ -17,8 +17,8 @@

defined( 'ABSPATH' ) || exit;

if ( ! class_exists( 'WC_AM_Client_2_7' ) ) {
class WC_AM_Client_2_7 {
if ( ! class_exists( 'WC_AM_Client_2_7_2' ) ) {
class WC_AM_Client_2_7_2 {

/**
* Class args
Expand Down Expand Up @@ -64,7 +64,7 @@ class WC_AM_Client_2_7 {

public function __construct( $file, $product_id, $software_version, $plugin_or_theme, $api_url, $software_title = '', $text_domain = '' ) {
$this->no_product_id = empty( $product_id ) ? true : false;
$this->plugin_or_theme = esc_attr( $plugin_or_theme );
$this->plugin_or_theme = esc_attr( strtolower( $plugin_or_theme ) );

if ( $this->no_product_id ) {
$this->identifier = $this->plugin_or_theme == 'plugin' ? dirname( untrailingslashit( plugin_basename( $file ) ) ) : get_stylesheet();
Expand Down Expand Up @@ -222,7 +222,13 @@ public function migrate_pre_2_0_data( $product_id, $software_title ) {
public function migrate_error_notice() { ?>
<div class="notice notice-error">
<p>
<?php esc_html_e( 'Attempt to migrate data failed. Deactivate then reactive this plugin or theme, then enter your API Key on the settings screen to receive software updates. Contact support if assistance is required.', $this->text_domain ); ?>
<?php
if ( $this->plugin_or_theme == 'plugin' ) {
esc_html_e( 'Attempt to migrate data failed. Go to the Plugins screen then deactivate and reactive this plugin to reset the API Key data, then enter your API Key on the settings screen to receive software updates. Contact support if assistance is required.', $this->text_domain );
} else {
esc_html_e( 'Attempt to migrate data failed. Switch themes, then switch back to this theme to reset the API Key data, then enter your API Key on the settings screen to receive software updates. Contact support if assistance is required.', $this->text_domain );
}
?>
</p>
</div>
<?php
Expand Down
14 changes: 7 additions & 7 deletions wc-api-manager-php-library.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: WooCommerce API Manager PHP Library for Plugins and Themes
* Plugin URI: https://www.toddlahman.com/shop/woocommerce-api-manager-php-library-for-plugins-and-themes/
* Description: Drop the wc-am-client.php library into a plugin or theme, and use the example code below after line 26.
* Version: 2.7.1
* Version: 2.7.2
* Author: Todd Lahman LLC
* Author URI: https://www.toddlahman.com/
* License: Copyright Todd Lahman LLC
Expand All @@ -29,7 +29,7 @@
*/

// Load WC_AM_Client class if it exists.
if ( ! class_exists( 'WC_AM_Client_2_7' ) ) {
if ( ! class_exists( 'WC_AM_Client_2_7_2' ) ) {
// Uncomment next line if this is a plugin
require_once( plugin_dir_path( __FILE__ ) . 'wc-am-client.php' );

Expand All @@ -38,7 +38,7 @@
}

// Instantiate WC_AM_Client class object if the WC_AM_Client class is loaded.
if ( class_exists( 'WC_AM_Client_2_7' ) ) {
if ( class_exists( 'WC_AM_Client_2_7_2' ) ) {
/**
* This file is only an example that includes a plugin header, and this code used to instantiate the client object. The variable $wcam_lib
* can be used to access the public properties from the WC_AM_Client class, but $wcam_lib must have a unique name. To find data saved by
Expand All @@ -61,13 +61,13 @@
*
* Example:
*
* $wcam_lib = new WC_AM_Client_2_7( $file, $product_id, $software_version, $plugin_or_theme, $api_url, $software_title );
* $wcam_lib = new WC_AM_Client_2_7_2( $file, $product_id, $software_version, $plugin_or_theme, $api_url, $software_title );
*/

// Example of empty string product_id.
//$wcam_lib = new WC_AM_Client_2_7( __FILE__, '', '1.0', 'plugin', 'http://wc/', 'Simple Comments - Simple' );
//$wcam_lib = new WC_AM_Client_2_7( __FILE__, '', '1.0', 'plugin', 'http://wc/', 'WooCommerce API Manager PHP Library for Plugins and Themes' );
//$wcam_lib = new WC_AM_Client_2_7_2( __FILE__, '', '1.0', 'plugin', 'http://wc/', 'Simple Comments - Simple' );
//$wcam_lib = new WC_AM_Client_2_7_2( __FILE__, '', '1.0', 'plugin', 'http://wc/', 'WooCommerce API Manager PHP Library for Plugins and Themes' );

// Preferred positive integer product_id.
$wcam_lib = new WC_AM_Client_2_7( __FILE__, 139932, '2.7', 'plugin', 'https://www.toddlahman.com/', 'WooCommerce API Manager PHP Library for Plugins and Themes' );
$wcam_lib = new WC_AM_Client_2_7_2( __FILE__, 139932, '2.7.1', 'plugin', 'https://www.toddlahman.com/', 'WooCommerce API Manager PHP Library for Plugins and Themes' );
}

0 comments on commit 90db857

Please sign in to comment.