Changeset 3753
- Timestamp:
- 07/29/2016 11:29:18 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php
r3664 r3753 132 132 $GLOBALS['comment'] = $comment; 133 133 $count = (int) DevHub_User_Contributed_Notes_Voting::count_votes( $comment->comment_ID, 'difference' ); 134 $comment_class = ( -1 > $count ) ? 'bad-note' : ''; 134 $curr_user_note = DevHub_User_Contributed_Notes_Voting::is_current_user_note( $comment->comment_ID ); 135 136 $comment_class = array(); 137 if ( -1 > $count ) { 138 $comment_class[] = 'bad-note'; 139 } 140 if ( $curr_user_note ) { 141 $comment_class[] = 'user-submitted-note'; 142 } 135 143 ?> 136 144 137 <li id="comment-<?php comment_ID(); ?>" <?php comment_class( $comment_class); ?>>145 <li id="comment-<?php comment_ID(); ?>" <?php comment_class( implode( ' ', $comment_class ) ); ?>> 138 146 <article id="div-comment-<?php comment_ID(); ?>" class="comment-body"> 139 147 <a href="#comment-content-<?php echo $comment->comment_ID; ?>" class="screen-reader-text"><?php _e( 'Skip to note content', 'wporg' ); ?></a> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content-voting.php
r3665 r3753 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 ); 204 } 205 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 if ( ! $comment_id ) { 214 global $comment; 215 $comment_id = $comment->comment_ID; 216 } 217 218 $note = get_comment( $comment_id ); 219 $user_id = get_current_user_id(); 220 221 if ( ! $note || ! $user_id ) { 222 return false; 223 } 224 225 if ( (int) $note->user_id === $user_id ) { 226 return true; 227 } 228 229 return false; 200 230 } 201 231 … … 264 294 265 295 $can_vote = self::user_can_vote( get_current_user_id(), $comment_id ); 296 $user_note = self::is_current_user_note( $comment_id ); 266 297 $logged_in = is_user_logged_in(); 267 298 $comment_link = get_comment_link( $comment_id ); … … 270 301 $log_in_str = __( 'You must log in to vote on the helpfulness of this note', 'wporg' ); 271 302 $log_in_url = add_query_arg( 'redirect_to', urlencode( $comment_link ), 'https://login.wordpress.org' ); 303 304 if ( ! $can_vote && $user_note ) { 305 $disabled_str = __( 'Voting for your own note is disabled', 'wporg' ); 306 } 272 307 273 308 echo '<div class="user-note-voting" data-nonce="' . esc_attr( $nonce ) . '">'; -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss
r3722 r3753 1483 1483 color: red; 1484 1484 } 1485 .user-submitted-note .dashicons { 1486 color: grey; 1487 } 1485 1488 1486 1489 .syntaxhighlighter { -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css
r3722 r3753 1818 1818 } 1819 1819 1820 .devhub-wrap .user-submitted-note .dashicons { 1821 color: grey; 1822 } 1823 1820 1824 .devhub-wrap .syntaxhighlighter { 1821 1825 /* These are !important due to use of !important in SyntaxHighlighter Evolved plugin. */
Note: See TracChangeset
for help on using the changeset viewer.