-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from G3ronim0/develop
Release 1.0.4
- Loading branch information
Showing
22 changed files
with
1,063 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
defined( 'ABSPATH' ) or die( 'Cheatin’ uh?' ); | ||
|
||
/** | ||
* Ouput Activate license button | ||
* | ||
* @since 1.0.4 | ||
*/ | ||
function wptxu_action_add_license() { | ||
?> | ||
|
||
<div><button type="button" id="wptxu_license_activate" class="button-secondary"> <?php _e( 'Activate License', 'wpt-tx-updater' ); ?></button><span id="wptxu-spinner-key" class="spinner"></span></div> | ||
|
||
<?php } | ||
|
||
/** | ||
* Ouput Deactivate license button and license informations | ||
* | ||
* @since 1.0.4 | ||
*/ | ||
function wptxu_action_remove_license( $expires ) { | ||
$now = current_time( 'timestamp' ); | ||
$expiration = strtotime( $expires, current_time( 'timestamp' ) ); | ||
$key = get_option( 'wptxu-sl-key' ); | ||
$license = get_transient( '_wptxu_license_data' ); | ||
|
||
if ( 'lifetime' === $expires ) { | ||
$expiration_message = __( 'License key never expires.', 'wpt-tx-updater' ); | ||
} elseif ( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) { | ||
$expiration_message = sprintf( | ||
__( 'Your license key expires soon! It expires on %s. <a href="%s" target="_blank" title="Renew license">Renew your license key</a>.', 'wpt-tx-updater' ), | ||
date_i18n( 'j F Y', strtotime( $expires, current_time( 'timestamp' ) ) ), | ||
WPTXU_STORE_URL.'/commander/?edd_license_key=' . $key | ||
); | ||
} else { | ||
$expiration_message = sprintf( | ||
__( 'Your license key expires on %s.', 'wpt-tx-updater' ), | ||
date_i18n( 'j F Y', strtotime( $expires, current_time( 'timestamp' ) ) ) | ||
); | ||
} | ||
|
||
?> | ||
<div class="wptxu-license-information"> | ||
<div><span class="wptxu-success dashicons dashicons-yes"></span> <?php _e( 'License active', 'wpt-tx-updater' ); ?></div> | ||
<div><span class="dashicons dashicons-backup"></span> <?php echo $expiration_message; ?></strong></div> | ||
<div><button type="button" id="wptxu_license_deactivate" class="button-secondary"><span class="wptxu-vam dashicons dashicons-no"></span> <?php _e( 'Deactivate License', 'wpt-tx-updater' ); ?></button><span id="wptxu-spinner-key" class="spinner"></span></div> | ||
</div> | ||
|
||
<?php } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
defined( 'ABSPATH' ) or die( 'Cheatin’ uh?' ); | ||
|
||
/** | ||
* Make a http call to EDD software licensing API | ||
* | ||
* @since 1.0.4 | ||
* | ||
* @param (string) $action (activate_license|check_license|delete_license) | ||
*/ | ||
function wptxu_sl_call( $action, $key ) { | ||
|
||
if ( $action == 'activate_license' ) { | ||
$api_params = array( | ||
'edd_action' => $action, | ||
'license' => $key, | ||
'item_name' => urlencode( WPTXU_SLUG ), // The name of our product in EDD. | ||
'url' => home_url(), | ||
); | ||
} else { | ||
$api_params = array( | ||
'edd_action' => $action, | ||
'license' => $key, | ||
'item_name' => urlencode( WPTXU_SLUG ), | ||
); | ||
} | ||
|
||
$args = array( | ||
'timeout' => 30, | ||
'sslverify' => false, | ||
'body' => $api_params, | ||
); | ||
|
||
// Call the custom API. | ||
$remote_call = wp_remote_post( add_query_arg( $api_params, WPTXU_STORE_URL ), $args ); | ||
|
||
// Make sure the response came back okay. | ||
if ( is_wp_error( $remote_call ) ) { | ||
$error_message = sprintf( __( '<p class="wptxu-error"><span class="dashicons dashicons-info"></span>There is a problem with remote site, please try again. %s</p>', 'wpt-tx-updater' ), $remote_call->get_error_message() ); | ||
return $error_message; | ||
} else { | ||
// Decode the license data. | ||
$license_data = json_decode( wp_remote_retrieve_body( $remote_call ) ); | ||
} | ||
|
||
return $license_data; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.