lists.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. defined('ABSPATH') || exit;
  3. @include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
  4. $controls = new NewsletterControls();
  5. $module = NewsletterSubscription::instance();
  6. $current_language = $module->get_current_language();
  7. $is_all_languages = $module->is_all_languages();
  8. $is_multilanguage = $module->is_multilanguage();
  9. $controls->add_language_warning();
  10. if (!$controls->is_action()) {
  11. $controls->data = $module->get_options('lists', $current_language);
  12. } else {
  13. if ($controls->is_action('save')) {
  14. $module->save_options($controls->data, 'lists', null, $current_language);
  15. $controls->add_message_saved();
  16. }
  17. if ($controls->is_action('unlink')) {
  18. $wpdb->query("update " . NEWSLETTER_USERS_TABLE . " set list_" . ((int) $controls->button_data) . "=0");
  19. $controls->add_message_done();
  20. }
  21. }
  22. for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
  23. if (!isset($controls->data['list_' . $i . '_forced'])) {
  24. $controls->data['list_' . $i . '_forced'] = empty($module->options['preferences_' . $i]) ? 0 : 1;
  25. }
  26. }
  27. $status = array(0 => 'Disabled/Private use', 1 => 'Only on profile page', 2 => 'Even on subscription forms', '3' => 'Hidden');
  28. ?>
  29. <script>
  30. jQuery(function () {
  31. jQuery(".tnp-notes").tooltip({
  32. content: function () {
  33. // That activates the HTML in the tooltip
  34. return this.title;
  35. }
  36. });
  37. });
  38. </script>
  39. <div class="wrap tnp-lists" id="tnp-wrap">
  40. <?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
  41. <div id="tnp-heading">
  42. <h2><?php _e('Lists', 'newsletter') ?></h2>
  43. </div>
  44. <div id="tnp-body">
  45. <form method="post" action="">
  46. <?php $controls->init(); ?>
  47. <p>
  48. <?php $controls->button_save(); ?>
  49. </p>
  50. <table class="widefat" style="width: auto">
  51. <thead>
  52. <tr>
  53. <th>#</th>
  54. <th><?php _e('Name', 'newsletter') ?></th>
  55. <?php if ($is_all_languages) { ?>
  56. <th><?php _e('Visibility', 'newsletter') ?></th>
  57. <th><?php _e('Pre-checked', 'newsletter') ?></th>
  58. <th><?php _e('Pre-assigned', 'newsletter') ?></th>
  59. <?php if ($is_multilanguage) { ?>
  60. <th><?php _e('Pre-assigned by language', 'newsletter') ?></th>
  61. <?php } ?>
  62. <?php } ?>
  63. <th><?php _e('Subscribers', 'newsletter') ?></th>
  64. <th>&nbsp;</th>
  65. <th><?php _e('Notes', 'newsletter') ?></th>
  66. </tr>
  67. </thead>
  68. <?php for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) { ?>
  69. <?php
  70. if (!$is_all_languages && empty($controls->data['list_' . $i])) {
  71. continue;
  72. }
  73. ?>
  74. <tr>
  75. <td><?php echo $i; ?></td>
  76. <td><?php $controls->text('list_' . $i, 50); ?></td>
  77. <?php if ($is_all_languages) { ?>
  78. <td><?php $controls->select('list_' . $i . '_status', $status); ?></td>
  79. <td><?php $controls->select('list_' . $i . '_checked', array(0 => 'No', 1 => 'Yes')); ?></td>
  80. <td><?php $controls->select('list_' . $i . '_forced', array(0 => 'No', 1 => 'Yes')); ?></td>
  81. <?php if ($is_multilanguage) { ?>
  82. <td><?php $controls->languages('list_' . $i . '_languages'); ?></td>
  83. <?php } ?>
  84. <?php } ?>
  85. <td><?php echo $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where list_" . $i . "=1 and status='C'"); ?></td>
  86. <td><?php $controls->button_confirm('unlink', __('Unlink everyone', 'newsletter'), '', $i); ?></td>
  87. <td>
  88. <?php $notes = apply_filters('newsletter_lists_notes', array(), $i); ?>
  89. <?php
  90. $text = '';
  91. foreach ($notes as $note) {
  92. $text .= $note . '<br>';
  93. }
  94. if (!empty($text)) {
  95. echo '<i class="fa fa-info-circle tnp-notes" title="', esc_attr($text), '"></i>';
  96. }
  97. ?>
  98. </td>
  99. </tr>
  100. <?php } ?>
  101. </table>
  102. <p>
  103. <?php $controls->button_save(); ?>
  104. </p>
  105. </form>
  106. </div>
  107. <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
  108. </div>