tnp-header.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?php
  2. global $current_user, $wpdb;
  3. defined('ABSPATH') || exit;
  4. $dismissed = get_option('newsletter_dismissed', array());
  5. $user_count = $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where status='C'");
  6. $is_administrator = current_user_can('administrator');
  7. function newsletter_print_entries($group) {
  8. $entries = apply_filters('newsletter_menu_' . $group, array());
  9. if ($entries) {
  10. foreach ($entries as &$entry) {
  11. echo '<li><a href="';
  12. echo $entry['url'];
  13. echo '">';
  14. echo $entry['label'];
  15. if (!empty($entry['description'])) {
  16. echo '<small>';
  17. echo $entry['description'];
  18. echo '</small>';
  19. }
  20. echo '</a></li>';
  21. }
  22. }
  23. }
  24. // Check the status to show a warning if needed
  25. $status_options = Newsletter::instance()->get_options('status');
  26. $warning = false;
  27. $warning |= empty($status_options['mail']);
  28. ?>
  29. <div class="tnp-drowpdown" id="tnp-header">
  30. <a href="?page=newsletter_main_index"><img src="<?php echo plugins_url('newsletter'); ?>/images/header/tnp-logo-red-header.png" class="tnp-header-logo" style="vertical-align: bottom;"></a>
  31. <ul>
  32. <li><a href="#"><i class="fa fa-users"></i> <?php _e('Subscribers', 'newsletter') ?> <i class="fa fa-chevron-down"></i></a>
  33. <ul>
  34. <li><a href="?page=newsletter_users_index"><i class="fa fa-search"></i> <?php _e('Search And Edit', 'newsletter') ?>
  35. <small><?php _e('Add, edit, search', 'newsletter') ?></small></a></li>
  36. <li><a href="?page=newsletter_profile_index"><i class="fa fa-user-circle"></i> <?php _e('Profile page', 'newsletter') ?>
  37. <small><?php _e('The subscriber personal profile editing panel', 'newsletter') ?></small></a></li>
  38. <li><a href="?page=newsletter_users_import"><i class="fa fa-upload"></i> <?php _e('Import', 'newsletter') ?>
  39. <small><?php _e('Import from external sources', 'newsletter') ?></small></a></li>
  40. <li><a href="?page=newsletter_users_export"><i class="fa fa-download"></i> <?php _e('Export', 'newsletter') ?>
  41. <small><?php _e('Export your subscribers list', 'newsletter') ?></small></a></li>
  42. <li><a href="?page=newsletter_users_massive"><i class="fa fa-wrench"></i> <?php _e('Maintenance', 'newsletter') ?>
  43. <small><?php _e('Massive actions: change list, clean up, ...', 'newsletter') ?></small></a></li>
  44. <li><a href="?page=newsletter_users_statistics"><i class="fa fa-chart-bar"></i> <?php _e('Statistics', 'newsletter') ?>
  45. <small><?php _e('All about your subscribers', 'newsletter') ?></small></a></li>
  46. <?php
  47. newsletter_print_entries('subscribers');
  48. ?>
  49. </ul>
  50. </li>
  51. <li><a href="#"><i class="fa fa-list"></i> <?php _e('List Building', 'newsletter') ?> <i class="fa fa-chevron-down"></i></a>
  52. <ul>
  53. <li><a href="?page=newsletter_subscription_options"><i class="fa fa-sign-in-alt"></i> <?php _e('Subscription', 'newsletter') ?>
  54. <small><?php _e('The subscription process in detail', 'newsletter') ?></small></a></li>
  55. <li><a href="?page=newsletter_subscription_antibot"><i class="fa fa-lock"></i> <?php _e('Security', 'newsletter') ?>
  56. <small><?php _e('Spam subscriptions control', 'newsletter') ?></small></a></li>
  57. <li>
  58. <a href="?page=newsletter_subscription_profile"><i class="fa fa-check-square"></i> <?php _e('Subscription Form Fields, Buttons, Labels', 'newsletter') ?>
  59. <small><?php _e('When and what data to collect', 'newsletter') ?></small></a>
  60. </li>
  61. <li>
  62. <a href="?page=newsletter_subscription_lists"><i class="fa fa-th-list"></i> <?php _e('Lists', 'newsletter') ?>
  63. <small><?php _e('Profile the subscribers for a better targeting', 'newsletter') ?></small></a>
  64. </li>
  65. <li>
  66. <a href="?page=newsletter_unsubscription_index"><i class="fa fa-sign-out-alt"></i> <?php _e('Unsubscription', 'newsletter') ?>
  67. <small><?php _e('How to give the last goodbye (or avoid it!)', 'newsletter') ?></small></a>
  68. </li>
  69. <li>
  70. <a href="?page=newsletter_subscription_forms"><i class="fa fa-edit"></i> <?php _e('Custom Forms', 'newsletter') ?>
  71. <small><?php _e('Hand coded form storage', 'newsletter') ?></small></a>
  72. </li>
  73. <?php
  74. newsletter_print_entries('subscription');
  75. ?>
  76. </ul>
  77. </li>
  78. <li><a href="#"><i class="fa fa-newspaper"></i> <?php _e('Newsletters', 'newsletter') ?> <i class="fa fa-chevron-down"></i></a>
  79. <ul>
  80. <li><a href="?page=newsletter_emails_theme"><i class="fa fa-plus"></i> <?php _e('Create newsletter', 'newsletter') ?>
  81. <small><?php _e('Start your new campaign', 'newsletter') ?></small></a></li>
  82. <li><a href="?page=newsletter_emails_index"><i class="fa fa-newspaper"></i> <?php _e('Newsletters', 'newsletter') ?>
  83. <small><?php _e('The classic "write & send" newsletters', 'newsletter') ?></small></a></li>
  84. <li><a href="?page=<?php echo apply_filters('newsletter_admin_page', 'newsletter_statistics_index') ?>"><i class="fa fa-chart-bar"></i> <?php _e('Statistics', 'newsletter') ?>
  85. <small><?php _e('Tracking configuration and basic data', 'newsletter') ?></small></a></li>
  86. <?php
  87. newsletter_print_entries('newsletters');
  88. ?>
  89. </ul>
  90. </li>
  91. <li><a href="#"><i class="fa fa-cog"></i> <?php _e('Settings', 'newsletter') ?> <i class="fa fa-chevron-down"></i></a>
  92. <ul>
  93. <?php if ($is_administrator) { ?>
  94. <li>
  95. <a href="?page=newsletter_main_main"><i class="fa fa-cogs"></i> <?php _e('General Settings', 'newsletter') ?>
  96. <small><?php _e('Delivery speed, sender details, ...', 'newsletter') ?></small></a>
  97. </li>
  98. <?php if (!class_exists('NewsletterSmtp')) { ?>
  99. <li>
  100. <a href="?page=newsletter_main_smtp"><i class="fa fa-server"></i> <?php _e('SMTP', 'newsletter') ?>
  101. <small><?php _e('External mail server', 'newsletter') ?></small>
  102. </a>
  103. </li>
  104. <?php } ?>
  105. <?php } ?>
  106. <li><a href="?page=newsletter_main_info"><i class="fa fa-info"></i> <?php _e('Company Info', 'newsletter') ?>
  107. <small><?php _e('Social, address, logo and general info', 'newsletter') ?></small></a></li>
  108. <li>
  109. <a href="?page=newsletter_subscription_template"><i class="fa fa-file-alt"></i> <?php _e('Messages Template', 'newsletter') ?>
  110. <small><?php _e('Change the look of your service emails', 'newsletter') ?></small></a>
  111. </li>
  112. <?php
  113. newsletter_print_entries('settings');
  114. ?>
  115. </ul>
  116. </li>
  117. <?php if ($is_administrator) { ?>
  118. <li>
  119. <a href="?page=newsletter_main_status"><i class="fa fa-thermometer"></i> <?php _e('Status', 'newsletter') ?>
  120. <?php if ($warning) { ?>
  121. <i class="fa fa-exclamation-triangle" style="color: red;"></i>
  122. <?php } ?>
  123. </a>
  124. </li>
  125. <?php } ?>
  126. <?php $license_data = Newsletter::instance()->get_license_data() ?>
  127. <?php if (empty($license_data)) { ?>
  128. <li class="tnp-professional-extensions-button"><a href="https://www.thenewsletterplugin.com/premium?utm_source=plugin&utm_medium=link&utm_campaign=header" target="_blank">
  129. <i class="fa fa-trophy"></i> <?php _e('Get Professional Addons', 'newsletter') ?></a>
  130. </li>
  131. <?php } elseif (is_wp_error($license_data)) { ?>
  132. <li class="tnp-professional-extensions-button-red">
  133. <a href="?page=newsletter_main_main"><i class="fa fa-hand-paper" style="color: white"></i> <?php _e('License not valid', 'newsletter') ?></a>
  134. </li>
  135. <?php } elseif ($license_data->expire == 0) { ?>
  136. <li class="tnp-professional-extensions-button"><a href="https://www.thenewsletterplugin.com/premium?utm_source=plugin&utm_medium=link&utm_campaign=header" target="_blank">
  137. <i class="fa fa-trophy"></i> <?php _e('Get Professional Addons', 'newsletter') ?></a>
  138. </li>
  139. <?php } elseif ($license_data->expire < time()) { ?>
  140. <li class="tnp-professional-extensions-button-red">
  141. <a href="?page=newsletter_main_main"><i class="fa fa-hand-paper" style="color: white"></i> <?php _e('License expired', 'newsletter') ?></a>
  142. </li>
  143. <?php } elseif ($license_data->expire >= time()) { ?>
  144. <?php $p = class_exists('NewsletterExtensions')?'newsletter_extensions_index':'newsletter_main_extensions'; ?>
  145. <li class="tnp-professional-extensions-button">
  146. <a href="?page=<?php echo $p?>"><i class="fa fa-check-square"></i> <?php _e('License active', 'newsletter') ?></a>
  147. </li>
  148. <?php } ?>
  149. </ul>
  150. </div>
  151. <?php if (isset($_GET['debug']) || !isset($dismissed['newsletter-shortcode'])) { ?>
  152. <?php
  153. // Check of Newsletter dedicated page
  154. if (!empty(Newsletter::instance()->options['page'])) {
  155. if (get_post_status(Newsletter::instance()->options['page']) === 'publish') {
  156. $content = get_post_field('post_content', Newsletter::instance()->options['page']);
  157. // With and without attributes
  158. if (strpos($content, '[newsletter]') === false && strpos($content, '[newsletter ') === false) {
  159. ?>
  160. <div class="tnp-notice">
  161. <a href="<?php echo $_SERVER['REQUEST_URI'] . '&noheader=1&dismiss=newsletter-shortcode' ?>" class="tnp-dismiss">&times;</a>
  162. The Newsletter dedicated page does not contain the [newsletter] shortcode. If you're using a visual composer it could be ok.
  163. <a href="<?php echo site_url('/wp-admin/post.php') ?>?post=<?php echo esc_attr(Newsletter::instance()->options['page']) ?>&action=edit"><strong>Edit the page</strong></a>.
  164. </div>
  165. <?php
  166. }
  167. }
  168. }
  169. ?>
  170. <?php } ?>
  171. <?php if (isset($_GET['debug']) || !isset($dismissed['rate']) && $user_count > 300) { ?>
  172. <div class="tnp-notice">
  173. <a href="<?php echo $_SERVER['REQUEST_URI'] . '&noheader=1&dismiss=rate' ?>" class="tnp-dismiss">&times;</a>
  174. We never asked before and we're curious: <a href="http://wordpress.org/plugins/newsletter/" target="_blank">would you rate this plugin</a>?
  175. (few seconds required - account on WordPress.org required, every blog owner should have one...). <strong>Really appreciated, The Newsletter Team</strong>.
  176. </div>
  177. <?php } ?>
  178. <?php if (isset($_GET['debug']) || !isset($dismissed['newsletter-page']) && empty(Newsletter::instance()->options['page'])) { ?>
  179. <div class="tnp-notice">
  180. <a href="<?php echo $_SERVER['REQUEST_URI'] . '&noheader=1&dismiss=newsletter-page' ?>" class="tnp-dismiss">&times;</a>
  181. You should create a blog page to show the subscription form and the subscription messages. Go to the
  182. <a href="?page=newsletter_main_main">general settings panel</a> to configure it.
  183. </div>
  184. <?php } ?>
  185. <?php if (isset($_GET['debug']) || !isset($dismissed['newsletter-subscribe']) && get_option('newsletter_install_time') && get_option('newsletter_install_time') < time() - 86400 * 15) { ?>
  186. <div class="tnp-notice">
  187. <a href="<?php echo $_SERVER['REQUEST_URI'] . '&noheader=1&dismiss=newsletter-subscribe' ?>" class="tnp-dismiss">&times;</a>
  188. If you want to be informed of important updates of Newsletter, you may want to subscribe to our newsletter<br>
  189. <form action="https://www.thenewsletterplugin.com/?na=s" target="_blank" method="post">
  190. <input type="hidden" value="plugin-header" name="nr">
  191. <input type="hidden" value="3" name="nl[]">
  192. <input type="hidden" value="single" name="optin">
  193. <input type="email" name="ne" value="<?php echo esc_attr(get_option('admin_email')) ?>">
  194. <input type="submit" value="<?php esc_attr_e('Subscribe', 'newsletter') ?>">
  195. </form>
  196. </div>
  197. <?php } ?>
  198. <div id="tnp-notification">
  199. <?php
  200. if (isset($controls)) {
  201. $controls->show();
  202. $controls->messages = '';
  203. $controls->errors = '';
  204. }
  205. ?>
  206. </div>