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

1,471 lines 60.4 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.68.1
7 Author: Lester 'GaMerZ' Chan
8 Author URI: https://lesterchan.net
9 Text Domain: wp-email
10 */
11
12 /*
13 Copyright 2020 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.68.1' );
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_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, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
422 return esc_attr( $ip );
423 }
424 }
425 }
426 }
427 }
428 }
429
430 ### Function: There Are Still Many PHP 4.x Users
431 if(!function_exists('htmlspecialchars_decode')) {
432 function htmlspecialchars_decode($string, $style = ENT_COMPAT) {
433 $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS,$style));
434 if($style === ENT_QUOTES) {
435 $translation['&#039;'] = '\'';
436 }
437 return strtr($string, $translation);
438 }
439 }
440
441
442 ### Function: Check Vaild Name (AlphaNumeric With Spaces Allowed Only)
443 if(!function_exists('is_valid_name')) {
444 function is_valid_name($name) {
445 $regex = '/[(\*\(\)\[\]\+\,\/\?\:\;\'\"\`\~\\#\$\%\^\&\<\>)+]/';
446 return !(preg_match($regex, $name));
447 }
448 }
449
450
451 ### Function: Check Valid E-Mail Address
452 if(!function_exists('is_valid_email')) {
453 function is_valid_email($email) {
454 $regex = '/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/';
455 return (preg_match($regex, $email));
456 }
457 }
458
459
460 ### Function: Check Valid Remarks (Ensure No E-Mail Injections)
461 if(!function_exists('is_valid_remarks')) {
462 function is_valid_remarks($content) {
463 $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');
464 foreach ($injection_strings as $spam) {
465 $check = strpos(strtolower($content), $spam);
466 if ($check !== false) {
467 return false;
468 }
469 }
470 return true;
471 }
472 }
473
474
475 ### Function: Check For E-Mail Spamming
476 function not_spamming() {
477 global $wpdb;
478
479 $last_emailed = $wpdb->get_var(
480 $wpdb->prepare( "SELECT email_timestamp FROM $wpdb->email WHERE email_ip = %s AND email_status = %s ORDER BY email_timestamp DESC LIMIT 1", get_ipaddress(), __( 'Success', 'wp-email' ) )
481 );
482
483 $email_allow_interval = (int) get_option( 'email_interval' ) * 60;
484 if( ( current_time( 'timestamp' ) - $last_emailed) < $email_allow_interval ) {
485 return false;
486 }
487
488 return true;
489 }
490
491
492 ### Function: E-Mail Flood Interval
493 function email_flood_interval($echo = true) {
494 $email_allow_interval_min = (int) get_option('email_interval');
495 if($echo) {
496 echo $email_allow_interval_min;
497 } else {
498 return $email_allow_interval_min;
499 }
500 }
501
502
503 ### Function: Fill In Email Fills If Logged In (By Aaron Campbell)
504 add_filter('email_form-fieldvalues', 'email_fill_fields');
505 function email_fill_fields($email_fields) {
506 global $current_user;
507 if ($current_user->ID > 0) {
508 $email_fields['yourname'] = esc_attr( $current_user->display_name );
509 $email_fields['youremail'] = esc_attr( $current_user->user_email );
510 }
511 return $email_fields;
512 }
513
514
515 ### Function: E-Mail Form Header
516 function email_form_header($echo = true, $temp_id) {
517 global $id;
518 if((int) $temp_id > 0) {
519 $id = $temp_id;
520 }
521 $using_permalink = get_option('permalink_structure');
522 $permalink = get_permalink();
523 // Fix For Static Page
524 if(get_option('show_on_front') === 'page' && is_page()) {
525 if((int) get_option('page_on_front') > 0) {
526 $permalink = _get_page_link();
527 }
528 }
529 $output = '';
530 if(!empty($using_permalink)) {
531 if(is_page()) {
532 $output .= '<form action="'.$permalink.'emailpage/" method="post">'."\n";
533 $output .= '<p style="display: none;"><input type="hidden" id="page_id" name="page_id" value="'.$id.'" /></p>'."\n";
534 } else {
535 $output = '<form action="'.$permalink.'email/" method="post">'."\n";
536 $output .= '<p style="display: none;"><input type="hidden" id="p" name="p" value="'.$id.'" /></p>'."\n";
537 }
538 } else {
539 if(is_page()) {
540 $output .= '<form action="'.$permalink.'&amp;wp_email=1" method="post">'."\n";
541 $output .= '<p style="display: none;"><input type="hidden" id="page_id" name="page_id" value="'.$id.'" /></p>'."\n";
542 } else {
543 $output .= '<form action="'.$permalink.'&amp;wp_email=1" method="post">'."\n";
544 $output .= '<p style="display: none;"><input type="hidden" id="p" name="p" value="'.$id.'" /></p>'."\n";
545 }
546 }
547 $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";
548 if($echo) {
549 echo $output;
550 } else {
551 return $output;
552 }
553 }
554
555
556 ### Function: E-Mail Form Header For Popup
557 function email_popup_form_header($echo = true, $temp_id) {
558 global $post;
559 $id = (int) $post->ID;
560 if((int) $temp_id > 0) {
561 $id = $temp_id;
562 }
563 $using_permalink = get_option('permalink_structure');
564 $permalink = get_permalink();
565 // Fix For Static Page
566 if(get_option('show_on_front') === 'page' && is_page()) {
567 if((int) get_option('page_on_front') > 0) {
568 $permalink = _get_page_link();
569 }
570 }
571 $output = '';
572 if(!empty($using_permalink)) {
573 if(is_page()) {
574 $output .= '<form action="'.$permalink.'emailpopuppage/" method="post">'."\n";
575 $output .= '<p style="display: none;"><input type="hidden" id="page_id" name="page_id" value="'.$id.'" /></p>'."\n";
576 } else {
577 $output = '<form action="'.$permalink.'emailpopup/" method="post">'."\n";
578 $output .= '<p style="display: none;"><input type="hidden" id="p" name="p" value="'.$id.'" /></p>'."\n";
579 }
580 } else {
581 if(is_page()) {
582 $output .= '<form action="'.$permalink.'&amp;emailpopup=1" method="post">'."\n";
583 $output .= '<p style="display: none;"><input type="hidden" id="page_id" name="page_id" value="'.$id.'" /></p>'."\n";
584 } else {
585 $output .= '<form action="'.$permalink.'&amp;emailpopup=1" method="post">'."\n";
586 $output .= '<p style="display: none;"><input type="hidden" id="p" name="p" value="'.$id.'" /></p>'."\n";
587 }
588 }
589 $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";
590 if($echo) {
591 echo $output;
592 } else {
593 return $output;
594 }
595 }
596
597
598 ### Function: Multiple E-Mails
599 function email_multiple($echo = true) {
600 $email_multiple = (int) get_option('email_multiple');
601 $outut = '';
602 if($email_multiple > 1) {
603 $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>';
604 if($echo) {
605 echo $outut;
606 } else {
607 return $output;
608 }
609 }
610 }
611
612
613 ### Function: Get EMail Total Sent
614 if(!function_exists('get_emails')) {
615 function get_emails($echo = true) {
616 global $wpdb;
617 $totalemails = $wpdb->get_var("SELECT COUNT(email_id) FROM $wpdb->email");
618 if($echo) {
619 echo number_format_i18n($totalemails);
620 } else {
621 return number_format_i18n($totalemails);
622 }
623 }
624 }
625
626
627 ### Function: Get EMail Total Sent Success
628 if( ! function_exists( 'get_emails_success' ) ) {
629 function get_emails_success( $echo = true ) {
630 global $wpdb;
631 $totalemails_success = $wpdb->get_var(
632 $wpdb->prepare( "SELECT COUNT(email_id) FROM $wpdb->email WHERE email_status = %s", __('Success', 'wp-email') )
633 );
634
635 if( $echo ) {
636 echo number_format_i18n( $totalemails_success );
637 } else {
638 return number_format_i18n( $totalemails_success );
639 }
640 }
641 }
642
643
644 ### Function: Get EMail Total Sent Failed
645 if( ! function_exists( 'get_emails_failed' ) ) {
646 function get_emails_failed( $echo = true ) {
647 global $wpdb;
648 $totalemails_failed = $wpdb->get_var(
649 $wpdb->prepare( "SELECT COUNT(email_id) FROM $wpdb->email WHERE email_status = %s", __('Failed', 'wp-email') )
650 );
651
652 if( $echo ) {
653 echo number_format_i18n( $totalemails_failed );
654 } else {
655 return number_format_i18n( $totalemails_failed );
656 }
657 }
658 }
659
660
661 ### Function: Get EMail Sent For Post
662 if( ! function_exists( 'get_email_count' ) ) {
663 function get_email_count( $post_id = 0, $echo = true ) {
664 global $wpdb;
665
666 if( $post_id === 0 ) {
667 global $post;
668 $post_id = $post->ID;
669 }
670
671 $totalemails = $wpdb->get_var(
672 $wpdb->prepare( "SELECT COUNT(email_id) FROM $wpdb->email WHERE email_postid = %d", $post_id )
673 );
674 if( $echo ) {
675 echo number_format_i18n( $totalemails );
676 } else {
677 return number_format_i18n( $totalemails );
678 }
679 }
680 }
681
682
683 ### Function: Get Most E-Mailed
684 if(!function_exists('get_mostemailed')) {
685 function get_mostemailed($mode = '', $limit = 10, $chars = 0, $echo = true) {
686 global $wpdb, $post;
687 $temp_post = $post;
688 $where = '';
689 $temp = '';
690 if(!empty($mode) && $mode != 'both') {
691 $where = "post_type = '$mode'";
692 } else {
693 $where = '1=1';
694 }
695 $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");
696 if($mostemailed) {
697 if($chars > 0) {
698 foreach ($mostemailed as $post) {
699 $post_title = get_the_title();
700 $email_total = (int) $post->email_total;
701 $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";
702 }
703 } else {
704 foreach ($mostemailed as $post) {
705 $post_title = get_the_title();
706 $email_total = (int) $post->email_total;
707 $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";
708 }
709 }
710 } else {
711 $temp = '<li>'.__('N/A', 'wp-email').'</li>'."\n";
712 }
713 $post = $temp_post;
714 if($echo) {
715 echo $temp;
716 } else {
717 return $temp;
718 }
719 }
720 }
721
722
723 ### Function: Load WP-EMail
724 add_action('template_redirect', 'wp_email', 5);
725 function wp_email() {
726 global $wp_query;
727
728 $template_redirect = apply_filters( 'wp_email_template_redirect', true );
729
730 if( $template_redirect ) {
731 if (array_key_exists('wp_email', $wp_query->query_vars)) {
732 include(WP_PLUGIN_DIR . '/wp-email/email-standalone.php');
733 exit();
734 } elseif (array_key_exists('wp_email_popup', $wp_query->query_vars)) {
735 include(WP_PLUGIN_DIR . '/wp-email/email-popup.php');
736 exit();
737 }
738 }
739 }
740
741
742 ### Function: Process E-Mail Form
743 add_action('wp_ajax_email', 'process_email_form');
744 add_action('wp_ajax_nopriv_email', 'process_email_form');
745 function process_email_form() {
746 global $wpdb, $post;
747 // If User Click On Mail
748 if(isset($_POST['action']) && $_POST['action'] == 'email') {
749
750 // Verify Referer
751 if(!check_ajax_referer('wp-email-nonce', 'wp-email_nonce', false))
752 {
753 _e('Failed To Verify Referrer', 'wp-email');
754 exit();
755 }
756
757 @session_start();
758 email_textdomain();
759 header('Content-Type: text/html; charset='.get_option('blog_charset').'');
760 // POST Variables
761 $yourname = ! empty($_POST['yourname']) ? sanitize_text_field( $_POST['yourname'] ) : '';
762 $youremail = ! empty($_POST['youremail']) ? sanitize_text_field( $_POST['youremail'] ) : '';
763 $yourremarks = ! empty($_POST['yourremarks'])? sanitize_text_field( $_POST['yourremarks'] ) : '';
764 $friendname = ! empty($_POST['friendname']) ? sanitize_text_field( $_POST['friendname'] ) : '';
765 $friendemail = ! empty($_POST['friendemail'])? sanitize_text_field( $_POST['friendemail'] ) : '';
766 $imageverify = ! empty($_POST['imageverify'])? $_POST['imageverify'] : '';
767 $p = ! empty($_POST['p']) ? (int) $_POST['p'] : 0;
768 $page_id = ! empty($_POST['page_id']) ? (int) $_POST['page_id'] : 0;
769 // Get Post Information
770 if($p > 0) {
771 $post_type = get_post_type($p);
772 $query_post = 'p='. $p . '&post_type=' . $post_type;
773 $id = $p;
774 } else {
775 $query_post = 'page_id='.$page_id;
776 $id = $page_id;
777 }
778 query_posts($query_post);
779 if(have_posts()) {
780 while(have_posts()) {
781 the_post();
782 $post_title = email_get_title();
783 $post_author = get_the_author();
784 $post_date = get_the_time(get_option('date_format').' ('.get_option('time_format').')', '', '', false);
785 $post_category = email_category(__(',', 'wp-email').' ');
786 $post_category_alt = strip_tags($post_category);
787 $post_excerpt = get_the_excerpt();
788 $post_content = email_content();
789 $post_content_alt = email_content_alt();
790 }
791 }
792 // Error
793 $error = '';
794 $error_field = array('yourname' => $yourname, 'youremail' => $youremail, 'yourremarks' => $yourremarks, 'friendname' => $friendname, 'friendemail' => $friendemail, 'id' => $id);
795 // Get Options
796 $email_fields = get_option('email_fields');
797 $email_image_verify = (int) get_option('email_imageverify');
798 // Multiple Names/Emails
799 $friends = array();
800 $friendname_count = 0;
801 $friendemail_count = 0;
802 $multiple_names = preg_split('/,|;/', $friendname);
803 $multiple_emails = preg_split('/,|;/', $friendemail);
804 $multiple_max = (int) get_option('email_multiple');
805 if($multiple_max === 0) { $multiple_max = 1; }
806 // Checking Your Name Field For Errors
807 if((int) $email_fields['yourname'] === 1) {
808 if(empty($yourname)) {
809 $error .= '<br /><strong>&raquo;</strong> '.__('Your Name is empty', 'wp-email');
810 }
811 if(!is_valid_name($yourname)) {
812 $error .= '<br /><strong>&raquo;</strong> '.__('Your Name is invalid', 'wp-email');
813 }
814 }
815 // Checking Your E-Mail Field For Errors
816 if((int) $email_fields['youremail'] === 1) {
817 if(empty($youremail)) {
818 $error .= '<br /><strong>&raquo;</strong> '.__('Your Email is empty', 'wp-email');
819 }
820 if(!is_valid_email($youremail)) {
821 $error .= '<br /><strong>&raquo;</strong> '.__('Your Email is invalid', 'wp-email');
822 }
823 }
824 // Checking Your Remarks Field For Errors
825 if((int) $email_fields['yourremarks'] === 1) {
826 if(!is_valid_remarks($yourremarks)) {
827 $error .= '<br /><strong>&raquo;</strong> '.__('Your Remarks is invalid', 'wp-email');
828 }
829 }
830 // Checking Friend's Name Field For Errors
831 if((int) $email_fields['friendname'] === 1) {
832 if(empty($friendname)) {
833 $error .= '<br /><strong>&raquo;</strong> '.__('Friend Name(s) is empty', 'wp-email');
834 } else {
835 if($multiple_names) {
836 foreach($multiple_names as $multiple_name) {
837 $multiple_name = trim($multiple_name);
838 if(empty($multiple_name)) {
839 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Name is empty: %s', 'wp-email'), $multiple_name);
840 } elseif(!is_valid_name($multiple_name)) {
841 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Name is invalid: %s', 'wp-email'), $multiple_name);
842 } else {
843 $friends[$friendname_count]['name'] = $multiple_name;
844 $friendname_count++;
845 }
846 if($friendname_count > $multiple_max) {
847 break;
848 }
849 }
850 }
851 }
852 }
853 // Checking Friend's E-Mail Field For Errors
854 if(empty($friendemail)) {
855 $error .= '<br /><strong>&raquo;</strong> '.__('Friend Email(s) is empty', 'wp-email');
856 } else {
857 if($multiple_emails) {
858 foreach($multiple_emails as $multiple_email) {
859 $multiple_email = trim($multiple_email);
860 if(empty($multiple_email)) {
861 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Email is empty: %s', 'wp-email'), $multiple_email);
862 } elseif(!is_valid_email($multiple_email)) {
863 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Email is invalid: %s', 'wp-email'), $multiple_email);
864 } else {
865 $friends[$friendemail_count]['email'] = $multiple_email;
866 $friendemail_count++;
867 }
868 if($friendemail_count > $multiple_max) {
869 break;
870 }
871 }
872 }
873 }
874 // Checking If The Fields Exceed The Size Of Maximum Entries Allowed
875 if(count($friends) > $multiple_max) {
876 $error .= '<br /><strong>&raquo;</strong> '.sprintf(_n('Maximum %s Friend allowed', 'Maximum %s Friend(s) allowed', $multiple_max, 'wp-email'), number_format_i18n($multiple_max));
877 }
878 if((int) $email_fields['friendname'] === 1) {
879 if($friendname_count !== $friendemail_count) {
880 $error .= '<br /><strong>&raquo;</strong> '.__('Friend Name(s) count does not tally with Friend Email(s) count', 'wp-email');
881 }
882 }
883 // Check Whether We Enable Image Verification
884 if($email_image_verify) {
885 $imageverify = strtoupper($imageverify);
886 if(empty($imageverify)) {
887 $error .= '<br /><strong>&raquo;</strong> '.__('Image Verification is empty', 'wp-email');
888 } else {
889 if($_SESSION['email_verify'] !== md5($imageverify)) {
890 $error .= '<br /><strong>&raquo;</strong> '.__('Image Verification failed', 'wp-email');
891 }
892 }
893 }
894 // If There Is No Error, We Process The E-Mail
895 if(empty($error) && not_spamming()) {
896 // If Remarks Is Empty, Assign N/A
897 if(empty($yourremarks)) { $yourremarks = __('N/A', 'wp-email'); }
898 // Template For E-Mail Subject
899 $template_email_subject = stripslashes(get_option('email_template_subject'));
900 $template_email_subject = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_subject);
901 $template_email_subject = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_subject);
902 $template_email_subject = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_subject);
903 $template_email_subject = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_subject);
904 $template_email_subject = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_subject);
905 $template_email_subject = str_replace("%EMAIL_POST_CATEGORY%", $post_category_alt, $template_email_subject);
906 $template_email_subject = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_subject);
907 $template_email_subject = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_subject);
908 $template_email_subject = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_subject);
909 // Template For E-Mail Body
910 $template_email_body = stripslashes(get_option('email_template_body'));
911 $template_email_body = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_body);
912 $template_email_body = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_body);
913 $template_email_body = str_replace("%EMAIL_YOUR_REMARKS%", $yourremarks, $template_email_body);
914 $template_email_body = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_body);
915 $template_email_body = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_body);
916 $template_email_body = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_body);
917 $template_email_body = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_body);
918 $template_email_body = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_body);
919 $template_email_body = str_replace("%EMAIL_POST_CATEGORY%", $post_category, $template_email_body);
920 $template_email_body = str_replace("%EMAIL_POST_EXCERPT%", $post_excerpt, $template_email_body);
921 $template_email_body = str_replace("%EMAIL_POST_CONTENT%", $post_content, $template_email_body);
922 $template_email_body = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_body);
923 $template_email_body = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_body);
924 $template_email_body = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_body);
925 if( is_rtl() ) {
926 $template_email_body = "<div style=\"direction: rtl;\">$template_email_body</div>";
927 }
928 // Template For E-Mail Alternate Body
929 $template_email_bodyalt = stripslashes(get_option('email_template_bodyalt'));
930 $template_email_bodyalt = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_bodyalt);
931 $template_email_bodyalt = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_bodyalt);
932 $template_email_bodyalt = str_replace("%EMAIL_YOUR_REMARKS%", $yourremarks, $template_email_bodyalt);
933 $template_email_bodyalt = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_bodyalt);
934 $template_email_bodyalt = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_bodyalt);
935 $template_email_bodyalt = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_bodyalt);
936 $template_email_bodyalt = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_bodyalt);
937 $template_email_bodyalt = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_bodyalt);
938 $template_email_bodyalt = str_replace("%EMAIL_POST_CATEGORY%", $post_category_alt, $template_email_bodyalt);
939 $template_email_bodyalt = str_replace("%EMAIL_POST_EXCERPT%", $post_excerpt, $template_email_bodyalt);
940 $template_email_bodyalt = str_replace("%EMAIL_POST_CONTENT%", $post_content_alt, $template_email_bodyalt);
941 $template_email_bodyalt = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_bodyalt);
942 $template_email_bodyalt = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_bodyalt);
943 $template_email_bodyalt = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_bodyalt);
944
945 $email_contenttype = get_option( 'email_contenttype' );
946 $email_charset = get_bloginfo( 'charset' );
947 $from = $yourname . ' <' . $youremail . '>';
948 $to = array();
949 foreach($friends as $friend) {
950 $to[] = $friend['name'] . ' <' . $friend['email'] . '>';
951 }
952 $subject = $template_email_subject;
953 $message = $email_contenttype === 'text/plain' ? $template_email_bodyalt : $template_email_body;
954 $headers = array(
955 'From: ' . $from,
956 'Content-Type: ' . $email_contenttype . '; charset=' . $email_charset,
957 );
958 $send_mail = wp_mail( implode( ', ', $to ), $subject, $message, $headers );
959
960 if( $send_mail ) {
961 $email_status = __('Success', 'wp-email');
962 // Template For Sent Successfully
963 $template_email_sentsuccess = stripslashes(get_option('email_template_sentsuccess'));
964 $template_email_sentsuccess = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_sentsuccess);
965 $template_email_sentsuccess = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_sentsuccess);
966 $template_email_sentsuccess = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_sentsuccess);
967 $template_email_sentsuccess = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_sentsuccess);
968 $template_email_sentsuccess = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_sentsuccess);
969 $template_email_sentsuccess = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_sentsuccess);
970 // If There Is Error Sending
971 } else {
972 if($yourremarks === __('N/A', 'wp-email')) { $yourremarks = ''; }
973 $email_status = __('Failed', 'wp-email');
974 // Template For Sent Failed
975 $template_email_sentfailed = stripslashes(get_option('email_template_sentfailed'));
976 $template_email_sentfailed = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_sentfailed);
977 $template_email_sentfailed = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_sentfailed);
978 $template_email_sentfailed = str_replace("%EMAIL_ERROR_MSG%", '', $template_email_sentfailed);
979 $template_email_sentfailed = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_sentfailed);
980 $template_email_sentfailed = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_sentfailed);
981 $template_email_sentfailed = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_sentfailed);
982 $template_email_sentfailed = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_sentfailed);
983 }
984 // Logging
985 $email_yourname = addslashes($yourname);
986 $email_youremail = addslashes($youremail);
987 $email_yourremarks = addslashes($yourremarks);
988 $email_postid = (int) get_the_id();
989 $email_posttitle = addslashes($post_title);
990 $email_timestamp = current_time('timestamp');
991 $email_ip = get_ipaddress();
992 $email_host = esc_attr(@gethostbyaddr($email_ip));
993 foreach($friends as $friend) {
994 $email_friendname = addslashes($friend['name']);
995 $email_friendemail = addslashes($friend['email']);
996 $wpdb->insert(
997 $wpdb->email,
998 array(
999 'email_yourname' => $email_yourname,
1000 'email_youremail' => $email_youremail,
1001 'email_yourremarks' => $email_yourremarks,
1002 'email_friendname' => $email_friendname,
1003 'email_friendemail' => $email_friendemail,
1004 'email_postid' => $email_postid,
1005 'email_posttitle' => $email_posttitle,
1006 'email_timestamp' => $email_timestamp,
1007 'email_ip' => $email_ip,
1008 'email_host' => $email_host,
1009 'email_status' => $email_status
1010 ),
1011 array(
1012 '%s',
1013 '%s',
1014 '%s',
1015 '%s',
1016 '%s',
1017 '%d',
1018 '%s',
1019 '%s',
1020 '%s',
1021 '%s',
1022 '%s'
1023 )
1024 );
1025 }
1026
1027 if($email_status === __('Success', 'wp-email')) {
1028 $output = $template_email_sentsuccess;
1029 } else {
1030 $output = $template_email_sentfailed;
1031 }
1032 echo $output;
1033 exit();
1034 // If There Are Errors
1035 } else {
1036 $error = substr($error, 21);
1037 $template_email_error = stripslashes(get_option('email_template_error'));
1038 $template_email_error = str_replace("%EMAIL_ERROR_MSG%", $error, $template_email_error);
1039 $template_email_error = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_error);
1040 $template_email_error = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_error);
1041 $template_email_error = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_error);
1042 $output = $template_email_error;
1043 $output .= email_form('', false, false, false, $error_field);
1044 echo $output;
1045 exit();
1046 } // End if(empty($error))
1047 } // End if(!empty($_POST['wp-email']))
1048 }
1049
1050
1051 ### Function: E-Mail Form
1052 function email_form($content, $echo = true, $subtitle = true, $div = true, $error_field = '') {
1053 global $wpdb, $multipage;
1054 // Variables
1055 $multipage = false;
1056 $post_title = email_get_title();
1057 $post_author = get_the_author();
1058 $post_date = get_the_time(get_option('date_format').' ('.get_option('time_format').')', '', '', false);
1059 $post_category = email_category(__(',', 'wp-email').' ');
1060 $post_category_alt = strip_tags($post_category);
1061 $email_fields = get_option('email_fields');
1062 $email_image_verify = (int) get_option('email_imageverify');
1063 $email_options = get_option('email_options');
1064 $email_type = (int) $email_options['email_type'];
1065 $error_field = apply_filters('email_form-fieldvalues', array());
1066 $output = '';
1067 // Template - Subtitle
1068 if($subtitle) {
1069 $template_subtitle = stripslashes(get_option('email_template_subtitle'));
1070 $template_subtitle = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_subtitle);
1071 $template_subtitle = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_subtitle);
1072 $template_subtitle = str_replace("%EMAIL_POST_DATE%", $post_date, $template_subtitle);
1073 $template_subtitle = str_replace("%EMAIL_POST_CATEGORY%", $post_category, $template_subtitle);
1074 $template_subtitle = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_subtitle);
1075 $template_subtitle = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_subtitle);
1076 $template_subtitle = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_subtitle);
1077 $output .= $template_subtitle;
1078 }
1079 // Display WP-EMail Form
1080 if($div) {
1081 $output .= '<div id="wp-email-content" class="wp-email">'."\n";
1082 }
1083 if (not_spamming()) {
1084 if(!post_password_required()) {
1085 if($email_type === 2){
1086 $output .= email_popup_form_header(false, (!empty($error_field['id']) ? $error_field['id'] : 0));
1087 } else {
1088 $output .= email_form_header(false, (!empty($error_field['id']) ? $error_field['id'] : 0));
1089 }
1090 $output .= '<p id="wp-email-required">'.__('* Required Field', 'wp-email').'</p>'."\n";
1091 if((int) $email_fields['yourname'] === 1) {
1092 $output .= '<p>'."\n";
1093 $output .= '<label for="yourname">'.__('Your Name: *', 'wp-email').'</label><br />'."\n";
1094 $output .= '<input type="text" size="50" id="yourname" name="yourname" class="TextField" value="' . ( ! empty( $error_field['yourname'] ) ? esc_attr( $error_field['yourname'] ) : '' ) . '" />'."\n";
1095 $output .= '</p>'."\n";
1096 }
1097 if((int) $email_fields['youremail'] === 1) {
1098 $output .= '<p>'."\n";
1099 $output .= '<label for="youremail">'.__('Your E-Mail: *', 'wp-email').'</label><br />'."\n";
1100 $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";
1101 $output .= '</p>'."\n";
1102 }
1103 if((int) $email_fields['yourremarks'] === 1) {
1104 $output .= '<p>'."\n";
1105 $output .= ' <label for="yourremarks">'.__('Your Remark:', 'wp-email').'</label><br />'."\n";
1106 $output .= ' <textarea cols="49" rows="8" id="yourremarks" name="yourremarks" class="Forms">';
1107 $val = email_get_remark();
1108 if ( !empty($error_field['yourremarks']) ) {
1109 $val = $error_field['yourremarks'];
1110 }
1111 if ( !empty($val) ) {
1112 $output .= esc_html($val);
1113 }
1114 $output .= '</textarea>'."\n";
1115 $output .= '</p>'."\n";
1116 }
1117 if((int) $email_fields['friendname'] === 1) {
1118 $output .= '<p>'."\n";
1119 $output .= '<label for="friendname">'.__('Friend\'s Name: *', 'wp-email').'</label><br />'."\n";
1120 $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";
1121 $output .= '</p>'."\n";
1122 }
1123 $output .= '<p>'."\n";
1124 $output .= '<label for="friendemail">'.__('Friend\'s E-Mail: *', 'wp-email').'</label><br />'."\n";
1125 $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";
1126 $output .= '</p>'."\n";
1127 if($email_image_verify) {
1128 $output .= '<p>'."\n";
1129 $output .= '<label for="imageverify">'.__('Image Verification: *', 'wp-email').'</label><br />'."\n";
1130 $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";
1131 $output .= '</p>'."\n";
1132 }
1133 $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";
1134 $output .= '</form>'."\n";
1135 } else {
1136 $output .= get_the_password_form();
1137 } // End if(!post_password_required())
1138 } else {
1139 $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";
1140 } // End if (not_spamming())
1141 $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";
1142 if($div) {
1143 $output .= '</div>'."\n";
1144 }
1145 email_removefilters();
1146 if($echo) {
1147 echo $output;
1148 } else {
1149 return $output;
1150 }
1151 }
1152
1153
1154 ### Function: Modify Default WordPress Listing To Make It Sorted By Most E-Mailed
1155 function email_fields($content) {
1156 global $wpdb;
1157 $content .= ", COUNT($wpdb->email.email_postid) AS email_total";
1158 return $content;
1159 }
1160 function email_join($content) {
1161 global $wpdb;
1162 $content .= " LEFT JOIN $wpdb->email ON $wpdb->email.email_postid = $wpdb->posts.ID";
1163 return $content;
1164 }
1165 function email_groupby($content) {
1166 global $wpdb;
1167 $content .= " $wpdb->email.email_postid";
1168 return $content;
1169 }
1170 function email_orderby($content) {
1171 $orderby = trim(addslashes($_GET['orderby']));
1172 if(empty($orderby) || ($orderby != 'asc' && $orderby != 'desc')) {
1173 $orderby = 'desc';
1174 }
1175
1176 return " email_total $orderby";
1177 }
1178
1179
1180 ### Process The Sorting
1181 /*
1182 if($_GET['sortby'] == 'email') {
1183 add_filter('posts_fields', 'email_fields');
1184 add_filter('posts_join', 'email_join');
1185 add_filter('posts_groupby', 'email_groupby');
1186 add_filter('posts_orderby', 'email_orderby');
1187 }
1188 */
1189
1190
1191 ### Function: Plug Into WP-Stats
1192 add_action( 'plugins_loaded','email_wp_stats' );
1193 function email_wp_stats() {
1194 add_filter( 'wp_stats_page_admin_plugins', 'email_page_admin_general_stats' );
1195 add_filter( 'wp_stats_page_admin_most', 'email_page_admin_most_stats' );
1196 add_filter( 'wp_stats_page_plugins', 'email_page_general_stats' );
1197 add_filter( 'wp_stats_page_most', 'email_page_most_stats' );
1198 }
1199
1200
1201 ### Function: Add WP-EMail General Stats To WP-Stats Page Options
1202 function email_page_admin_general_stats($content) {
1203 $stats_display = get_option('stats_display');
1204 if($stats_display['email'] === 1) {
1205 $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";
1206 } else {
1207 $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";
1208 }
1209 return $content;
1210 }
1211
1212
1213 ### Function: Add WP-EMail Top Most/Highest Stats To WP-Stats Page Options
1214 function email_page_admin_most_stats($content) {
1215 $stats_display = get_option('stats_display');
1216 $stats_mostlimit = (int) get_option('stats_mostlimit');
1217 if($stats_display['emailed_most_post'] === 1) {
1218 $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";
1219 } else {
1220 $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";
1221 }
1222 if($stats_display['emailed_most_page'] === 1) {
1223 $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";
1224 } else {
1225 $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";
1226 }
1227 return $content;
1228 }
1229
1230
1231 ### Function: Add WP-EMail General Stats To WP-Stats Page
1232 function email_page_general_stats($content) {
1233 global $wpdb;
1234 $stats_display = get_option('stats_display');
1235 $email_stats_array = array();
1236 $email_stats_array['total'] = 0;
1237 $email_stats_array[__('Success', 'wp-email')] = 0;
1238 $email_stats_array[__('Failed', 'wp-email')] = 0;
1239 if($stats_display['email'] === 1) {
1240 $email_stats = $wpdb->get_results("SELECT email_status, COUNT(email_id) AS email_total FROM $wpdb->email GROUP BY email_status");
1241 if($email_stats) {
1242 foreach($email_stats as $email_stat) {
1243 $email_stats_array[$email_stat->email_status] = (int) $email_stat->email_total;
1244 $email_stats_array['total'] += (int) $email_stat->email_total;
1245 }
1246 }
1247
1248 $content .= '<p><strong>'.__('WP-EMail', 'wp-email').'</strong></p>'."\n";
1249 $content .= '<ul>'."\n";
1250 $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";
1251 $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";
1252 $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";
1253 $content .= '</ul>'."\n";
1254 }
1255 return $content;
1256 }
1257
1258
1259 ### Function: Add WP-EMail Top Most/Highest Stats To WP-Stats Page
1260 function email_page_most_stats($content) {
1261 $stats_display = get_option('stats_display');
1262 $stats_mostlimit = (int) get_option('stats_mostlimit');
1263 if($stats_display['emailed_most_post'] === 1) {
1264 $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";
1265 $content .= '<ul>'."\n";
1266 $content .= get_mostemailed('post', $stats_mostlimit, 0, false);
1267 $content .= '</ul>'."\n";
1268 }
1269 if($stats_display['emailed_most_page'] === 1) {
1270 $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";
1271 $content .= '<ul>'."\n";
1272 $content .= get_mostemailed('page', $stats_mostlimit, 0, false);
1273 $content .= '</ul>'."\n";
1274 }
1275 return $content;
1276 }
1277
1278
1279 ### Class: WP-EMail Widget
1280 class WP_Widget_Email extends WP_Widget {
1281 // Constructor
1282 public function __construct() {
1283 $widget_ops = array('description' => __('WP-EMail emails statistics', 'wp-email'));
1284 parent::__construct('email', __('Email', 'wp-email'), $widget_ops);
1285 }
1286
1287 // Display Widget
1288 public function widget( $args, $instance ) {
1289 $title = isset( $instance['title'] ) ? apply_filters( 'widget_title', esc_attr( $instance['title'] ) ) : '';
1290 $type = isset( $instance['type'] ) ? esc_attr( $instance['type'] ) : '';
1291 $mode = isset( $instance['mode'] ) ? esc_attr( $instance['mode'] ) : '';
1292 $limit = isset( $instance['limit'] ) ? (int) $instance['limit'] : 10;
1293 $chars = isset( $instance['chars'] ) ? (int) $instance['chars'] : 200;
1294 echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title'];
1295 echo '<ul>'."\n";
1296 switch($type) {
1297 case 'most_emailed':
1298 get_mostemailed($mode, $limit, $chars);
1299 break;
1300 }
1301 echo '</ul>'."\n";
1302 echo $args['after_widget'];
1303 }
1304
1305 // When Widget Control Form Is Posted
1306 public function update( $new_instance, $old_instance ) {
1307 if ( ! isset( $new_instance['submit'] ) ) {
1308 return false;
1309 }
1310 $instance = $old_instance;
1311 $instance['title'] = isset( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
1312 $instance['type'] = isset( $new_instance['type'] ) ? strip_tags( $new_instance['type'] ) : '';
1313 $instance['mode'] = isset( $new_instance['mode'] ) ? strip_tags( $new_instance['mode'] ) : '';
1314 $instance['limit'] = isset( $new_instance['limit'] ) ? (int) $new_instance['limit'] : 10;
1315 $instance['chars'] = isset( $new_instance['chars'] ) ? (int) $new_instance['chars'] : 200;
1316 return $instance;
1317 }
1318
1319 // DIsplay Widget Control Form
1320 function form( $instance ) {
1321 $instance = wp_parse_args((array) $instance, array('title' => __('EMail', 'wp-email'), 'type' => 'most_emailed', 'mode' => 'both', 'limit' => 10, 'chars' => 200));
1322 $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
1323 $type = isset( $instance['type'] ) ? esc_attr( $instance['type'] ) : '';
1324 $mode = isset( $instance['mode'] ) ? esc_attr( $instance['mode'] ) : '';
1325 $limit = isset( $instance['limit'] ) ? (int) $instance['limit'] : 10;
1326 $chars = isset( $instance['chars'] ) ? (int) $instance['chars'] : 200;
1327 ?>
1328 <p>
1329 <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>
1330 </p>
1331 <p>
1332 <label for="<?php echo $this->get_field_id('type'); ?>"><?php _e('Statistics Type:', 'wp-email'); ?>
1333 <select name="<?php echo $this->get_field_name('type'); ?>" id="<?php echo $this->get_field_id('type'); ?>" class="widefat">
1334 <option value="most_emailed"<?php selected('most_emailed', $type); ?>><?php _e('Most Emailed', 'wp-email'); ?></option>
1335 </select>
1336 </label>
1337 </p>
1338 <p>
1339 <label for="<?php echo $this->get_field_id('mode'); ?>"><?php _e('Include Views From:', 'wp-email'); ?>
1340 <select name="<?php echo $this->get_field_name('mode'); ?>" id="<?php echo $this->get_field_id('mode'); ?>" class="widefat">
1341 <option value="both"<?php selected('both', $mode); ?>><?php _e('Posts &amp; Pages', 'wp-email'); ?></option>
1342 <option value="post"<?php selected('post', $mode); ?>><?php _e('Posts Only', 'wp-email'); ?></option>
1343 <option value="page"<?php selected('page', $mode); ?>><?php _e('Pages Only', 'wp-email'); ?></option>
1344 </select>
1345 </label>
1346 </p>
1347 <p>
1348 <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>
1349 </p>
1350 <p>
1351 <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 />
1352 <small><?php _e('<strong>0</strong> to disable.', 'wp-email'); ?></small>
1353 </p>
1354 <input type="hidden" id="<?php echo $this->get_field_id('submit'); ?>" name="<?php echo $this->get_field_name('submit'); ?>" value="1" />
1355 <?php
1356 }
1357 }
1358
1359
1360 ### Function: Init WP-EMail Widget
1361 add_action('widgets_init', 'widget_email_init');
1362 function widget_email_init() {
1363 email_textdomain();
1364 register_widget('WP_Widget_Email');
1365 }
1366
1367
1368 ### Function: Activate Plugin
1369 register_activation_hook( __FILE__, 'email_activation' );
1370 function email_activation( $network_wide ) {
1371 if ( is_multisite() && $network_wide ) {
1372 $ms_sites = function_exists( 'get_sites' ) ? get_sites() : wp_get_sites();
1373
1374 if( 0 < count( $ms_sites ) ) {
1375 foreach ( $ms_sites as $ms_site ) {
1376 $blog_id = class_exists( 'WP_Site' ) ? $ms_site->blog_id : $ms_site['blog_id'];
1377 switch_to_blog( $blog_id );
1378 email_activate();
1379 restore_current_blog();
1380 }
1381 }
1382 } else {
1383 email_activate();
1384 }
1385 }
1386
1387 function email_activate() {
1388 global $wpdb;
1389
1390 if(@is_file(ABSPATH.'/wp-admin/upgrade-functions.php')) {
1391 include_once ABSPATH.'/wp-admin/upgrade-functions.php';
1392 } elseif(@is_file(ABSPATH.'/wp-admin/includes/upgrade.php')) {
1393 include_once ABSPATH.'/wp-admin/includes/upgrade.php';
1394 } else {
1395 die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'');
1396 }
1397
1398 $charset_collate = '';
1399 if($wpdb->supports_collation()) {
1400 if(!empty($wpdb->charset)) {
1401 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
1402 }
1403 if(!empty($wpdb->collate)) {
1404 $charset_collate .= " COLLATE $wpdb->collate";
1405 }
1406 }
1407
1408 // Create E-Mail Table
1409 $create_table = "CREATE TABLE $wpdb->email (".
1410 "email_id int(10) NOT NULL auto_increment,".
1411 "email_yourname varchar(200) NOT NULL default '',".
1412 "email_youremail varchar(200) NOT NULL default '',".
1413 "email_yourremarks text NOT NULL,".
1414 "email_friendname varchar(200) NOT NULL default '',".
1415 "email_friendemail varchar(200) NOT NULL default '',".
1416 "email_postid int(10) NOT NULL default '0',".
1417 "email_posttitle text NOT NULL,".
1418 "email_timestamp varchar(20) NOT NULL default '',".
1419 "email_ip varchar(100) NOT NULL default '',".
1420 "email_host varchar(200) NOT NULL default '',".
1421 "email_status varchar(20) NOT NULL default '',".
1422 "PRIMARY KEY (email_id)) $charset_collate;";
1423 maybe_create_table($wpdb->email, $create_table);
1424
1425 // Add In Options
1426 add_option('email_contenttype', 'text/html');
1427 add_option('email_template_subject', __('Recommended Article By %EMAIL_YOUR_NAME%: %EMAIL_POST_TITLE%', 'wp-email'));
1428 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'));
1429 add_option('email_template_bodyalt', __('Hi %EMAIL_FRIEND_NAME%,'."\n".
1430 'Your friend, %EMAIL_YOUR_NAME%, has recommended this article entitled \'%EMAIL_POST_TITLE%\' to you.'."\n\n".
1431 'Here is his/her remarks:'."\n".
1432 '%EMAIL_YOUR_REMARKS%'."\n\n".
1433 '%EMAIL_POST_TITLE%'."\n".
1434 'Posted By %EMAIL_POST_AUTHOR% On %EMAIL_POST_DATE% In %EMAIL_POST_CATEGORY%'."\n".
1435 '%EMAIL_POST_CONTENT%'."\n".
1436 'Article taken from %EMAIL_BLOG_NAME% - %EMAIL_BLOG_URL%'."\n".
1437 'URL to article: %EMAIL_PERMALINK%', 'wp-email'));
1438 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'));
1439 add_option('email_template_sentfailed', '<p>'.__('An error has occurred when trying to send this email.', 'wp-email').'</p>');
1440 add_option('email_template_error', '<p>'.__('An error has occurred: ', 'wp-email').'<br /><strong>&raquo;</strong> %EMAIL_ERROR_MSG%</p>');
1441 add_option('email_interval', 10);
1442 add_option('email_snippet', 0);
1443 add_option('email_multiple', 5);
1444
1445 // Version 2.05 Options
1446 add_option('email_imageverify', 1);
1447
1448 // Version 2.10 Options
1449 $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>');
1450 add_option('email_options', $email_options);
1451 $email_fields = array('yourname' => 1, 'youremail' => 1, 'yourremarks' => 1, 'friendname' => 1, 'friendemail' => 1);
1452 add_option('email_fields', $email_fields);
1453
1454 // Version 2.11 Options
1455 add_option('email_template_title', __('E-Mail \'%EMAIL_POST_TITLE%\' To A Friend', 'wp-email'));
1456 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>');
1457
1458 // Version 2.68.0
1459 delete_option( 'email_smtp' );
1460 delete_option( 'email_mailer' );
1461
1462 // Set 'manage_email' Capabilities To Administrator
1463 $role = get_role('administrator');
1464 if(!$role->has_cap('manage_email')) {
1465 $role->add_cap('manage_email');
1466 }
1467
1468 // Flush Rewrite Rules
1469 flush_rewrite_rules();
1470 }
1471