PluginProbe
WP-EMail / 2.69.0
WP-EMail v2.69.0
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.0, at wp-email.php

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