Plugin Directory

Changeset 2634590


Ignore:
Timestamp:
11/24/2021 08:59:42 AM (4 years ago)
Author:
Sygnoos
Message:

New version 4.0.5 released

Location:
popup-builder/trunk
Files:
1 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • popup-builder/trunk/com/classes/Actions.php

    r2584791 r2634590  
    44use \SgpbPopupConfig;
    55use \SgpbDataConfig;
     6
    67
    78class Actions
     
    7071
    7172    private function checkIfLicenseIsActive($license, $itemId, $storeURL, $key) {
     73        /* TODO change the domain to a valid domain name! from store url before the production */
    7274        $transient = 'sgpb-license-key-'.$key.'-requested';
    7375        if ( false !== ( $value = get_transient( $transient ) ) ) {
    7476            return;
    7577        }
    76         $apiParams = array(
    77             'edd_action' => 'activate_license',
    78             'license'    => $license,
    79             'item_id'    => $itemId, // The ID of the item in EDD
    80             'url'        => home_url()
     78        $params = array(
     79            'woo_sl_action'     => 'status-check',
     80            'licence_key'       => $license,
     81            'product_unique_id' => $itemId,
     82            'domain'            => home_url()
    8183        );
    82         $response = wp_remote_post($storeURL, array('timeout' => 15, 'sslverify' => false, 'body' => $apiParams));
     84        $requestUri = 'https://popup-builder.com/index.php?'.http_build_query($params);
     85        $response = wp_remote_get($requestUri);
    8386        if (!is_wp_error($response) || 200 == wp_remote_retrieve_response_code($response)) {
    8487            $licenseData = json_decode(wp_remote_retrieve_body($response));
    85             update_option('sgpb-license-status-'.$key, $licenseData->license);
    86             set_transient($transient, $licenseData->item_name, WEEK_IN_SECONDS);
    87         }
    88 
     88            $status = isset($licenseData[0]->licence_status) && $licenseData[0]->licence_status === 'active' ? 'valid' : $licenseData[0]->licence_status;
     89            update_option('sgpb-license-status-'.$key, $status);
     90            set_transient($transient, $licenseData[0]->status_code, WEEK_IN_SECONDS);
     91        }
    8992    }
    9093    public function updatesInit()
    9194    {
    92         if (!class_exists('sgpb\EDD_SL_Plugin_Updater')) {
     95        if (!class_exists('sgpb\WOOSL_CodeAutoUpdate')) {
    9396            // load our custom updater if it doesn't already exist
    94             require_once(SG_POPUP_LIBS_PATH .'EDD_SL_Plugin_Updater.php');
     97            require_once(SG_POPUP_LIBS_PATH .'WOOSL_CodeAutoUpdate.php');
    9598        }
    9699        $licenses = (new License())->getLicenses();
     100
    97101        foreach ($licenses as $license) {
    98102            $key = @$license['key'];
     
    139143                continue;
    140144            }
    141             $sgpbUpdater = new EDD_SL_Plugin_Updater($storeURL, $pluginMainFilePath, array(
    142                 'version'   => $version,        // current version number
    143                 'license'   => $licenseKey, // license key (used get_option above to retrieve from DB)
    144                 'item_id'   => $license['itemId'],  // id of this plugin
    145                 'author'    => $license['autor'],   // author of this plugin
    146                 'beta'      => false // set to true if you wish customers to receive update notifications of beta releases
    147             ));
     145            $sgpbUpdater = new WOOSL_CodeAutoUpdate(
     146                'https://popup-builder.com/index.php',
     147                $pluginMainFilePath,
     148                $itemId,
     149                $licenseKey,
     150                $version
     151            );
    148152        }
    149153    }
  • popup-builder/trunk/com/classes/Updates.php

    r2578665 r2634590  
    22namespace sgpb;
    33
     4/* TODO change the domain name before production */
    45
    56class Updates
     
    6162    }
    6263
     64    private function activateLicense($license, $itemId)
     65    {
     66        $params = array(
     67            'woo_sl_action'     => 'activate',
     68            'licence_key'       => $license,
     69            'product_unique_id' => $itemId,
     70            'domain'            => home_url()
     71        );
     72
     73        $requestUri = 'https://popup-builder.com/index.php?'.http_build_query($params);
     74
     75        return wp_remote_get($requestUri);
     76    }
     77
     78    private function deactivateLicense($license, $itemId)
     79    {
     80        $params = array(
     81            'woo_sl_action'     => 'deactivate',
     82            'licence_key'       => $license,
     83            'product_unique_id' => $itemId,
     84            'domain'            => home_url()
     85        );
     86
     87        $requestUri = 'https://popup-builder.com/index.php?'.http_build_query($params);
     88
     89        return wp_remote_get($requestUri);
     90    }
     91
    6392    public function sgpbActivateLicense()
    6493    {
     
    6897            $key = @$license['key'];
    6998            $itemId = @$license['itemId'];
    70             $itemName = @$license['itemName'];
    71             $storeURL = @$license['storeURL'];
    7299            $this->licenseKey = $key;
    73100
     
    84111                // retrieve the license from the database
    85112                $license = trim(get_option('sgpb-license-key-'.$key));
    86                 // data to send in our API request
    87                 $apiParams = array(
    88                     'edd_action' => 'activate_license',
    89                     'license'    => $license,
    90                     'item_id'    => $itemId, // The ID of the item in EDD
    91                     'url'        => home_url()
    92                 );
    93                 // Call the custom API.
    94                 $response = wp_remote_post($storeURL, array('timeout' => 15, 'sslverify' => false, 'body' => $apiParams));
    95                 // make sure the response came back okay
    96                 if (is_wp_error($response) || 200 !== wp_remote_retrieve_response_code($response)) {
    97                     $errorMessage = $response->get_error_message();
    98                     $message = (is_wp_error($response) && ! empty($errorMessage)) ? $errorMessage : __('An error occurred, please try again.', SG_POPUP_TEXT_DOMAIN);
    99                 }
    100                 else {
    101                     $licenseData = json_decode(wp_remote_retrieve_body($response));
    102                     if (false === $licenseData->success) {
    103                         switch ($licenseData->error) {
    104                             case 'expired' :
    105                                 $message = sprintf(
    106                                     __('Your license key expired on %s.', SG_POPUP_TEXT_DOMAIN),
    107                                     date_i18n(get_option('date_format'), strtotime($licenseData->expires, current_time('timestamp')))
    108                                 );
    109                                 break;
    110                             case 'revoked' :
    111                                 $message = __('Your license key has been disabled.', SG_POPUP_TEXT_DOMAIN);
    112                                 break;
    113                             case 'missing' :
    114                                 $message = __('Invalid license.', SG_POPUP_TEXT_DOMAIN);
    115                                 break;
    116                             case 'invalid' :
    117                             case 'site_inactive' :
    118                                 $message = __('Your license is not active for this URL.',SG_POPUP_TEXT_DOMAIN);
    119                                 break;
    120                             case 'item_name_mismatch' :
    121                                 $message = sprintf(__('This appears to be an invalid license key for %s.', SG_POPUP_TEXT_DOMAIN), $itemName);
    122                                 break;
    123                             case 'no_activations_left' :
    124                                 $message = __('You\'ve already used the permitted number of this license key!', SG_POPUP_TEXT_DOMAIN);
    125                                 break;
    126                             default :
    127                                 $message = __('An error occurred, please try again.', SG_POPUP_TEXT_DOMAIN);
    128                                 break;
     113                $data = $this->activateLicense($license, $itemId);
     114                if (!is_wp_error($data) && $data['response']['code'] == 200) {
     115                    $dataBody = json_decode($data['body']);
     116                    if (isset($dataBody[0]->status)) {
     117                        if ($dataBody[0]->status == 'success' && ($dataBody[0]->status_code == 's100' || $dataBody[0]->status_code == 's101')) {
     118                            update_option('sgpb-license-status-'.$key, 'valid');
     119                            $hasInactiveExtensions = AdminHelper::hasInactiveExtensions();
     120
     121                            if (empty($hasInactiveExtensions)) {
     122                                delete_option('SGPB_INACTIVE_EXTENSIONS', 'inactive');
     123                            }
     124
     125                            wp_redirect(admin_url('edit.php?post_type='.SG_POPUP_POST_TYPE.'&page='.SGPB_POPUP_LICENSE));
     126                            exit();
    129127                        }
    130128                    }
    131129                }
    132                 // Check if anything passed on a message constituting a failure
    133                 if (!empty($message)) {
    134                     $baseUrl = admin_url('edit.php?post_type='.SG_POPUP_POST_TYPE.'&page='.SGPB_POPUP_LICENSE);
    135                     $redirect = add_query_arg(array('sl_activation' => 'false', 'message' => urlencode($message)), $baseUrl);
    136                     wp_redirect($redirect);
    137                     exit();
    138                 }
    139                 // $licenseData->license will be either "valid" or "invalid"
    140                 update_option('sgpb-license-status-'.$key, $licenseData->license);
    141                 $hasInactiveExtensions = AdminHelper::hasInactiveExtensions();
    142                 // all available extensions have active license status
    143                 if (empty($hasInactiveExtensions)) {
    144                     // and if we don't have inactive extensions, remove option, until new one activation
    145                     delete_option('SGPB_INACTIVE_EXTENSIONS', 'inactive');
    146                 }
    147                 wp_redirect(admin_url('edit.php?post_type='.SG_POPUP_POST_TYPE.'&page='.SGPB_POPUP_LICENSE));
     130
     131                $message = __('An error occurred, please try again.', SG_POPUP_TEXT_DOMAIN);
     132                $baseUrl = admin_url('edit.php?post_type='.SG_POPUP_POST_TYPE.'&page='.SGPB_POPUP_LICENSE);
     133                $redirect = add_query_arg(array('sl_activation' => 'false', 'message' => urlencode($message)), $baseUrl);
     134                wp_redirect($redirect);
    148135                exit();
    149136            }
     
    152139                $license = trim(get_option('sgpb-license-key-'.$key));
    153140                // data to send in our API request
    154                 $apiParams = array(
    155                     'edd_action' => 'deactivate_license',
    156                     'license'    => $license,
    157                     'item_id'    => $itemId, // The ID of the item in EDD
    158                     'url'        => home_url()
    159                 );
    160                 $home = home_url();
    161                 // Send the remote request
    162                 $response = wp_remote_post($storeURL, array('body' => $apiParams, 'timeout' => 15, 'sslverify' => false));
     141                $response = $this->deactivateLicense($license, $itemId);
    163142                if (is_wp_error($response) || 200 !== wp_remote_retrieve_response_code($response)) {
    164                     $errorMessage = $response->get_error_message();
    165                     $message = (is_wp_error($response) && ! empty($errorMessage)) ? $errorMessage : __('An error occurred, please try again.', SG_POPUP_TEXT_DOMAIN);
     143                    $message = __('An error occurred, please try again.', SG_POPUP_TEXT_DOMAIN);
    166144                    $baseUrl = admin_url('edit.php?post_type='.SG_POPUP_POST_TYPE.'&page='.SGPB_POPUP_LICENSE);
    167145                    $redirect = add_query_arg(array('message' => urlencode($message)), $baseUrl);
  • popup-builder/trunk/com/config/configPackage.php

    r2585890 r2634590  
    44}
    55
    6 define('SG_POPUP_VERSION', '4.0.4');
     6define('SG_POPUP_VERSION', '4.0.5');
    77define('SGPB_POPUP_PKG', SGPB_POPUP_PKG_FREE);
    88define('POPUP_BUILDER_BASENAME', 'popupbuilder-platinum/popup-builder.php');
  • popup-builder/trunk/popup-builder.php

    r2585890 r2634590  
    44* Plugin URI: https://popup-builder.com
    55* Description: The most complete popup plugin. Html, image, iframe, shortcode, video and many other popup types. Manage popup dimensions, effects, themes and more.
    6 * Version: 4.0.4
     6* Version: 4.0.5
    77* Author: Sygnoos
    88* Author URI: https://sygnoos.com
  • popup-builder/trunk/readme.txt

    r2585890 r2634590  
    99Tested up to: 5.8
    1010Requires PHP: 5.3.3
    11 Stable tag: 4.0.4
     11Stable tag: 4.0.5
    1212License: GPLv2 or later
    1313License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    146146== Changelog ==
    147147
     148= Version 4.0.5 =
     149* Bug fixes and improvements
     150
    148151= Version 4.0.4 =
    149152* Bug fixed related to JS files that some 3rd party plugins minify on our side
Note: See TracChangeset for help on using the changeset viewer.