Skip to content

Commit 0ad3500

Browse files
committed
Update license/asset handling
1 parent 3b1eb4a commit 0ad3500

File tree

5 files changed

+33
-11
lines changed

5 files changed

+33
-11
lines changed

assets/build/js/edd-sl-sdk.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/src/js/license.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
}
7575
if ( data.license.length && action === 'deactivate' ) {
7676
$( '.edd-sl-sdk__license--input' ).removeAttribute( 'readonly' );
77-
} else if ( action === 'activate' || action === 'verify' ) {
77+
$( '.edd-sl-sdk__license-status-message' ).remove();
78+
} else if ( action === 'activate' ) {
7879
$( '.edd-sl-sdk__license--input' ).setAttribute( 'readonly', 'true' );
7980
if ( res.data.url && res.data.url.length ) {
8081
setTimeout( () => {

edd-sl-sdk.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@
2626

2727
add_action( 'after_setup_theme', 'edd_sl_sdk_register_1_0_0', 0, 0 ); // WRCS: DEFINED_VERSION.
2828

29-
// phpcs:disable Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace
3029
/**
3130
* Registers this version of Action Scheduler.
3231
*/
3332
function edd_sl_sdk_register_1_0_0() {
34-
// WRCS: DEFINED_VERSION.
33+
$version = '1.0.0';
3534
$versions = EasyDigitalDownloads\Updater\Versions::instance();
36-
$versions->register( '1.0.0', 'edd_sl_sdk_initialize_1_0_0' ); // WRCS: DEFINED_VERSION.
35+
$versions->register( $version, 'edd_sl_sdk_initialize_1_0_0' ); // WRCS: DEFINED_VERSION.
36+
if ( ! defined( 'EDD_SL_SDK_VERSION' ) ) {
37+
define( 'EDD_SL_SDK_VERSION', $version );
38+
}
3739
}
3840

3941
// phpcs:disable Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace

src/Handlers/Handler.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ public function license_modal() {
8686
?>
8787
<div class="edd-sdk-notice--overlay"></div>
8888
<?php
89-
wp_enqueue_script( 'edd-sdk-notice', EDD_SL_SDK_URL . 'assets/build/js/edd-sl-sdk.js', array(), '1.0.0', true );
90-
wp_enqueue_style( 'edd-sdk-notice', EDD_SL_SDK_URL . 'assets/build/css/style-edd-sl-sdk.css', array(), '1.0.0' );
89+
wp_enqueue_script( 'edd-sdk-notice', EDD_SL_SDK_URL . 'assets/build/js/edd-sl-sdk.js', array(), EDD_SL_SDK_VERSION, true );
90+
wp_enqueue_style( 'edd-sdk-notice', EDD_SL_SDK_URL . 'assets/build/css/style-edd-sl-sdk.css', array(), EDD_SL_SDK_VERSION );
9191
wp_localize_script(
9292
'edd-sdk-notice',
9393
'edd_sdk_notice',
@@ -186,4 +186,22 @@ protected function get_default_api_request_args() {
186186
'allow_tracking' => $this->license->get_allow_tracking(),
187187
);
188188
}
189+
190+
/**
191+
* Gets the slug for the API request.
192+
*
193+
* @since <next-version>
194+
* @return string
195+
*/
196+
protected function get_slug(): string {
197+
if ( empty( $this->args['file'] ) ) {
198+
return '';
199+
}
200+
201+
if ( ! $this->slug ) {
202+
$this->slug = basename( dirname( $this->args['file'] ) );
203+
}
204+
205+
return $this->slug;
206+
}
189207
}

src/Licensing/License.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ public function get_key_option_name() {
7777
* @return string
7878
*/
7979
public function get_actions( $should_echo = false ) {
80-
$status = get_option( $this->get_status_option_name() );
81-
$button = $this->get_button_args( $status );
82-
$timestamp = time();
80+
$license_data = get_option( $this->get_status_option_name() );
81+
$status = $license_data->license ?? 'inactive';
82+
$button = $this->get_button_args( $status );
83+
$timestamp = time();
8384
if ( ! $should_echo ) {
8485
ob_start();
8586
}
@@ -361,6 +362,6 @@ private function can_manage_license( $nonce_name = 'edd_sl_sdk_license_handler'
361362
* @return string
362363
*/
363364
private function get_status_option_name() {
364-
return ! empty( $this->args['option_name'] ) ? "{$this->args['option_name']}_status" : "{$this->slug}_license_status";
365+
return ! empty( $this->args['option_name'] ) ? "{$this->args['option_name']}_license" : "{$this->slug}_license";
365366
}
366367
}

0 commit comments

Comments
 (0)