* @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 ); $nounce = wp_create_nonce('hidelm'); $optionName = 'onp_lm_' . $this->plugin->pluginName . '_' . $nounce; $optionValue = get_option( $optionName ); if ( !empty( $optionValue ) ) { $this->hidden = true; } } /** * [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'] ) ? htmlspecialchars ( 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 = htmlspecialchars( 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'); } ?>
plugin->pluginTitle ) ?>
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' ) { ?>trial ) { ?>
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() ) {?> |
plugin->options['title'] ) ?>
data; $remained = round( ( $licenseData['Expired'] - time() ) / (60 * 60 * 24), 2 ); ?>
%s).', 'onp_licensing_325'), $email ) ?>
needChangeAssembly() ) { ?>
Warning! The License Manager will get inaccessible when you click the button "Hide License Manager".', 'onp_licensing_325') ?>
%s on the page options.php:', 'onp_licensing_325'), $optionName ) ?>
">