-
Notifications
You must be signed in to change notification settings - Fork 383
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
#936 - comment confirmation message #1020
Conversation
initially we were going to use an alternate success message if the user has had an accepted comment before, however this is more complex to do since you need to check etc. |
@westonruter this is ready for review now. I'm unsure of the approach. I think it's ok, but a second opinion will be good. |
@DavidCramer I think there may be a better way. We actually can determine if the comment was approved via in the add_filter( 'comment_post_redirect', function( $location, $comment ) {
wp_send_json( array(
'approved' => '1' === (string) $comment->comment_approved,
) );
}, PHP_INT_MAX, 2 ); Then inside of <div submit-success>
<template type="amp-mustache">
{{#approved}}
<?php esc_html_e( 'Your comment has been posted.', 'amp' ); ?>
{{/approved}}
{{^approved}}
<?php esc_html_e( 'Your comment is awaiting moderation.', 'default' ); ?>
{{/approved}}
</template>
</div> Note how it's re-using the default moderation string in core. I couldn't find a default message regarding a comment being accepted, however. |
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.
You may want to open a new PR to implement the alternative approach.
@DavidCramer on second thought, it may be better to return the message in the same way is being done for the die handler: add_filter( 'comment_post_redirect', function( $location, $comment ) {
if ( '1' === (string) $comment->comment_approved ) {
$message = __( 'Your comment has been approved.', 'amp' );
} else {
$message = __( 'Your comment is awaiting moderation.', 'default' );
}
$message = apply_filters( 'amp_comment_submitted_message', $message, $comment );
wp_send_json( array(
'message' => $message,
'approved' => $comment->comment_approved,
) );
}, PHP_INT_MAX, 2 ); Then inside of <div submit-success>
<template type="amp-mustache">
{{{message}}}
</template>
</div> This will allow for the message to be filtered and for plugins to add support for custom comment statuses. |
This adds a setting in the discussion page to allow for the changing of the success message when posting a comment.
Fixes #936