* @copyright (c) 2013, OnePress Ltd * * @package core * @since 1.0.0 */ /** * Licensing Manager Page * * License page is a place where a user can check updated and manage the license. * * @since 1.0.0 */ class OnpLicensing325_LicenseManagerPage extends FactoryPages321_AdminPage { public $id = 'license-manager'; public $purchasePrice = '$'; /** * If true, offers to activate a trial version. * * @since 3.1.1 * @var boolean */ public $trial = true; /** * If true, shows hits regarding where the user can get a key linked with CodeCanyon. * * @since 3.1.1 * @var boolean */ public $codecanyon = true; /** * If true, shows the FAQ section. * * @since 3.1.1 * @var boolean */ public $faq = true; /** * If true, then tells how to activate a 'premium version', * otherwise tells how to activate 'plugin'. * @since 3.1.1 * @var boolean */ public $premium = true; public function __construct( $plugin) { parent::__construct($plugin); if ( !$this->menuTitle ) $this->menuTitle = __('License Manager', 'onp_licensing_325'); // turns off the license manager if we use the embedded license key if ( $plugin->license && $plugin->license->isEmbedded() ) { $this->hidden = true; } $this->site = site_url(); $this->domain = parse_url( $this->site, PHP_URL_HOST ); } /** * [MAGIC] Magic method that configures assets for a page. */ public function assets($scripts, $styles) { $this->styles->request( array( 'bootstrap.core' ), 'bootstrap' ); $this->styles->add(ONP_LICENSING_325_URL . '/assets/css/license-manager.css'); $this->scripts->add(ONP_LICENSING_325_URL . '/assets/js/license-manager.js'); } // ------------------------------------------------------------------ // Page Actions // ------------------------------------------------------------------ /** * Shows current license type. */ public function indexAction() { $licenseManager = $license = $this->plugin->license; $updatesManager = $this->plugin->updates; $licenseKey = isset( $_POST['licensekey'] ) ? trim( $_POST['licensekey'] ) : null; $scope = isset( $_GET['scope'] ) ? $_GET['scope'] : null; $error = $response = null; // processing a form submission for activation a key if ( isset( $_POST['licensekey'] ) ) { $scope = 'submit-key'; $licenseKey = trim( $_POST['licensekey'] ); if ( empty( $licenseKey ) ) { $error = new WP_Error('FORM:KeyEmpty', __('Please enter your license key to continue.', 'onp_licensing_325')); } else { $response = $licenseManager->activateKey( $licenseKey ); if ( is_wp_error( $response ) ) $error = $response; else $licenseKey = null; } // displaying results of other actions (deletion of a key, checking updates and so on) } else { $code = isset( $_GET['code'] ) ? $_GET['code'] : null; $message = isset( $_GET['message'] ) ? $_GET['message'] : null; if ( $code && $message ) $error = new WP_Error($code, urldecode ( base64_decode($message) ) ); } // preparing some data to display $licenseData = $licenseManager->data; $remained = round( ( $licenseData['Expired'] - time() ) / (60 * 60 * 24), 2 ); $isInfinity = empty( $licenseData['Expired']); // preparing an error data to dispaly if ( $error ) { $parts = explode( ':', $error->get_error_code() ); $errorSource = $parts[0]; } // creating a customer account if it's required if ( $response && !$error && ( isset( $licenseManager->data['KeyBound'] ) && !$licenseManager->data['KeyBound'] ) ) { $this->redirectToAction('createAccount', array('onp_ref' => 'key-activation')); } if ( $response && !$error && ( isset( $licenseManager->data['KeyBound'] ) && $licenseManager->data['KeyBound'] ) ) { $this->redirectToAction('finish'); } ?>
showError($error, $scope) ?>

Plugins page and update the plugin to complete deletion if it\'s needed.', 'onp_licensing_325') ?>

isActualVersion() ) { ?> needChangeAssembly() ) { ?> Click here to get the update.', 'onp_licensing_325'), $this->plugin->license->build ) ?> Click here to get the update.', 'onp_licensing_325'), $updatesManager->lastCheck['Build'] . '-' . $updatesManager->lastCheck['Version'] ) ?>

