protected function save() { $licenseData = null; if (!empty($this->license)) { $licenseData = $this->license->getData(); unset($licenseData['sites']); } $options = array('license_key' => $this->storeLicenseKey ? $this->licenseKey : null, 'site_token' => $this->siteToken, 'license' => $licenseData); if ($this->licenseScope === self::LICENSE_SCOPE_NETWORK) { update_site_option($this->optionName, $options); } else { update_option($this->optionName, $options); } }
/** * @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; }