Skip to content
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

Revert "Display who was notified for an editorial comment" #472

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 1 addition & 44 deletions modules/editorial-comments/editorial-comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ function add_admin_scripts( ) {
return;

wp_enqueue_script( 'edit_flow-post_comment', $this->module_url . 'lib/editorial-comments.js', array( 'jquery','post' ), EDIT_FLOW_VERSION, true );
wp_localize_script( 'edit_flow-post_comment', '__ef_localize_post_comment', array(
'and' => esc_html__( 'and', 'edit-flow' ),
'none_notified' => esc_html__( 'No one will be notified.', 'edit-flow' ),
) );

wp_enqueue_style( 'edit-flow-editorial-comments-css', $this->module_url . 'lib/editorial-comments.css', false, EDIT_FLOW_VERSION, 'all' );

$thread_comments = (int) get_option('thread_comments');
Expand Down Expand Up @@ -202,12 +197,6 @@ function the_comment_form( ) {
<textarea id="ef-replycontent" name="replycontent" cols="40" rows="5"></textarea>
</div>

<?php if ( $this->module_enabled( 'notifications' ) ) : ?>
<label for="ef-reply-notifier"><?php esc_html_e( 'The following will be notified:', 'edit-flow' ); ?>
<input id="ef-reply-notifier" class="ef-reply-notifier-message" readonly>
</label>
<?php endif; ?>

<p id="ef-replysubmit">
<a class="ef-replysave button-primary alignright" href="#comments-form">
<span id="ef-replybtn"><?php _e('Submit Response', 'edit-flow') ?></span>
Expand All @@ -229,28 +218,6 @@ function the_comment_form( ) {
<?php
}

/**
* Maybe display who was notified underneath an editorial comment.
*
* @param int $comment_id
* @return void
*/
function maybe_output_comment_meta( $comment_id ) {
if ( ! $this->module_enabled( 'notifications' ) || ! apply_filters( 'ef_editorial_comments_show_notified_users', true ) ) {
return;
}

$notification = get_comment_meta( $comment_id, 'notification_list', true );

if ( empty( $notification ) ) {
$message = esc_html__( 'No users or groups were notified.', 'edit-flow' );
} else {
$message = '<strong>'. esc_html__( 'Notified', 'edit-flow' ) . ':</strong> ' . esc_html( $notification );
}

echo '<p class="ef-notification-meta">' . $message . '</p>';
}

/**
* Displays a single comment
*/
Expand Down Expand Up @@ -301,7 +268,6 @@ function the_comment($comment, $args, $depth) {
</h5>

<div class="comment-content"><?php comment_text(); ?></div>
<?php $this->maybe_output_comment_meta( $comment->comment_ID ); ?>
<p class="row-actions"><?php echo $actions_string; ?></p>

</div>
Expand All @@ -324,7 +290,7 @@ function ajax_insert_comment( ) {

// Set up comment data
$post_id = absint( $_POST['post_id'] );
$parent = absint( $_POST['parent'] );
$parent = absint( $_POST['parent'] );

// Only allow the comment if user can edit post
// @TODO: allow contributers to add comments as well (?)
Expand Down Expand Up @@ -366,15 +332,6 @@ function ajax_insert_comment( ) {
$comment_id = wp_insert_comment($data);
$comment = get_comment($comment_id);

// Save the list of notified users/usergroups.
if ( $this->module_enabled( 'notifications' ) && apply_filters( 'ef_editorial_comments_show_notified_users', true ) ) {
$notification = isset( $_POST['notification'] ) ? sanitize_text_field( $_POST['notification'] ) : '';

if ( ! empty( $notification ) && __( 'No one will be notified.', 'edit-flow' ) !== $notification ) {
add_comment_meta( $comment_id, 'notification_list', $notification );
}
}

// Register actions -- will be used to set up notifications and other modules can hook into this
if ( $comment_id )
do_action( 'ef_post_insert_editorial_comment', $comment );
Expand Down
35 changes: 2 additions & 33 deletions modules/editorial-comments/lib/editorial-comments.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,9 @@
border-bottom: 1px solid #e5e5e5;
background: #fff;
}

.row-actions {
margin-top: 0;
}

#ef-comments li:hover p.row-actions,
#ef-comments li:hover .ef-notification-meta {
#ef-comments li:hover p.row-actions {
visibility: visible;
}

#ef-comments li p.row-actions {
text-align: right;
}
Expand Down Expand Up @@ -118,28 +111,4 @@
#ef-comment-rbutton {
margin-top: 10px;
margin-bottom: 10px;
}

input[readonly].ef-reply-notifier-message {
height: 2em;
width: 100%;
padding: 0.5em;
border: none;
font-size: 1em;
border-left: 4px solid #46b450;
}

label[for="ef-reply-notifier"] {
margin: 0.75em 0;
display: block;
cursor: default;
}

input[readonly].ef-none-selected {
border-left: 4px solid #dc3232;
}

.ef-notification-meta {
margin-bottom: 0;
visibility: hidden;
}
}
45 changes: 1 addition & 44 deletions modules/editorial-comments/lib/editorial-comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ editorialCommentReply = {
// Bind click events to cancel and submit buttons
jQuery('a.ef-replycancel', row).click(function() { return editorialCommentReply.revert(); });
jQuery('a.ef-replysave', row).click(function() { return editorialCommentReply.send(); });

// Watch for changes to the subscribed users.
$( '#ef-post_following_box' ).on( 'following_list_updated', function() {
editorialCommentReply.notifiedMessage();
} );
},

