PluginProbe
WP-EMail / 2.64
WP-EMail v2.64
3.0.0 trunk 1.00 2.00b 2.01 2.02 2.03 2.04 2.04a 2.05 2.06 2.07 2.10 2.11 2.20 2.30 2.31 2.40 2.50 2.51 2.52 2.61 2.62 2.63 2.64 All 42 releases
wp-email / wp-email.php

wp-email.php in WP-EMail 2.64, at wp-email.php

1,465 lines 60.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: WP-EMail
4 Plugin URI: http://lesterchan.net/portfolio/programming/php/
5 Description: Allows people to recommand/send your WordPress blog's post/page to a friend.
6 Version: 2.64
7 Author: Lester 'GaMerZ' Chan
8 Author URI: http://lesterchan.net
9 Text Domain: wp-email
10 */
11
12 /*
13 Copyright 2014 Lester Chan (email : lesterchan@gmail.com)
14
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 2 of the License, or
18 (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 */
29
30
31 ### Define: Show Email Remarks In Logs?
32 define('EMAIL_SHOW_REMARKS', true);
33
34
35 ### Create Text Domain For Translations
36 add_action( 'plugins_loaded', 'email_textdomain' );
37 function email_textdomain() {
38 load_plugin_textdomain( 'wp-email', false, dirname( plugin_basename( __FILE__ ) ) );
39 }
40
41
42 ### E-Mail Table Name
43 global $wpdb;
44 $wpdb->email = $wpdb->prefix.'email';
45
46
47 ### Function: E-Mail Administration Menu
48 add_action('admin_menu', 'email_menu');
49 function email_menu() {
50 add_menu_page(__('E-Mail', 'wp-email'), __('E-Mail', 'wp-email'), 'manage_email', 'wp-email/email-manager.php', '', 'dashicons-email-alt');
51 add_submenu_page('wp-email/email-manager.php', __('Manage E-Mail', 'wp-email'), __('Manage E-Mail', 'wp-email'), 'manage_email', 'wp-email/email-manager.php');
52 add_submenu_page('wp-email/email-manager.php', __('E-Mail Options', 'wp-email'), __('E-Mail Options', 'wp-email'), 'manage_email', 'wp-email/email-options.php');
53 }
54
55
56 ### Function: Add htaccess Rewrite Endpoint - this handles all the rules
57 add_action( 'init', 'wp_email_endpoint' );
58 function wp_email_endpoint() {
59 add_rewrite_endpoint( 'email', EP_PERMALINK | EP_PAGES );
60 add_rewrite_endpoint( 'emailpopup', EP_PERMALINK | EP_PAGES );
61 }
62
63
64 ### Function: E-Mail Public Variables
65 add_filter('query_vars', 'email_variables');
66 function email_variables($public_query_vars) {
67 $public_query_vars[] = 'email';
68 $public_query_vars[] = 'emailpopup';
69 return $public_query_vars;
70 }
71
72
73 ### Function: Print Out jQuery Script At The Top
74 add_action('wp_head', 'email_javascripts_header');
75 function email_javascripts_header() {
76 wp_print_scripts('jquery');
77 }
78
79
80 ### Function: Enqueue E-Mail Javascripts/CSS
81 add_action('wp_enqueue_scripts', 'email_scripts');
82 function email_scripts() {
83 global $text_direction;
84 if(@file_exists(TEMPLATEPATH.'/email-css.css')) {
85 wp_enqueue_style('wp-email', get_stylesheet_directory_uri().'/email-css.css', false, '2.60', 'all');
86 } else {
87 wp_enqueue_style('wp-email', plugins_url('wp-email/email-css.css'), false, '2.60', 'all');
88 }
89 if('rtl' == $text_direction) {
90 if(@file_exists(TEMPLATEPATH.'/email-css-rtl.css')) {
91 wp_enqueue_style('wp-email-rtl', get_stylesheet_directory_uri().'/email-css-rtl.css', false, '2.60', 'all');
92 } else {
93 wp_enqueue_style('wp-email-rtl', plugins_url('wp-email/email-css-rtl.css'), false, '2.60', 'all');
94 }
95 }
96 $email_max = intval(get_option('email_multiple'));
97 wp_enqueue_script('wp-email', plugins_url('wp-email/email-js.js'), array('jquery'), '2.63', true);
98 wp_localize_script('wp-email', 'emailL10n', array(
99 'ajax_url' => admin_url('admin-ajax.php'),
100 'max_allowed' => $email_max,
101 'text_error' => __('The Following Error Occurs:', 'wp-email'),
102 'text_name_invalid' => __('- Your Name is empty/invalid', 'wp-email'),
103 'text_email_invalid' => __('- Your Email is empty/invalid', 'wp-email'),
104 'text_remarks_invalid' => __('- Your Remarks is invalid', 'wp-email'),
105 'text_friend_names_empty' => __('- Friend Name(s) is empty', 'wp-email'),
106 'text_friend_name_invalid' => __('- Friend Name is empty/invalid: ', 'wp-email'),
107 'text_max_friend_names_allowed' => sprintf(_n('- Maximum %s Friend Name allowed', '- Maximum %s Friend Names allowed', $email_max, 'wp-email'), number_format_i18n($email_max)),
108 'text_friend_emails_empty' => __('- Friend Email(s) is empty', 'wp-email'),
109 'text_friend_email_invalid' => __('- Friend Email is invalid: ', 'wp-email'),
110 'text_max_friend_emails_allowed' => sprintf(_n('- Maximum %s Friend Email allowed', '- Maximum %s Friend Emails allowed', $email_max, 'wp-email'), number_format_i18n($email_max)),
111 'text_friends_tally' => __('- Friend Name(s) count does not tally with Friend Email(s) count', 'wp-email'),
112 'text_image_verify_empty' => __('- Image Verification is empty', 'wp-email')
113 ));
114 }
115
116
117 ### Function: Display E-Mail Link
118 function email_link($email_post_text = '', $email_page_text = '', $echo = true) {
119 global $id;
120 $output = '';
121 $using_permalink = get_option('permalink_structure');
122 $email_options = get_option('email_options');
123 $email_style = intval($email_options['email_style']);
124 $email_type = intval($email_options['email_type']);
125 if(empty($email_post_text)) {
126 $email_text = stripslashes($email_options['post_text']);
127 } else {
128 $email_text = $email_post_text;
129 }
130 $email_icon = plugins_url('wp-email/images/'.$email_options['email_icon']);
131 $email_link = get_permalink();
132 $email_html = stripslashes($email_options['email_html']);
133 $onclick = '';
134 // Fix For Static Page
135 if(get_option('show_on_front') == 'page' && is_page()) {
136 if(intval(get_option('page_on_front')) > 0) {
137 $email_link = _get_page_link();
138 }
139 }
140 switch($email_type) {
141 // E-Mail Standalone Page
142 case 1:
143 if(!empty($using_permalink)) {
144 if(substr($email_link, -1, 1) != '/') {
145 $email_link= $email_link.'/';
146 }
147 if(is_page()) {
148 if(empty($email_page_text)) {
149 $email_text = stripslashes($email_options['page_text']);
150 } else {
151 $email_text = $email_page_text;
152 }
153 }
154 $email_link = $email_link.'email/';
155 } else {
156 if(is_page()) {
157 if(empty($email_page_text)) {
158 $email_text = stripslashes($email_options['page_text']);
159 } else {
160 $email_text = $email_page_text;
161 }
162 }
163 $email_link = $email_link.'&amp;email=1';
164 }
165 break;
166 // E-Mail Popup
167 case 2:
168 if(!empty($using_permalink)) {
169 if(substr($email_link, -1, 1) != '/') {
170 $email_link= $email_link.'/';
171 }
172 if(is_page()) {
173 if(empty($email_page_text)) {
174 $email_text = stripslashes($email_options['page_text']);
175 } else {
176 $email_text = $email_page_text;
177 }
178 }
179 $email_link = $email_link.'emailpopup/';
180 } else {
181 if(is_page()) {
182 if(empty($email_page_text)) {
183 $email_text = stripslashes($email_options['page_text']);
184 } else {
185 $email_text = $email_page_text;
186 }
187 }
188 $email_link = $email_link.'&amp;emailpopup=1';
189 }
190 $onclick = ' onclick="email_popup(this.href); return false;" ';
191 break;
192 }
193 unset($email_options);
194 switch($email_style) {
195 // Icon + Text Link
196 case 1:
197 $output = '<a href="'.$email_link.'"'.$onclick.' title="'.$email_text.'" rel="nofollow"><img class="WP-EmailIcon" src="'.$email_icon.'" alt="'.$email_text.'" title="'.$email_text.'" style="border: 0px;" /></a>&nbsp;<a href="'.$email_link.'"'.$onclick.' title="'.$email_text.'" rel="nofollow">'.$email_text.'</a>';
198 break;
199 // Icon Only
200 case 2:
201 $output = '<a href="'.$email_link.'"'.$onclick.' title="'.$email_text.'" rel="nofollow"><img class="WP-EmailIcon" src="'.$email_icon.'" alt="'.$email_text.'" title="'.$email_text.'" style="border: 0px;" /></a>';
202 break;
203 // Text Link Only
204 case 3:
205 $output = '<a href="'.$email_link.'"'.$onclick.' title="'.$email_text.'" rel="nofollow">'.$email_text.'</a>';
206 break;
207 case 4:
208 $email_html = str_replace("%EMAIL_URL%", $email_link, $email_html);
209 $email_html = str_replace("%EMAIL_POPUP%", $onclick, $email_html);
210 $email_html = str_replace("%EMAIL_TEXT%", $email_text, $email_html);
211 $email_html = str_replace("%EMAIL_ICON_URL%", $email_icon, $email_html);
212 $output = $email_html;
213 break;
214 }
215 if($echo) {
216 echo $output."\n";
217 } else {
218 return $output;
219 }
220 }
221
222
223 ### Function: Short Code For Inserting Email Links Into Posts/Pages
224 add_shortcode('email_link', 'email_link_shortcode');
225 function email_link_shortcode($atts) {
226 if(!is_feed()) {
227 return email_link('', '', false);
228 } else {
229 return __('Note: There is an email link embedded within this post, please visit this post to email it.', 'wp-email');
230 }
231 }
232 function email_link_shortcode2($atts) {
233 return;
234 }
235
236
237 ### Function: Short Code For DO NOT EMAIL Content
238 add_shortcode('donotemail', 'email_donotemail_shortcode');
239 function email_donotemail_shortcode($atts, $content = null) {
240 return do_shortcode($content);
241 }
242 function email_donotemail_shortcode2($atts, $content = null) {
243 return;
244 }
245
246
247 ### Function: Snippet Words
248 if(!function_exists('snippet_words')) {
249 function snippet_words($text, $length = 0) {
250 $words = split(' ', $text);
251 return join(" ",array_slice($words, 0, $length)).'...';
252 }
253 }
254
255
256 ### Function: Snippet Text
257 if(!function_exists('snippet_text')) {
258 function snippet_text($text, $length = 0) {
259 if (defined('MB_OVERLOAD_STRING')) {
260 $text = @html_entity_decode($text, ENT_QUOTES, get_option('blog_charset'));
261 if (mb_strlen($text) > $length) {
262 return htmlentities(mb_substr($text,0,$length), ENT_COMPAT, get_option('blog_charset')).'...';
263 } else {
264 return htmlentities($text, ENT_COMPAT, get_option('blog_charset'));
265 }
266 } else {
267 $text = @html_entity_decode($text, ENT_QUOTES, get_option('blog_charset'));
268 if (strlen($text) > $length) {
269 return htmlentities(substr($text,0,$length), ENT_COMPAT, get_option('blog_charset')).'...';
270 } else {
271 return htmlentities($text, ENT_COMPAT, get_option('blog_charset'));
272 }
273 }
274 }
275 }
276
277
278 ### Function: Add E-Mail Filters
279 function email_addfilters() {
280 global $emailfilters_count;
281 if(get_option('k2version') === false) {
282 $loop_count = 0;
283 } else {
284 $loop_count = 1;
285 }
286 if(intval($emailfilters_count) == $loop_count) {
287 add_filter('the_title', 'email_title');
288 add_filter('the_content', 'email_form', 10, 5);
289 }
290 $emailfilters_count++;
291 }
292
293
294 ### Function: Remove E-Mail Filters
295 function email_removefilters() {
296 remove_filter('the_title', 'email_title');
297 remove_filter('the_content', 'email_form', 10, 5);
298 }
299
300
301 ### Function: E-Mail Page Title
302 function email_pagetitle($page_title) {
303 $page_title .= ' &raquo; '.__('E-Mail', 'wp-email');
304 return $page_title;
305 }
306
307
308 ### Function: Add noindex & nofollow to meta
309 function email_meta_nofollow() {
310 echo '<meta name="robots" content="noindex, nofollow" />'."\n";
311 }
312
313
314 ### Function: E-Mail Post ID
315 if(!function_exists('get_the_id')) {
316 function get_the_id() {
317 global $id;
318 return $id;
319 }
320 }
321
322
323 ### Function: Get E-Mail Remark
324 function email_get_remark() {
325 global $post;
326 return get_post_meta($post->ID, 'wp-email-remark', true);
327 }
328
329
330 ### Function: Get E-Mail Title
331 function email_get_title() {
332 global $post;
333 $post_title = get_post_meta($post->ID, 'wp-email-title', true);
334 if( empty($post_title) ) {
335 $post_title = $post->post_title;
336 }
337 if(!empty($post->post_password)) {
338 $post_title = sprintf(__('Protected: %s', 'wp-email'), $post_title);
339 } elseif($post->post_status == 'private') {
340 $post_title = sprintf(__('Private: %s', 'wp-email'), $post_title);
341 }
342 return $post_title;
343 }
344
345
346 ### Function: E-Mail Title
347 function email_title($page_title) {
348 if(in_the_loop()) {
349 $post_title = email_get_title();
350 $post_author = get_the_author();
351 $post_date = get_the_time(get_option('date_format').' ('.get_option('time_format').')', '', '', false);
352 $post_category = email_category(__(',', 'wp-email').' ');
353 $post_category_alt = strip_tags($post_category);
354 $template_title = stripslashes(get_option('email_template_title'));
355 $template_title = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_title);
356 $template_title = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_title);
357 $template_title = str_replace("%EMAIL_POST_DATE%", $post_date, $template_title);
358 $template_title = str_replace("%EMAIL_POST_CATEGORY%", $post_category, $template_title);
359 $template_title = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_title);
360 $template_title = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_title);
361 $template_title = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_title);
362 return $template_title;
363 } else {
364 return $page_title;
365 }
366 }
367
368
369 ### Function: E-Mail Category
370 function email_category($separator = ', ', $parents='') {
371 return get_the_category_list($separator, $parents);
372 }
373
374
375 ### Function: E-Mail Content
376 function email_content() {
377 $content = get_email_content();
378 $email_snippet = intval(get_option('email_snippet'));
379 if($email_snippet > 0) {
380 return snippet_words($content , $email_snippet);
381 } else {
382 return $content;
383 }
384 }
385
386
387 ### Function: E-Mail Alternate Content
388 function email_content_alt() {
389 remove_filter('the_content', 'wptexturize');
390 $content = get_email_content();
391 $content = clean_pre($content);
392 $content = strip_tags($content);
393 $email_snippet = intval(get_option('email_snippet'));
394 if($email_snippet > 0) {
395 return snippet_words($content , $email_snippet);
396 } else {
397 return $content;
398 }
399 }
400
401
402 ### Function: E-Mail Get The Content
403 function get_email_content() {
404 global $pages, $multipage, $numpages, $post;
405 if(post_password_required()) {
406 return __('Password Protected Post', 'wp-email');
407 }
408 if($multipage) {
409 for($page = 0; $page < $numpages; $page++) {
410 $content .= $pages[$page];
411 }
412 } else {
413 $content = $pages[0];
414 }
415 $content = html_entity_decode($content);
416 $content = htmlspecialchars_decode($content);
417 if(function_exists('print_rewrite')) {
418 remove_shortcode('donotprint');
419 add_shortcode('donotprint', 'print_donotprint_shortcode2');
420 }
421 remove_shortcode('donotemail');
422 add_shortcode('donotemail', 'email_donotemail_shortcode2');
423 remove_shortcode('email_link');
424 add_shortcode('email_link', 'email_link_shortcode2');
425 $content = apply_filters('the_content', $content);
426 return $content;
427 }
428
429
430 ### Function: Get IP Address
431 function get_email_ipaddress() {
432 if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
433 $ip_address = $_SERVER["REMOTE_ADDR"];
434 } else {
435 $ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
436 }
437 if(strpos($ip_address, ',') !== false) {
438 $ip_address = explode(',', $ip_address);
439 $ip_address = $ip_address[0];
440 }
441 return esc_attr($ip_address);
442 }
443
444 ### Function: There Are Still Many PHP 4.x Users
445 if(!function_exists('htmlspecialchars_decode')) {
446 function htmlspecialchars_decode($string, $style = ENT_COMPAT) {
447 $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS,$style));
448 if($style === ENT_QUOTES) {
449 $translation['&#039;'] = '\'';
450 }
451 return strtr($string, $translation);
452 }
453 }
454
455
456 ### Function: Check Vaild Name (AlphaNumeric With Spaces Allowed Only)
457 if(!function_exists('is_valid_name')) {
458 function is_valid_name($name) {
459 $regex = '/[(\*\(\)\[\]\+\,\/\?\:\;\'\"\`\~\\#\$\%\^\&\<\>)+]/';
460 return !(preg_match($regex, $name));
461 }
462 }
463
464
465 ### Function: Check Valid E-Mail Address
466 if(!function_exists('is_valid_email')) {
467 function is_valid_email($email) {
468 $regex = '/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/';
469 return (preg_match($regex, $email));
470 }
471 }
472
473
474 ### Function: Check Valid Remarks (Ensure No E-Mail Injections)
475 if(!function_exists('is_valid_remarks')) {
476 function is_valid_remarks($content) {
477 $injection_strings = array('apparently-to', 'cc', 'bcc', 'boundary', 'charset', 'content-disposition', 'content-type', 'content-transfer-encoding', 'errors-to', 'in-reply-to', 'message-id', 'mime-version', 'multipart/mixed', 'multipart/alternative', 'multipart/related', 'reply-to', 'x-mailer', 'x-sender', 'x-uidl');
478 foreach ($injection_strings as $spam) {
479 $check = strpos(strtolower($content), $spam);
480 if ($check !== false) {
481 return false;
482 }
483 }
484 return true;
485 }
486 }
487
488
489 ### Function: Check For E-Mail Spamming
490 function not_spamming() {
491 global $wpdb;
492 $current_time = current_time('timestamp');
493 $email_ip = get_email_ipaddress();
494 $email_host = esc_attr(@gethostbyaddr($email_ip));
495 $email_status = __('Success', 'wp-email');
496 $last_emailed = $wpdb->get_var("SELECT email_timestamp FROM $wpdb->email WHERE email_ip = '$email_ip' AND email_host = '$email_host' AND email_status = '$email_status' ORDER BY email_timestamp DESC LIMIT 1");
497 $email_allow_interval = intval(get_option('email_interval'))*60;
498 if(($current_time-$last_emailed) < $email_allow_interval) {
499 return false;
500 } else {
501 return true;
502 }
503 }
504
505
506 ### Function: E-Mail Flood Interval
507 function email_flood_interval($echo = true) {
508 $email_allow_interval_min = intval(get_option('email_interval'));
509 if($echo) {
510 echo $email_allow_interval_min;
511 } else {
512 return $email_allow_interval_min;
513 }
514 }
515
516
517 ### Function: Fill In Email Fills If Logged In (By Aaron Campbell)
518 add_filter('email_form-fieldvalues', 'email_fill_fields');
519 function email_fill_fields($email_fields) {
520 global $current_user;
521 if ($current_user->ID > 0) {
522 $email_fields['yourname'] = trim(esc_attr($current_user->first_name.' '.$current_user->last_name));
523 $email_fields['youremail'] = esc_attr($current_user->user_email);
524 }
525 return $email_fields;
526 }
527
528
529 ### Function: E-Mail Form Header
530 function email_form_header($echo = true, $temp_id) {
531 global $id;
532 if(intval($temp_id) > 0) {
533 $id = $temp_id;
534 }
535 $using_permalink = get_option('permalink_structure');
536 $permalink = get_permalink();
537 // Fix For Static Page
538 if(get_option('show_on_front') == 'page' && is_page()) {
539 if(intval(get_option('page_on_front')) > 0) {
540 $permalink = _get_page_link();
541 }
542 }
543 $output = '';
544 if(!empty($using_permalink)) {
545 if(is_page()) {
546 $output .= '<form action="'.$permalink.'emailpage/" method="post">'."\n";
547 $output .= '<p style="display: none;"><input type="hidden" id="page_id" name="page_id" value="'.$id.'" /></p>'."\n";
548 } else {
549 $output = '<form action="'.$permalink.'email/" method="post">'."\n";
550 $output .= '<p style="display: none;"><input type="hidden" id="p" name="p" value="'.$id.'" /></p>'."\n";
551 }
552 } else {
553 if(is_page()) {
554 $output .= '<form action="'.$permalink.'&amp;email=1" method="post">'."\n";
555 $output .= '<p style="display: none;"><input type="hidden" id="page_id" name="page_id" value="'.$id.'" /></p>'."\n";
556 } else {
557 $output .= '<form action="'.$permalink.'&amp;email=1" method="post">'."\n";
558 $output .= '<p style="display: none;"><input type="hidden" id="p" name="p" value="'.$id.'" /></p>'."\n";
559 }
560 }
561 $output .= '<p style="display: none;"><input type="hidden" id="wp-email_nonce" name="wp-email_nonce" value="'.wp_create_nonce('wp-email-nonce').'" /></p>'."\n";
562 if($echo) {
563 echo $output;
564 } else {
565 return $output;
566 }
567 }
568
569
570 ### Function: E-Mail Form Header For Popup
571 function email_popup_form_header($echo = true, $temp_id) {
572 global $post;
573 $id = intval($post->ID);
574 if(intval($temp_id) > 0) {
575 $id = $temp_id;
576 }
577 $using_permalink = get_option('permalink_structure');
578 $permalink = get_permalink();
579 // Fix For Static Page
580 if(get_option('show_on_front') == 'page' && is_page()) {
581 if(intval(get_option('page_on_front')) > 0) {
582 $permalink = _get_page_link();
583 }
584 }
585 $output = '';
586 if(!empty($using_permalink)) {
587 if(is_page()) {
588 $output .= '<form action="'.$permalink.'emailpopuppage/" method="post">'."\n";
589 $output .= '<p style="display: none;"><input type="hidden" id="page_id" name="page_id" value="'.$id.'" /></p>'."\n";
590 } else {
591 $output = '<form action="'.$permalink.'emailpopup/" method="post">'."\n";
592 $output .= '<p style="display: none;"><input type="hidden" id="p" name="p" value="'.$id.'" /></p>'."\n";
593 }
594 } else {
595 if(is_page()) {
596 $output .= '<form action="'.$permalink.'&amp;emailpopup=1" method="post">'."\n";
597 $output .= '<p style="display: none;"><input type="hidden" id="page_id" name="page_id" value="'.$id.'" /></p>'."\n";
598 } else {
599 $output .= '<form action="'.$permalink.'&amp;emailpopup=1" method="post">'."\n";
600 $output .= '<p style="display: none;"><input type="hidden" id="p" name="p" value="'.$id.'" /></p>'."\n";
601 }
602 }
603 $output .= '<p style="display: none;"><input type="hidden" id="wp-email_nonce" name="wp-email_nonce" value="'.wp_create_nonce('wp-email-nonce').'" /></p>'."\n";
604 if($echo) {
605 echo $output;
606 } else {
607 return $output;
608 }
609 }
610
611
612 ### Function: Multiple E-Mails
613 function email_multiple($echo = true) {
614 $email_multiple = intval(get_option('email_multiple'));
615 if($email_multiple > 1) {
616 $output = '<br /><em>'.sprintf(_n('Separate multiple entries with a comma. Maximum %s entry.', 'Separate multiple entries with a comma. Maximum %s entries.', $email_multiple, 'wp-email'), number_format_i18n($email_multiple)).'</em>';
617 if($echo) {
618 echo $outut;
619 } else {
620 return $output;
621 }
622 }
623 }
624
625
626 ### Function: Get EMail Total Sent
627 if(!function_exists('get_emails')) {
628 function get_emails($echo = true) {
629 global $wpdb;
630 $totalemails = $wpdb->get_var("SELECT COUNT(email_id) FROM $wpdb->email");
631 if($echo) {
632 echo number_format_i18n($totalemails);
633 } else {
634 return number_format_i18n($totalemails);
635 }
636 }
637 }
638
639
640 ### Function: Get EMail Total Sent Success
641 if(!function_exists('get_emails_success')) {
642 function get_emails_success($echo = true) {
643 global $wpdb;
644 $totalemails_success = $wpdb->get_var("SELECT COUNT(email_id) FROM $wpdb->email WHERE email_status = '".__('Success', 'wp-email')."'");
645 if($echo) {
646 echo number_format_i18n($totalemails_success);
647 } else {
648 return number_format_i18n($totalemails_success);
649 }
650 }
651 }
652
653
654 ### Function: Get EMail Total Sent Failed
655 if(!function_exists('get_emails_failed')) {
656 function get_emails_failed($echo = true) {
657 global $wpdb;
658 $totalemails_failed = $wpdb->get_var("SELECT COUNT(email_id) FROM $wpdb->email WHERE email_status = '".__('Failed', 'wp-email')."'");
659 if($echo) {
660 echo number_format_i18n($totalemails_failed);
661 } else {
662 return number_format_i18n($totalemails_failed);
663 }
664 }
665 }
666
667
668 ### Function: Get EMail Sent For Post
669 if(!function_exists('get_email_count')) {
670 function get_email_count($post_id = 0, $echo = true) {
671 global $wpdb;
672 if($post_id == 0) {
673 global $post;
674 $post_id = $post->ID;
675 }
676 $post_id = intval($post_id);
677 $totalemails = $wpdb->get_var("SELECT COUNT(email_id) FROM $wpdb->email WHERE email_postid = $post_id");
678 if($echo) {
679 echo number_format_i18n($totalemails);
680 } else {
681 return number_format_i18n($totalemails);
682 }
683 }
684 }
685
686
687 ### Function: Get Most E-Mailed
688 if(!function_exists('get_mostemailed')) {
689 function get_mostemailed($mode = '', $limit = 10, $chars = 0, $echo = true) {
690 global $wpdb, $post;
691 $temp_post = $post;
692 $where = '';
693 $temp = '';
694 if(!empty($mode) && $mode != 'both') {
695 $where = "post_type = '$mode'";
696 } else {
697 $where = '1=1';
698 }
699 $mostemailed= $wpdb->get_results("SELECT $wpdb->posts.*, COUNT($wpdb->email.email_postid) AS email_total FROM $wpdb->email LEFT JOIN $wpdb->posts ON $wpdb->email.email_postid = $wpdb->posts.ID WHERE post_date < '".current_time('mysql')."' AND $where AND post_password = '' AND post_status = 'publish' GROUP BY $wpdb->email.email_postid ORDER BY email_total DESC LIMIT $limit");
700 if($mostemailed) {
701 if($chars > 0) {
702 foreach ($mostemailed as $post) {
703 $post_title = get_the_title();
704 $email_total = intval($post->email_total);
705 $temp .= "<li><a href=\"".get_permalink()."\">".snippet_text($post_title, $chars)."</a> - ".sprintf(_n('%s email', '%s emails', $email_total, 'wp-email'), number_format_i18n($email_total))."</li>\n";
706 }
707 } else {
708 foreach ($mostemailed as $post) {
709 $post_title = get_the_title();
710 $email_total = intval($post->email_total);
711 $temp .= "<li><a href=\"".get_permalink()."\">$post_title</a> - ".sprintf(_n('%s email', '%s emails', $email_total, 'wp-email'), number_format_i18n($email_total))."</li>\n";
712 }
713 }
714 } else {
715 $temp = '<li>'.__('N/A', 'wp-email').'</li>'."\n";
716 }
717 $post = $temp_post;
718 if($echo) {
719 echo $temp;
720 } else {
721 return $temp;
722 }
723 }
724 }
725
726
727 ### Function: Load WP-EMail
728 add_action('template_redirect', 'wp_email', 5);
729 function wp_email() {
730 global $wp_query;
731
732 $template_redirect = apply_filters( 'wp_email_template_redirect', true );
733
734 if( $template_redirect ) {
735 if (array_key_exists('email', $wp_query->query_vars)) {
736 include(WP_PLUGIN_DIR . '/wp-email/email-standalone.php');
737 exit();
738 } elseif (array_key_exists('emailpopup', $wp_query->query_vars)) {
739 include(WP_PLUGIN_DIR . '/wp-email/email-popup.php');
740 exit();
741 }
742 }
743 }
744
745
746 ### Function: Process E-Mail Form
747 add_action('wp_ajax_email', 'process_email_form');
748 add_action('wp_ajax_nopriv_email', 'process_email_form');
749 function process_email_form() {
750 global $wpdb, $post, $text_direction;
751 // If User Click On Mail
752 if(isset($_POST['action']) && $_POST['action'] == 'email') {
753
754 // Verify Referer
755 if(!check_ajax_referer('wp-email-nonce', 'wp-email_nonce', false))
756 {
757 _e('Failed To Verify Referrer', 'wp-email');
758 exit();
759 }
760
761 @session_start();
762 email_textdomain();
763 header('Content-Type: text/html; charset='.get_option('blog_charset').'');
764 // POST Variables
765 $yourname = (!empty($_POST['yourname']) ? strip_tags(stripslashes(trim($_POST['yourname']))) : '');
766 $youremail = (!empty($_POST['youremail']) ? strip_tags(stripslashes(trim($_POST['youremail']))) : '');
767 $yourremarks = (!empty($_POST['yourremarks'])? strip_tags(stripslashes(trim($_POST['yourremarks']))) : '');
768 $friendname = (!empty($_POST['friendname']) ? strip_tags(stripslashes(trim($_POST['friendname']))) : '');
769 $friendemail = (!empty($_POST['friendemail'])? strip_tags(stripslashes(trim($_POST['friendemail']))) : '');
770 $imageverify = (!empty($_POST['imageverify'])? $_POST['imageverify'] : '');
771 $p = (!empty($_POST['p']) ? intval($_POST['p']) : 0);
772 $page_id = (!empty($_POST['page_id']) ? intval($_POST['page_id']) : 0);
773 // Get Post Information
774 if($p > 0) {
775 $post_type = get_post_type($p);
776 $query_post = 'p='. $p . '&post_type=' . $post_type;
777 $id = $p;
778 } else {
779 $query_post = 'page_id='.$page_id;
780 $id = $page_id;
781 }
782 query_posts($query_post);
783 if(have_posts()) {
784 while(have_posts()) {
785 the_post();
786 $post_title = email_get_title();
787 $post_author = get_the_author();
788 $post_date = get_the_time(get_option('date_format').' ('.get_option('time_format').')', '', '', false);
789 $post_category = email_category(__(',', 'wp-email').' ');
790 $post_category_alt = strip_tags($post_category);
791 $post_excerpt = get_the_excerpt();
792 $post_content = email_content();
793 $post_content_alt = email_content_alt();
794 }
795 }
796 // Error
797 $error = '';
798 $error_field = array('yourname' => $yourname, 'youremail' => $youremail, 'yourremarks' => $yourremarks, 'friendname' => $friendname, 'friendemail' => $friendemail, 'id' => $id);
799 // Get Options
800 $email_fields = get_option('email_fields');
801 $email_image_verify = intval(get_option('email_imageverify'));
802 $email_smtp = get_option('email_smtp');
803 // Multiple Names/Emails
804 $friends = array();
805 $friendname_count = 0;
806 $friendemail_count = 0;
807 $multiple_names = explode(',', $friendname);
808 $multiple_emails = explode(',', $friendemail);
809 $multiple_max = intval(get_option('email_multiple'));
810 if($multiple_max == 0) { $multiple_max = 1; }
811 // Checking Your Name Field For Errors
812 if(intval($email_fields['yourname']) == 1) {
813 if(empty($yourname)) {
814 $error .= '<br /><strong>&raquo;</strong> '.__('Your Name is empty', 'wp-email');
815 }
816 if(!is_valid_name($yourname)) {
817 $error .= '<br /><strong>&raquo;</strong> '.__('Your Name is invalid', 'wp-email');
818 }
819 }
820 // Checking Your E-Mail Field For Errors
821 if(intval($email_fields['youremail']) == 1) {
822 if(empty($youremail)) {
823 $error .= '<br /><strong>&raquo;</strong> '.__('Your Email is empty', 'wp-email');
824 }
825 if(!is_valid_email($youremail)) {
826 $error .= '<br /><strong>&raquo;</strong> '.__('Your Email is invalid', 'wp-email');
827 }
828 }
829 // Checking Your Remarks Field For Errors
830 if(intval($email_fields['yourremarks']) == 1) {
831 if(!is_valid_remarks($yourremarks)) {
832 $error .= '<br /><strong>&raquo;</strong> '.__('Your Remarks is invalid', 'wp-email');
833 }
834 }
835 // Checking Friend's Name Field For Errors
836 if(intval($email_fields['friendname']) == 1) {
837 if(empty($friendname)) {
838 $error .= '<br /><strong>&raquo;</strong> '.__('Friend Name(s) is empty', 'wp-email');
839 } else {
840 if($multiple_names) {
841 foreach($multiple_names as $multiple_name) {
842 $multiple_name = trim($multiple_name);
843 if(empty($multiple_name)) {
844 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Name is empty: %s', 'wp-email'), $multiple_name);
845 } elseif(!is_valid_name($multiple_name)) {
846 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Name is invalid: %s', 'wp-email'), $multiple_name);
847 } else {
848 $friends[$friendname_count]['name'] = $multiple_name;
849 $friendname_count++;
850 }
851 if($friendname_count > $multiple_max) {
852 break;
853 }
854 }
855 }
856 }
857 }
858 // Checking Friend's E-Mail Field For Errors
859 if(empty($friendemail)) {
860 $error .= '<br /><strong>&raquo;</strong> '.__('Friend Email(s) is empty', 'wp-email');
861 } else {
862 if($multiple_emails) {
863 foreach($multiple_emails as $multiple_email) {
864 $multiple_email = trim($multiple_email);
865 if(empty($multiple_email)) {
866 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Email is empty: %s', 'wp-email'), $multiple_email);
867 } elseif(!is_valid_email($multiple_email)) {
868 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Email is invalid: %s', 'wp-email'), $multiple_email);
869 } else {
870 $friends[$friendemail_count]['email'] = $multiple_email;
871 $friendemail_count++;
872 }
873 if($friendemail_count > $multiple_max) {
874 break;
875 }
876 }
877 }
878 }
879 // Checking If The Fields Exceed The Size Of Maximum Entries Allowed
880 if(sizeof($friends) > $multiple_max) {
881 $error .= '<br /><strong>&raquo;</strong> '.sprintf(_n('Maximum %s Friend allowed', 'Maximum %s Friend(s) allowed', $multiple_max, 'wp-email'), number_format_i18n($multiple_max));
882 }
883 if(intval($email_fields['friendname']) == 1) {
884 if($friendname_count != $friendemail_count) {
885 $error .= '<br /><strong>&raquo;</strong> '.__('Friend Name(s) count does not tally with Friend Email(s) count', 'wp-email');
886 }
887 }
888 // Check Whether We Enable Image Verification
889 if($email_image_verify) {
890 $imageverify = strtoupper($imageverify);
891 if(empty($imageverify)) {
892 $error .= '<br /><strong>&raquo;</strong> '.__('Image Verification is empty', 'wp-email');
893 } else {
894 if($_SESSION['email_verify'] != md5($imageverify)) {
895 $error .= '<br /><strong>&raquo;</strong> '.__('Image Verification failed', 'wp-email');
896 }
897 }
898 }
899 // If There Is No Error, We Process The E-Mail
900 if(empty($error) && not_spamming()) {
901 // If Remarks Is Empty, Assign N/A
902 if(empty($yourremarks)) { $yourremarks = __('N/A', 'wp-email'); }
903 // Template For E-Mail Subject
904 $template_email_subject = stripslashes(get_option('email_template_subject'));
905 $template_email_subject = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_subject);
906 $template_email_subject = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_subject);
907 $template_email_subject = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_subject);
908 $template_email_subject = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_subject);
909 $template_email_subject = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_subject);
910 $template_email_subject = str_replace("%EMAIL_POST_CATEGORY%", $post_category_alt, $template_email_subject);
911 $template_email_subject = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_subject);
912 $template_email_subject = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_subject);
913 $template_email_subject = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_subject);
914 // Template For E-Mail Body
915 $template_email_body = stripslashes(get_option('email_template_body'));
916 $template_email_body = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_body);
917 $template_email_body = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_body);
918 $template_email_body = str_replace("%EMAIL_YOUR_REMARKS%", $yourremarks, $template_email_body);
919 $template_email_body = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_body);
920 $template_email_body = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_body);
921 $template_email_body = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_body);
922 $template_email_body = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_body);
923 $template_email_body = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_body);
924 $template_email_body = str_replace("%EMAIL_POST_CATEGORY%", $post_category, $template_email_body);
925 $template_email_body = str_replace("%EMAIL_POST_EXCERPT%", $post_excerpt, $template_email_body);
926 $template_email_body = str_replace("%EMAIL_POST_CONTENT%", $post_content, $template_email_body);
927 $template_email_body = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_body);
928 $template_email_body = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_body);
929 $template_email_body = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_body);
930 if('rtl' == $text_direction) {
931 $template_email_body = "<div style=\"direction: rtl;\">$template_email_body</div>";
932 }
933 // Template For E-Mail Alternate Body
934 $template_email_bodyalt = stripslashes(get_option('email_template_bodyalt'));
935 $template_email_bodyalt = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_bodyalt);
936 $template_email_bodyalt = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_bodyalt);
937 $template_email_bodyalt = str_replace("%EMAIL_YOUR_REMARKS%", $yourremarks, $template_email_bodyalt);
938 $template_email_bodyalt = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_bodyalt);
939 $template_email_bodyalt = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_bodyalt);
940 $template_email_bodyalt = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_bodyalt);
941 $template_email_bodyalt = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_bodyalt);
942 $template_email_bodyalt = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_bodyalt);
943 $template_email_bodyalt = str_replace("%EMAIL_POST_CATEGORY%", $post_category_alt, $template_email_bodyalt);
944 $template_email_bodyalt = str_replace("%EMAIL_POST_EXCERPT%", $post_excerpt, $template_email_bodyalt);
945 $template_email_bodyalt = str_replace("%EMAIL_POST_CONTENT%", $post_content_alt, $template_email_bodyalt);
946 $template_email_bodyalt = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_bodyalt);
947 $template_email_bodyalt = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_bodyalt);
948 $template_email_bodyalt = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_bodyalt);
949 // PHP Mailer Variables
950 if (!class_exists("phpmailer")) {
951 require_once(ABSPATH.WPINC.'/class-phpmailer.php');
952 }
953 $mail = new PHPMailer();
954 $mail->From = $youremail;
955 $mail->FromName = $yourname;
956 foreach($friends as $friend) {
957 $mail->AddAddress($friend['email'], $friend['name']);
958 }
959 $mail->CharSet = strtolower(get_bloginfo('charset'));
960 $mail->Username = $email_smtp['username'];
961 $mail->Password = $email_smtp['password'];
962 $mail->Host = $email_smtp['server'];
963 $mail->Mailer = get_option('email_mailer');
964 if($mail->Mailer == 'smtp') {
965 $mail->SMTPAuth = true;
966 }
967 $mail->ContentType = get_option('email_contenttype');
968 $mail->Subject = $template_email_subject;
969 if(get_option('email_contenttype') == 'text/plain') {
970 $mail->Body = $template_email_bodyalt;
971 } else {
972 $mail->Body = $template_email_body;
973 $mail->AltBody = $template_email_bodyalt;
974 }
975 // Send The Mail if($mail->Send()) {
976 if($mail->Send()) {
977 $email_status = __('Success', 'wp-email');
978 // Template For Sent Successfully
979 $template_email_sentsuccess = stripslashes(get_option('email_template_sentsuccess'));
980 $template_email_sentsuccess = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_sentsuccess);
981 $template_email_sentsuccess = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_sentsuccess);
982 $template_email_sentsuccess = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_sentsuccess);
983 $template_email_sentsuccess = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_sentsuccess);
984 $template_email_sentsuccess = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_sentsuccess);
985 $template_email_sentsuccess = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_sentsuccess);
986 // If There Is Error Sending
987 } else {
988 if($yourremarks == __('N/A', 'wp-email')) { $yourremarks = ''; }
989 $email_status = __('Failed', 'wp-email');
990 // Template For Sent Failed
991 $template_email_sentfailed = stripslashes(get_option('email_template_sentfailed'));
992 $template_email_sentfailed = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_sentfailed);
993 $template_email_sentfailed = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_sentfailed);
994 $template_email_sentfailed = str_replace("%EMAIL_ERROR_MSG%", $mail->ErrorInfo, $template_email_sentfailed);
995 $template_email_sentfailed = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_sentfailed);
996 $template_email_sentfailed = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_sentfailed);
997 $template_email_sentfailed = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_sentfailed);
998 $template_email_sentfailed = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_sentfailed);
999 }
1000 // Logging
1001 $email_yourname = addslashes($yourname);
1002 $email_youremail = addslashes($youremail);
1003 $email_yourremarks = addslashes($yourremarks);
1004 $email_postid = intval(get_the_id());
1005 $email_posttitle = addslashes($post_title);
1006 $email_timestamp = current_time('timestamp');
1007 $email_ip = get_email_ipaddress();
1008 $email_host = esc_attr(@gethostbyaddr($email_ip));
1009 foreach($friends as $friend) {
1010 $email_friendname = addslashes($friend['name']);
1011 $email_friendemail = addslashes($friend['email']);
1012 $wpdb->query("INSERT INTO $wpdb->email VALUES (0, '$email_yourname', '$email_youremail', '$email_yourremarks', '$email_friendname', '$email_friendemail', $email_postid, '$email_posttitle', '$email_timestamp', '$email_ip', '$email_host', '$email_status')");
1013 }
1014 if($email_status == __('Success', 'wp-email')) {
1015 $output = $template_email_sentsuccess;
1016 } else {
1017 $output = $template_email_sentfailed;
1018 }
1019 echo $output;
1020 exit();
1021 // If There Are Errors
1022 } else {
1023 $error = substr($error, 21);
1024 $template_email_error = stripslashes(get_option('email_template_error'));
1025 $template_email_error = str_replace("%EMAIL_ERROR_MSG%", $error, $template_email_error);
1026 $template_email_error = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_error);
1027 $template_email_error = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_error);
1028 $template_email_error = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_error);
1029 $output = $template_email_error;
1030 $output .= email_form('', false, false, false, $error_field);
1031 echo $output;
1032 exit();
1033 } // End if(empty($error))
1034 } // End if(!empty($_POST['wp-email']))
1035 }
1036
1037
1038 ### Function: E-Mail Form
1039 function email_form($content, $echo = true, $subtitle = true, $div = true, $error_field = '') {
1040 global $wpdb, $multipage;
1041 // Variables
1042 $multipage = false;
1043 $post_title = email_get_title();
1044 $post_author = get_the_author();
1045 $post_date = get_the_time(get_option('date_format').' ('.get_option('time_format').')', '', '', false);
1046 $post_category = email_category(__(',', 'wp-email').' ');
1047 $post_category_alt = strip_tags($post_category);
1048 $email_fields = get_option('email_fields');
1049 $email_image_verify = intval(get_option('email_imageverify'));
1050 $email_options = get_option('email_options');
1051 $email_type = intval($email_options['email_type']);
1052 $error_field = apply_filters('email_form-fieldvalues', $error_field);
1053 $output = '';
1054 // Template - Subtitle
1055 if($subtitle) {
1056 $template_subtitle = stripslashes(get_option('email_template_subtitle'));
1057 $template_subtitle = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_subtitle);
1058 $template_subtitle = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_subtitle);
1059 $template_subtitle = str_replace("%EMAIL_POST_DATE%", $post_date, $template_subtitle);
1060 $template_subtitle = str_replace("%EMAIL_POST_CATEGORY%", $post_category, $template_subtitle);
1061 $template_subtitle = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_subtitle);
1062 $template_subtitle = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_subtitle);
1063 $template_subtitle = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_subtitle);
1064 $output .= $template_subtitle;
1065 }
1066 // Display WP-EMail Form
1067 if($div) {
1068 $output .= '<div id="wp-email-content" class="wp-email">'."\n";
1069 }
1070 if (not_spamming()) {
1071 if(!post_password_required()) {
1072 if($email_type == 2){
1073 $output .= email_popup_form_header(false, (!empty($error_field['id']) ? $error_field['id'] : 0));
1074 } else {
1075 $output .= email_form_header(false, (!empty($error_field['id']) ? $error_field['id'] : 0));
1076 }
1077 $output .= '<p id="wp-email-required">'.__('* Required Field', 'wp-email').'</p>'."\n";
1078 if(intval($email_fields['yourname']) == 1) {
1079 $output .= '<p>'."\n";
1080 $output .= '<label for="yourname">'.__('Your Name: *', 'wp-email').'</label><br />'."\n";
1081 $output .= '<input type="text" size="50" id="yourname" name="yourname" class="TextField" value="'.(!empty($error_field['yourname']) ? $error_field['yourname'] : '').'" />'."\n";
1082 $output .= '</p>'."\n";
1083 }
1084 if(intval($email_fields['youremail']) == 1) {
1085 $output .= '<p>'."\n";
1086 $output .= '<label for="youremail">'.__('Your E-Mail: *', 'wp-email').'</label><br />'."\n";
1087 $output .= '<input type="text" size="50" id="youremail" name="youremail" class="TextField" value="'.(!empty($error_field['youremail']) ? $error_field['youremail'] : '').'" dir="ltr" />'."\n";
1088 $output .= '</p>'."\n";
1089 }
1090 if(intval($email_fields['yourremarks']) == 1) {
1091 $output .= '<p>'."\n";
1092 $output .= ' <label for="yourremarks">'.__('Your Remark:', 'wp-email').'</label><br />'."\n";
1093 $output .= ' <textarea cols="49" rows="8" id="yourremarks" name="yourremarks" class="Forms">';
1094 $val = email_get_remark();
1095 if ( !empty($error_field['yourremarks']) ) {
1096 $val = $error_field['yourremarks'];
1097 }
1098 if ( !empty($val) ) {
1099 $output .= esc_html($val);
1100 }
1101 $output .= '</textarea>'."\n";
1102 $output .= '</p>'."\n";
1103 }
1104 if(intval($email_fields['friendname']) == 1) {
1105 $output .= '<p>'."\n";
1106 $output .= '<label for="friendname">'.__('Friend\'s Name: *', 'wp-email').'</label><br />'."\n";
1107 $output .= '<input type="text" size="50" id="friendname" name="friendname" class="TextField" value="'.(!empty($error_field['friendname']) ? $error_field['friendname'] : '').'" />'.email_multiple(false)."\n";
1108 $output .= '</p>'."\n";
1109 }
1110 $output .= '<p>'."\n";
1111 $output .= '<label for="friendemail">'.__('Friend\'s E-Mail: *', 'wp-email').'</label><br />'."\n";
1112 $output .= '<input type="text" size="50" id="friendemail" name="friendemail" class="TextField" value="'.(!empty($error_field['friendemail']) ? $error_field['friendemail'] : '').'" dir="ltr" />'.email_multiple(false)."\n";
1113 $output .= '</p>'."\n";
1114 if($email_image_verify) {
1115 $output .= '<p>'."\n";
1116 $output .= '<label for="imageverify">'.__('Image Verification: *', 'wp-email').'</label><br />'."\n";
1117 $output .= '<img src="'.plugins_url('wp-email/email-image-verify.php').'" width="55" height="15" alt="'.__('E-Mail Image Verification', 'wp-email').'" /><input type="text" size="5" maxlength="5" id="imageverify" name="imageverify" class="TextField" />'."\n";
1118 $output .= '</p>'."\n";
1119 }
1120 $output .= '<p id="wp-email-button"><input type="button" value="'.__(' Mail It! ', 'wp-email').'" id="wp-email-submit" class="Button" onclick="email_form();" onkeypress="email_form();" /></p>'."\n";
1121 $output .= '</form>'."\n";
1122 } else {
1123 $output .= get_the_password_form();
1124 } // End if(!post_password_required())
1125 } else {
1126 $output .= '<p>'.sprintf(_n('Please wait for <strong>%s Minute</strong> before sending the next article.', 'Please wait for <strong>%s Minutes</strong> before sending the next article.', email_flood_interval(false), 'wp-email'), email_flood_interval(false)).'</p>'."\n";
1127 } // End if (not_spamming())
1128 $output .= '<div id="wp-email-loading" class="wp-email-loading"><img src="'.plugins_url('wp-email/images/loading.gif').'" width="16" height="16" alt="'.__('Loading', 'wp-email').' ..." title="'.__('Loading', 'wp-email').' ..." class="wp-email-image" />&nbsp;'.__('Loading', 'wp-email').' ...</div>'."\n";
1129 if($div) {
1130 $output .= '</div>'."\n";
1131 }
1132 email_removefilters();
1133 if($echo) {
1134 echo $output;
1135 } else {
1136 return $output;
1137 }
1138 }
1139
1140
1141 ### Function: Modify Default WordPress Listing To Make It Sorted By Most E-Mailed
1142 function email_fields($content) {
1143 global $wpdb;
1144 $content .= ", COUNT($wpdb->email.email_postid) AS email_total";
1145 return $content;
1146 }
1147 function email_join($content) {
1148 global $wpdb;
1149 $content .= " LEFT JOIN $wpdb->email ON $wpdb->email.email_postid = $wpdb->posts.ID";
1150 return $content;
1151 }
1152 function email_groupby($content) {
1153 global $wpdb;
1154 $content .= " $wpdb->email.email_postid";
1155 return $content;
1156 }
1157 function email_orderby($content) {
1158 $orderby = trim(addslashes($_GET['orderby']));
1159 if(empty($orderby) || ($orderby != 'asc' && $orderby != 'desc')) {
1160 $orderby = 'desc';
1161 }
1162 $content = " email_total $orderby";
1163 return $content;
1164 }
1165
1166
1167 ### Process The Sorting
1168 /*
1169 if($_GET['sortby'] == 'email') {
1170 add_filter('posts_fields', 'email_fields');
1171 add_filter('posts_join', 'email_join');
1172 add_filter('posts_groupby', 'email_groupby');
1173 add_filter('posts_orderby', 'email_orderby');
1174 }
1175 */
1176
1177
1178 ### Function: Plug Into WP-Stats
1179 add_action('wp','email_wp_stats');
1180 function email_wp_stats() {
1181 if(function_exists('stats_page')) {
1182 add_filter('wp_stats_page_admin_plugins', 'email_page_admin_general_stats');
1183 add_filter('wp_stats_page_admin_most', 'email_page_admin_most_stats');
1184 add_filter('wp_stats_page_plugins', 'email_page_general_stats');
1185 add_filter('wp_stats_page_most', 'email_page_most_stats');
1186 }
1187 }
1188
1189
1190 ### Function: Add WP-EMail General Stats To WP-Stats Page Options
1191 function email_page_admin_general_stats($content) {
1192 $stats_display = get_option('stats_display');
1193 if($stats_display['email'] == 1) {
1194 $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_email" value="email" checked="checked" />&nbsp;&nbsp;<label for="wpstats_email">'.__('WP-EMail', 'wp-email').'</label><br />'."\n";
1195 } else {
1196 $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_email" value="email" />&nbsp;&nbsp;<label for="wpstats_email">'.__('WP-EMail', 'wp-email').'</label><br />'."\n";
1197 }
1198 return $content;
1199 }
1200
1201
1202 ### Function: Add WP-EMail Top Most/Highest Stats To WP-Stats Page Options
1203 function email_page_admin_most_stats($content) {
1204 $stats_display = get_option('stats_display');
1205 $stats_mostlimit = intval(get_option('stats_mostlimit'));
1206 if($stats_display['emailed_most_post'] == 1) {
1207 $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_emailed_most_post" value="emailed_most_post" checked="checked" />&nbsp;&nbsp;<label for="wpstats_emailed_most_post">'.sprintf(_n('%s Most Emailed Post', '%s Most Emailed Posts', $stats_mostlimit, 'wp-email'), number_format_i18n($stats_mostlimit)).'</label><br />'."\n";
1208 } else {
1209 $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_emailed_most_post" value="emailed_most_post" />&nbsp;&nbsp;<label for="wpstats_emailed_most_post">'.sprintf(_n('%s Most Emailed Post', '%s Most Emailed Posts', $stats_mostlimit, 'wp-email'), number_format_i18n($stats_mostlimit)).'</label><br />'."\n";
1210 }
1211 if($stats_display['emailed_most_page'] == 1) {
1212 $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_emailed_most_page" value="emailed_most_page" checked="checked" />&nbsp;&nbsp;<label for="wpstats_emailed_most_page">'.sprintf(_n('%s Most Emailed Page', '%s Most Emailed Pages', $stats_mostlimit, 'wp-email'), number_format_i18n($stats_mostlimit)).'</label><br />'."\n";
1213 } else {
1214 $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_emailed_most_page" value="emailed_most_page" />&nbsp;&nbsp;<label for="wpstats_emailed_most_page">'.sprintf(_n('%s Most Emailed Page', '%s Most Emailed Pages', $stats_mostlimit, 'wp-email'), number_format_i18n($stats_mostlimit)).'</label><br />'."\n";
1215 }
1216 return $content;
1217 }
1218
1219
1220 ### Function: Add WP-EMail General Stats To WP-Stats Page
1221 function email_page_general_stats($content) {
1222 global $wpdb;
1223 $stats_display = get_option('stats_display');
1224 if($stats_display['email'] == 1) {
1225 $email_stats = $wpdb->get_results("SELECT email_status, COUNT(email_id) AS email_total FROM $wpdb->email GROUP BY email_status");
1226 if($email_stats) {
1227 $email_stats_array = array();
1228 $email_stats_array['total'] = 0;
1229 foreach($email_stats as $email_stat) {
1230 $email_stats_array[$email_stat->email_status] = intval($email_stat->email_total);
1231 $email_stats_array['total'] += intval($email_stat->email_total);
1232 }
1233 }
1234 $content .= '<p><strong>'.__('WP-EMail', 'wp-email').'</strong></p>'."\n";
1235 $content .= '<ul>'."\n";
1236 $content .= '<li>'.sprintf(_n('<strong>%s</strong> email was sent.', '<strong>%s</strong> emails were sent.', $email_stats_array['total'], 'wp-email'), number_format_i18n($email_stats_array['total'])).'</li>'."\n";
1237 $content .= '<li>'.sprintf(_n('<strong>%s</strong> email was sent successfully.', '<strong>%s</strong> emails were sent successfully.', $email_stats_array[__('Success', 'wp-email')], 'wp-email'), number_format_i18n($email_stats_array[__('Success', 'wp-email')])).'</li>'."\n";
1238 $content .= '<li>'.sprintf(_n('<strong>%s</strong> email failed to send.', '<strong>%s</strong> emails failed to send.', $email_stats_array[__('Failed', 'wp-email')], 'wp-email'), number_format_i18n($email_stats_array[__('Failed', 'wp-email')])).'</li>'."\n";
1239 $content .= '</ul>'."\n";
1240 }
1241 return $content;
1242 }
1243
1244
1245 ### Function: Add WP-EMail Top Most/Highest Stats To WP-Stats Page
1246 function email_page_most_stats($content) {
1247 $stats_display = get_option('stats_display');
1248 $stats_mostlimit = intval(get_option('stats_mostlimit'));
1249 if($stats_display['emailed_most_post'] == 1) {
1250 $content .= '<p><strong>'.sprintf(_n('%s Most Emailed Post', '%s Most Emailed Posts', $stats_mostlimit, 'wp-email'), number_format_i18n($stats_mostlimit)).'</strong></p>'."\n";
1251 $content .= '<ul>'."\n";
1252 $content .= get_mostemailed('post', $stats_mostlimit, 0, false);
1253 $content .= '</ul>'."\n";
1254 }
1255 if($stats_display['emailed_most_page'] == 1) {
1256 $content .= '<p><strong>'.sprintf(_n('%s Most Emailed Page', '%s Most Emailed Pages', $stats_mostlimit, 'wp-email'), number_format_i18n($stats_mostlimit)).'</strong></p>'."\n";
1257 $content .= '<ul>'."\n";
1258 $content .= get_mostemailed('page', $stats_mostlimit, 0, false);
1259 $content .= '</ul>'."\n";
1260 }
1261 return $content;
1262 }
1263
1264
1265 ### Class: WP-EMail Widget
1266 class WP_Widget_Email extends WP_Widget {
1267 // Constructor
1268 function WP_Widget_Email() {
1269 $widget_ops = array('description' => __('WP-EMail emails statistics', 'wp-email'));
1270 $this->WP_Widget('email', __('Email', 'wp-email'), $widget_ops);
1271 }
1272
1273 // Display Widget
1274 function widget($args, $instance) {
1275 extract($args);
1276 $title = apply_filters('widget_title', esc_attr($instance['title']));
1277 $type = esc_attr($instance['type']);
1278 $mode = esc_attr($instance['mode']);
1279 $limit = intval($instance['limit']);
1280 $chars = intval($instance['chars']);
1281 //$cat_ids = explode(',', esc_attr($instance['cat_ids']));
1282 echo $before_widget.$before_title.$title.$after_title;
1283 echo '<ul>'."\n";
1284 switch($type) {
1285 case 'most_emailed':
1286 get_mostemailed($mode, $limit, $chars);
1287 break;
1288 }
1289 echo '</ul>'."\n";
1290 echo $after_widget;
1291 }
1292
1293 // When Widget Control Form Is Posted
1294 function update($new_instance, $old_instance) {
1295 if (!isset($new_instance['submit'])) {
1296 return false;
1297 }
1298 $instance = $old_instance;
1299 $instance['title'] = strip_tags($new_instance['title']);
1300 $instance['type'] = strip_tags($new_instance['type']);
1301 $instance['mode'] = strip_tags($new_instance['mode']);
1302 $instance['limit'] = intval($new_instance['limit']);
1303 $instance['chars'] = intval($new_instance['chars']);
1304 //$instance['cat_ids'] = strip_tags($new_instance['cat_ids']);
1305 return $instance;
1306 }
1307
1308 // DIsplay Widget Control Form
1309 function form($instance) {
1310 global $wpdb;
1311 $instance = wp_parse_args((array) $instance, array('title' => __('EMail', 'wp-email'), 'type' => 'most_emailed', 'mode' => 'both', 'limit' => 10, 'chars' => 200));
1312 $title = esc_attr($instance['title']);
1313 $type = esc_attr($instance['type']);
1314 $mode = esc_attr($instance['mode']);
1315 $limit = intval($instance['limit']);
1316 $chars = intval($instance['chars']);
1317 //$cat_ids = esc_attr($instance['cat_ids']);
1318 ?>
1319 <p>
1320 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'wp-email'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label>
1321 </p>
1322 <p>
1323 <label for="<?php echo $this->get_field_id('type'); ?>"><?php _e('Statistics Type:', 'wp-email'); ?>
1324 <select name="<?php echo $this->get_field_name('type'); ?>" id="<?php echo $this->get_field_id('type'); ?>" class="widefat">
1325 <option value="most_emailed"<?php selected('most_emailed', $type); ?>><?php _e('Most Emailed', 'wp-email'); ?></option>
1326 </select>
1327 </label>
1328 </p>
1329 <p>
1330 <label for="<?php echo $this->get_field_id('mode'); ?>"><?php _e('Include Views From:', 'wp-email'); ?>
1331 <select name="<?php echo $this->get_field_name('mode'); ?>" id="<?php echo $this->get_field_id('mode'); ?>" class="widefat">
1332 <option value="both"<?php selected('both', $mode); ?>><?php _e('Posts &amp; Pages', 'wp-email'); ?></option>
1333 <option value="post"<?php selected('post', $mode); ?>><?php _e('Posts Only', 'wp-email'); ?></option>
1334 <option value="page"<?php selected('page', $mode); ?>><?php _e('Pages Only', 'wp-email'); ?></option>
1335 </select>
1336 </label>
1337 </p>
1338 <p>
1339 <label for="<?php echo $this->get_field_id('limit'); ?>"><?php _e('No. Of Records To Show:', 'wp-email'); ?> <input class="widefat" id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="text" value="<?php echo $limit; ?>" /></label>
1340 </p>
1341 <p>
1342 <label for="<?php echo $this->get_field_id('chars'); ?>"><?php _e('Maximum Post Title Length (Characters):', 'wp-email'); ?> <input class="widefat" id="<?php echo $this->get_field_id('chars'); ?>" name="<?php echo $this->get_field_name('chars'); ?>" type="text" value="<?php echo $chars; ?>" /></label><br />
1343 <small><?php _e('<strong>0</strong> to disable.', 'wp-email'); ?></small>
1344 </p>
1345 <input type="hidden" id="<?php echo $this->get_field_id('submit'); ?>" name="<?php echo $this->get_field_name('submit'); ?>" value="1" />
1346 <?php
1347 }
1348 }
1349
1350
1351 ### Function: Init WP-EMail Widget
1352 add_action('widgets_init', 'widget_email_init');
1353 function widget_email_init() {
1354 email_textdomain();
1355 register_widget('WP_Widget_Email');
1356 }
1357
1358
1359 ### Function: Activate Plugin
1360 register_activation_hook( __FILE__, 'email_activation' );
1361 function email_activation( $network_wide )
1362 {
1363 if ( is_multisite() && $network_wide )
1364 {
1365 $ms_sites = wp_get_sites();
1366
1367 if( 0 < sizeof( $ms_sites ) )
1368 {
1369 foreach ( $ms_sites as $ms_site )
1370 {
1371 switch_to_blog( $ms_site['blog_id'] );
1372 email_activate();
1373 }
1374 }
1375
1376 restore_current_blog();
1377 }
1378 else
1379 {
1380 email_activate();
1381 }
1382 }
1383
1384 function email_activate() {
1385 global $wpdb;
1386
1387 if(@is_file(ABSPATH.'/wp-admin/upgrade-functions.php')) {
1388 include_once(ABSPATH.'/wp-admin/upgrade-functions.php');
1389 } elseif(@is_file(ABSPATH.'/wp-admin/includes/upgrade.php')) {
1390 include_once(ABSPATH.'/wp-admin/includes/upgrade.php');
1391 } else {
1392 die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'');
1393 }
1394
1395 $charset_collate = '';
1396 if($wpdb->supports_collation()) {
1397 if(!empty($wpdb->charset)) {
1398 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
1399 }
1400 if(!empty($wpdb->collate)) {
1401 $charset_collate .= " COLLATE $wpdb->collate";
1402 }
1403 }
1404
1405 // Create E-Mail Table
1406 $create_table = "CREATE TABLE $wpdb->email (".
1407 "email_id int(10) NOT NULL auto_increment,".
1408 "email_yourname varchar(200) NOT NULL default '',".
1409 "email_youremail varchar(200) NOT NULL default '',".
1410 "email_yourremarks text NOT NULL,".
1411 "email_friendname varchar(200) NOT NULL default '',".
1412 "email_friendemail varchar(200) NOT NULL default '',".
1413 "email_postid int(10) NOT NULL default '0',".
1414 "email_posttitle text NOT NULL,".
1415 "email_timestamp varchar(20) NOT NULL default '',".
1416 "email_ip varchar(100) NOT NULL default '',".
1417 "email_host varchar(200) NOT NULL default '',".
1418 "email_status varchar(20) NOT NULL default '',".
1419 "PRIMARY KEY (email_id)) $charset_collate;";
1420 maybe_create_table($wpdb->email, $create_table);
1421
1422 // Add In Options
1423 add_option('email_smtp', array('username' => '', 'password' => '', 'server' => ''));
1424 add_option('email_contenttype', 'text/html');
1425 add_option('email_mailer', 'php');
1426 add_option('email_template_subject', __('Recommended Article By %EMAIL_YOUR_NAME%: %EMAIL_POST_TITLE%', 'wp-email'));
1427 add_option('email_template_body', __('<p>Hi <strong>%EMAIL_FRIEND_NAME%</strong>,<br />Your friend, <strong>%EMAIL_YOUR_NAME%</strong>, has recommended this article entitled \'<strong>%EMAIL_POST_TITLE%</strong>\' to you.</p><p><strong>Here is his/her remark:</strong><br />%EMAIL_YOUR_REMARKS%</p><p><strong>%EMAIL_POST_TITLE%</strong><br />Posted By %EMAIL_POST_AUTHOR% On %EMAIL_POST_DATE% In %EMAIL_POST_CATEGORY%</p>%EMAIL_POST_CONTENT%<p>Article taken from %EMAIL_BLOG_NAME% - <a href="%EMAIL_BLOG_URL%">%EMAIL_BLOG_URL%</a><br />URL to article: <a href="%EMAIL_PERMALINK%">%EMAIL_PERMALINK%</a></p>', 'wp-email'));
1428 add_option('email_template_bodyalt', __('Hi %EMAIL_FRIEND_NAME%,'."\n".
1429 'Your friend, %EMAIL_YOUR_NAME%, has recommended this article entitled \'%EMAIL_POST_TITLE%\' to you.'."\n\n".
1430 'Here is his/her remarks:'."\n".
1431 '%EMAIL_YOUR_REMARKS%'."\n\n".
1432 '%EMAIL_POST_TITLE%'."\n".
1433 'Posted By %EMAIL_POST_AUTHOR% On %EMAIL_POST_DATE% In %EMAIL_POST_CATEGORY%'."\n".
1434 '%EMAIL_POST_CONTENT%'."\n".
1435 'Article taken from %EMAIL_BLOG_NAME% - %EMAIL_BLOG_URL%'."\n".
1436 'URL to article: %EMAIL_PERMALINK%', 'wp-email'));
1437 add_option('email_template_sentsuccess', '<p>'.__('Article: <strong>%EMAIL_POST_TITLE%</strong> has been sent to <strong>%EMAIL_FRIEND_NAME% (%EMAIL_FRIEND_EMAIL%)</strong></p><p>&laquo; <a href="%EMAIL_PERMALINK%">'.__('Back to %EMAIL_POST_TITLE%', 'wp-email').'</a></p>', 'wp-email'));
1438 add_option('email_template_sentfailed', '<p>'.__('An error has occurred when trying to send this email: ', 'wp-email').'<br /><strong>&raquo;</strong> %EMAIL_ERROR_MSG%</p>');
1439 add_option('email_template_error', '<p>'.__('An error has occurred: ', 'wp-email').'<br /><strong>&raquo;</strong> %EMAIL_ERROR_MSG%</p>');
1440 add_option('email_interval', 10);
1441 add_option('email_snippet', 0);
1442 add_option('email_multiple', 5);
1443
1444 // Version 2.05 Options
1445 add_option('email_imageverify', 1);
1446
1447 // Version 2.10 Options
1448 $email_options = array('post_text' => __('Email This Post', 'wp-email'), 'page_text' => __('Email This Page', 'wp-email'), 'email_icon' => 'email_famfamfam.png', 'email_type' => 1, 'email_style' => 1, 'email_html' => '<a href="%EMAIL_URL%" rel="nofollow" title="%EMAIL_TEXT%">%EMAIL_TEXT%</a>');
1449 add_option('email_options', $email_options);
1450 $email_fields = array('yourname' => 1, 'youremail' => 1, 'yourremarks' => 1, 'friendname' => 1, 'friendemail' => 1);
1451 add_option('email_fields', $email_fields);
1452
1453 // Version 2.11 Options
1454 add_option('email_template_title', __('E-Mail \'%EMAIL_POST_TITLE%\' To A Friend', 'wp-email'));
1455 add_option('email_template_subtitle', '<p style="text-align: center;">'.__('Email a copy of <strong>\'%EMAIL_POST_TITLE%\'</strong> to a friend', 'wp-email').'</p>');
1456
1457 // Set 'manage_email' Capabilities To Administrator
1458 $role = get_role('administrator');
1459 if(!$role->has_cap('manage_email')) {
1460 $role->add_cap('manage_email');
1461 }
1462
1463 // Flush Rewrite Rules
1464 flush_rewrite_rules();
1465 }