/** * @param string|null $currentKey * @param string|null $currentToken * @param Wslm_ProductLicense $currentLicense */ public function license_ui_upgrade_link($currentKey = null, $currentToken = null, $currentLicense = null) { if (empty($currentKey) && empty($currentToken)) { return; } $upgradeLink = 'http://adminmenueditor.com/upgrade-license/'; $upgradeText = 'Upgrade or renew license'; if ($currentLicense && $currentLicense->getStatus() === 'expired') { $upgradeLink = 'http://adminmenueditor.com/renew-license/'; $upgradeText = 'Renew license'; } if (!empty($currentKey)) { $upgradeLink = add_query_arg('license_key', $currentKey, $upgradeLink); } $externalIcon = plugins_url('/images/external.png', $this->wp_menu_editor->plugin_file); ?> <p> <label>Actions:</label> <a href="<?php echo esc_attr($upgradeLink); ?> " rel="external" target="_blank" title="Opens in a new window" > <?php echo $upgradeText; ?> <img src="<?php echo esc_attr($externalIcon); ?> " alt="External link icon" width="10" height="10"> </a> </p><?php }
/** * @param Wslm_ProductLicense $license * @param bool $usingToken * @return array */ public function prepareLicenseForOutput($license, $usingToken = false) { $data = $license->getData(); $data['status'] = $license->getStatus(); //Ensure timestamps are formatted consistently. foreach (array('issued_on', 'expires_on') as $datetimeField) { if (isset($data[$datetimeField])) { $data[$datetimeField] = gmdate('c', strtotime($data[$datetimeField])); } } $visibleFields = array_fill_keys(array('license_key', 'product_slug', 'status', 'issued_on', 'max_sites', 'expires_on', 'sites', 'site_url', 'error'), true); if ($usingToken) { $visibleFields = array_merge($visibleFields, array('license_key' => false, 'sites' => false)); } $visibleFields = apply_filters('wslm_api_visible_license_fields', $visibleFields); $data = array_intersect_key($data, array_filter($visibleFields)); return $data; }
/** * @param string $status * @param string $message * @param Wslm_ProductLicense $currentLicense */ private function printLicenseDetails($status, $message = '', $currentLicense = null) { $currentKey = $this->licenseManager->getLicenseKey(); $currentToken = $this->licenseManager->getSiteToken(); ?> <p> <span class="license-status"> <label>Status:</label> <?php echo $status; ?> </span> </p> <?php if (!empty($currentKey)) { ?> <p><label>License key:</label> <?php echo htmlentities($currentKey); ?> </p><?php } if (!empty($currentToken) && $this->tokenDisplayEnabled) { ?> <p><label>Site token:</label> <?php echo htmlentities($currentToken); ?> </p><?php } $expiresOn = isset($currentLicense) ? $currentLicense->get('expires_on') : null; if ($expiresOn) { $formattedDate = date_i18n(get_option('date_format'), strtotime($expiresOn)); ?> <p> <label>Expires:</label> <span title="<?php echo esc_attr($expiresOn); ?> "><?php echo $formattedDate; ?> </span> </p> <?php } do_action('wslm_license_ui_details-' . $this->slug, $currentKey, $currentToken); if (!empty($message)) { echo '<p>', $message, '</p>'; } }
public function hasExistingLicense() { return $this->getSiteToken() !== null && $this->license !== null && $this->license->isExisting(); }