revert : function() {
Expand Down Expand Up @@ -70,9 +65,6 @@ editorialCommentReply = {
}

jQuery('#ef-comment_respond').hide();

// Display who will be notified for this comment
this.notifiedMessage();

// Show reply textbox
jQuery('#ef-replyrow')
Expand Down Expand Up @@ -109,8 +101,7 @@ editorialCommentReply = {
post.parent = (jQuery("#ef-comment_parent").val()=='') ? 0 : jQuery("#ef-comment_parent").val();
post._nonce = jQuery("#ef_comment_nonce").val();
post.post_id = jQuery("#ef-post_id").val();
post.notification = jQuery('#ef-reply-notifier').val();


// Send the request
jQuery.ajax({
type : 'POST',
Expand All @@ -123,40 +114,6 @@ editorialCommentReply = {
return false;
},

/**
* Display who will be notified of the new comment.
*/
notifiedMessage : function() {
var message_wrapper = jQuery( '#ef-reply-notifier' );

if ( ! message_wrapper[0] ) {
return;
}

var subscribed_users = jQuery( '.ef-post_following_list li input:checkbox:checked' );

// No users will be notified, so return early with a default message.
if ( 0 === subscribed_users.length ) {
message_wrapper.addClass( 'ef-none-selected' );
message_wrapper.val( __ef_localize_post_comment.none_notified );
return;
}

var usernames = [];
subscribed_users.each( function() {
usernames.push( $( this ).next().text() );
} );

// Convert array of usernames into a sentence.
var message = usernames.pop();
if ( usernames.length > 0 ) {
message = usernames.join( ', ' ) + ' ' + __ef_localize_post_comment.and + ' ' + message + '.';
}

message_wrapper.removeClass( 'ef-none-selected' );
message_wrapper.val( message );
},

show : function(xml) {
var response, comment, supplemental, id, bg;

Expand Down
4 changes: 0 additions & 4 deletions modules/notifications/lib/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ jQuery(document).ready(function($) {
url : (ajaxurl) ? ajaxurl : wpListL10n.url,
data : params,
success : function(x) {

// This event is used to show an updated list of who will be notified of editorial comments and status updates.
$( '#ef-post_following_box' ).trigger( 'following_list_updated' );

var backgroundColor = parent_this.css( 'background-color' );
$(parent_this.parent().parent())
.animate( { 'backgroundColor':'#CCEEBB' }, 200 )
Expand Down