function populate_licenses($form) { $choices = array(); foreach ($form['fields'] as $field) { if ($field->type != 'select' || strpos($field->cssClass, 'donkey-licenses') === false) { continue; } $licenses = apply_filters('donkey_gravityforms_populate_licenses', donkey_get_user()->get_licenses()); if (!empty($licenses)) { foreach ($licenses as $license) { $license = donkey_get_license($license); if (!$license->is_active()) { continue; } $bad = array('WordPress Directory Theme', 'Marketplace WordPress Theme', 'WordPress Job Board Theme', 'WP Job Manager', '-', '--', '—'); $name = trim(str_replace($bad, '', $license->get_item_name())); $choices[] = array('value' => 'valid-' . sanitize_title($license->get_item_name()), 'text' => $name . ' — Expires: ' . esc_attr($license->get_expiration(get_option('date_format')))); } } $choices = apply_filters('donkey_gravityforms_populate_license_choices', $choices); if (empty($choices)) { $choices[] = array('value' => 'no-licenses', 'text' => __('No theme or plugin licenses found.', 'donkey')); } $field->choices = $choices; } return $form; }
private function fetchHtml($data) { global $wpdb; $html = array(); $email = $data['customer']['email']; $user = get_user_by('email', $email); $user = donkey_get_user($user->ID); $licenses = $user->get_licenses(); if ('' != $user->get_envato_username()) { $html[] = '<p>Envato Username: <strong>' . $user->get_envato_username() . '</strong></p>'; if ('' != $user->get_envato_display_name()) { $html[] = '<p>' . $user->get_envato_display_name() . ', ' . $user->get_envato_country() . '</p>'; } } if (!empty($licenses)) { foreach ($licenses as $license) { $license = donkey_get_license($license); // clean name - astoundify format $name = $license->get_item_name(); $name = str_replace(array('WordPress Directory Theme', 'Digital Marketplace WordPress Theme', 'WordPress Job Board Theme', '-'), '', $name); $name = trim($name); $html[] = '<table>'; $html[] = '<tr>'; $html[] = '<td style="border: 1px solid #ccc;"><strong>' . $name . '</strong></td>'; $html[] = '<td style="border: 1px solid #ccc;"><span style="badge ' . ($license->is_active() ? 'green' : 'red') . ' ">' . $license->is_active() ? 'Valid' : 'Expired' . '</span></td>'; $html[] = '</tr>'; $html[] = '<tr>'; $html[] = '<td colspan="2" style="border: 1px solid #ccc;">' . $license->get_code() . '</td>'; $html[] = '</tr>'; $html[] = '<tr>'; $html[] = '<td colspan="2" style="border: 1px solid #ccc;">Expires: ' . $license->get_expiration('Y-m-d') . '</td>'; $html[] = '</tr>'; $html[] = '<table>'; } } else { $html[] = '<p>' . __('No licenses', 'donkey') . '</p>'; } return implode('', $html); return $html; }
<thead> <tr> <th width="70%"><?php _e('Item', 'donkey'); ?> </th> <th><?php _e('Support Status', 'donkey'); ?> </th> </tr> </thead> <tbody> <?php foreach ($licenses as $license) { $license = donkey_get_license($license); ?> <tr> <td> <?php echo $license->get_item_name(); ?> <br /> <small><?php echo $license->get_code(); ?> </small> </td> <td> <span class="license-status" title="<?php printf(__('Expires %s', 'donkey'), $license->get_expiration());