PluginProbe
WP-EMail / 2.63
WP-EMail v2.63
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.63, at wp-email.php

1,462 lines 60.1 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.63
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 if( array_key_exists( 'email' , $wp_query->query_vars ) ) {
732 include(WP_PLUGIN_DIR.'/wp-email/email-standalone.php');
733 exit();
734 } elseif( array_key_exists( 'emailpopup' , $wp_query->query_vars ) ) {
735 include(WP_PLUGIN_DIR.'/wp-email/email-popup.php');
736 exit();
737 }
738 }
739
740
741 ### Function: Process E-Mail Form
742 add_action('wp_ajax_email', 'process_email_form');
743 add_action('wp_ajax_nopriv_email', 'process_email_form');
744 function process_email_form() {
745 global $wpdb, $post, $text_direction;
746 // If User Click On Mail
747 if(isset($_POST['action']) && $_POST['action'] == 'email') {
748
749 // Verify Referer
750 if(!check_ajax_referer('wp-email-nonce', 'wp-email_nonce', false))
751 {
752 _e('Failed To Verify Referrer', 'wp-email');
753 exit();
754 }
755
756 @session_start();
757 email_textdomain();
758 header('Content-Type: text/html; charset='.get_option('blog_charset').'');
759 // POST Variables
760 $yourname = (!empty($_POST['yourname']) ? strip_tags(stripslashes(trim($_POST['yourname']))) : '');
761 $youremail = (!empty($_POST['youremail']) ? strip_tags(stripslashes(trim($_POST['youremail']))) : '');
762 $yourremarks = (!empty($_POST['yourremarks'])? strip_tags(stripslashes(trim($_POST['yourremarks']))) : '');
763 $friendname = (!empty($_POST['friendname']) ? strip_tags(stripslashes(trim($_POST['friendname']))) : '');
764 $friendemail = (!empty($_POST['friendemail'])? strip_tags(stripslashes(trim($_POST['friendemail']))) : '');
765 $imageverify = (!empty($_POST['imageverify'])? $_POST['imageverify'] : '');
766 $p = (!empty($_POST['p']) ? intval($_POST['p']) : 0);
767 $page_id = (!empty($_POST['page_id']) ? intval($_POST['page_id']) : 0);
768 // Get Post Information
769 if($p > 0) {
770 $post_type = get_post_type($p);
771 $query_post = 'p='. $p . '&post_type=' . $post_type;
772 $id = $p;
773 } else {
774 $query_post = 'page_id='.$page_id;
775 $id = $page_id;
776 }
777 query_posts($query_post);
778 if(have_posts()) {
779 while(have_posts()) {
780 the_post();
781 $post_title = email_get_title();
782 $post_author = get_the_author();
783 $post_date = get_the_time(get_option('date_format').' ('.get_option('time_format').')', '', '', false);
784 $post_category = email_category(__(',', 'wp-email').' ');
785 $post_category_alt = strip_tags($post_category);
786 $post_excerpt = get_the_excerpt();
787 $post_content = email_content();
788 $post_content_alt = email_content_alt();
789 }
790 }
791 // Error
792 $error = '';
793 $error_field = array('yourname' => $yourname, 'youremail' => $youremail, 'yourremarks' => $yourremarks, 'friendname' => $friendname, 'friendemail' => $friendemail, 'id' => $id);
794 // Get Options
795 $email_fields = get_option('email_fields');
796 $email_image_verify = intval(get_option('email_imageverify'));
797 $email_smtp = get_option('email_smtp');
798 // Multiple Names/Emails
799 $friends = array();
800 $friendname_count = 0;
801 $friendemail_count = 0;
802 $multiple_names = explode(',', $friendname);
803 $multiple_emails = explode(',', $friendemail);
804 $multiple_max = intval(get_option('email_multiple'));
805 if($multiple_max == 0) { $multiple_max = 1; }
806 // Checking Your Name Field For Errors
807 if(intval($email_fields['yourname']) == 1) {
808 if(empty($yourname)) {
809 $error .= '<br /><strong>&raquo;</strong> '.__('Your Name is empty', 'wp-email');
810 }
811 if(!is_valid_name($yourname)) {
812 $error .= '<br /><strong>&raquo;</strong> '.__('Your Name is invalid', 'wp-email');
813 }
814 }
815 // Checking Your E-Mail Field For Errors
816 if(intval($email_fields['youremail']) == 1) {
817 if(empty($youremail)) {
818 $error .= '<br /><strong>&raquo;</strong> '.__('Your Email is empty', 'wp-email');
819 }
820 if(!is_valid_email($youremail)) {
821 $error .= '<br /><strong>&raquo;</strong> '.__('Your Email is invalid', 'wp-email');
822 }
823 }
824 // Checking Your Remarks Field For Errors
825 if(intval($email_fields['yourremarks']) == 1) {
826 if(!is_valid_remarks($yourremarks)) {
827 $error .= '<br /><strong>&raquo;</strong> '.__('Your Remarks is invalid', 'wp-email');
828 }
829 }
830 // Checking Friend's Name Field For Errors
831 if(intval($email_fields['friendname']) == 1) {
832 if(empty($friendname)) {
833 $error .= '<br /><strong>&raquo;</strong> '.__('Friend Name(s) is empty', 'wp-email');
834 } else {
835 if($multiple_names) {
836 foreach($multiple_names as $multiple_name) {
837 $multiple_name = trim($multiple_name);
838 if(empty($multiple_name)) {
839 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Name is empty: %s', 'wp-email'), $multiple_name);
840 } elseif(!is_valid_name($multiple_name)) {
841 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Name is invalid: %s', 'wp-email'), $multiple_name);
842 } else {
843 $friends[$friendname_count]['name'] = $multiple_name;
844 $friendname_count++;
845 }
846 if($friendname_count > $multiple_max) {
847 break;
848 }
849 }
850 }
851 }
852 }
853 // Checking Friend's E-Mail Field For Errors
854 if(empty($friendemail)) {
855 $error .= '<br /><strong>&raquo;</strong> '.__('Friend Email(s) is empty', 'wp-email');
856 } else {
857 if($multiple_emails) {
858 foreach($multiple_emails as $multiple_email) {
859 $multiple_email = trim($multiple_email);
860 if(empty($multiple_email)) {
861 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Email is empty: %s', 'wp-email'), $multiple_email);
862 } elseif(!is_valid_email($multiple_email)) {
863 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Email is invalid: %s', 'wp-email'), $multiple_email);
864 } else {
865 $friends[$friendemail_count]['email'] = $multiple_email;
866 $friendemail_count++;
867 }
868 if($friendemail_count > $multiple_max) {
869 break;
870 }
871 }
872 }
873 }
874 // Checking If The Fields Exceed The Size Of Maximum Entries Allowed
875 if(sizeof($friends) > $multiple_max) {
876 $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));
877 }
878 if(intval($email_fields['friendname']) == 1) {
879 if($friendname_count != $friendemail_count) {
880 $error .= '<br /><strong>&raquo;</strong> '.__('Friend Name(s) count does not tally with Friend Email(s) count', 'wp-email');
881 }
882 }
883 // Check Whether We Enable Image Verification
884 if($email_image_verify) {
885 $imageverify = strtoupper($imageverify);
886 if(empty($imageverify)) {
887 $error .= '<br /><strong>&raquo;</strong> '.__('Image Verification is empty', 'wp-email');
888 } else {
889 if($_SESSION['email_verify'] != md5($imageverify)) {
890 $error .= '<br /><strong>&raquo;</strong> '.__('Image Verification failed', 'wp-email');
891 }
892 }
893 }
894 // If There Is No Error, We Process The E-Mail
895 if(empty($error) && not_spamming()) {
896 // If Remarks Is Empty, Assign N/A
897 if(empty($yourremarks)) { $yourremarks = __('N/A', 'wp-email'); }
898 // Template For E-Mail Subject
899 $template_email_subject = stripslashes(get_option('email_template_subject'));
900 $template_email_subject = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_subject);
901 $template_email_subject = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_subject);
902 $template_email_subject = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_subject);
903 $template_email_subject = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_subject);
904 $template_email_subject = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_subject);
905 $template_email_subject = str_replace("%EMAIL_POST_CATEGORY%", $post_category_alt, $template_email_subject);
906 $template_email_subject = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_subject);
907 $template_email_subject = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_subject);
908 $template_email_subject = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_subject);
909 // Template For E-Mail Body
910 $template_email_body = stripslashes(get_option('email_template_body'));
911 $template_email_body = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_body);
912 $template_email_body = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_body);
913 $template_email_body = str_replace("%EMAIL_YOUR_REMARKS%", $yourremarks, $template_email_body);
914 $template_email_body = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_body);
915 $template_email_body = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_body);
916 $template_email_body = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_body);
917 $template_email_body = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_body);
918 $template_email_body = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_body);
919 $template_email_body = str_replace("%EMAIL_POST_CATEGORY%", $post_category, $template_email_body);
920 $template_email_body = str_replace("%EMAIL_POST_EXCERPT%", $post_excerpt, $template_email_body);
921 $template_email_body = str_replace("%EMAIL_POST_CONTENT%", $post_content, $template_email_body);
922 $template_email_body = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_body);
923 $template_email_body = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_body);
924 $template_email_body = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_body);
925 if('rtl' == $text_direction) {
926 $template_email_body = "<div style=\"direction: rtl;\">$template_email_body</div>";
927 }
928 // Template For E-Mail Alternate Body
929 $template_email_bodyalt = stripslashes(get_option('email_template_bodyalt'));
930 $template_email_bodyalt = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_bodyalt);
931 $template_email_bodyalt = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_bodyalt);
932 $template_email_bodyalt = str_replace("%EMAIL_YOUR_REMARKS%", $yourremarks, $template_email_bodyalt);
933 $template_email_bodyalt = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_bodyalt);
934 $template_email_bodyalt = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_bodyalt);
935 $template_email_bodyalt = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_bodyalt);
936 $template_email_bodyalt = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_bodyalt);
937 $template_email_bodyalt = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_bodyalt);
938 $template_email_bodyalt = str_replace("%EMAIL_POST_CATEGORY%", $post_category_alt, $template_email_bodyalt);
939 $template_email_bodyalt = str_replace("%EMAIL_POST_EXCERPT%", $post_excerpt, $template_email_bodyalt);
940 $template_email_bodyalt = str_replace("%EMAIL_POST_CONTENT%", $post_content_alt, $template_email_bodyalt);
941 $template_email_bodyalt = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_bodyalt);
942 $template_email_bodyalt = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_bodyalt);
943 $template_email_bodyalt = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_bodyalt);
944 // PHP Mailer Variables
945 if (!class_exists("phpmailer")) {
946 require_once(ABSPATH.WPINC.'/class-phpmailer.php');
947 }
948 $mail = new PHPMailer();
949 $mail->From = $youremail;
950 $mail->FromName = $yourname;
951 foreach($friends as $friend) {
952 $mail->AddAddress($friend['email'], $friend['name']);
953 }
954 $mail->CharSet = strtolower(get_bloginfo('charset'));
955 $mail->Username = $email_smtp['username'];
956 $mail->Password = $email_smtp['password'];
957 $mail->Host = $email_smtp['server'];
958 $mail->Mailer = get_option('email_mailer');
959 if($mail->Mailer == 'smtp') {
960 $mail->SMTPAuth = true;
961 }
962 $mail->ContentType = get_option('email_contenttype');
963 $mail->Subject = $template_email_subject;
964 if(get_option('email_contenttype') == 'text/plain') {
965 $mail->Body = $template_email_bodyalt;
966 } else {
967 $mail->Body = $template_email_body;
968 $mail->AltBody = $template_email_bodyalt;
969 }
970 // Send The Mail if($mail->Send()) {
971 if($mail->Send()) {
972 $email_status = __('Success', 'wp-email');
973 // Template For Sent Successfully
974 $template_email_sentsuccess = stripslashes(get_option('email_template_sentsuccess'));
975 $template_email_sentsuccess = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_sentsuccess);
976 $template_email_sentsuccess = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_sentsuccess);
977 $template_email_sentsuccess = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_sentsuccess);
978 $template_email_sentsuccess = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_sentsuccess);
979 $template_email_sentsuccess = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_sentsuccess);
980 $template_email_sentsuccess = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_sentsuccess);
981 // If There Is Error Sending
982 } else {
983 if($yourremarks == __('N/A', 'wp-email')) { $yourremarks = ''; }
984 $email_status = __('Failed', 'wp-email');
985 // Template For Sent Failed
986 $template_email_sentfailed = stripslashes(get_option('email_template_sentfailed'));
987 $template_email_sentfailed = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_sentfailed);
988 $template_email_sentfailed = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_sentfailed);
989 $template_email_sentfailed = str_replace("%EMAIL_ERROR_MSG%", $mail->ErrorInfo, $template_email_sentfailed);
990 $template_email_sentfailed = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_sentfailed);
991 $template_email_sentfailed = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_sentfailed);
992 $template_email_sentfailed = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_sentfailed);
993 $template_email_sentfailed = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_sentfailed);
994 }
995 // Logging
996 $email_yourname = addslashes($yourname);
997 $email_youremail = addslashes($youremail);
998 $email_yourremarks = addslashes($yourremarks);
999 $email_postid = intval(get_the_id());
1000 $email_posttitle = addslashes($post_title);
1001 $email_timestamp = current_time('timestamp');
1002 $email_ip = get_email_ipaddress();
1003 $email_host = esc_attr(@gethostbyaddr($email_ip));
1004 foreach($friends as $friend) {
1005 $email_friendname = addslashes($friend['name']);
1006 $email_friendemail = addslashes($friend['email']);
1007 $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')");
1008 }
1009 if($email_status == __('Success', 'wp-email')) {
1010 $output = $template_email_sentsuccess;
1011 } else {
1012 $output = $template_email_sentfailed;
1013 }
1014 echo $output;
1015 exit();
1016 // If There Are Errors
1017 } else {
1018 $error = substr($error, 21);
1019 $template_email_error = stripslashes(get_option('email_template_error'));
1020 $template_email_error = str_replace("%EMAIL_ERROR_MSG%", $error, $template_email_error);
1021 $template_email_error = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_error);
1022 $template_email_error = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_error);
1023 $template_email_error = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_error);
1024 $output = $template_email_error;
1025 $output .= email_form('', false, false, false, $error_field);
1026 echo $output;
1027 exit();
1028 } // End if(empty($error))
1029 } // End if(!empty($_POST['wp-email']))
1030 }
1031
1032
1033 ### Function: E-Mail Form
1034 function email_form($content, $echo = true, $subtitle = true, $div = true, $error_field = '') {
1035 global $wpdb, $multipage;
1036 // Variables
1037 $multipage = false;
1038 $post_title = email_get_title();
1039 $post_author = get_the_author();
1040 $post_date = get_the_time(get_option('date_format').' ('.get_option('time_format').')', '', '', false);
1041 $post_category = email_category(__(',', 'wp-email').' ');
1042 $post_category_alt = strip_tags($post_category);
1043 $email_fields = get_option('email_fields');
1044 $email_image_verify = intval(get_option('email_imageverify'));
1045 $email_options = get_option('email_options');
1046 $email_type = intval($email_options['email_type']);
1047 $error_field = apply_filters('email_form-fieldvalues', $error_field);
1048 $output = '';
1049 // Template - Subtitle
1050 if($subtitle) {
1051 $template_subtitle = stripslashes(get_option('email_template_subtitle'));
1052 $template_subtitle = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_subtitle);
1053 $template_subtitle = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_subtitle);
1054 $template_subtitle = str_replace("%EMAIL_POST_DATE%", $post_date, $template_subtitle);
1055 $template_subtitle = str_replace("%EMAIL_POST_CATEGORY%", $post_category, $template_subtitle);
1056 $template_subtitle = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_subtitle);
1057 $template_subtitle = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_subtitle);
1058 $template_subtitle = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_subtitle);
1059 $output .= $template_subtitle;
1060 }
1061 // Display WP-EMail Form
1062 if($div) {
1063 $output .= '<div id="wp-email-content" class="wp-email">'."\n";
1064 }
1065 if (not_spamming()) {
1066 if(!post_password_required()) {
1067 if($email_type == 2){
1068 $output .= email_popup_form_header(false, (!empty($error_field['id']) ? $error_field['id'] : 0));
1069 } else {
1070 $output .= email_form_header(false, (!empty($error_field['id']) ? $error_field['id'] : 0));
1071 }
1072 $output .= '<p id="wp-email-required">'.__('* Required Field', 'wp-email').'</p>'."\n";
1073 if(intval($email_fields['yourname']) == 1) {
1074 $output .= '<p>'."\n";
1075 $output .= '<label for="yourname">'.__('Your Name: *', 'wp-email').'</label><br />'."\n";
1076 $output .= '<input type="text" size="50" id="yourname" name="yourname" class="TextField" value="'.(!empty($error_field['yourname']) ? $error_field['yourname'] : '').'" />'."\n";
1077 $output .= '</p>'."\n";
1078 }
1079 if(intval($email_fields['youremail']) == 1) {
1080 $output .= '<p>'."\n";
1081 $output .= '<label for="youremail">'.__('Your E-Mail: *', 'wp-email').'</label><br />'."\n";
1082 $output .= '<input type="text" size="50" id="youremail" name="youremail" class="TextField" value="'.(!empty($error_field['youremail']) ? $error_field['youremail'] : '').'" dir="ltr" />'."\n";
1083 $output .= '</p>'."\n";
1084 }
1085 if(intval($email_fields['yourremarks']) == 1) {
1086 $output .= '<p>'."\n";
1087 $output .= ' <label for="yourremarks">'.__('Your Remark:', 'wp-email').'</label><br />'."\n";
1088 $output .= ' <textarea cols="49" rows="8" id="yourremarks" name="yourremarks" class="Forms">';
1089 $val = email_get_remark();
1090 if ( !empty($error_field['yourremarks']) ) {
1091 $val = $error_field['yourremarks'];
1092 }
1093 if ( !empty($val) ) {
1094 $output .= esc_html($val);
1095 }
1096 $output .= '</textarea>'."\n";
1097 $output .= '</p>'."\n";
1098 }
1099 if(intval($email_fields['friendname']) == 1) {
1100 $output .= '<p>'."\n";
1101 $output .= '<label for="friendname">'.__('Friend\'s Name: *', 'wp-email').'</label><br />'."\n";
1102 $output .= '<input type="text" size="50" id="friendname" name="friendname" class="TextField" value="'.(!empty($error_field['friendname']) ? $error_field['friendname'] : '').'" />'.email_multiple(false)."\n";
1103 $output .= '</p>'."\n";
1104 }
1105 $output .= '<p>'."\n";
1106 $output .= '<label for="friendemail">'.__('Friend\'s E-Mail: *', 'wp-email').'</label><br />'."\n";
1107 $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";
1108 $output .= '</p>'."\n";
1109 if($email_image_verify) {
1110 $output .= '<p>'."\n";
1111 $output .= '<label for="imageverify">'.__('Image Verification: *', 'wp-email').'</label><br />'."\n";
1112 $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";
1113 $output .= '</p>'."\n";
1114 }
1115 $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";
1116 $output .= '</form>'."\n";
1117 } else {
1118 $output .= get_the_password_form();
1119 } // End if(!post_password_required())
1120 } else {
1121 $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";
1122 } // End if (not_spamming())
1123 $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";
1124 if($div) {
1125 $output .= '</div>'."\n";
1126 }
1127 email_removefilters();
1128 if($echo) {
1129 echo $output;
1130 } else {
1131 return $output;
1132 }
1133 }
1134
1135
1136 ### Function: Modify Default WordPress Listing To Make It Sorted By Most E-Mailed
1137 function email_fields($content) {
1138 global $wpdb;
1139 $content .= ", COUNT($wpdb->email.email_postid) AS email_total";
1140 return $content;
1141 }
1142 function email_join($content) {
1143 global $wpdb;
1144 $content .= " LEFT JOIN $wpdb->email ON $wpdb->email.email_postid = $wpdb->posts.ID";
1145 return $content;
1146 }
1147 function email_groupby($content) {
1148 global $wpdb;
1149 $content .= " $wpdb->email.email_postid";
1150 return $content;
1151 }
1152 function email_orderby($content) {
1153 $orderby = trim(addslashes($_GET['orderby']));
1154 if(empty($orderby) || ($orderby != 'asc' && $orderby != 'desc')) {
1155 $orderby = 'desc';
1156 }
1157 $content = " email_total $orderby";
1158 return $content;
1159 }
1160
1161
1162 ### Process The Sorting
1163 /*
1164 if($_GET['sortby'] == 'email') {
1165 add_filter('posts_fields', 'email_fields');
1166 add_filter('posts_join', 'email_join');
1167 add_filter('posts_groupby', 'email_groupby');
1168 add_filter('posts_orderby', 'email_orderby');
1169 }
1170 */
1171
1172
1173 ### Function: Plug Into WP-Stats
1174 add_action('wp','email_wp_stats');
1175 function email_wp_stats() {
1176 if(function_exists('stats_page')) {
1177 if(strpos(get_option('stats_url'), $_SERVER['REQUEST_URI']) || strpos($_SERVER['REQUEST_URI'], 'stats-options.php') || strpos($_SERVER['REQUEST_URI'], 'wp-stats/wp-stats.php')) {
1178 add_filter('wp_stats_page_admin_plugins', 'email_page_admin_general_stats');
1179 add_filter('wp_stats_page_admin_most', 'email_page_admin_most_stats');
1180 add_filter('wp_stats_page_plugins', 'email_page_general_stats');
1181 add_filter('wp_stats_page_most', 'email_page_most_stats');
1182 }
1183 }
1184 }
1185
1186
1187 ### Function: Add WP-EMail General Stats To WP-Stats Page Options
1188 function email_page_admin_general_stats($content) {
1189 $stats_display = get_option('stats_display');
1190 if($stats_display['email'] == 1) {
1191 $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";
1192 } else {
1193 $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";
1194 }
1195 return $content;
1196 }
1197
1198
1199 ### Function: Add WP-EMail Top Most/Highest Stats To WP-Stats Page Options
1200 function email_page_admin_most_stats($content) {
1201 $stats_display = get_option('stats_display');
1202 $stats_mostlimit = intval(get_option('stats_mostlimit'));
1203 if($stats_display['emailed_most_post'] == 1) {
1204 $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";
1205 } else {
1206 $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";
1207 }
1208 if($stats_display['emailed_most_page'] == 1) {
1209 $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";
1210 } else {
1211 $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";
1212 }
1213 return $content;
1214 }
1215
1216
1217 ### Function: Add WP-EMail General Stats To WP-Stats Page
1218 function email_page_general_stats($content) {
1219 global $wpdb;
1220 $stats_display = get_option('stats_display');
1221 if($stats_display['email'] == 1) {
1222 $email_stats = $wpdb->get_results("SELECT email_status, COUNT(email_id) AS email_total FROM $wpdb->email GROUP BY email_status");
1223 if($email_stats) {
1224 $email_stats_array = array();
1225 $email_stats_array['total'] = 0;
1226 foreach($email_stats as $email_stat) {
1227 $email_stats_array[$email_stat->email_status] = intval($email_stat->email_total);
1228 $email_stats_array['total'] += intval($email_stat->email_total);
1229 }
1230 }
1231 $content .= '<p><strong>'.__('WP-EMail', 'wp-email').'</strong></p>'."\n";
1232 $content .= '<ul>'."\n";
1233 $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";
1234 $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";
1235 $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";
1236 $content .= '</ul>'."\n";
1237 }
1238 return $content;
1239 }
1240
1241
1242 ### Function: Add WP-EMail Top Most/Highest Stats To WP-Stats Page
1243 function email_page_most_stats($content) {
1244 $stats_display = get_option('stats_display');
1245 $stats_mostlimit = intval(get_option('stats_mostlimit'));
1246 if($stats_display['emailed_most_post'] == 1) {
1247 $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";
1248 $content .= '<ul>'."\n";
1249 $content .= get_mostemailed('post', $stats_mostlimit, 0, false);
1250 $content .= '</ul>'."\n";
1251 }
1252 if($stats_display['emailed_most_page'] == 1) {
1253 $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";
1254 $content .= '<ul>'."\n";
1255 $content .= get_mostemailed('page', $stats_mostlimit, 0, false);
1256 $content .= '</ul>'."\n";
1257 }
1258 return $content;
1259 }
1260
1261
1262 ### Class: WP-EMail Widget
1263 class WP_Widget_Email extends WP_Widget {
1264 // Constructor
1265 function WP_Widget_Email() {
1266 $widget_ops = array('description' => __('WP-EMail emails statistics', 'wp-email'));
1267 $this->WP_Widget('email', __('Email', 'wp-email'), $widget_ops);
1268 }
1269
1270 // Display Widget
1271 function widget($args, $instance) {
1272 extract($args);
1273 $title = apply_filters('widget_title', esc_attr($instance['title']));
1274 $type = esc_attr($instance['type']);
1275 $mode = esc_attr($instance['mode']);
1276 $limit = intval($instance['limit']);
1277 $chars = intval($instance['chars']);
1278 //$cat_ids = explode(',', esc_attr($instance['cat_ids']));
1279 echo $before_widget.$before_title.$title.$after_title;
1280 echo '<ul>'."\n";
1281 switch($type) {
1282 case 'most_emailed':
1283 get_mostemailed($mode, $limit, $chars);
1284 break;
1285 }
1286 echo '</ul>'."\n";
1287 echo $after_widget;
1288 }
1289
1290 // When Widget Control Form Is Posted
1291 function update($new_instance, $old_instance) {
1292 if (!isset($new_instance['submit'])) {
1293 return false;
1294 }
1295 $instance = $old_instance;
1296 $instance['title'] = strip_tags($new_instance['title']);
1297 $instance['type'] = strip_tags($new_instance['type']);
1298 $instance['mode'] = strip_tags($new_instance['mode']);
1299 $instance['limit'] = intval($new_instance['limit']);
1300 $instance['chars'] = intval($new_instance['chars']);
1301 //$instance['cat_ids'] = strip_tags($new_instance['cat_ids']);
1302 return $instance;
1303 }
1304
1305 // DIsplay Widget Control Form
1306 function form($instance) {
1307 global $wpdb;
1308 $instance = wp_parse_args((array) $instance, array('title' => __('EMail', 'wp-email'), 'type' => 'most_emailed', 'mode' => 'both', 'limit' => 10, 'chars' => 200));
1309 $title = esc_attr($instance['title']);
1310 $type = esc_attr($instance['type']);
1311 $mode = esc_attr($instance['mode']);
1312 $limit = intval($instance['limit']);
1313 $chars = intval($instance['chars']);
1314 //$cat_ids = esc_attr($instance['cat_ids']);
1315 ?>
1316 <p>
1317 <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>
1318 </p>
1319 <p>
1320 <label for="<?php echo $this->get_field_id('type'); ?>"><?php _e('Statistics Type:', 'wp-email'); ?>
1321 <select name="<?php echo $this->get_field_name('type'); ?>" id="<?php echo $this->get_field_id('type'); ?>" class="widefat">
1322 <option value="most_emailed"<?php selected('most_emailed', $type); ?>><?php _e('Most Emailed', 'wp-email'); ?></option>
1323 </select>
1324 </label>
1325 </p>
1326 <p>
1327 <label for="<?php echo $this->get_field_id('mode'); ?>"><?php _e('Include Views From:', 'wp-email'); ?>
1328 <select name="<?php echo $this->get_field_name('mode'); ?>" id="<?php echo $this->get_field_id('mode'); ?>" class="widefat">
1329 <option value="both"<?php selected('both', $mode); ?>><?php _e('Posts &amp; Pages', 'wp-email'); ?></option>
1330 <option value="post"<?php selected('post', $mode); ?>><?php _e('Posts Only', 'wp-email'); ?></option>
1331 <option value="page"<?php selected('page', $mode); ?>><?php _e('Pages Only', 'wp-email'); ?></option>
1332 </select>
1333 </label>
1334 </p>
1335 <p>
1336 <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>
1337 </p>
1338 <p>
1339 <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 />
1340 <small><?php _e('<strong>0</strong> to disable.', 'wp-email'); ?></small>
1341 </p>
1342 <input type="hidden" id="<?php echo $this->get_field_id('submit'); ?>" name="<?php echo $this->get_field_name('submit'); ?>" value="1" />
1343 <?php
1344 }
1345 }
1346
1347
1348 ### Function: Init WP-EMail Widget
1349 add_action('widgets_init', 'widget_email_init');
1350 function widget_email_init() {
1351 email_textdomain();
1352 register_widget('WP_Widget_Email');
1353 }
1354
1355
1356 ### Function: Activate Plugin
1357 register_activation_hook( __FILE__, 'email_activation' );
1358 function email_activation( $network_wide )
1359 {
1360 if ( is_multisite() && $network_wide )
1361 {
1362 $ms_sites = wp_get_sites();
1363
1364 if( 0 < sizeof( $ms_sites ) )
1365 {
1366 foreach ( $ms_sites as $ms_site )
1367 {
1368 switch_to_blog( $ms_site['blog_id'] );
1369 email_activate();
1370 }
1371 }
1372
1373 restore_current_blog();
1374 }
1375 else
1376 {
1377 email_activate();
1378 }
1379 }
1380
1381 function email_activate() {
1382 global $wpdb;
1383
1384 if(@is_file(ABSPATH.'/wp-admin/upgrade-functions.php')) {
1385 include_once(ABSPATH.'/wp-admin/upgrade-functions.php');
1386 } elseif(@is_file(ABSPATH.'/wp-admin/includes/upgrade.php')) {
1387 include_once(ABSPATH.'/wp-admin/includes/upgrade.php');
1388 } else {
1389 die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'');
1390 }
1391
1392 $charset_collate = '';
1393 if($wpdb->supports_collation()) {
1394 if(!empty($wpdb->charset)) {
1395 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
1396 }
1397 if(!empty($wpdb->collate)) {
1398 $charset_collate .= " COLLATE $wpdb->collate";
1399 }
1400 }
1401
1402 // Create E-Mail Table
1403 $create_table = "CREATE TABLE $wpdb->email (".
1404 "email_id int(10) NOT NULL auto_increment,".
1405 "email_yourname varchar(200) NOT NULL default '',".
1406 "email_youremail varchar(200) NOT NULL default '',".
1407 "email_yourremarks text NOT NULL,".
1408 "email_friendname varchar(200) NOT NULL default '',".
1409 "email_friendemail varchar(200) NOT NULL default '',".
1410 "email_postid int(10) NOT NULL default '0',".
1411 "email_posttitle text NOT NULL,".
1412 "email_timestamp varchar(20) NOT NULL default '',".
1413 "email_ip varchar(100) NOT NULL default '',".
1414 "email_host varchar(200) NOT NULL default '',".
1415 "email_status varchar(20) NOT NULL default '',".
1416 "PRIMARY KEY (email_id)) $charset_collate;";
1417 maybe_create_table($wpdb->email, $create_table);
1418
1419 // Add In Options
1420 add_option('email_smtp', array('username' => '', 'password' => '', 'server' => ''));
1421 add_option('email_contenttype', 'text/html');
1422 add_option('email_mailer', 'php');
1423 add_option('email_template_subject', __('Recommended Article By %EMAIL_YOUR_NAME%: %EMAIL_POST_TITLE%', 'wp-email'));
1424 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'));
1425 add_option('email_template_bodyalt', __('Hi %EMAIL_FRIEND_NAME%,'."\n".
1426 'Your friend, %EMAIL_YOUR_NAME%, has recommended this article entitled \'%EMAIL_POST_TITLE%\' to you.'."\n\n".
1427 'Here is his/her remarks:'."\n".
1428 '%EMAIL_YOUR_REMARKS%'."\n\n".
1429 '%EMAIL_POST_TITLE%'."\n".
1430 'Posted By %EMAIL_POST_AUTHOR% On %EMAIL_POST_DATE% In %EMAIL_POST_CATEGORY%'."\n".
1431 '%EMAIL_POST_CONTENT%'."\n".
1432 'Article taken from %EMAIL_BLOG_NAME% - %EMAIL_BLOG_URL%'."\n".
1433 'URL to article: %EMAIL_PERMALINK%', 'wp-email'));
1434 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'));
1435 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>');
1436 add_option('email_template_error', '<p>'.__('An error has occurred: ', 'wp-email').'<br /><strong>&raquo;</strong> %EMAIL_ERROR_MSG%</p>');
1437 add_option('email_interval', 10);
1438 add_option('email_snippet', 0);
1439 add_option('email_multiple', 5);
1440
1441 // Version 2.05 Options
1442 add_option('email_imageverify', 1);
1443
1444 // Version 2.10 Options
1445 $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>');
1446 add_option('email_options', $email_options);
1447 $email_fields = array('yourname' => 1, 'youremail' => 1, 'yourremarks' => 1, 'friendname' => 1, 'friendemail' => 1);
1448 add_option('email_fields', $email_fields);
1449
1450 // Version 2.11 Options
1451 add_option('email_template_title', __('E-Mail \'%EMAIL_POST_TITLE%\' To A Friend', 'wp-email'));
1452 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>');
1453
1454 // Set 'manage_email' Capabilities To Administrator
1455 $role = get_role('administrator');
1456 if(!$role->has_cap('manage_email')) {
1457 $role->add_cap('manage_email');
1458 }
1459
1460 // Flush Rewrite Rules
1461 flush_rewrite_rules();
1462 }