hasUpgrade() ) { ?> purchasePrice ) ) { ?> purchasePrice ) ?> plugin->pluginTitle ) ) { ?>

plugin->pluginTitle ) ?>

hasKey() ) { ?>

hasKey() ) { ?>
data['Build'] !== 'free' ) { ?> data['Category'] == 'free' ) { ?> codecanyon ) { ?>

Click here.', 'onp_licensing_325') ?>

trial ) { ?>

trial version for 7 days to test the plugin on this site.', 'onp_licensing_325'), $this->getActionUrl('activateTrial') ) ?>

data['Category'] == 'free' ) { ?>

activate a premium version for a trial period (7 days).', 'onp_licensing_325'), $this->getActionUrl('activateTrial') ) ?> here to learn more about the premium version.', 'onp_licensing_325'), onp_licensing_325_get_purchase_url( $this->plugin ) ) ?>

domain ?> plugin->version ?> isVersionChecked() ) { ?> isActualVersion() ) { ?> needChangeAssembly() ) { ?> plugin->license->build ) ?> lastCheck['Build'] ?>-lastCheck['Version'] ?> data['Build'] ?> isExpired() ) {?>
" method="post"> premium ) { ?>

premium ) { ?>

Lean more about the premium version and get the license key to activate it now!', 'onp_licensing_325'), onp_licensing_325_get_purchase_url( $this->plugin ) ) ?>

Lean more about this plugin and get the license key to activate it now!', 'onp_licensing_325'), onp_licensing_325_get_purchase_url( $this->plugin ) ) ?>

data['Build'] !== 'free' ) { ?> isVersionChecked() ) { ?> lastCheck['Checked'] ) ) { ?> %1$s.', 'onp_licensing_325'), date( 'g:i a, j M y', $updatesManager->lastCheck['Checked'] ) ) ?> never.', 'onp_licensing_325') ?> isActualVersion() ) { ?> %1$s, you use the up-to-date version. ', 'onp_licensing_325'), date( 'g:i a, j M y', $updatesManager->lastCheck['Checked'] ) ) ?> %1$s, %2$s. ', 'onp_licensing_325'), date( 'g:i a, j M y', $updatesManager->lastCheck['Checked'] ), $updatesManager->lastCheck['Version'] ) ?> here to check updates manually.', 'onp_licensing_325'), $this->getActionUrl('checkUpdates') ) ?> [ ]
faq ) { ?>
plugin->updates; $licenseManager = $license = $this->plugin->license; $email = isset( $_GET['email'] ) ? $_REQUEST['email'] : null; $urlToRedirect = apply_filters('onp_license_manager_success_redirect_' . $this->plugin->pluginName, $this->getActionUrl('index') ); $btnText = apply_filters('onp_license_manager_success_button_' . $this->plugin->pluginName, __('Okay, I got it', 'onp_licensing_325') ); ?>

plugin->options['title'] ) ?>

data; $remained = round( ( $licenseData['Expired'] - time() ) / (60 * 60 * 24), 2 ); ?>

%s).', 'onp_licensing_325'), $email ) ?>

plugin->options['account'] ?>

