Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ $client->set_textdomain( 'your-project-textdomain' );
```

## Example Plugin
[surecart-plugin-license.zip](https://d.pr/f/DVzMC0)
[surecart-plugin-license.zip](https://d.pr/f/6ZyfAS)

## Example Theme
[surecart-theme-license.zip](https://d.pr/f/m51Tt5)
[surecart-theme-license.zip](https://d.pr/f/RK8NFS)

For full setup and functionality details, see the official documentation: [Licensing Setup and Functionality](https://surecart.com/docs/licensing-setup-and-functionality/).
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Client {
*
* @var string
*/
public $version = '1.2.0';
public $version = '1.2.1';

/**
* Name of the plugin
Expand Down
31 changes: 23 additions & 8 deletions src/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,18 +293,33 @@ public function print_css() {
/**
* Get the activation.
*
* A read never writes to stored options; it only surfaces an error message.
* On a 404 the stale activation_id is left in the database (it gets overwritten
* on reactivation), but this still returns false so the page shows "Activate
* License" instead of a "Deactivate License" button that would just keep failing.
*
* @return Object|false
*/
public function get_activation() {
$activation = false;
if ( $this->activation_id ) {
$activation = $this->client->activation()->get( $this->activation_id );
if ( is_wp_error( $activation ) ) {
$this->add_error( 'deactivaed', $this->client->__( 'Your license has been deactivated for this site.', 'surecart' ) );
$this->clear_options();
}
if ( ! $this->activation_id ) {
return false;
}

$activation = $this->client->activation()->get( $this->activation_id );

if ( ! is_wp_error( $activation ) ) {
return $activation;
}
return $activation;

if ( 'not_found' === $activation->get_error_code() ) {
$this->add_error( 'activation_removed', $this->client->__( 'The activation for this site was removed. Click Activate License to reconnect it.' ) );
return false;
}

$this->add_error( 'unverified', $this->client->__( 'Could not verify your license right now. Your license key has been kept; please try again later.' ) );

// Keep the form in "activated" state so the user is not asked to re-enter the key.
return (object) array( 'id' => $this->activation_id );
}

/**
Expand Down
Loading