Add mechanism to report comment content modifications via sync#6929
Add mechanism to report comment content modifications via sync#6929
Conversation
… knows when comment was edited
…n comment contents is updated
Adding listener for wp_update_comment_data so I can compare old comment contents with new comment contents and conditionally invoke another action that the sync listener will listen for
…ync listeners are listening for
| $data, | ||
| $comment['comment_content'], | ||
| ); | ||
| do_action( 'modified_comment_contents', $action_args ); |
There was a problem hiding this comment.
Lets prefixs this with jetpack_ since it is something unique to jetpack.
There was a problem hiding this comment.
Do we need to pass in all this data? Can we just pass in the comment ID?
There was a problem hiding this comment.
Done! prefixed with 'jetpack' and passed before and after for content, author, author_email, and author_url if they changed.
| */ | ||
| public function handle_comment_contents_modification( $data, $comment ) { | ||
|
|
||
| if ( $data['comment_content'] != $comment['comment_content'] ) { |
There was a problem hiding this comment.
I think we should compare more then just the comment content, in the ui you can change the name, email and the website as well.
| * @param array $data The new, processed comment data. | ||
| * @param array $comment The old, unslashed comment data. | ||
| */ | ||
| public function handle_comment_contents_modification( $data, $comment ) { |
There was a problem hiding this comment.
$data is a very generic variable name. Can we make it more explicit $new_comment.
| public function test_modify_comment_contents() { | ||
|
|
||
| //Confirm that 'modify_comment' action is set after changing comment contents | ||
| $this->comment->comment_content = "foo bar baz"; |
There was a problem hiding this comment.
lets expand this to test also the changes to the name, email, website and content
…est author, author email, author url update
| $new_comment['comment_ID'], | ||
| $changes, | ||
| ); | ||
| do_action( 'jetpack_modified_comment_contents', $action_args ); |
There was a problem hiding this comment.
Lets document this do_action like we do others.
There was a problem hiding this comment.
Lets call the do action like this
do_action( 'jetpack_modified_comment_contents',$new_comment['comment_ID'], $changes );
This adds some a bit more consistency
| add_action( 'comment_approved_to_unapproved', $callable ); | ||
| add_action( 'comment_unapproved_to_approved', $callable ); | ||
| add_action( 'jetpack_modified_comment_contents', $callable ); | ||
|
|
There was a problem hiding this comment.
I had left the space to differentiate/set it apart it from the sync listener callbacks, but done!
| add_action( 'untrash_post_comments', $callable ); | ||
| add_action( 'comment_approved_to_unapproved', $callable ); | ||
| add_action( 'comment_unapproved_to_approved', $callable ); | ||
| add_action( 'jetpack_modified_comment_contents', $callable ); |
There was a problem hiding this comment.
add_action( 'jetpack_modified_comment_contents', $callable ); will need to be updated to
add_action( 'jetpack_modified_comment_contents', $callable, 10, 2 );
|
Great work! |
… 4.7 since it lacks wp_update_comment_data filter
* Changelog: initial commit for 4.9 release. * Changelog: add #6929 * Changelog: move old changelogs to changelog.txt * Readme: restore deleted release post link. The post is now live. * Changelog: add #6853 * Changelog: add #6856 * Changelog: add #6857 * Changelog: add #6884 * Changelog: add #6885 * Changelog: add #6892 * Changelog: add #6894 * Changelog: add #6898 * Changelog: add #6899 * Changelog: add #6900 * Changelog: add #6909 * Changelog: add #6927 * Changelog: add #6947 * Chagelog: add #6958 * Changelog: add #6961 * Changelog: add #6963 * Changelog: add #6965 * Changelog: add #6986 * Changelog: add #7000 * Changelog: add #7013 * Changelog: add #7015 * Changelog: add #7019 * Changelog: add #7028 * Changelog: add #6998 * Changelog: add #6999 * Changelog: add #7044 * Changelog: add #6881 * Changelog: add #6922 * Changelog: add #6940 * Changelog: add #6962 * Changelog: add #6942 * Changelog: add #6959 * Changelog: add #7018 * Changelog: add #6948 * Changelog: add #6657 * Changelog: add #7030 * Changelog: add #7048 * Changelog: add #7031 * Changelog: add #6990 * Changelog: add #6957 * Changelog: add #7027
Adds non-sync listener for comment update data, and fires action sync listener is listening for if the comment contents is modified
Changes proposed in this Pull Request:
Testing instructions:
Proposed changelog entry for your changes: