Skip to content

Commit c50c91e

Browse files
committed
adds get version call
1 parent fc94be4 commit c50c91e

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

src/Modules/Licenser.php

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,11 @@ private function do_license_process( $license, $action = 'toggle' ) {
463463
$response = wp_remote_get( sprintf( '%slicense/check/%s/%s/%s/%s', Product::API_URL, rawurlencode( $this->product->get_name() ), $license, rawurlencode( home_url() ), Loader::get_cache_token() ) );
464464
} else {
465465
$response = wp_remote_post(
466-
sprintf( '%slicense/%s/%s/%s/%s/%s', Product::API_URL, $action, rawurlencode( $this->product->get_name() ), $license ),
466+
sprintf( '%slicense/%s/%s/%s', Product::API_URL, $action, rawurlencode( $this->product->get_name() ), $license ),
467467
array(
468-
'body' => array(
468+
'body' => wp_json_encode( array(
469469
'url' => rawurlencode( home_url() ),
470-
),
470+
) ),
471471
'headers' => array(
472472
'Content-Type' => 'application/json',
473473
),
@@ -515,8 +515,7 @@ private function do_license_process( $license, $action = 'toggle' ) {
515515
}
516516
update_option( $this->product->get_key() . '_license_data', $license_data );
517517
set_transient( $this->product->get_key() . '_license_data', $license_data, 12 * HOUR_IN_SECONDS );
518-
519-
if ( 'valid' !== $license_data->license ) {
518+
if ( 'activate' === $action && 'valid' !== $license_data->license ) {
520519
return new \WP_Error( 'themeisle-license-invalid', 'ERROR: Invalid license provided.' );
521520
}
522521

@@ -641,17 +640,15 @@ function check_for_update() {
641640
* @return bool|mixed Update api response.
642641
*/
643642
private function get_version_data() {
644-
$api_params = array(
645-
'edd_action' => 'get_version',
646-
'version' => $this->product->get_version(),
647-
'license' => empty( $this->license_key ) ? 'free' : $this->license_key,
648-
'name' => rawurlencode( $this->product->get_name() ),
649-
'slug' => $this->product->get_slug(),
650-
'author' => rawurlencode( $this->get_distributor_name() ),
651-
'url' => rawurlencode( home_url() ),
652-
);
653-
$response = wp_remote_get(
654-
add_query_arg( $api_params, $this->get_api_url() ),
643+
644+
$response = wp_remote_get(
645+
sprintf( '%slicense/version/%s/%s/%s/%s',
646+
Product::API_URL,
647+
rawurlencode( $this->product->get_name() ),
648+
( empty( $this->license_key ) ? 'free' : $this->license_key ),
649+
$this->product->get_version(),
650+
rawurlencode( home_url() )
651+
),
655652
array(
656653
'timeout' => 15,
657654
'sslverify' => false,

0 commit comments

Comments
 (0)