-
Notifications
You must be signed in to change notification settings - Fork 800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments: Moderation Emails Overrides #8144
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this be activated for all Jetpack users? Should we check if Jetpack is connected to WordPress.com before to make those changes?
Should we check if the user has linked their account to WordPress.com? Indeed, it could be that the site is connected to WordPress.com, but the post author has not linked their account to WordPress.com, and thus is not able to access the site in WordPress.com.
moderation-emails-override.php
Outdated
* @param array $emails An array of email addresses to receive a comment notification. | ||
* @param int $comment_id The comment ID. | ||
*/ | ||
$emails = apply_filters( 'comment_notification_recipients', $emails, $comment->comment_ID ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since those are core hooks, you do not need to include the whole docblock. Something like this would do the trick:
/** This filter is documented in core/src/wp-includes/pluggable.php */
moderation-emails-override.php
Outdated
* Default false. | ||
* @param int $comment_id The comment ID. | ||
*/ | ||
$notify_author = apply_filters( 'comment_notification_notify_author', false, $comment->comment_ID ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
moderation-emails-override.php
Outdated
* @param string $notify_message The comment notification email text. | ||
* @param int $comment_id Comment ID. | ||
*/ | ||
$notify_message = apply_filters( 'comment_notification_text', $notify_message, $comment->comment_ID ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
moderation-emails-override.php
Outdated
* @param string $subject The comment notification email subject. | ||
* @param int $comment_id Comment ID. | ||
*/ | ||
$subject = apply_filters( 'comment_notification_subject', $subject, $comment->comment_ID ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
moderation-emails-override.php
Outdated
* @param string $message_headers Headers for the comment notification email. | ||
* @param int $comment_id Comment ID. | ||
*/ | ||
$message_headers = apply_filters( 'comment_notification_headers', $message_headers, $comment->comment_ID ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
78aa2e1
to
b22555c
Compare
Works great! Can we somehow make sure that we don't clobber an existing user's own versions of these pluggable functions? If one exists already in a plugin, it should get to be active, regardless of loading sequences. |
@jeherve I've added a few checks so that it only works when Jetpack is connected and when all the users to be notified are connected to WordPress.com. |
we already check with |
My thought at the time was to hook the check and the require to something quite late, something after which a plugin would normally hook itself, like |
87dea84
to
0876f11
Compare
Do folks recall if |
class.jetpack.php
Outdated
@@ -640,6 +640,10 @@ private function __construct() { | |||
// We should make sure to only do this for front end links. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should update this comment
@rodrigoi which version would you like to target? 5.7 has a code freeze on the 26th and releases on Jan 2nd. Stick with 5.7 or move to 5.8? |
This one was testing pretty well for me. @jeherve Would it be possible for folks to take another look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple of comments regarding coding standards. There seems to be a lot more places where proper spacing is missing, but I didn't want to leave too many comments. This could benefit from another pass to correct them before merging.
Otherwise this looks fine to me.
moderation-emails-override.php
Outdated
@@ -0,0 +1,328 @@ | |||
<?php | |||
|
|||
if ( ! function_exists('wp_notify_postauthor') && Jetpack::is_active() ) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing spaces before/after parens.
moderation-emails-override.php
Outdated
|
||
$switched_locale = switch_to_locale( get_locale() ); | ||
|
||
$comment_author_domain = @gethostbyaddr($comment->comment_author_IP); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing spaces here too.
moderation-emails-override.php
Outdated
|
||
// The blogname option is escaped with esc_html on the way into the database in sanitize_option | ||
// we want to reverse this for the plain text arena of emails. | ||
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More spaces. :)
If this is referring to front end facing setting, afaik it's still not available.
Apart from what @kwight already suggested, I don't think there is much we can do. There is an option for checking for conflicting plugins in addition to |
I'm punting this PR for the Jetpack 5.8 release for the following reasons.
|
I'm sorry @rodrigoi . Forgot to reply , but there was no beta-2 (nor people around to help re-test :P ) |
@oskosk no problem. @Automattic/jetpack Any chance we can get this merged? Whos commandeering the |
5e34e12
to
cebf37b
Compare
@rodrigoi Sorry. I totally missed the first ping. There wasn't any beta-2 anyways. We'll get this in for 5.8 don't worry. |
cebf37b
to
de3dc76
Compare
@oskosk any chance we can get this merged? |
… links to WordPress.com
… and if all emails have WordPress.com accounts
…calypso_redirect option is set
de3dc76
to
f0fd596
Compare
4c62f15
to
fc70e8c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the code, it works fine, except I fixed indentation and moved the override file to the library folder.
One thing I noticed though: the connected users that we send emails to are checked by their email. But it can happen that a user uses one email on their Jetpack site, and another email on WordPress.com. I think the next step for this would be to actually check the user, not the email.
thanks @zinigor!! I've run the code thru phpcs/phpbfs to fix the formatting, so I'll triple check next time. Using the email is intentional. We don't want to send inaccessible WP.com links to a non WP.com linked email address. If the target email is Jetpack only, we want the users to go to |
What I mean is that an email mismatch doesn't mean that the user is not connected to WordPress.com. There can be legitimate cases when a user is logged in to WordPress.com, has connected their Jetpack user, and will have no problems accessing Calypso links, but the emails don't match. |
@zinigor I'll set up a test case for that scenario as soon as possible, but I'd like to keep it on a new PR because this has been open for a long time 😄 |
* Changelog 5.8: create base for changelog. * Update 5.8 release post link * fix 5.8 release date * Updates to plugin description * Changelog: add #8499 * Changelog: add #8506 * Changelog: add #8509 * Changelog: add #8516 * Changelog: add #8517 * Changelog: add #8523 * Changelog: add #8547 * Changelog: add #8496 * Changelog: add #8584 * Changelog: add #8595 * Changelog: add #8445 * Changelog: add #8431 * Changelog: add #8284 * Changelog: add #8270 * Changelog: add #8124 * Changelog: add #8581 * Changelog: add #8463 * Changelog: add #8568 (#8646) * Updates to testing list and changelog * Changelog: add #8443 * Changelog: add #8459 * Changelog: add #8469 * Changelog: add #8464 * Changelog: add #8478 and #8479 * Changelog: add #8483 * Changelog: add #8488 * Changelog: add #8513 * Changelog: add #8555 * Changelog: add #8565 * Changelog: add #8601 * Changelog: add #8612 * Changelog: add first pass at Search items. * Changelog: add more info to help test Search. * Changelog: add #8144 * Changelog: add #8313 * Changelog: add #8419 * Changelog: add #8465 * Changelog: add #8515 * Changelog: add #8587 * Changelog: add #8591 * Changelog: add #8659 * Changelog: add #8661 * Changelog: add #8671 * Changelog: add 5.7.1 to archived changelog too. * Reverted changes to readme, removed entry about backups.
Related:
Automattic/wp-calypso#19110
Automattic/wp-calypso#17949
Depends on:
Automattic/wp-calypso#19635
Changes proposed in this Pull Request:
wp_notify_postauthor
andwp_notify_moderator
to point the user to WordPress.compluggable.php
on Corev4.8.3
and only the moderation links have been modified.Testing instructions:
Enable
edit_links_calypso_redirect
option by addingtrue
to this line:To test moderation
To test notifications