Ticket #1755: 1755.patch
File 1755.patch, 4.6 KB (added by , 8 years ago) |
---|
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php
131 131 function wporg_developer_user_note( $comment, $args, $depth ) { 132 132 $GLOBALS['comment'] = $comment; 133 133 $count = (int) DevHub_User_Contributed_Notes_Voting::count_votes( $comment->comment_ID, 'difference' ); 134 $curr_user_note = DevHub_User_Contributed_Notes_Voting::is_current_user_note( $comment->comment_ID ); 134 135 $comment_class = ( -1 > $count ) ? 'bad-note' : ''; 136 $comment_class .= $curr_user_note ? ' user-submitted-vote' : ''; 137 $comment_class = trim( $comment_class ); 135 138 ?> 136 139 137 140 <li id="comment-<?php comment_ID(); ?>" <?php comment_class( $comment_class ); ?>> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content-voting.php
194 194 // Comment, if provided, must be approved. 195 195 if ( $comment_id ) { 196 196 $can = ( '1' == get_comment( $comment_id )->comment_approved ); 197 // Users can't vote on their own comments. 198 if ( $can && self::is_current_user_note( $comment_id ) ) { 199 $can = false; 200 } 197 201 } 198 202 199 203 return apply_filters( 'devhub_user_can_vote', $can, $user_id, $comment_id ); 200 204 } 201 205 202 206 /** 207 * Determines if a note was submitted by the current user. 208 * 209 * @param int $comment_id The comment ID, or empty to use current comment. 210 * @return bool True if the note was submitted by the current user. 211 */ 212 public static function is_current_user_note( $comment_id = '' ) { 213 214 if ( ! $comment_id ) { 215 global $comment; 216 $comment_id = $comment->comment_ID; 217 } 218 219 $note = get_comment( $comment_id ); 220 $user_id = get_current_user_id(); 221 222 if ( ! $note || ! $user_id ) { 223 return false; 224 } 225 226 if ( (int) $note->user_id === $user_id ) { 227 return true; 228 } 229 230 return false; 231 } 232 233 /** 203 234 * Has user upvoted the comment? 204 235 * 205 236 * @access public … … 263 294 } 264 295 265 296 $can_vote = self::user_can_vote( get_current_user_id(), $comment_id ); 297 $user_note = self::is_current_user_note( $comment_id ); 266 298 $logged_in = is_user_logged_in(); 267 299 $comment_link = get_comment_link( $comment_id ); 268 300 $nonce = wp_create_nonce( 'user-note-vote-' . $comment_id ); … … 270 302 $log_in_str = __( 'You must log in to vote on the helpfulness of this note', 'wporg' ); 271 303 $log_in_url = add_query_arg( 'redirect_to', urlencode( $comment_link ), 'https://login.wordpress.org' ); 272 304 305 if ( !$can_vote && $user_note ) { 306 $disabled_str = __( 'Voting for your own note is disabled', 'wporg' ); 307 } 308 273 309 echo '<div class="user-note-voting" data-nonce="' . esc_attr( $nonce ) . '">'; 274 310 275 311 // Up vote link -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss
1478 1478 .user-voted.user-note-voting-down .dashicons { 1479 1479 color: red; 1480 1480 } 1481 .user-submitted-vote .dashicons { 1482 color: grey; 1483 } 1481 1484 1482 1485 .syntaxhighlighter { 1483 1486 /* These are !important due to use of !important in SyntaxHighlighter Evolved plugin. */ -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css
1568 1568 .devhub-wrap .user-voted.user-note-voting-down .dashicons { 1569 1569 color: red; 1570 1570 } 1571 .devhub-wrap .user-submitted-vote .dashicons { 1572 color: grey; 1573 } 1571 1574 .devhub-wrap .syntaxhighlighter { 1572 1575 /* These are !important due to use of !important in SyntaxHighlighter Evolved plugin. */ 1573 1576 max-width: 100% !important;