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

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