/** * Generate the array of settings passed to the EDD license call * * @since 1.7.4 * * @param string $action The action to send to edd, such as `check_license` * @param string $license The license key to have passed to EDD * * @return array */ function _get_edd_settings($action = '', $license = '') { // retrieve our license key from the DB $license_key = empty($license) ? trim($this->Addon->get_app_setting('license_key')) : $license; $settings = array('version' => self::version, 'license' => $license_key, 'item_name' => self::name, 'item_id' => self::item_id, 'author' => self::author, 'language' => get_locale(), 'url' => home_url()); if (!empty($action)) { $settings['edd_action'] = esc_attr($action); } $settings = array_map('urlencode', $settings); return $settings; }
public function validate_license_key($value, $field) { // No license? No status. if (empty($value)) { return NULL; } $response = $this->license_call(array('license' => $this->Addon->get_app_setting('license_key'), 'edd_action' => 'check_license', 'field_id' => $field['name'])); $response = is_string($response) ? json_decode($response, true) : $response; switch ($response['license']) { case 'valid': $return = true; break; case 'invalid': $return = false; //$this->Addon->set_field_error( $field, $response['message'] ); break; default: //$this->Addon->set_field_error( $field, $response['message'] ); $return = false; } return $return; }