Changeset 33891 for trunk/src/wp-includes/comment-functions.php
- Timestamp:
- 09/03/2015 06:16:35 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment-functions.php
r33822 r33891 165 165 * @global object $comment 166 166 * 167 * @param object|string|int $comment Comment to retrieve.167 * @param WP_Comment|string|int $comment Comment to retrieve. 168 168 * @param string $output Optional. OBJECT or ARRAY_A or ARRAY_N constants. 169 * @return object|array|null Depends on $output value.169 * @return WP_Comment|array|null Depends on $output value. 170 170 */ 171 171 function get_comment(&$comment, $output = OBJECT) { 172 global $wpdb; 173 174 if ( empty($comment) ) { 175 if ( isset($GLOBALS['comment']) ) 176 $_comment = & $GLOBALS['comment']; 177 else 178 $_comment = null; 179 } elseif ( is_object($comment) ) { 180 wp_cache_add($comment->comment_ID, $comment, 'comment'); 172 if ( empty( $comment ) && isset( $GLOBALS['comment'] ) ) { 173 $comment = $GLOBALS['comment']; 174 } 175 176 if ( $comment instanceof WP_Comment ) { 181 177 $_comment = $comment; 178 } elseif ( is_object( $comment ) ) { 179 $_comment = new WP_Comment( $comment ); 182 180 } else { 183 if ( isset($GLOBALS['comment']) && ($GLOBALS['comment']->comment_ID == $comment) ) { 184 $_comment = & $GLOBALS['comment']; 185 } elseif ( ! $_comment = wp_cache_get($comment, 'comment') ) { 186 $_comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment)); 187 if ( ! $_comment ) 188 return null; 189 wp_cache_add($_comment->comment_ID, $_comment, 'comment'); 190 } 181 $_comment = WP_Comment::get_instance( $comment ); 182 } 183 184 if ( ! $_comment ) { 185 return null; 191 186 } 192 187 … … 203 198 return $_comment; 204 199 } elseif ( $output == ARRAY_A ) { 205 $__comment = get_object_vars($_comment); 206 return $__comment; 200 return $_comment->to_array(); 207 201 } elseif ( $output == ARRAY_N ) { 208 $__comment = array_values(get_object_vars($_comment)); 209 return $__comment; 210 } else { 211 return $_comment; 212 } 202 return array_values( $_comment->to_array() ); 203 } 204 return $_comment; 213 205 } 214 206 … … 480 472 * to recall previous comments by this commentator that are still held in moderation. 481 473 * 482 * @param object $comment Comment object.483 * @param object $userComment author's object.474 * @param WP_Comment $comment Comment object. 475 * @param object $user Comment author's object. 484 476 * 485 477 * @since 3.4.0 … … 761 753 * @global WP_Query $wp_query 762 754 * 763 * @param array $comments Optional array of comment objects. Defaults to $wp_query->comments755 * @param array $comments Optional array of WP_Comment objects. Defaults to $wp_query->comments 764 756 * @param int $per_page Optional comments per page. 765 757 * @param bool $threaded Optional control over flat or threaded comments. … … 1289 1281 * @since 2.7.0 1290 1282 * 1291 * @param object $comment Comment object.1283 * @param WP_Comment $comment Comment object. 1292 1284 */ 1293 1285 do_action( "comment_{$old_status}_to_{$new_status}", $comment ); … … 1304 1296 * @since 2.7.0 1305 1297 * 1306 * @param int $comment_ID The comment ID.1307 * @param obj$comment Comment object.1298 * @param int $comment_ID The comment ID. 1299 * @param WP_Comment $comment Comment object. 1308 1300 */ 1309 1301 do_action( "comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment ); … … 1424 1416 * @since 2.8.0 1425 1417 * 1426 * @param int $id The comment ID.1427 * @param obj$comment Comment object.1418 * @param int $id The comment ID. 1419 * @param WP_Comment $comment Comment object. 1428 1420 */ 1429 1421 do_action( 'wp_insert_comment', $id, $comment );
Note: See TracChangeset
for help on using the changeset viewer.