index.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. defined('ABSPATH') || exit;
  3. require_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
  4. $controls = new NewsletterControls();
  5. $module = NewsletterEmails::instance();
  6. if ($controls->is_action('copy')) {
  7. $original = Newsletter::instance()->get_email($_POST['btn']);
  8. $email = array();
  9. $email['subject'] = $original->subject;
  10. $email['message'] = $original->message;
  11. $email['message_text'] = $original->message_text;
  12. $email['send_on'] = time();
  13. $email['type'] = 'message';
  14. $email['editor'] = $original->editor;
  15. $email['track'] = $original->track;
  16. $email['options'] = $original->options;
  17. $module->save_email($email);
  18. $controls->messages .= __('Message duplicated.', 'newsletter');
  19. }
  20. if ($controls->is_action('delete')) {
  21. $module->delete_email($_POST['btn']);
  22. $controls->add_message_deleted();
  23. }
  24. if ($controls->is_action('delete_selected')) {
  25. $r = Newsletter::instance()->delete_email($_POST['ids']);
  26. $controls->messages .= $r . ' message(s) deleted';
  27. }
  28. $emails = $module->get_emails('message');
  29. ?>
  30. <div class="wrap tnp-emails tnp-emails-index" id="tnp-wrap">
  31. <?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
  32. <div id="tnp-heading">
  33. <h2><?php _e('Newsletters', 'newsletter') ?></h2>
  34. </div>
  35. <div id="tnp-body">
  36. <form method="post" action="">
  37. <?php $controls->init(); ?>
  38. <p>
  39. <a href="<?php echo $module->get_admin_page_url('theme'); ?>" class="button-primary"><?php _e('New newsletter', 'newsletter') ?></a>
  40. <?php $controls->button_confirm('delete_selected', __('Delete selected newsletters', 'newsletter')); ?>
  41. </p>
  42. <table class="widefat tnp-newsletters-list" style="width: 100%">
  43. <thead>
  44. <tr>
  45. <th>&nbsp;</th>
  46. <th>Id</th>
  47. <th><?php _e('Subject', 'newsletter') ?></th>
  48. <th><?php _e('Status', 'newsletter') ?></th>
  49. <th><?php _e('Progress', 'newsletter') ?>&nbsp;(*)</th>
  50. <th><?php _e('Date', 'newsletter') ?></th>
  51. <th>&nbsp;</th>
  52. <th>&nbsp;</th>
  53. <th>&nbsp;</th>
  54. <th>&nbsp;</th>
  55. <th>&nbsp;</th>
  56. </tr>
  57. </thead>
  58. <tbody>
  59. <?php
  60. foreach ($emails as $email) { ?>
  61. <tr>
  62. <td><input type="checkbox" name="ids[]" value="<?php echo $email->id; ?>"/></td>
  63. <td><?php echo $email->id; ?></td>
  64. <td><?php
  65. if ($email->subject)
  66. echo htmlspecialchars($email->subject);
  67. else
  68. echo "Newsletter #" . $email->id;
  69. ?>
  70. </td>
  71. <td>
  72. <?php $module->show_email_status_label($email) ?>
  73. </td>
  74. <td>
  75. <?php $module->show_email_progress_bar($email, array('numbers'=>true)) ?>
  76. </td>
  77. <td><?php if ($email->status == 'sent' || $email->status == 'sending') echo $module->format_date($email->send_on); ?></td>
  78. <td>
  79. <?php echo $module->get_edit_button($email) ?>
  80. </td>
  81. <td>
  82. <a class="button-primary" href="<?php echo NewsletterStatistics::instance()->get_statistics_url($email->id); ?>"><i class="fa fa-chart-bar"></i> <?php _e('Statistics', 'newsletter') ?></a>
  83. </td>
  84. <td><a class="button-primary" target="_blank" rel="noopener" href="<?php echo home_url('/')?>?na=view&id=<?php echo $email->id; ?>"><i class="fa fa-eye"></i>&nbsp;<?php _e('View', 'newsletter')?></a></td>
  85. <td><?php $controls->button_copy($email->id); ?></td>
  86. <td><?php $controls->button_delete($email->id); ?></td>
  87. </tr>
  88. <?php } ?>
  89. </tbody>
  90. </table>
  91. <p>
  92. (*) <?php _e('Expected total at the end of the delivery may differ due to subscriptions/unsubscriptions occurred meanwhile.', 'newsletter') ?>
  93. </p>
  94. </form>
  95. </div>
  96. <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
  97. </div>