newsletters.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. if (!defined('ABSPATH')) exit;
  3. require_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
  4. $module = NewsletterStatistics::instance();
  5. $controls = new NewsletterControls();
  6. $emails = Newsletter::instance()->get_emails();
  7. $types = $wpdb->get_results("select distinct type from " . NEWSLETTER_EMAILS_TABLE);
  8. $type_options = array();
  9. foreach ($types as $type) {
  10. if ($type->type == 'followup')
  11. continue;
  12. if ($type->type == 'message') {
  13. $type_options[$type->type] = 'Standard Newsletter';
  14. } else if ($type->type == 'feed') {
  15. $type_options[$type->type] = 'Feed by Mail';
  16. } else if (strpos($type->type, 'automated') === 0) {
  17. list($a, $id) = explode('_', $type->type);
  18. $type_options[$type->type] = 'Automated Channel ' . $id;
  19. } else {
  20. $type_options[$type->type] = $type->type;
  21. }
  22. }
  23. ?>
  24. <div class="wrap" id="tnp-wrap">
  25. <?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
  26. <div id="tnp-heading">
  27. <h2><?php _e('Newsletters', 'newsletter') ?></h2>
  28. </div>
  29. <div id="tnp-body">
  30. <form method="post" action="">
  31. <?php $controls->init(); ?>
  32. <table class="widefat">
  33. <thead>
  34. <tr>
  35. <th>Id</th>
  36. <th><?php _e('Subject', 'newsletter') ?></th>
  37. <th>Type</th>
  38. <th><?php _e('Status', 'newsletter') ?></th>
  39. <th>&nbsp;</th>
  40. <th>&nbsp;</th>
  41. <th><?php _e('Tracking', 'newsletter') ?></th>
  42. <th>&nbsp;</th>
  43. </tr>
  44. </thead>
  45. <tbody>
  46. <?php foreach ($emails as &$email) { ?>
  47. <?php if ($email->type != 'message' && $email->type != 'feed') continue; ?>
  48. <tr>
  49. <td><?php echo $email->id; ?></td>
  50. <td><?php echo esc_html($email->subject); ?></td>
  51. <td><?php echo esc_html($module->get_email_type_label($email)) ?></td>
  52. <td><?php echo esc_html($module->get_email_status_label($email)) ?></td>
  53. <td><?php if ($email->status == 'sent' || $email->status == 'sending') echo $email->sent . ' ' . __('of', 'newsletter') . ' ' . $email->total; ?></td>
  54. <td><?php if ($email->status == 'sent' || $email->status == 'sending') echo $module->format_date($email->send_on); ?></td>
  55. <td><?php echo $email->track == 1 ? 'Yes' : 'No'; ?></td>
  56. <td>
  57. <a class="button-primary" href="<?php echo NewsletterStatistics::instance()->get_statistics_url($email->id); ?>">statistics</a>
  58. </td>
  59. </tr>
  60. <?php } ?>
  61. </tbody>
  62. </table>
  63. </form>
  64. </div>
  65. <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
  66. </div>