PageRenderTime 48ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/docroot/wp-content/plugins/wp-email-notification/email_notification_2.3.1.php

https://bitbucket.org/greg_gallant/cd-blog
PHP | 564 lines | 347 code | 118 blank | 99 comment | 96 complexity | 8eb1ac827ae8e99084cf3ec885cf2d2a MD5 | raw file
Possible License(s): LGPL-2.1, GPL-3.0, GPL-2.0, BSD-3-Clause
  1. <?php
  2. /*
  3. Plugin Name: WordPress Email Notification Plugin v2.3.1
  4. Plugin URI: http://watershedstudio.com/portfolio/software/wp-email-notification.html
  5. Description: Allow People To Sign Up For E-Mail Notifications
  6. Author: Brian Groce
  7. Version: 2.3.1
  8. Author URI: http://briangroce.com/
  9. */
  10. //--------------------------------------------------------//
  11. // CREATE VARIABLES
  12. //--------------------------------------------------------//
  13. if(!isset($wpdb->posts)) {
  14. $wpdb->posts = $table_prefix . 'posts';
  15. $wpdb->postmeta = $table_prefix . 'postmeta';
  16. $wpdb->users = $table_prefix . 'users';
  17. }
  18. if(!isset($wpdb->email_list)) {
  19. $wpdb->email_list = 'wp_email_list';
  20. }
  21. //********************************************//
  22. // email_notification_admin
  23. //********************************************//
  24. function email_notification_admin() {
  25. add_management_page(__("Email Notification"), __('Email Notification'), 8, 'wp-email-notification/index.php');
  26. }
  27. //********************************************//
  28. // email_notification_form
  29. //********************************************//
  30. function email_notification_form($notify) {
  31. $pull_config = "SELECT default_send FROM wp_email_list_config WHERE id = '1'";
  32. $pull_config_result = mysql_query($pull_config);
  33. if (!$pull_config_result) { exit; }
  34. if (mysql_num_rows($pull_config_result) == 0) { exit; }
  35. while ($row = mysql_fetch_assoc($pull_config_result)) {
  36. $default_send = $row['default_send'];
  37. switch($default_send){
  38. case "No":
  39. $sendN = "selected=\"selected\"";
  40. break;
  41. case "Yes":
  42. $sendY = "selected=\"selected\"";
  43. break;
  44. }
  45. echo "
  46. <fieldset id=\"email_notification\">
  47. <legend>Notify Subscribers?</legend>
  48. <div>
  49. <select id=\"notify\" name=\"notify\" value=\"$default_send\" />
  50. <option $sendY>Yes</option>
  51. <option $sendN>No</option>
  52. </select>
  53. </div>
  54. </fieldset>
  55. ";
  56. }
  57. return $notify;
  58. }
  59. //********************************************//
  60. // email_notification_send
  61. //********************************************//
  62. function email_notification_send($post_ID) {
  63. //--------------------------------------------------------//
  64. // GET CONFIG INFO
  65. //--------------------------------------------------------//
  66. $query = "select * from wp_email_list_config where id = '1'";
  67. $res = mysql_query($query) or print mysql_error();
  68. $row = mysql_fetch_assoc($res);
  69. $from_email = $row['from_email'];
  70. $admin_email = $row['admin_email'];
  71. $nice_urls = $row['nice_urls'];
  72. $show_content = $row['show_content'];
  73. $html_email = $row['html_email'];
  74. $html_template = ABSPATH."/wp-content/plugins/wp-email-notification/email_template.html";
  75. # Site Information
  76. $site_name = $row['site_name'];
  77. $site_url = $row['site_url'];
  78. $blog_url = $row['blog_url'];
  79. # Set Globals
  80. global $wpdb, $table_prefix;
  81. $wpdb->email_list_future = $table_prefix . 'email_list_future';
  82. $notify = $_POST['notify'];
  83. //--------------------------------------------------------//
  84. // GRAB POST STATUS
  85. //--------------------------------------------------------//
  86. $prev_status = $_POST['prev_status'];
  87. $post_status = $_POST['post_status'];
  88. if (isset($_POST['publish'])) $post_status = 'publish';
  89. //--------------------------------------------------------//
  90. // are we going from draft/private to published?
  91. //--------------------------------------------------------//
  92. if ($prev_status != 'publish' && $post_status == 'publish' && $notify == 'Yes') {
  93. # Grab post date info
  94. $post_year = $_POST['aa'];
  95. $post_month = $_POST['mm'];
  96. $post_day = $_POST['jj'];
  97. $post_hour = $_POST['hh'];
  98. $post_minute = $_POST['mn'];
  99. # Add leading zeros to month
  100. if ($post_month == "1") { $post_month = "01"; }
  101. if ($post_month == "2") { $post_month = "02"; }
  102. if ($post_month == "3") { $post_month = "03"; }
  103. if ($post_month == "4") { $post_month = "04"; }
  104. if ($post_month == "5") { $post_month = "05"; }
  105. if ($post_month == "6") { $post_month = "06"; }
  106. if ($post_month == "7") { $post_month = "07"; }
  107. if ($post_month == "8") { $post_month = "08"; }
  108. if ($post_month == "9") { $post_month = "09"; }
  109. # Date diff calculation
  110. $post_date = "$post_year$post_month$post_day$post_hour$post_minute";
  111. $curr_date = date("YmdHi");
  112. $date_diff = $curr_date - $post_date;
  113. # If post is future dated
  114. if ($date_diff < 0){
  115. # Check for existing post
  116. $check_existing = "SELECT post_ID ";
  117. $check_existing .= "FROM $wpdb->email_list_future ";
  118. $check_existing .= "WHERE post_ID = '$post_ID'";
  119. $check_existing_result = mysql_query($check_existing);
  120. $check_existing_nrows = mysql_num_rows($check_existing_result);
  121. # If it's an update
  122. if ($check_existing_nrows > 0) {
  123. $update_future = "UPDATE $wpdb->email_list_future ";
  124. $update_future .= "SET ";
  125. $update_future .= "post_date = '$post_date' ";
  126. $update_future .= "WHERE post_ID = '$post_ID'";
  127. $update_future_result = mysql_query($update_future);
  128. }
  129. else {
  130. # If it's a new record
  131. $insert_future = "INSERT INTO $wpdb->email_list_future (post_ID, post_date, notification_sent) VALUES ('$post_ID', '$post_date', 'n')";
  132. $insert_future_result = mysql_query($insert_future);
  133. }
  134. }
  135. # Not future dated so mail it
  136. else {
  137. //--------------------------------------------------------//
  138. // SELECT POSTS FROM WP FUNCTIONS
  139. //--------------------------------------------------------//
  140. $posts = & query_posts("p=$post_ID");
  141. the_post();
  142. $post_content = get_the_content();
  143. $post_content = stripslashes($post_content);
  144. $post_content = str_replace(array("â&#x20AC;&#x153;","â&#x20AC;?","â&#x20AC;&#x2122;","â&#x20AC;&#x201C;","â&#x20AC;&#x201D;","â&#x20AC;?","&nbsp;"), array('"','"','´','&#x2013;','&#x2014;','...',' '), $post_content);
  145. $post_content = utf8_decode($post_content);
  146. $post_filtered = apply_filters('the_content', $post_content);
  147. $post_filtered = str_replace(']]>', ']]&gt;', $post_filtered);
  148. $post_title = get_the_title();
  149. $post_title = stripslashes($post_title);
  150. $post_title = str_replace(array("â&#x20AC;&#x153;","â&#x20AC;?","â&#x20AC;&#x2122;","â&#x20AC;&#x201C;","â&#x20AC;&#x201D;","â&#x20AC;?"), array('"','"','´','&#x2013;','&#x2014;','...'), $post_title);
  151. $post_title = utf8_decode($post_title);
  152. $post_author = get_the_author();
  153. $post_time = get_the_time( ' F jS, Y' );
  154. // Replace entities
  155. if ($html_email != 'Yes'){
  156. $post_content = str_replace(array("<ul>","</ul>","<ol>","</ol>","<li>","</li>"), array('','','','','* ',''), $post_content);
  157. $post_content = strip_tags($post_content);
  158. }
  159. else {
  160. $post_content = $post_content . "\n"; // just to make things a little easier, pad the end
  161. $post_content = preg_replace('|<br />\s*<br />|', "\n\n", $post_content);
  162. $post_content = preg_replace('!(<(?:table|ul|ol|li|pre|form|blockquote|h[1-6])[^>]*>)!', "\n$1", $post_content); // Space things out a little
  163. $post_content = preg_replace('!(</(?:table|ul|ol|li|pre|form|blockquote|h[1-6])>)!', "$1\n", $post_content); // Space things out a little
  164. $post_content = preg_replace("/(\r\n|\r)/", "\n", $post_content); // cross-platform newlines
  165. $post_content = preg_replace("/\n\n+/", "\n\n", $post_content); // take care of duplicates
  166. $post_content = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "\t<p>$1</p>\n", $post_content); // make paragraphs, including one at the end
  167. $post_content = preg_replace('|<p>\s*?</p>|', '', $post_content); // under certain strange conditions it could create a P of entirely whitespace
  168. $post_content = preg_replace("|<p>(<li.+?)</p>|", "$1", $post_content); // problem with nested lists
  169. $post_content = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $post_content);
  170. $post_content = str_replace('</blockquote></p>', '</p></blockquote>', $post_content);
  171. $post_content = preg_replace('!<p>\s*(</?(?:table|tr|td|th|div|ul|ol|li|pre|select|form|blockquote|p|h[1-6])[^>]*>)!', "$1", $post_content);
  172. $post_content = preg_replace('!(</?(?:table|tr|td|th|div|ul|ol|li|pre|select|form|blockquote|p|h[1-6])[^>]*>)\s*</p>!', "$1", $post_content);
  173. $post_content = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $post_content); // optionally make line breaks
  174. $post_content = preg_replace('!(</?(?:table|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|p|h[1-6])[^>]*>)\s*<br />!', "$1", $post_content);
  175. $post_content = preg_replace('!<br />(\s*</?(?:p|li|div|th|pre|td|ul|ol)>)!', '$1', $post_content);
  176. $post_content = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $post_content);
  177. }
  178. //--------------------------------------------------------//
  179. // BUILD URL
  180. //--------------------------------------------------------//
  181. if ($post_title != '' && $nice_urls == 'Yes'){
  182. // This is for the nicer URL permalink
  183. $url = get_permalink($post_ID);
  184. }
  185. else {
  186. // This is for the default URL permalink
  187. $url = "$blog_url/index.php?p=$post_ID";
  188. }
  189. //--------------------------------------------------------//
  190. // HTML VERSION OF MESSAGE
  191. //--------------------------------------------------------//
  192. if ($html_email == 'Yes'){
  193. $msg = ""; // initialize variable
  194. if ($html_template != "" ) {
  195. $msg = file_get_contents($html_template);
  196. }
  197. // If the template file is empty...
  198. if ($msg == "") {
  199. if ($post_title != ''){
  200. $msg = "<p>A new entry titled '@@title' has been posted to @@site.</p>";
  201. $msg .= "<hr /><h1><a href=\"$url\">@@title</a></h1>";
  202. }
  203. else {
  204. $msg = "<p>A new entry has been posted to @@site.</p>";
  205. $msg .= "<hr /><h1><a href=\"$url\">$url</a></h1>";
  206. }
  207. if ($show_content == 'Yes') { $msg .= "@@content"; }
  208. $msg .= "<hr />@@subscriptionDetails";
  209. }
  210. # Replace variables
  211. $msg = str_replace('@@title',$post_title,$msg);
  212. $msg = str_replace('@@site',$site_name,$msg);
  213. $msg = str_replace('@@permalink',$url,$msg);
  214. $msg = str_replace('@@content',$post_filtered,$msg);
  215. $msg = str_replace('@@author',$post_author,$msg);
  216. $msg = str_replace('@@time',$post_time,$msg);
  217. $msg = str_replace('@@date',$post_date,$msg);
  218. $subscriptionDetails = "You have signed up to receive these notifications. <br /><br />";
  219. $subscriptionDetails .= "If you would like to unsubscribe, visit the url below:<br />";
  220. $subscriptionDetails .= "<a href=\"$site_url/maillist/index.php?action=unsub&addr=@@to_addr\">$site_url/maillist/index.php?action=unsub&addr=@@to_addr</a><br />";
  221. $msg = str_replace('@@subscriptionDetails',$subscriptionDetails,$msg);
  222. }
  223. //--------------------------------------------------------//
  224. // TEXT VERSION OF MESSAGE
  225. //--------------------------------------------------------//
  226. else {
  227. if ($post_title != ''){
  228. $msg = "A new entry titled '$post_title' has been posted to $site_name.\n\n";
  229. }
  230. else {
  231. $msg = "A new entry has been posted to $site_name.\n\n";
  232. }
  233. if ($show_content == 'Yes') {
  234. $msg .= "$post_content\n\n";
  235. }
  236. $msg .= "$url\n\n";
  237. $msg .= "------------------------------------------------------\n\n";
  238. $msg .= "You have signed up to receive these notifications. \n\n";
  239. $msg .= "If you would like to unsubscribe, visit the url below:\n";
  240. // This is for the default URL permalink
  241. $msg .= "$site_url/maillist/index.php?action=unsub&addr=@@to_addr\n";
  242. }
  243. //--------------------------------------------------------//
  244. // EMAIL HEADER
  245. //--------------------------------------------------------//
  246. $header = "MIME-Version: 1.0\r\n";
  247. if ($html_email == 'Yes'){
  248. $header .= "Content-Type: text/html; charset=\"" . get_settings('blog_charset') . "\"\r\n";
  249. }
  250. else {
  251. $header .= "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\r\n";
  252. }
  253. $header .= "From: \"$site_name\" <$from_email>\n";
  254. $header .= "Reply-To: $from_email\n";
  255. $header .= "Return-Path: $from_email\n";
  256. //--------------------------------------------------------//
  257. // SUBJECT
  258. //--------------------------------------------------------//
  259. if ($post_title != ''){
  260. $subject = "$site_name: $post_title";
  261. }
  262. else {
  263. $subject = "$site_name: New Entry";
  264. }
  265. //--------------------------------------------------------//
  266. // SELECT USERS TO EMAIL FROM DB
  267. //--------------------------------------------------------//
  268. $query = "SELECT email_addr FROM $wpdb->email_list WHERE gets_mail = 1";
  269. $res = mysql_query($query);
  270. // Mail it
  271. while ($row = mysql_fetch_assoc($res)) {
  272. $addr = $row['email_addr'];
  273. $msgFinal = str_replace('@@to_addr',$addr,$msg);
  274. Mail($addr, $subject, $msgFinal, $header);
  275. }
  276. return $post_ID; // It may be buggy otherwise.
  277. }
  278. } // end if moving from draft/private to published
  279. }
  280. //--------------------------------------------------------//
  281. // email_notification_future_send
  282. //--------------------------------------------------------//
  283. function email_notification_future_send() {
  284. # Set Globals
  285. global $wpdb, $table_prefix;
  286. $wpdb->email_list_future = $table_prefix . 'email_list_future';
  287. $wpdb->posts = $table_prefix . 'posts';
  288. # Date diff calculation
  289. $curr_date = date("YmdHi");
  290. # Check the DB for posts that need to be sent
  291. $check_existing = "SELECT * ";
  292. $check_existing .= "FROM $wpdb->email_list_future ";
  293. $check_existing .= "WHERE post_date < '$curr_date' ";
  294. $check_existing .= "AND notification_sent = 'n' ";
  295. $check_existing_result = mysql_query($check_existing);
  296. $check_existing_nrows = mysql_num_rows($check_existing_result);
  297. # Don't process unless there are entries that need to be e-mailed
  298. while ($future_row = mysql_fetch_assoc($check_existing_result)) {
  299. $send_post_ID = $future_row['post_ID'];
  300. # GET CONFIG INFO #
  301. $query_config = "select * from wp_email_list_config where id = '1'";
  302. $res_config = mysql_query($query_config) or print mysql_error();
  303. $config_row = mysql_fetch_assoc($res_config);
  304. $from_email = $config_row['from_email'];
  305. $admin_email = $config_row['admin_email'];
  306. $nice_urls = $config_row['nice_urls'];
  307. $show_content = $config_row['show_content'];
  308. $html_email = $config_row['html_email'];
  309. $html_template = ABSPATH."/wp-content/plugins/wp-email-notification/email_template.html";
  310. # Site Information
  311. $site_name = $config_row['site_name'];
  312. $site_url = $config_row['site_url'];
  313. $blog_url = $config_row['blog_url'];
  314. # Select the post from the DB
  315. $select_post = "SELECT * ";
  316. $select_post .= "FROM $wpdb->posts ";
  317. $select_post .= "WHERE ID = '$send_post_ID' ";
  318. $select_post_result = mysql_query($select_post);
  319. # Grab the post...
  320. while ($post_row = mysql_fetch_assoc($select_post_result)) {
  321. $post_url = $post_row[guid];
  322. $post_content = $post_row[post_content];
  323. $post_content_filtered = $post_row[post_content_filtered];
  324. $post_title = $post_row[post_title];
  325. $post_author = $post_row[post_author];
  326. $post_time = $post_row[post_date];
  327. $string_date = strtotime("$post_time");
  328. $post_time = date("F jS, Y", $string_date);
  329. $post_content = stripslashes($post_content);
  330. $post_content = str_replace(array("â&#x20AC;&#x153;","â&#x20AC;?","â&#x20AC;&#x2122;","â&#x20AC;&#x201C;","â&#x20AC;&#x201D;","â&#x20AC;?","&nbsp;"), array('"','"','´','&#x2013;','&#x2014;','...',' '), $post_content);
  331. $post_content = utf8_decode($post_content);
  332. $post_content_filtered = apply_filters('the_content', $post_content);
  333. $post_content_filtered = str_replace(']]>', ']]&gt;', $post_content_filtered);
  334. $post_title = stripslashes($post_title);
  335. $post_title = str_replace(array("â&#x20AC;&#x153;","â&#x20AC;?","â&#x20AC;&#x2122;","â&#x20AC;&#x201C;","â&#x20AC;&#x201D;","â&#x20AC;?"), array('"','"','´','&#x2013;','&#x2014;','...'), $post_title);
  336. $post_title = utf8_decode($post_title);
  337. # Replace entities
  338. if ($html_email != 'Yes'){
  339. $post_content = str_replace(array("<ul>","</ul>","<ol>","</ol>","<li>","</li>"), array('','','','','* ',''), $post_content);
  340. $post_content = strip_tags($post_content);
  341. }
  342. else {
  343. $post_content = $post_content . "\n"; // just to make things a little easier, pad the end
  344. $post_content = preg_replace('|<br />\s*<br />|', "\n\n", $post_content);
  345. $post_content = preg_replace('!(<(?:table|ul|ol|li|pre|form|blockquote|h[1-6])[^>]*>)!', "\n$1", $post_content); // Space things out a little
  346. $post_content = preg_replace('!(</(?:table|ul|ol|li|pre|form|blockquote|h[1-6])>)!', "$1\n", $post_content); // Space things out a little
  347. $post_content = preg_replace("/(\r\n|\r)/", "\n", $post_content); // cross-platform newlines
  348. $post_content = preg_replace("/\n\n+/", "\n\n", $post_content); // take care of duplicates
  349. $post_content = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "\t<p>$1</p>\n", $post_content); // make paragraphs, including one at the end
  350. $post_content = preg_replace('|<p>\s*?</p>|', '', $post_content); // under certain strange conditions it could create a P of entirely whitespace
  351. $post_content = preg_replace("|<p>(<li.+?)</p>|", "$1", $post_content); // problem with nested lists
  352. $post_content = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $post_content);
  353. $post_content = str_replace('</blockquote></p>', '</p></blockquote>', $post_content);
  354. $post_content = preg_replace('!<p>\s*(</?(?:table|tr|td|th|div|ul|ol|li|pre|select|form|blockquote|p|h[1-6])[^>]*>)!', "$1", $post_content);
  355. $post_content = preg_replace('!(</?(?:table|tr|td|th|div|ul|ol|li|pre|select|form|blockquote|p|h[1-6])[^>]*>)\s*</p>!', "$1", $post_content);
  356. $post_content = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $post_content); // optionally make line breaks
  357. $post_content = preg_replace('!(</?(?:table|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|p|h[1-6])[^>]*>)\s*<br />!', "$1", $post_content);
  358. $post_content = preg_replace('!<br />(\s*</?(?:p|li|div|th|pre|td|ul|ol)>)!', '$1', $post_content);
  359. $post_content = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $post_content);
  360. }
  361. # Build the URL
  362. $url = $post_url;
  363. # HTML VERSION OF MESSAGE #
  364. if ($html_email == 'Yes'){
  365. $msg = ""; // initialize variable
  366. if ($html_template != "" ) { $msg = file_get_contents($html_template); }
  367. // If the template file is empty...
  368. if ($msg == "") {
  369. if ($post_title != ''){
  370. $msg = "<p>A new entry titled '@@title' has been posted to @@site.</p>";
  371. $msg .= "<hr /><h1><a href=\"$url\">@@title</a></h1>";
  372. } else {
  373. $msg = "<p>A new entry has been posted to @@site.</p>";
  374. $msg .= "<hr /><h1><a href=\"$url\">$url</a></h1>";
  375. }
  376. if ($show_content == 'Yes') { $msg .= "@@content"; }
  377. $msg .= "<hr />@@subscriptionDetails";
  378. }
  379. # Replace variables
  380. $msg = str_replace('@@title',$post_title,$msg);
  381. $msg = str_replace('@@site',$site_name,$msg);
  382. $msg = str_replace('@@permalink',$url,$msg);
  383. $msg = str_replace('@@content',$post_content_filtered,$msg);
  384. $msg = str_replace('@@author',$post_author,$msg);
  385. $msg = str_replace('@@time',$post_time,$msg);
  386. //$msg = str_replace('@@date',$post_date,$msg);
  387. $subscriptionDetails = "You have signed up to receive these notifications. <br /><br />";
  388. $subscriptionDetails .= "If you would like to unsubscribe, visit the url below:<br />";
  389. $subscriptionDetails .= "<a href=\"" . $site_url . "maillist/index.php?action=unsub&addr=@@to_addr\">" . $site_url . "maillist/index.php?action=unsub&addr=@@to_addr</a><br />";
  390. $msg = str_replace('@@subscriptionDetails',$subscriptionDetails,$msg);
  391. } # END HTML VERSION OF MESSAGE #
  392. # TEXT VERSION OF MESSAGE #
  393. else {
  394. if ($post_title != ''){ $msg = "A new entry titled '$post_title' has been posted to $site_name.\n\n"; }
  395. else { $msg = "A new entry has been posted to $site_name.\n\n"; }
  396. if ($show_content == 'Yes') { $msg .= "$post_content\n\n"; }
  397. $msg .= "$url\n\n";
  398. $msg .= "------------------------------------------------------\n\n";
  399. $msg .= "You have signed up to receive these notifications. \n\n";
  400. $msg .= "If you would like to unsubscribe, visit the url below:\n";
  401. // This is for the default URL permalink
  402. $msg .= "$site_url/maillist/index.php?action=unsub&addr=@@to_addr\n";
  403. } # END TEXT VERSION OF MESSAGE #
  404. # EMAIL HEADER #
  405. $header = "MIME-Version: 1.0\r\n";
  406. if ($html_email == 'Yes'){ $header .= "Content-Type: text/html; charset=\"" . get_settings('blog_charset') . "\"\r\n"; }
  407. else { $header .= "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\r\n"; }
  408. $header .= "From: \"$site_name\" <$from_email>\n";
  409. $header .= "Reply-To: $from_email\n";
  410. $header .= "Return-Path: $from_email\n";
  411. # SUBJECT #
  412. if ($post_title != ''){ $subject = "$site_name: $post_title"; }
  413. else { $subject = "$site_name: New Entry"; }
  414. # Update notification_sent to 'y'
  415. $update_future = "UPDATE $wpdb->email_list_future ";
  416. $update_future .= "SET ";
  417. $update_future .= "notification_sent = 'y' ";
  418. $update_future .= "WHERE post_ID = '$send_post_ID'";
  419. $update_future_result = mysql_query($update_future);
  420. # Email the post
  421. $email_query = "SELECT email_addr FROM $wpdb->email_list WHERE gets_mail = 1";
  422. $email_res = mysql_query($email_query);
  423. while ($email_row = mysql_fetch_assoc($email_res)) {
  424. $addr = $email_row['email_addr'];
  425. $msgFinal = str_replace('@@to_addr',$addr,$msg);
  426. Mail($addr, $subject, $msgFinal, $header);
  427. }
  428. }
  429. }
  430. }
  431. //********************************************//
  432. // Actions
  433. //********************************************//
  434. // Notify box in advanced mode
  435. add_action('edit_form_advanced', 'email_notification_form');
  436. // Notify box in simple mode
  437. add_action('simple_edit_form', 'email_notification_form');
  438. // Notify box in page mode
  439. add_action('edit_page_form', 'email_notification_form');
  440. // Admin menu
  441. add_action('admin_menu', 'email_notification_admin');
  442. // Send the notification
  443. add_action('publish_post', 'email_notification_send', 5);
  444. // Send the notification of future dated posts
  445. add_action('publish_post', 'email_notification_future_send');
  446. ?>