12 |
12 |
13 /** This filter is documented in wp-admin/options.php */ |
13 /** This filter is documented in wp-admin/options.php */ |
14 if ( ! apply_filters( 'enable_post_by_email_configuration', true ) ) |
14 if ( ! apply_filters( 'enable_post_by_email_configuration', true ) ) |
15 wp_die( __( 'This action has been disabled by the administrator.' ) ); |
15 wp_die( __( 'This action has been disabled by the administrator.' ) ); |
16 |
16 |
17 /** Allow a plugin to do a complete takeover of Post by Email **/ |
17 /** |
18 do_action('wp-mail.php'); |
18 * Fires to allow a plugin to do a complete takeover of Post by Email. |
|
19 * |
|
20 * @since 2.9.0 |
|
21 */ |
|
22 do_action( 'wp-mail.php' ); |
19 |
23 |
20 /** Get the POP3 class with which to access the mailbox. */ |
24 /** Get the POP3 class with which to access the mailbox. */ |
21 require_once( ABSPATH . WPINC . '/class-pop3.php' ); |
25 require_once( ABSPATH . WPINC . '/class-pop3.php' ); |
22 |
26 |
23 /** Only check at this interval for new messages. */ |
27 /** Only check at this interval for new messages. */ |
62 $content_transfer_encoding = ''; |
66 $content_transfer_encoding = ''; |
63 $post_author = 1; |
67 $post_author = 1; |
64 $author_found = false; |
68 $author_found = false; |
65 $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); |
69 $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); |
66 foreach ($message as $line) { |
70 foreach ($message as $line) { |
67 // body signal |
71 // Body signal. |
68 if ( strlen($line) < 3 ) |
72 if ( strlen($line) < 3 ) |
69 $bodysignal = true; |
73 $bodysignal = true; |
70 if ( $bodysignal ) { |
74 if ( $bodysignal ) { |
71 $content .= $line; |
75 $content .= $line; |
72 } else { |
76 } else { |
102 } |
106 } |
103 $subject = explode($phone_delim, $subject); |
107 $subject = explode($phone_delim, $subject); |
104 $subject = $subject[0]; |
108 $subject = $subject[0]; |
105 } |
109 } |
106 |
110 |
107 // Set the author using the email address (From or Reply-To, the last used) |
111 /* |
108 // otherwise use the site admin |
112 * Set the author using the email address (From or Reply-To, the last used) |
|
113 * otherwise use the site admin. |
|
114 */ |
109 if ( ! $author_found && preg_match( '/^(From|Reply-To): /', $line ) ) { |
115 if ( ! $author_found && preg_match( '/^(From|Reply-To): /', $line ) ) { |
110 if ( preg_match('|[a-z0-9_.-]+@[a-z0-9_.-]+(?!.*<)|i', $line, $matches) ) |
116 if ( preg_match('|[a-z0-9_.-]+@[a-z0-9_.-]+(?!.*<)|i', $line, $matches) ) |
111 $author = $matches[0]; |
117 $author = $matches[0]; |
112 else |
118 else |
113 $author = trim($line); |
119 $author = trim($line); |
165 $subject = trim($subject); |
171 $subject = trim($subject); |
166 |
172 |
167 if ( $content_type == 'multipart/alternative' ) { |
173 if ( $content_type == 'multipart/alternative' ) { |
168 $content = explode('--'.$boundary, $content); |
174 $content = explode('--'.$boundary, $content); |
169 $content = $content[2]; |
175 $content = $content[2]; |
170 // match case-insensitive content-transfer-encoding |
176 |
|
177 // Match case-insensitive content-transfer-encoding. |
171 if ( preg_match( '/Content-Transfer-Encoding: quoted-printable/i', $content, $delim) ) { |
178 if ( preg_match( '/Content-Transfer-Encoding: quoted-printable/i', $content, $delim) ) { |
172 $content = explode($delim[0], $content); |
179 $content = explode($delim[0], $content); |
173 $content = $content[1]; |
180 $content = $content[1]; |
174 } |
181 } |
175 $content = strip_tags($content, '<img><p><br><i><b><u><em><strong><strike><font><span><div>'); |
182 $content = strip_tags($content, '<img><p><br><i><b><u><em><strong><strike><font><span><div>'); |
176 } |
183 } |
177 $content = trim($content); |
184 $content = trim($content); |
178 |
185 |
179 //Give Post-By-Email extending plugins full access to the content |
186 /** |
180 //Either the raw content or the content of the last quoted-printable section |
187 * Filter the original content of the email. |
181 $content = apply_filters('wp_mail_original_content', $content); |
188 * |
|
189 * Give Post-By-Email extending plugins full access to the content, either |
|
190 * the raw content, or the content of the last quoted-printable section. |
|
191 * |
|
192 * @since 2.8.0 |
|
193 * |
|
194 * @param string $content The original email content. |
|
195 */ |
|
196 $content = apply_filters( 'wp_mail_original_content', $content ); |
182 |
197 |
183 if ( false !== stripos($content_transfer_encoding, "quoted-printable") ) { |
198 if ( false !== stripos($content_transfer_encoding, "quoted-printable") ) { |
184 $content = quoted_printable_decode($content); |
199 $content = quoted_printable_decode($content); |
185 } |
200 } |
186 |
201 |
192 $content = explode($phone_delim, $content); |
207 $content = explode($phone_delim, $content); |
193 $content = empty( $content[1] ) ? $content[0] : $content[1]; |
208 $content = empty( $content[1] ) ? $content[0] : $content[1]; |
194 |
209 |
195 $content = trim($content); |
210 $content = trim($content); |
196 |
211 |
197 $post_content = apply_filters('phone_content', $content); |
212 /** |
|
213 * Filter the content of the post submitted by email before saving. |
|
214 * |
|
215 * @since 1.2.0 |
|
216 * |
|
217 * @param string $content The email content. |
|
218 */ |
|
219 $post_content = apply_filters( 'phone_content', $content ); |
198 |
220 |
199 $post_title = xmlrpc_getposttitle($content); |
221 $post_title = xmlrpc_getposttitle($content); |
200 |
222 |
201 if ($post_title == '') $post_title = $subject; |
223 if ($post_title == '') $post_title = $subject; |
202 |
224 |
211 |
233 |
212 // We couldn't post, for whatever reason. Better move forward to the next email. |
234 // We couldn't post, for whatever reason. Better move forward to the next email. |
213 if ( empty( $post_ID ) ) |
235 if ( empty( $post_ID ) ) |
214 continue; |
236 continue; |
215 |
237 |
216 do_action('publish_phone', $post_ID); |
238 /** |
|
239 * Fires after a post submitted by email is published. |
|
240 * |
|
241 * @since 1.2.0 |
|
242 * |
|
243 * @param int $post_ID The post ID. |
|
244 */ |
|
245 do_action( 'publish_phone', $post_ID ); |
217 |
246 |
218 echo "\n<p>" . sprintf(__('<strong>Author:</strong> %s'), esc_html($post_author)) . '</p>'; |
247 echo "\n<p>" . sprintf(__('<strong>Author:</strong> %s'), esc_html($post_author)) . '</p>'; |
219 echo "\n<p>" . sprintf(__('<strong>Posted title:</strong> %s'), esc_html($post_title)) . '</p>'; |
248 echo "\n<p>" . sprintf(__('<strong>Posted title:</strong> %s'), esc_html($post_title)) . '</p>'; |
220 |
249 |
221 if(!$pop3->delete($i)) { |
250 if(!$pop3->delete($i)) { |