theme.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. if (!defined('ABSPATH'))
  3. exit;
  4. require_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
  5. $controls = new NewsletterControls();
  6. $module = NewsletterEmails::instance();
  7. if ($controls->is_action('theme')) {
  8. $controls->merge($module->themes->get_options($controls->data['theme']));
  9. $module->save_options($controls->data);
  10. }
  11. if ($controls->data == null) {
  12. $controls->data = $module->get_options();
  13. }
  14. function newsletter_emails_update_options($options) {
  15. add_option('newsletter_emails', '', null, 'no');
  16. update_option('newsletter_emails', $options);
  17. }
  18. function newsletter_emails_update_theme_options($theme, $options) {
  19. $x = strrpos($theme, '/');
  20. if ($x !== false) {
  21. $theme = substr($theme, $x + 1);
  22. }
  23. add_option('newsletter_emails_' . $theme, '', null, 'no');
  24. update_option('newsletter_emails_' . $theme, $options);
  25. }
  26. function newsletter_emails_get_options() {
  27. $options = get_option('newsletter_emails', array());
  28. return $options;
  29. }
  30. function newsletter_emails_get_theme_options($theme) {
  31. $x = strrpos($theme, '/');
  32. if ($x !== false) {
  33. $theme = substr($theme, $x + 1);
  34. }
  35. $options = get_option('newsletter_emails_' . $theme, array());
  36. return $options;
  37. }
  38. $themes = $module->themes->get_all_with_data();
  39. ?>
  40. <div class="wrap tnp-emails tnp-emails-theme" id="tnp-wrap">
  41. <?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
  42. <div id="tnp-heading">
  43. <h2><?php _e('Select a theme', 'newsletter') ?>
  44. <a class="tnp-btn-h1" href="https://www.thenewsletterplugin.com/plugins/newsletter/newsletter-themes" target="_blank">Custom themes</a>
  45. </h2>
  46. </div>
  47. <div id="tnp-body" class="tnp-darkbg">
  48. <form method="post" id="newsletter-form" action="<?php echo $module->get_admin_page_url('new'); ?>">
  49. <?php $controls->init(); ?>
  50. <?php $controls->hidden('theme'); ?>
  51. <div class="tnp-themes-new">
  52. <div class="tnp-theme-preview">
  53. <p><?php echo _e('Responsive Drag & Drop Composer', 'newsletter') ?></p>
  54. <a href="<?php echo $module->get_admin_page_url('composer'); ?>" style="margin-right: 20px; margin-bottom: 20px">
  55. <img src="<?php echo plugins_url('newsletter') . '/emails/images/composer.gif' ?>" width="420" height="200">
  56. </a>
  57. </div>
  58. <div class="tnp-theme-preview">
  59. <p>&lt;&gt; Raw HTML</p>
  60. <a href="#" onclick="var f = document.getElementById('newsletter-form');
  61. f.act.value = 'theme';
  62. f.elements['options[theme]'].value = 'rawhtml';
  63. f.submit();
  64. return false;" style="margin-right: 20px; margin-bottom: 20px">
  65. <img src="<?php echo plugins_url('newsletter') . '/emails/images/html.png' ?>" width="200" height="200">
  66. </a>
  67. </div>
  68. </div>
  69. <?php foreach ($themes as $key => $data) { ?>
  70. <div class="tnp-theme-preview">
  71. <p><?php echo esc_html($data['name']) ?></p>
  72. <a href="#" onclick="var f = document.getElementById('newsletter-form');
  73. f.act.value = 'theme';
  74. f.elements['options[theme]'].value = '<?php echo esc_js($data['id']) ?>';
  75. f.submit();
  76. return false;" style="margin-right: 20px; margin-bottom: 20px">
  77. <img src="<?php echo esc_attr($data['screenshot']) ?>" width="200" height="200">
  78. </a>
  79. </div>
  80. <?php } ?>
  81. </form>
  82. </div>
  83. <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
  84. </div>