/**
  * Renders an HTML textarea
  *
  * @since 1.9
  *
  * @param array $args Arguments for the textarea
  * @return string textarea
  */
 public function textarea($args = array())
 {
     $defaults = array('name' => 'textarea', 'value' => null, 'label' => null, 'desc' => null, 'class' => 'large-text', 'disabled' => false);
     $args = wp_parse_args($args, $defaults);
     $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
     $disabled = '';
     if ($args['disabled']) {
         $disabled = ' disabled="disabled"';
     }
     $output = '<span id="edd-' . edd_sanitize_key($args['name']) . '-wrap">';
     if (!empty($args['label'])) {
         $output .= '<label class="edd-label" for="' . edd_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
     }
     $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . edd_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
     if (!empty($args['desc'])) {
         $output .= '<span class="edd-description">' . esc_html($args['desc']) . '</span>';
     }
     $output .= '</span>';
     return $output;
 }
 function edd_license_key_callback($args)
 {
     $edd_option = edd_get_option($args['id']);
     $messages = array();
     $license = get_option($args['options']['is_valid_license_option']);
     if ($edd_option) {
         $value = $edd_option;
     } else {
         $value = isset($args['std']) ? $args['std'] : '';
     }
     if (!empty($license) && is_object($license)) {
         // activate_license 'invalid' on anything other than valid, so if there was an error capture it
         if (false === $license->success) {
             switch ($license->error) {
                 case 'expired':
                     $class = 'expired';
                     $messages[] = sprintf(__('Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'easy-digital-downloads'), date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp'))), 'https://easydigitaldownloads.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired');
                     $license_status = 'license-' . $class . '-notice';
                     break;
                 case 'revoked':
                     $class = 'error';
                     $messages[] = sprintf(__('Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'easy-digital-downloads'), 'https://easydigitaldownloads.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked');
                     $license_status = 'license-' . $class . '-notice';
                     break;
                 case 'missing':
                     $class = 'error';
                     $messages[] = sprintf(__('Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'easy-digital-downloads'), 'https://easydigitaldownloads.com/your-account?utm_campaign=admin&utm_source=licenses&utm_medium=missing');
                     $license_status = 'license-' . $class . '-notice';
                     break;
                 case 'invalid':
                 case 'site_inactive':
                     $class = 'error';
                     $messages[] = sprintf(__('Your %s is not active for this URL. Please <a href="%s" target="_blank">visit your account page</a> to manage your license key URLs.', 'easy-digital-downloads'), $args['name'], 'https://easydigitaldownloads.com/your-account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid');
                     $license_status = 'license-' . $class . '-notice';
                     break;
                 case 'item_name_mismatch':
                     $class = 'error';
                     $messages[] = sprintf(__('This appears to be an invalid license key for %s.', 'easy-digital-downloads'), $args['name']);
                     $license_status = 'license-' . $class . '-notice';
                     break;
                 case 'no_activations_left':
                     $class = 'error';
                     $messages[] = sprintf(__('Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'easy-digital-downloads'), 'https://easydigitaldownloads.com/your-account/');
                     $license_status = 'license-' . $class . '-notice';
                     break;
                 case 'license_not_activable':
                     $class = 'error';
                     $messages[] = __('The key you entered belongs to a bundle, please use the product specific license key.', 'easy-digital-downloads');
                     $license_status = 'license-' . $class . '-notice';
                     break;
                 default:
                     $class = 'error';
                     $error = !empty($license->error) ? $license->error : __('unknown_error', 'easy-digital-downloads');
                     $messages[] = sprintf(__('There was an error with this license key: %s. Please <a href="%s">contact our support team</a>.', 'easy-digital-downloads'), $error, 'https://easydigitaldownlaods.com/support');
                     $license_status = 'license-' . $class . '-notice';
                     break;
             }
         } else {
             switch ($license->license) {
                 case 'valid':
                 default:
                     $class = 'valid';
                     $now = current_time('timestamp');
                     $expiration = strtotime($license->expires, current_time('timestamp'));
                     if ('lifetime' === $license->expires) {
                         $messages[] = __('License key never expires.', 'easy-digital-downloads');
                         $license_status = 'license-lifetime-notice';
                     } elseif ($expiration > $now && $expiration - $now < DAY_IN_SECONDS * 30) {
                         $messages[] = sprintf(__('Your license key expires soon! It expires on %s. <a href="%s" target="_blank">Renew your license key</a>.', 'easy-digital-downloads'), date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp'))), 'https://easydigitaldownloads.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew');
                         $license_status = 'license-expires-soon-notice';
                     } else {
                         $messages[] = sprintf(__('Your license key expires on %s.', 'easy-digital-downloads'), date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp'))));
                         $license_status = 'license-expiration-date-notice';
                     }
                     break;
             }
         }
     } else {
         $class = 'empty';
         $messages[] = sprintf(__('To receive updates, please enter your valid %s license key.', 'easy-digital-downloads'), $args['name']);
         $license_status = null;
     }
     $class .= ' ' . edd_sanitize_html_class($args['field_class']);
     $size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular';
     $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="edd_settings[' . edd_sanitize_key($args['id']) . ']" name="edd_settings[' . edd_sanitize_key($args['id']) . ']" value="' . esc_attr($value) . '"/>';
     if (is_object($license) && 'valid' == $license->license || 'valid' == $license) {
         $html .= '<input type="submit" class="button-secondary" name="' . $args['id'] . '_deactivate" value="' . __('Deactivate License', 'easy-digital-downloads') . '"/>';
     }
     $html .= '<label for="edd_settings[' . edd_sanitize_key($args['id']) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
     if (!empty($messages)) {
         foreach ($messages as $message) {
             $html .= '<div class="edd-license-data edd-license-' . $class . ' ' . $license_status . '">';
             $html .= '<p>' . $message . '</p>';
             $html .= '</div>';
         }
     }
     wp_nonce_field(edd_sanitize_key($args['id']) . '-nonce', edd_sanitize_key($args['id']) . '-nonce');
     echo $html;
 }