theme.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. global $newsletter; // Newsletter object
  3. global $post; // Current post managed by WordPress
  4. if (!defined('ABSPATH'))
  5. exit;
  6. /*
  7. * Some variabled are prepared by Newsletter Plus and are available inside the theme,
  8. * for example the theme options used to build the email body as configured by blog
  9. * owner.
  10. *
  11. * $theme_options - is an associative array with theme options: every option starts
  12. * with "theme_" as required. See the theme-options.php file for details.
  13. * Inside that array there are the autmated email options as well, if needed.
  14. * A special value can be present in theme_options and is the "last_run" which indicates
  15. * when th automated email has been composed last time. Is should be used to find if
  16. * there are now posts or not.
  17. *
  18. * $is_test - if true it means we are composing an email for test purpose.
  19. */
  20. // This array will be passed to WordPress to extract the posts
  21. $filters = array();
  22. // Maximum number of post to retrieve
  23. $filters['posts_per_page'] = (int) $theme_options['theme_max_posts'];
  24. if ($filters['posts_per_page'] == 0)
  25. $filters['posts_per_page'] = 10;
  26. // Include only posts from specified categories. Do not filter per category is no
  27. // one category has been selected.
  28. if (is_array($theme_options['theme_categories'])) {
  29. $filters['cat'] = implode(',', $theme_options['theme_categories']);
  30. }
  31. // Retrieve the posts asking them to WordPress
  32. $posts = get_posts($filters);
  33. ?>
  34. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  35. <html>
  36. <head>
  37. <title></title>
  38. </head>
  39. <body>
  40. <table bgcolor="#c0c0c0" width="100%" cellpadding="20" cellspacing="0" border="0">
  41. <tr>
  42. <td align="center">
  43. <table width="500" bgcolor="#ffffff" align="center" cellspacing="10" cellpadding="0" style="border: 1px solid #666;">
  44. <tr>
  45. <td style="font-size: 30px">
  46. <i><?php echo get_option('blogname'); ?></i>
  47. </td>
  48. </tr>
  49. <tr>
  50. <td style="border-top: 1px solid #eee; border-bottom: 1px solid #eee; font-size: 12px; color: #999">
  51. <br />NEWSLETTER<br /><br />
  52. </td>
  53. </tr>
  54. <tr>
  55. <td style="font-size: 14px; color: #666">
  56. <p>Dear {name}, here an update from <?php echo get_option('blogname'); ?>.</p>
  57. </td>
  58. </tr>
  59. <?php
  60. // Do not use &post, it leads to problems...
  61. foreach ($posts as $post) {
  62. // Setup the post (WordPress requirement)
  63. setup_postdata($post);
  64. // The theme can "suggest" a subject replacing the one configured, for example. In this case
  65. // the theme, is there is no subject, suggest the first post title.
  66. if (empty($theme_options['subject']))
  67. $theme_options['subject'] = $post->post_title;
  68. // Extract a thumbnail, return null if no thumb can be found
  69. $image = nt_post_image(get_the_ID());
  70. ?>
  71. <tr>
  72. <td style="font-size: 14px; color: #666">
  73. <?php if ($image != null) { ?>
  74. <img src="<?php echo $image; ?>" alt="picture" align="left"/>
  75. <?php } ?>
  76. <p><a target="_tab" href="<?php echo get_permalink(); ?>" style="font-size: 16px; color: #000; text-decoration: none"><?php the_title(); ?></a></p>
  77. <?php the_excerpt(); ?>
  78. </td>
  79. </tr>
  80. <?php
  81. }
  82. ?>
  83. <?php if (!isset($theme_options['theme_social_disable'])) { ?>
  84. <tr>
  85. <td style="font-family: Arial; font-size: 12px">
  86. <?php include WP_PLUGIN_DIR . '/newsletter/emails/themes/default/social.php'; ?>
  87. </td>
  88. </tr>
  89. <?php } ?>
  90. <tr>
  91. <td style="border-top: 1px solid #eee; border-bottom: 1px solid #eee; font-size: 12px; color: #999">
  92. You received this email because you subscribed for it as {email}. If you'd like, you can <a target="_tab" href="{unsubscription_url}">unsubscribe</a>.
  93. </td>
  94. </tr>
  95. </table>
  96. </td>
  97. </tr>
  98. </table>
  99. </body>
  100. </html>