Ticket #1755: 1755.2.patch
File 1755.2.patch, 7.1 KB (added by , 9 years ago) |
---|
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content-voting.php
292 292 $comment_id = $comment->comment_ID; 293 293 } 294 294 295 $can_vote = self::user_can_vote( get_current_user_id(), $comment_id ); 296 $user_note = self::is_current_user_note( $comment_id ); 297 $logged_in = is_user_logged_in(); 298 $comment_link = get_comment_link( $comment_id ); 299 $nonce = wp_create_nonce( 'user-note-vote-' . $comment_id ); 300 $disabled_str = __( 'Voting for this note is disabled', 'wporg' ); 301 $log_in_str = __( 'You must log in to vote on the helpfulness of this note', 'wporg' ); 302 $log_in_url = add_query_arg( 'redirect_to', urlencode( $comment_link ), 'https://login.wordpress.org' ); 295 $can_vote = self::user_can_vote( get_current_user_id(), $comment_id ); 296 $user_upvoted = self::has_user_upvoted_comment( $comment_id ); 297 $user_downvoted = ( $user_upvoted ? false : self::has_user_downvoted_comment( $comment_id ) ); 298 $logged_in = is_user_logged_in(); 299 $comment_link = get_comment_link( $comment_id ); 300 $nonce = wp_create_nonce( 'user-note-vote-' . $comment_id ); 301 $disabled_str = __( 'Voting for this note is disabled', 'wporg' ); 302 $cancel_str = __( 'Click to cancel your vote.', 'wporg' ); 303 $log_in_str = __( 'You must log in to vote on the helpfulness of this note', 'wporg' ); 304 $log_in_url = add_query_arg( 'redirect_to', urlencode( $comment_link ), 'https://login.wordpress.org' ); 305 $class = ''; 303 306 304 if ( ! $can_vote && $user_note) {307 if ( ! $can_vote && self::is_current_user_note( $comment_id ) ) { 305 308 $disabled_str = __( 'Voting for your own note is disabled', 'wporg' ); 306 309 } 307 310 308 311 echo '<div class="user-note-voting" data-nonce="' . esc_attr( $nonce ) . '">'; 309 312 310 // Up vote link 311 $user_upvoted = self::has_user_upvoted_comment( $comment_id ); 312 if ( $can_vote ) { 313 $title = $user_upvoted ? 314 __( 'You have voted to indicate this note was helpful', 'wporg' ) : 315 __( 'Vote up if this note was helpful', 'wporg' ); 316 $tag = $user_upvoted ? 'span' : 'a'; 313 // Up vote 314 if ( $can_vote && !$user_downvoted ) { 315 // This user can vote. (user is logged in and it's not a note from the current user) 316 // And the user has not already downvoted this note. 317 $tag = 'a'; 318 319 if( $user_upvoted ) { 320 $title = __( 'You have voted to indicate this note was helpful.', 'wporg' ); 321 $title .= ' ' . $cancel_str; 322 } else { 323 $title = __( 'Vote up if this note was helpful', 'wporg' ); 324 } 317 325 } else { 318 $title = ! $logged_in ? $log_in_str : $disabled_str; 319 $tag = $logged_in ? 'span' : 'a'; 326 $tag = 'span'; 327 $class = ' vote-disabled'; 328 $title = $disabled_str; 329 330 // User has downvoted this note 331 if( $user_downvoted ) { 332 $title = __( "Voting up is disabled because you've already downvoted this note" , 'wporg' ); 333 } 334 335 // User is not logged in. Display log in link 336 if( ! $logged_in ) { 337 $tag = 'a'; 338 $class = ''; 339 $title = $log_in_str; 340 } 320 341 } 342 343 $class .= $user_upvoted ? ' user-voted' : ''; 344 321 345 echo "<{$tag} " 322 . 'class="user-note-voting-up' . ( $user_upvoted ? ' user-voted' : '' )346 . 'class="user-note-voting-up' . $class 323 347 . '" title="' . esc_attr( $title ) 324 348 . '" data-id="' . esc_attr( $comment_id ) 325 349 . '" data-vote="up'; … … 347 371 . self::count_votes( $comment_id, 'difference' ) 348 372 . '</span>'; 349 373 350 // Down vote link 351 $user_downvoted = ( $user_upvoted ? false : self::has_user_downvoted_comment( $comment_id ) ); 352 if ( $can_vote ) { 353 $title = $user_downvoted ? 354 __( 'You have voted to indicate this note was not helpful', 'wporg' ) : 355 __( 'Vote down if this note was not helpful', 'wporg' ); 356 $tag = $user_downvoted ? 'span' : 'a'; 374 // Down vote 375 $class = ''; 376 377 if ( $can_vote && !$user_upvoted) { 378 // This user can vote. (user is logged in and it's not a note from the current user) 379 // And the user has not already upvoted this note. 380 $tag = 'a'; 381 382 if( $user_downvoted ) { 383 $title = __( 'You have voted to indicate this note was not helpful.', 'wporg' ); 384 $title .= ' ' . $cancel_str; 385 } else { 386 $title = __( 'Vote down if this note was not helpful', 'wporg' ); 387 } 357 388 } else { 358 $title = ! $logged_in ? $log_in_str : $disabled_str; 359 $tag = $logged_in ? 'span' : 'a'; 389 $tag = 'span'; 390 $class = ' vote-disabled'; 391 $title = $disabled_str; 392 393 // User has upvoted this note 394 if( $user_upvoted ) { 395 $title = __( "Voting down is disabled because you've already upvoted this note" , 'wporg' ); 396 } 397 398 // User is not logged in. Display log in link 399 if( ! $logged_in ) { 400 $tag = 'a'; 401 $class = ''; 402 $title = $log_in_str; 403 } 360 404 } 405 406 $class .= $user_downvoted ? ' user-voted' : ''; 407 361 408 echo "<{$tag} " 362 . 'class="user-note-voting-down' . ( $user_downvoted ? ' user-voted' : '' )409 . 'class="user-note-voting-down' . $class 363 410 . '" title="' . esc_attr( $title ) 364 411 . '" data-id="' . esc_attr( $comment_id ) 365 412 . '" data-vote="down'; … … 485 532 // Get list of people who cast the same vote. 486 533 $add_to_list = get_comment_meta( $comment_id, $add_to, true ); 487 534 488 // Don't do anything if user isrecasting the same vote as before.535 // Remove user from list if recasting the same vote as before. 489 536 if ( in_array( $user_id, (array) $add_to_list ) ) { 490 return false; 537 unset( $add_to_list[ array_search( $user_id, $add_to_list ) ] ); 538 update_comment_meta( $comment_id, $add_to, $add_to_list ); 539 return true; 491 540 } 492 541 493 542 // If the user had previously cast the opposite vote, undo that older vote. -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss
1482 1482 .user-voted.user-note-voting-down .dashicons { 1483 1483 color: red; 1484 1484 } 1485 .user-submitted-note .dashicons { 1485 .user-submitted-note .dashicons, 1486 .vote-disabled .dashicons { 1486 1487 color: grey; 1487 1488 } 1488 1489 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css
1817 1817 color: red; 1818 1818 } 1819 1819 1820 .devhub-wrap .user-submitted-note .dashicons { 1820 .devhub-wrap .user-submitted-note .dashicons, 1821 .devhub-wrap .vote-disabled .dashicons { 1821 1822 color: grey; 1822 1823 } 1823 1824