needChangeAssembly() ) { ?>

plugin->license; $currentUser = wp_get_current_user(); $email = isset( $_REQUEST['email'] ) ? $_REQUEST['email'] : $currentUser->user_email; $key = $this->plugin->license->key; $pluginName = $this->plugin->pluginTitle; // if true, the congratulation text will be shown $ref = isset( $_REQUEST['onp_ref'] ) ? $_REQUEST['onp_ref'] : null; // if not empty, the error message will be shown $error = false; if ( isset( $_POST['submit'] ) ) { $congrats = false; $subscribe = isset( $_REQUEST['subscribe'] ) ? true: false; if ( empty($email) ) { $error = new WP_Error('FORM:EmailEmpty', __('Please enter your email adress to create a customer account.', 'onp_licensing_325')); } else { $result = $licenseManager->createAccount( $email, $subscribe ); if ( is_wp_error( $result ) ) $error = $result; } // everything is ok, account created if ( !$error ) { $this->redirectToAction('accountCreated', array( 'email' => rawurlencode( $email ), 'cancelCode' => isset( $result['CancelCode'] ) ? $result['CancelCode'] : null, 'confirmationId' => isset( $result['ConfirmationId'] ) ? $result['ConfirmationId'] : null )); } if ( $error ) { $code = $error->get_error_code(); // the account for this email is already crated, are you sure to link the key to this account? if ( $code === 'API:KeyBinding.CustomerExiststsAreYouSureToBindKey' ) { $this->redirectToAction('accountAlreadyCreated', array('email' => rawurlencode( $email ))); } // the key already is linked to this email if ( $code === 'API:KeyBinding.KeyAlreadyBoundToThisEmail' ) { $this->redirectToAction('finish', array('email' => rawurlencode( $email ), 'onp_ref' => 'binding')); } } } ?>

showError( $error ); ?>

()

' />
plugin->license; $updatesManager = $this->plugin->updates; // if not empty, the error message will be shown $error = false; if ( isset( $_POST['submit'] ) ) { if ( empty($email) ) { $error = new WP_Error('FORM:EmailEmpty', __('Please enter your email adress.', 'onp_licensing_325')); } else { $result = $licenseManager->bindKey( $email ); if ( is_wp_error( $result ) ) $error = $result; } if ( !$error ) { $this->redirectToAction('finish', array('email' => rawurlencode( $email ), 'onp_ref' => 'binding')); } if ( $error ) { $code = $error->get_error_code(); // the key already is linked to this email if ( $code === 'API:KeyBinding.KeyAlreadyBoundToThisEmail' ) { $this->redirectToAction('finish', array('email' => rawurlencode( $email ), 'onp_ref' => 'binding')); } } } ?>

showError( $error ); ?>

here.', 'onp_licensing_325'), $this->plugin->options['account'] ) ?>

showError( $error ); ?>

1 %s.', 'onp_licensing_325'), $email ) ?>

2

plugin->license; $result = $licenseManager->cancelAccount( $cancelCode, $confirmationId ); if ( is_wp_error( $result ) ) $error = $result; if ( !$error ) { $this->redirectToAction('createAccount', array('onp_ref' => 'cancel-account')); } // retrun back if it's not possible to cancel the account if ( $error ) { $code = $error->get_error_code(); $this->redirectToAction('accountCreated', array( 'code' => $code, 'message' => base64_encode( $error->get_error_message( $code ) ), 'email' => rawurlencode( $email ), 'cancelCode' => $cancelCode, 'confirmationId' => $confirmationId )); } } /** * Show error from got from the License Server. * * @since 1.0.5 * @param WP_Error $error An error to show. */ private function showError( $error, $action = null ) { if ( empty( $error ) ) return; $parts = explode( ':', $error->get_error_code() ); $errorSource = $parts[0]; $errorCode = $parts[1]; ?>

get_error_message() ?>

get_error_message() ?>

click here for trying to activate your key manualy.', 'onp_licensing_325'), $this->getActionUrl('activateKeyManualy', array('key' => $_POST['licensekey'] )) ); } elseif ($action == 'trial') { printf( __('Please click here for trying to activate your trial manualy.', 'onp_licensing_325'), $this->getActionUrl('activateTrialManualy') ); } elseif ($action == 'delete-key') { printf( __('Please click here for trying to delete key manualy.', 'onp_licensing_325'), $this->getActionUrl('deleteKeyManualy') ); } else { ?>

get_error_message() ?>

plugin->license; $licenseManager->resetLicense(true); $this->redirectToAction('index', array('scope' => 'reset-license')); } /** * Deletes a current key. */ public function deleteKeyAction() { $licenseManager = $license = $this->plugin->license; if ( $licenseManager->hasKey()) { $error = $licenseManager->deleteKey(); if (is_wp_error($error)) { $this->redirectToAction('index', array( 'scope' => 'delete-key', 'code' => $error->get_error_code(), 'message' => base64_encode( $error->get_error_message()))); } $this->redirectToAction('index', array('scope' => 'delete-key')); } $this->indexAction(); } /** * Trys to activate the trial license and then redirect to the index page. */ public function activateTrialAction() { $licenseManager = $this->plugin->license; $response = $licenseManager->activateTrial(); if (is_wp_error($response)) { $this->redirectToAction('index', array( 'scope' => 'trial', 'code' => $response->get_error_code(), 'message' => urlencode( base64_encode( $response->get_error_message()))) ); } $this->redirectToAction('finish', array('onp_ref' => 'trial')); } /** * Allows to activate a key manualy. */ public function activateKeyManualyAction() { $licenseManager = $this->plugin->license; if ( isset( $_POST['response'] ) ) { $error = $licenseManager->activateKeyManualy( $_POST['response'] ); if (is_wp_error($error)) { $this->redirectToAction('index', array( 'scope' => 'submit-key', 'code' => $error->get_error_code(), 'message' => urlencode( base64_encode( $error->get_error_message()))) ); } $this->redirectToAction('finish', array('onp_ref' => 'manual-key-activation')); } else { $this->requestUrl = $licenseManager->getLinkToActivateKey( $_GET['key'] ); } ?>

  • 1. Click here to get an activation code.', 'onp_licensing_325'), $this->requestUrl ) ?>
  • 2.
plugin->license; $this->requestUrl = $licenseManager->getLinkToDeleteKey(); if ( isset( $_POST['response'] ) ) { $error = $licenseManager->deleteKeyManualy( $_POST['response'] ); if (is_wp_error($error)) { $this->redirectToAction('index', array( 'scope' => 'delete-key', 'code' => $error->get_error_code(), 'message' => urlencode( base64_encode( $error->get_error_message()))) ); } $this->redirectToAction('index', array('scope' => 'delete-key', 'code' => 'ok')); } ?>

  • 1. Click here to send the deactivation request.', 'onp_licensing_325'), $this->requestUrl ) ?>
  • 2.
verify code
plugin->license; $this->requestUrl = $licenseManager->getLinkToActivateTrial(); if ( isset( $_POST['response'] ) ) { $error = $licenseManager->activateKeyManualy( $_POST['response'] ); if (is_wp_error($error)) { $this->redirectToAction('index', array( 'scope' => 'trial', 'code' => $error->get_error_code(), 'message' => urlencode( base64_encode( $error->get_error_message()))) ); } $this->redirectToAction('finish', array('onp_ref' => 'manual-trial-activation')); } ?>

Trial Activation

Please perfome the following steps to activate the plugin manualy.

  • 1. Click here to send the activation request.', 'onp_licensing_325'), $this->requestUrl ) ?>
  • 2.
verify code
plugin->updates->checkUpdates(); if (is_wp_error($error)) { $this->redirectToAction('index', array( 'scope' => 'check-updates', 'code' => $error->get_error_code(), 'message' => urlencode( base64_encode( $error->get_error_message()))) ); } $this->redirectToAction('index', array('scope' => 'check-updates')); } public function internalKeysAction( $sender = 'index' ) { $licenseManager = $this->plugin->license; $saved = false; if ( isset( $_POST['site_secret'] ) ) { update_option('onp_site_secret', trim( $_POST['site_secret'] )); $saved = true; } $siteSecret = get_option('onp_site_secret', null); $keySecret = ( !empty($licenseManager->data ) && isset($licenseManager->data['KeySecret']) ) ? $licenseManager->data['KeySecret'] : ''; ?>

License Manager Internal Keys

You actually don't need to change something here. Please change the values below only if OnePress supports ask you to do it.

The changes has been saved successfully!
The license has been reset successfully!