1
|
|
|
<?php |
2
|
|
|
/** phpcs:disable Squiz.Commenting.FileComment.MissingPackageTag,Generic.Commenting.DocComment.MissingShort |
3
|
|
|
* |
4
|
|
|
* Declare two functions to handle notification emails to authors and moderators. |
5
|
|
|
* |
6
|
|
|
* These functions are hooked into filters to short circuit the regular flow and send the emails. |
7
|
|
|
* Code was copied from the original pluggable functions and slightly modified (modifications are commented). |
8
|
|
|
* |
9
|
|
|
* In the past, we used to overwrite the whole pluggable function, but we started using filters to avoid having |
10
|
|
|
* to check for Jetpack::is_active() too early in the load flow. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
use Automattic\Jetpack\Redirect; |
14
|
|
|
|
15
|
|
|
// phpcs:disable WordPress.WP.I18n.MissingArgDomain --reason: WP Core string. |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Short circuits the {@see `wp_notify_postauthor`} function via the `comment_notification_recipients` filter. |
19
|
|
|
* |
20
|
|
|
* Notify an author (and/or others) of a comment/trackback/pingback on a post. |
21
|
|
|
* |
22
|
|
|
* @since 5.8.0 |
23
|
|
|
* @since 9.3.0 Switched from pluggable function to filter callback |
24
|
|
|
* |
25
|
|
|
* @param array $emails List of recipients. |
26
|
|
|
* @param int|WP_Comment $comment_id Comment ID or WP_Comment object. |
27
|
|
|
* @return array Empty array to shortcircuit wp_notify_postauthor execution. $emails if we want to disable the filter. |
28
|
|
|
*/ |
29
|
|
|
function jetpack_notify_postauthor( $emails, $comment_id ) { |
30
|
|
|
// Don't do anything if Jetpack isn't active. |
31
|
|
|
if ( ! Jetpack::is_active() || empty( $emails ) ) { |
32
|
|
|
return $emails; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
// Original function modified: Code before the comment_notification_recipients filter removed. |
36
|
|
|
|
37
|
|
|
$comment = get_comment( $comment_id ); |
38
|
|
|
|
39
|
|
|
$post = get_post( $comment->comment_post_ID ); |
40
|
|
|
$author = get_userdata( $post->post_author ); |
41
|
|
|
|
42
|
|
|
// Facilitate unsetting below without knowing the keys. |
43
|
|
|
$emails = array_flip( $emails ); |
44
|
|
|
|
45
|
|
|
/** This filter is documented in core/src/wp-includes/pluggable.php */ |
46
|
|
|
$notify_author = apply_filters( 'comment_notification_notify_author', false, $comment->comment_ID ); |
|
|
|
|
47
|
|
|
|
48
|
|
|
// The comment was left by the author. |
49
|
|
|
if ( $author && ! $notify_author && $comment->user_id == $post->post_author ) { |
50
|
|
|
unset( $emails[ $author->user_email ] ); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
// The author moderated a comment on their own post. |
54
|
|
|
if ( $author && ! $notify_author && get_current_user_id() == $post->post_author ) { |
55
|
|
|
unset( $emails[ $author->user_email ] ); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
// The post author is no longer a member of the blog. |
59
|
|
|
if ( $author && ! $notify_author && ! user_can( $post->post_author, 'read_post', $post->ID ) ) { |
60
|
|
|
unset( $emails[ $author->user_email ] ); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
// If there's no email to send the comment to, bail, otherwise flip array back around for use below. |
64
|
|
|
if ( ! count( $emails ) ) { |
65
|
|
|
return array(); // Original function modified. Return empty array instead of false. |
66
|
|
|
} else { |
67
|
|
|
$emails = array_flip( $emails ); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
$switched_locale = switch_to_locale( get_locale() ); |
71
|
|
|
|
72
|
|
|
$comment_author_domain = ''; |
73
|
|
|
if ( WP_Http::is_ip_address( $comment->comment_author_IP ) ) { |
74
|
|
|
$comment_author_domain = gethostbyaddr( $comment->comment_author_IP ); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
// The blogname option is escaped with esc_html on the way into the database in sanitize_option |
78
|
|
|
// we want to reverse this for the plain text arena of emails. |
79
|
|
|
$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
80
|
|
|
$comment_content = wp_specialchars_decode( $comment->comment_content ); |
81
|
|
|
|
82
|
|
|
// Original function modified. |
83
|
|
|
$moderate_on_wpcom = ! in_array( false, array_map( 'jetpack_notify_is_user_connected_by_email', $emails ) ); |
84
|
|
|
|
85
|
|
|
switch ( $comment->comment_type ) { |
86
|
|
View Code Duplication |
case 'trackback': |
87
|
|
|
/* translators: 1: Post title */ |
88
|
|
|
$notify_message = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n"; |
89
|
|
|
/* translators: 1: Trackback/pingback website name, 2: website IP address, 3: website hostname */ |
90
|
|
|
$notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
91
|
|
|
/* translators: %s: Site URL */ |
92
|
|
|
$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; |
93
|
|
|
/* translators: %s: Comment Content */ |
94
|
|
|
$notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n"; |
95
|
|
|
$notify_message .= __( 'You can see all trackbacks on this post here:' ) . "\r\n"; |
96
|
|
|
/* translators: 1: blog name, 2: post title */ |
97
|
|
|
$subject = sprintf( __( '[%1$s] Trackback: "%2$s"' ), $blogname, $post->post_title ); |
98
|
|
|
break; |
99
|
|
View Code Duplication |
case 'pingback': |
100
|
|
|
/* translators: 1: Post title */ |
101
|
|
|
$notify_message = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n"; |
102
|
|
|
/* translators: 1: Trackback/pingback website name, 2: website IP address, 3: website hostname */ |
103
|
|
|
$notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
104
|
|
|
/* translators: %s: Site URL */ |
105
|
|
|
$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; |
106
|
|
|
/* translators: %s: Comment Content */ |
107
|
|
|
$notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n"; |
108
|
|
|
$notify_message .= __( 'You can see all pingbacks on this post here:' ) . "\r\n"; |
109
|
|
|
/* translators: 1: blog name, 2: post title */ |
110
|
|
|
$subject = sprintf( __( '[%1$s] Pingback: "%2$s"' ), $blogname, $post->post_title ); |
111
|
|
|
break; |
112
|
|
|
default: // Comments. |
113
|
|
|
/* translators: 1: Post title */ |
114
|
|
|
$notify_message = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n"; |
115
|
|
|
/* translators: 1: comment author, 2: comment author's IP address, 3: comment author's hostname */ |
116
|
|
|
$notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
117
|
|
|
/* translators: %s: Email address */ |
118
|
|
|
$notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n"; |
119
|
|
|
/* translators: %s: Site URL */ |
120
|
|
|
$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; |
121
|
|
|
/* translators: %s: Comment Content */ |
122
|
|
|
$notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n"; |
123
|
|
|
$notify_message .= __( 'You can see all comments on this post here:' ) . "\r\n"; |
124
|
|
|
/* translators: 1: blog name, 2: post title */ |
125
|
|
|
$subject = sprintf( __( '[%1$s] Comment: "%2$s"' ), $blogname, $post->post_title ); |
126
|
|
|
break; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
// Original function modified: Consider $moderate_on_wpcom when building $notify_message. |
130
|
|
|
$notify_message .= $moderate_on_wpcom |
131
|
|
|
? Redirect::get_url( |
132
|
|
|
'calypso-comments-all', |
133
|
|
|
array( |
134
|
|
|
'path' => $comment->comment_post_ID, |
135
|
|
|
) |
136
|
|
|
) . "/\r\n\r\n" |
137
|
|
|
: get_permalink( $comment->comment_post_ID ) . "#comments\r\n\r\n"; |
138
|
|
|
|
139
|
|
|
/* translators: %s: URL */ |
140
|
|
|
$notify_message .= sprintf( __( 'Permalink: %s' ), get_comment_link( $comment ) ) . "\r\n"; |
141
|
|
|
|
142
|
|
|
$base_wpcom_edit_comment_url = Redirect::get_url( |
143
|
|
|
'calypso-edit-comment', |
144
|
|
|
array( |
145
|
|
|
'path' => $comment_id, |
146
|
|
|
'query' => 'action=__action__', // __action__ will be replaced by the actual action. |
147
|
|
|
) |
148
|
|
|
); |
149
|
|
|
|
150
|
|
|
// Original function modified: Consider $moderate_on_wpcom when building $notify_message. |
151
|
|
|
if ( user_can( $post->post_author, 'edit_comment', $comment->comment_ID ) ) { |
152
|
|
View Code Duplication |
if ( EMPTY_TRASH_DAYS ) { |
153
|
|
|
$notify_message .= sprintf( |
154
|
|
|
/* translators: Placeholder is the edit URL */ |
155
|
|
|
__( 'Trash it: %s' ), |
156
|
|
|
$moderate_on_wpcom |
157
|
|
|
? str_replace( '__action__', 'trash', $base_wpcom_edit_comment_url ) |
158
|
|
|
: admin_url( "comment.php?action=trash&c={$comment->comment_ID}#wpbody-content" ) |
159
|
|
|
) . "\r\n"; |
160
|
|
|
} else { |
161
|
|
|
$notify_message .= sprintf( |
162
|
|
|
/* translators: Placeholder is the edit URL */ |
163
|
|
|
__( 'Delete it: %s' ), |
164
|
|
|
$moderate_on_wpcom |
165
|
|
|
? str_replace( '__action__', 'delete', $base_wpcom_edit_comment_url ) |
166
|
|
|
: admin_url( "comment.php?action=delete&c={$comment->comment_ID}#wpbody-content" ) |
167
|
|
|
) . "\r\n"; |
168
|
|
|
} |
169
|
|
|
$notify_message .= sprintf( |
170
|
|
|
/* translators: Placeholder is the edit URL */ |
171
|
|
|
__( 'Spam it: %s' ), |
172
|
|
|
$moderate_on_wpcom |
173
|
|
|
? str_replace( '__action__', 'spam', $base_wpcom_edit_comment_url ) |
174
|
|
|
: admin_url( "comment.php?action=spam&c={$comment->comment_ID}#wpbody-content" ) |
175
|
|
|
) . "\r\n"; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
$wp_email = 'wordpress@' . preg_replace( '#^www\.#', '', strtolower( $_SERVER['SERVER_NAME'] ) ); |
179
|
|
|
|
180
|
|
|
if ( '' == $comment->comment_author ) { |
181
|
|
|
$from = "From: \"$blogname\" <$wp_email>"; |
182
|
|
|
if ( '' != $comment->comment_author_email ) { |
183
|
|
|
$reply_to = "Reply-To: $comment->comment_author_email"; |
184
|
|
|
} |
185
|
|
|
} else { |
186
|
|
|
$from = "From: \"$comment->comment_author\" <$wp_email>"; |
187
|
|
|
if ( '' != $comment->comment_author_email ) { |
188
|
|
|
$reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>"; |
189
|
|
|
} |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
$message_headers = "$from\n" |
193
|
|
|
. 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n"; |
194
|
|
|
|
195
|
|
|
if ( isset( $reply_to ) ) { |
196
|
|
|
$message_headers .= $reply_to . "\n"; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** This filter is documented in core/src/wp-includes/pluggable.php */ |
200
|
|
|
$notify_message = apply_filters( 'comment_notification_text', $notify_message, $comment->comment_ID ); |
|
|
|
|
201
|
|
|
|
202
|
|
|
/** This filter is documented in core/src/wp-includes/pluggable.php */ |
203
|
|
|
$subject = apply_filters( 'comment_notification_subject', $subject, $comment->comment_ID ); |
|
|
|
|
204
|
|
|
|
205
|
|
|
/** This filter is documented in core/src/wp-includes/pluggable.php */ |
206
|
|
|
$message_headers = apply_filters( 'comment_notification_headers', $message_headers, $comment->comment_ID ); |
|
|
|
|
207
|
|
|
|
208
|
|
|
foreach ( $emails as $email ) { |
209
|
|
|
wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers ); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
if ( $switched_locale ) { |
213
|
|
|
restore_previous_locale(); |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
return array(); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* Short circuits the {@see `wp_notify_moderator`} function via the `notify_moderator` filter. |
221
|
|
|
* |
222
|
|
|
* Notifies the moderator of the site about a new comment that is awaiting approval. |
223
|
|
|
* |
224
|
|
|
* @since 5.8.0 |
225
|
|
|
* @since 9.2.0 Switched from pluggable function to filter callback |
226
|
|
|
* |
227
|
|
|
* @global wpdb $wpdb WordPress database abstraction object. |
228
|
|
|
* |
229
|
|
|
* @param string $notify_moderator The value of the moderation_notify option. |
230
|
|
|
* @param int $comment_id Comment ID. |
231
|
|
|
* @return boolean Returns false to shortcircuit the execution of wp_notify_moderator |
232
|
|
|
*/ |
233
|
|
|
function jetpack_notify_moderator( $notify_moderator, $comment_id ) { |
234
|
|
|
|
235
|
|
|
// If Jetpack is not active, or if Notify moderators options is not set, let the default flow go on. |
236
|
|
|
if ( ! $notify_moderator || ! Jetpack::is_active() ) { |
237
|
|
|
return $notify_moderator; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
// Original function modified: Removed code before the notify_moderator filter. |
241
|
|
|
|
242
|
|
|
global $wpdb; |
243
|
|
|
|
244
|
|
|
$comment = get_comment( $comment_id ); |
245
|
|
|
$post = get_post( $comment->comment_post_ID ); |
246
|
|
|
$user = get_userdata( $post->post_author ); |
247
|
|
|
// Send to the administration and to the post author if the author can modify the comment. |
248
|
|
|
$emails = array( get_option( 'admin_email' ) ); |
249
|
|
|
if ( $user && user_can( $user->ID, 'edit_comment', $comment_id ) && ! empty( $user->user_email ) ) { |
250
|
|
|
if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) ) { |
251
|
|
|
$emails[] = $user->user_email; |
252
|
|
|
} |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
$switched_locale = switch_to_locale( get_locale() ); |
256
|
|
|
|
257
|
|
|
$comment_author_domain = ''; |
258
|
|
|
if ( WP_Http::is_ip_address( $comment->comment_author_IP ) ) { |
259
|
|
|
$comment_author_domain = gethostbyaddr( $comment->comment_author_IP ); |
260
|
|
|
} |
261
|
|
|
$comments_waiting = $wpdb->get_var( "SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'" ); |
262
|
|
|
|
263
|
|
|
// The blogname option is escaped with esc_html on the way into the database in sanitize_option |
264
|
|
|
// we want to reverse this for the plain text arena of emails. |
265
|
|
|
$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
266
|
|
|
$comment_content = wp_specialchars_decode( $comment->comment_content ); |
267
|
|
|
|
268
|
|
|
switch ( $comment->comment_type ) { |
269
|
|
View Code Duplication |
case 'trackback': |
270
|
|
|
/* translators: 1: Post title */ |
271
|
|
|
$notify_message = sprintf( __( 'A new trackback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n"; |
272
|
|
|
$notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n"; |
273
|
|
|
/* translators: 1: Trackback/pingback website name, 2: website IP address, 3: website hostname */ |
274
|
|
|
$notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
275
|
|
|
/* translators: 1: Trackback/pingback/comment author URL */ |
276
|
|
|
$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; |
277
|
|
|
$notify_message .= __( 'Trackback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n"; |
278
|
|
|
break; |
279
|
|
View Code Duplication |
case 'pingback': |
280
|
|
|
/* translators: 1: Post title */ |
281
|
|
|
$notify_message = sprintf( __( 'A new pingback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n"; |
282
|
|
|
$notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n"; |
283
|
|
|
/* translators: 1: Trackback/pingback website name, 2: website IP address, 3: website hostname */ |
284
|
|
|
$notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
285
|
|
|
/* translators: 1: Trackback/pingback/comment author URL */ |
286
|
|
|
$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; |
287
|
|
|
$notify_message .= __( 'Pingback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n"; |
288
|
|
|
break; |
289
|
|
View Code Duplication |
default: // Comments. |
290
|
|
|
/* translators: 1: Post title */ |
291
|
|
|
$notify_message = sprintf( __( 'A new comment on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n"; |
292
|
|
|
$notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n"; |
293
|
|
|
/* translators: 1: Comment author name, 2: comment author's IP address, 3: comment author's hostname */ |
294
|
|
|
$notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
295
|
|
|
/* translators: 1: Comment author URL */ |
296
|
|
|
$notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n"; |
297
|
|
|
/* translators: 1: Trackback/pingback/comment author URL */ |
298
|
|
|
$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; |
299
|
|
|
/* translators: 1: Comment text */ |
300
|
|
|
$notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n"; |
301
|
|
|
break; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
/** This filter is documented in core/src/wp-includes/pluggable.php */ |
305
|
|
|
$emails = apply_filters( 'comment_moderation_recipients', $emails, $comment_id ); |
|
|
|
|
306
|
|
|
|
307
|
|
|
// Original function modified. |
308
|
|
|
$moderate_on_wpcom = ! in_array( false, array_map( 'jetpack_notify_is_user_connected_by_email', $emails ) ); |
309
|
|
|
|
310
|
|
|
$base_wpcom_edit_comment_url = Redirect::get_url( |
311
|
|
|
'calypso-edit-comment', |
312
|
|
|
array( |
313
|
|
|
'path' => $comment_id, |
314
|
|
|
'query' => 'action=__action__', // __action__ will be replaced by the actual action. |
315
|
|
|
) |
316
|
|
|
); |
317
|
|
|
|
318
|
|
|
// Original function modified: Consider $moderate_on_wpcom when building $notify_message. |
319
|
|
|
$notify_message .= sprintf( |
320
|
|
|
/* translators: Comment moderation. 1: Comment action URL */ |
321
|
|
|
__( 'Approve it: %s' ), |
322
|
|
|
$moderate_on_wpcom |
323
|
|
|
? str_replace( '__action__', 'approve', $base_wpcom_edit_comment_url ) |
324
|
|
|
: admin_url( "comment.php?action=approve&c={$comment_id}#wpbody-content" ) |
325
|
|
|
) . "\r\n"; |
326
|
|
|
|
327
|
|
View Code Duplication |
if ( EMPTY_TRASH_DAYS ) { |
328
|
|
|
$notify_message .= sprintf( |
329
|
|
|
/* translators: Comment moderation. 1: Comment action URL */ |
330
|
|
|
__( 'Trash it: %s' ), |
331
|
|
|
$moderate_on_wpcom |
332
|
|
|
? str_replace( '__action__', 'trash', $base_wpcom_edit_comment_url ) |
333
|
|
|
: admin_url( "comment.php?action=trash&c={$comment_id}#wpbody-content" ) |
334
|
|
|
) . "\r\n"; |
335
|
|
|
} else { |
336
|
|
|
$notify_message .= sprintf( |
337
|
|
|
/* translators: Comment moderation. 1: Comment action URL */ |
338
|
|
|
__( 'Delete it: %s' ), |
339
|
|
|
$moderate_on_wpcom |
340
|
|
|
? str_replace( '__action__', 'delete', $base_wpcom_edit_comment_url ) |
341
|
|
|
: admin_url( "comment.php?action=delete&c={$comment_id}#wpbody-content" ) |
342
|
|
|
) . "\r\n"; |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
$notify_message .= sprintf( |
346
|
|
|
/* translators: Comment moderation. 1: Comment action URL */ |
347
|
|
|
__( 'Spam it: %s' ), |
348
|
|
|
$moderate_on_wpcom |
349
|
|
|
? str_replace( '__action__', 'spam', $base_wpcom_edit_comment_url ) |
350
|
|
|
: admin_url( "comment.php?action=spam&c={$comment_id}#wpbody-content" ) |
351
|
|
|
) . "\r\n"; |
352
|
|
|
|
353
|
|
|
$notify_message .= sprintf( |
354
|
|
|
/* translators: Comment moderation. 1: Number of comments awaiting approval */ |
355
|
|
|
_n( |
356
|
|
|
'Currently %s comment is waiting for approval. Please visit the moderation panel:', |
357
|
|
|
'Currently %s comments are waiting for approval. Please visit the moderation panel:', |
358
|
|
|
$comments_waiting |
359
|
|
|
), |
360
|
|
|
number_format_i18n( $comments_waiting ) |
361
|
|
|
) . "\r\n"; |
362
|
|
|
|
363
|
|
|
$notify_message .= $moderate_on_wpcom |
364
|
|
|
? Redirect::get_url( 'calypso-comments-pending' ) |
365
|
|
|
: admin_url( 'edit-comments.php?comment_status=moderated#wpbody-content' ) . "\r\n"; |
366
|
|
|
|
367
|
|
|
/* translators: Comment moderation notification email subject. 1: Site name, 2: Post title */ |
368
|
|
|
$subject = sprintf( __( '[%1$s] Please moderate: "%2$s"' ), $blogname, $post->post_title ); |
369
|
|
|
$message_headers = ''; |
370
|
|
|
|
371
|
|
|
/** This filter is documented in core/src/wp-includes/pluggable.php */ |
372
|
|
|
$notify_message = apply_filters( 'comment_moderation_text', $notify_message, $comment_id ); |
|
|
|
|
373
|
|
|
|
374
|
|
|
/** This filter is documented in core/src/wp-includes/pluggable.php */ |
375
|
|
|
$subject = apply_filters( 'comment_moderation_subject', $subject, $comment_id ); |
|
|
|
|
376
|
|
|
|
377
|
|
|
/** This filter is documented in core/src/wp-includes/pluggable.php */ |
378
|
|
|
$message_headers = apply_filters( 'comment_moderation_headers', $message_headers, $comment_id ); |
|
|
|
|
379
|
|
|
|
380
|
|
|
foreach ( $emails as $email ) { |
381
|
|
|
wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers ); |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
if ( $switched_locale ) { |
385
|
|
|
restore_previous_locale(); |
386
|
|
|
} |
387
|
|
|
|
388
|
|
|
return false; |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
/** |
392
|
|
|
* Gets an user by email and verify if it's connected |
393
|
|
|
* |
394
|
|
|
* @param string $email The user email. |
395
|
|
|
* @return boolean |
396
|
|
|
*/ |
397
|
|
|
function jetpack_notify_is_user_connected_by_email( $email ) { |
398
|
|
|
$user = get_user_by( 'email', $email ); |
399
|
|
|
return Jetpack::is_user_connected( $user->ID ); |
400
|
|
|
} |
401
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.