| 1 |
<?php |
| 2 |
/** |
| 3 |
* WP-EMail backwards compatibility shims. |
| 4 |
* |
| 5 |
* Before 3.0.0 the plugin defined a handful of helpers at global scope under |
| 6 |
* unprefixed names, each wrapped in function_exists() because wp-print and |
| 7 |
* wp-postratings define some of the same ones and whichever plugin loaded |
| 8 |
* first won. The logic now lives in the plugin's classes; these wrappers stay |
| 9 |
* so nothing that depended on that arrangement breaks. |
| 10 |
* |
| 11 |
* Still guarded, and for the same reason: a sibling plugin may already have |
| 12 |
* defined the name. |
| 13 |
* |
| 14 |
* @package WP-EMail |
| 15 |
*/ |
| 16 |
|
| 17 |
defined( 'ABSPATH' ) || exit; |
| 18 |
|
| 19 |
if ( ! function_exists( 'get_ipaddress' ) ) { |
| 20 |
/** |
| 21 |
* The visitor's IP address. |
| 22 |
* |
| 23 |
* @return string |
| 24 |
*/ |
| 25 |
function get_ipaddress() { |
| 26 |
return WP_Email_Form::ip_address(); |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
if ( ! function_exists( 'is_valid_name' ) ) { |
| 31 |
/** |
| 32 |
* Whether a string is acceptable as a person's name. |
| 33 |
* |
| 34 |
* @param string $name Candidate. |
| 35 |
* |
| 36 |
* @return bool |
| 37 |
*/ |
| 38 |
function is_valid_name( $name ) { |
| 39 |
return WP_Email_Form::is_valid_name( $name ); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
if ( ! function_exists( 'is_valid_email' ) ) { |
| 44 |
/** |
| 45 |
* Whether a string is an e-mail address. |
| 46 |
* |
| 47 |
* @param string $email Candidate. |
| 48 |
* |
| 49 |
* @return bool |
| 50 |
*/ |
| 51 |
function is_valid_email( $email ) { |
| 52 |
return WP_Email_Form::is_valid_email( $email ); |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
if ( ! function_exists( 'is_valid_remarks' ) ) { |
| 57 |
/** |
| 58 |
* Whether a string is free of mail-header injection attempts. |
| 59 |
* |
| 60 |
* @param string $content Candidate. |
| 61 |
* |
| 62 |
* @return bool |
| 63 |
*/ |
| 64 |
function is_valid_remarks( $content ) { |
| 65 |
return WP_Email_Form::is_valid_remarks( $content ); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
if ( ! function_exists( 'snippet_words' ) ) { |
| 70 |
/** |
| 71 |
* Trim text to a number of words. |
| 72 |
* |
| 73 |
* @param string $text Text to trim. |
| 74 |
* @param int $length Word count. |
| 75 |
* |
| 76 |
* @return string |
| 77 |
*/ |
| 78 |
function snippet_words( $text, $length = 0 ) { |
| 79 |
return WP_Email_Template::words( $text, $length ); |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
if ( ! function_exists( 'snippet_text' ) ) { |
| 84 |
/** |
| 85 |
* Trim text to a number of characters. |
| 86 |
* |
| 87 |
* @param string $text Text to trim. |
| 88 |
* @param int $length Character count. |
| 89 |
* |
| 90 |
* @return string |
| 91 |
*/ |
| 92 |
function snippet_text( $text, $length = 0 ) { |
| 93 |
return WP_Email_Template::characters( $text, $length ); |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* Handle a submitted e-mail form. |
| 99 |
* |
| 100 |
* The AJAX callback is registered as WP_Email_Form::process() now. This wrapper |
| 101 |
* only helps code that called the function directly -- anything doing |
| 102 |
* remove_action( 'wp_ajax_email', 'process_email_form' ) needs the |
| 103 |
* wp_email_template_redirect filter or its own unhook of the new callback. |
| 104 |
* |
| 105 |
* @return void |
| 106 |
*/ |
| 107 |
function process_email_form() { |
| 108 |
WP_Email_Form::process(); |
| 109 |
} |
| 110 |
|
| 111 |
/** |
| 112 |
* Add the filters that turn a post into the e-mail form. |
| 113 |
* |
| 114 |
* @param WP_Query|null $query Query being started, as loop_start passes it. |
| 115 |
* |
| 116 |
* @return void |
| 117 |
*/ |
| 118 |
function email_addfilters( $query = null ) { |
| 119 |
WP_Email::add_filters( $query ); |
| 120 |
} |
| 121 |
|
| 122 |
/** |
| 123 |
* Remove them again. |
| 124 |
* |
| 125 |
* @return void |
| 126 |
*/ |
| 127 |
function email_removefilters() { |
| 128 |
WP_Email::remove_filters(); |
| 129 |
} |
| 130 |
|
| 131 |
/** |
| 132 |
* Emit the noindex robots meta tag. |
| 133 |
* |
| 134 |
* @return void |
| 135 |
*/ |
| 136 |
function email_meta_nofollow() { |
| 137 |
WP_Email::noindex(); |
| 138 |
} |
| 139 |
|