Make WordPress Core

Ticket #54149: get_comment_.code-search

File get_comment_.code-search, 20.4 KB (added by costdev, 5 years ago)
Line 
1# Query: get_comment(
2# Flags: CaseSensitive
3# Excluding: *.diff
4# ContextLines: 1
5
6164 results - 36 files
7
8src/wp-admin/comment.php:
9 40 $comment_id = absint( $_REQUEST['c'] );
10 41: $comment = get_comment( $comment_id );
11 42
12
13 200 if ( $comment->comment_parent ) {
14 201: $parent = get_comment( $comment->comment_parent );
15 202 $parent_link = esc_url( get_comment_link( $parent ) );
16
17 276
18 277: $comment = get_comment( $comment_id );
19 278 if ( ! $comment ) {
20
21src/wp-admin/edit-comments.php:
22 321 if ( $same > 0 ) {
23 322: $comment = get_comment( $same );
24 323 if ( $comment ) {
25
26src/wp-admin/edit-form-comment.php:
27 167 if ( $comment->comment_parent ) :
28 168: $parent = get_comment( $comment->comment_parent );
29 169 if ( $parent ) :
30
31src/wp-admin/includes/ajax-actions.php:
32 437 $time = time();
33 438: $comment = get_comment( $comment_id );
34 439 $comment_status = '';
35
36 520 $time = time();
37 521: $comment = get_comment( $comment_id );
38 522 $counts = wp_count_comments();
39
40 690
41 691: $comment = get_comment( $id );
42 692
43
44 949 $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
45 950: $comment = get_comment( $id );
46 951
47
48 1230 }
49 1231: get_comment( $comment );
50 1232 $wp_list_table->single_row( $comment );
51
52 1317 if ( ! empty( $_POST['approve_parent'] ) ) {
53 1318: $parent = get_comment( $comment_parent );
54 1319
55
56 1336
57 1337: $comment = get_comment( $comment_id );
58 1338
59
60 1421
61 1422: $comment = get_comment( $comment_id );
62 1423
63
64src/wp-admin/includes/class-wp-comments-list-table.php:
65 67 public function floated_admin_avatar( $name, $comment_id ) {
66 68: $comment = get_comment( $comment_id );
67 69 $avatar = get_avatar( $comment, 32, 'mystery' );
68
69 898 if ( $comment->comment_parent ) {
70 899: $parent = get_comment( $comment->comment_parent );
71 900
72
73src/wp-admin/includes/comment.php:
74 110 function get_comment_to_edit( $id ) {
75 111: $comment = get_comment( $id );
76 112 if ( ! $comment ) {
77
78 194 function floated_admin_avatar( $name ) {
79 195: $avatar = get_avatar( get_comment(), 32, 'mystery' );
80 196 return "$avatar $name";
81
82src/wp-admin/includes/template.php:
83 775 * @since 0.71
84 776: * @since 4.4.0 Converted to use get_comment() instead of the global `$comment`.
85 777 *
86
87 801
88 802: $post_date = ( $for_post ) ? $post->post_date : get_comment()->comment_date;
89 803 $jj = ( $edit ) ? mysql2date( 'd', $post_date, false ) : current_time( 'd' );
90
91src/wp-includes/capabilities.php:
92 394 case 'edit_comment':
93 395: $comment = get_comment( $args[0] );
94 396 if ( ! $comment ) {
95
96src/wp-includes/class-wp-comment-query.php:
97 474 foreach ( $comment_ids as $comment_id ) {
98 475: $_comment = get_comment( $comment_id );
99 476 if ( $_comment ) {
100
101 1061 foreach ( $descendant_ids as $descendant_id ) {
102 1062: $all_comments[] = get_comment( $descendant_id );
103 1063 }
104
105 1069 foreach ( $all_comments as $k => $c ) {
106 1070: $_c = get_comment( $c->comment_ID );
107 1071
108
109src/wp-includes/class-wp-xmlrpc-server.php:
110 3583
111 3584: $comment = get_comment( $comment_id );
112 3585 if ( ! $comment ) {
113
114 3720
115 3721: if ( ! get_comment( $comment_ID ) ) {
116 3722 return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
117
118 3788
119 3789: if ( ! get_comment( $comment_ID ) ) {
120 3790 return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
121
122src/wp-includes/comment-template.php:
123 24 function get_comment_author( $comment_ID = 0 ) {
124 25: $comment = get_comment( $comment_ID );
125 26
126
127 60 function comment_author( $comment_ID = 0 ) {
128 61: $comment = get_comment( $comment_ID );
129 62 $author = get_comment_author( $comment );
130
131 86 function get_comment_author_email( $comment_ID = 0 ) {
132 87: $comment = get_comment( $comment_ID );
133 88
134
135 117 function comment_author_email( $comment_ID = 0 ) {
136 118: $comment = get_comment( $comment_ID );
137 119 $author_email = get_comment_author_email( $comment );
138
139 178 function get_comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) {
140 179: $comment = get_comment( $comment );
141 180
142
143 208 *
144 209: * Both get_comment_author_url() and get_comment_author() rely on get_comment(),
145 210 * which falls back to the global comment variable if the $comment_ID argument is empty.
146
147 219 function get_comment_author_link( $comment_ID = 0 ) {
148 220: $comment = get_comment( $comment_ID );
149 221 $url = get_comment_author_url( $comment );
150
151 267 function get_comment_author_IP( $comment_ID = 0 ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
152 268: $comment = get_comment( $comment_ID );
153 269
154
155 306 function get_comment_author_url( $comment_ID = 0 ) {
156 307: $comment = get_comment( $comment_ID );
157 308 $url = '';
158
159 339 function comment_author_url( $comment_ID = 0 ) {
160 340: $comment = get_comment( $comment_ID );
161 341 $author_url = get_comment_author_url( $comment );
162
163 463
164 464: $comment = get_comment( $comment_id );
165 465 if ( ! $comment ) {
166
167 552 function get_comment_date( $format = '', $comment_ID = 0 ) {
168 553: $comment = get_comment( $comment_ID );
169 554
170
171 597 function get_comment_excerpt( $comment_ID = 0 ) {
172 598: $comment = get_comment( $comment_ID );
173 599
174
175 642 function comment_excerpt( $comment_ID = 0 ) {
176 643: $comment = get_comment( $comment_ID );
177 644 $comment_excerpt = get_comment_excerpt( $comment );
178
179 665 function get_comment_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
180 666: $comment = get_comment();
181 667
182
183 716
184 717: $comment = get_comment( $comment );
185 718
186
187 968 function get_comment_text( $comment_ID = 0, $args = array() ) {
188 969: $comment = get_comment( $comment_ID );
189 970
190
191 973 if ( is_comment_feed() && $comment->comment_parent ) {
192 974: $parent = get_comment( $comment->comment_parent );
193 975 if ( $parent ) {
194
195 1013 function comment_text( $comment_ID = 0, $args = array() ) {
196 1014: $comment = get_comment( $comment_ID );
197 1015
198
199 1042 function get_comment_time( $format = '', $gmt = false, $translate = true ) {
200 1043: $comment = get_comment();
201 1044
202
203 1086 function get_comment_type( $comment_ID = 0 ) {
204 1087: $comment = get_comment( $comment_ID );
205 1088
206
207 1692
208 1693: $comment = get_comment( $comment );
209 1694
210
211 2014 // Sets the global so that template tags can be used in the comment form.
212 2015: $comment = get_comment( $reply_to_id );
213 2016
214
215src/wp-includes/comment.php:
216 194 */
217 195: function get_comment( $comment = null, $output = OBJECT ) {
218 196 if ( empty( $comment ) && isset( $GLOBALS['comment'] ) ) {
219
220 1088
221 1089: $comment = get_comment( $comment_ID );
222 1090 if ( ! $comment ) {
223
224 1475 global $wpdb;
225 1476: $comment = get_comment( $comment_id );
226 1477 if ( ! $comment ) {
227
228 1553
229 1554: $comment = get_comment( $comment_id );
230 1555 if ( ! $comment ) {
231
232 1601 function wp_untrash_comment( $comment_id ) {
233 1602: $comment = get_comment( $comment_id );
234 1603 if ( ! $comment ) {
235
236 1652 function wp_spam_comment( $comment_id ) {
237 1653: $comment = get_comment( $comment_id );
238 1654 if ( ! $comment ) {
239
240 1700 function wp_unspam_comment( $comment_id ) {
241 1701: $comment = get_comment( $comment_id );
242 1702 if ( ! $comment ) {
243
244 1751 function wp_get_comment_status( $comment_id ) {
245 1752: $comment = get_comment( $comment_id );
246 1753 if ( ! $comment ) {
247
248 1939 $comment_id = (int) $_GET['unapproved'];
249 1940: $comment = get_comment( $comment_id );
250 1941
251
252 2034
253 2035: $comment = get_comment( $id );
254 2036
255
256 2299 function wp_new_comment_notify_moderator( $comment_ID ) {
257 2300: $comment = get_comment( $comment_ID );
258 2301
259
260 2326 function wp_new_comment_notify_postauthor( $comment_ID ) {
261 2327: $comment = get_comment( $comment_ID );
262 2328
263
264 2395
265 2396: $comment_old = clone get_comment( $comment_id );
266 2397
267
268 2407
269 2408: $comment = get_comment( $comment_old->comment_ID );
270 2409
271
272 2450 // First, get all of the original fields.
273 2451: $comment = get_comment( $commentarr['comment_ID'], ARRAY_A );
274 2452 if ( empty( $comment ) ) {
275
276 2563
277 2564: $comment = get_comment( $comment_ID );
278 2565
279
280 3575
281 3576: return get_comment( $comment_id );
282 3577 }
283
284src/wp-includes/deprecated.php:
285 1230 * @since 0.71
286 1231: * @deprecated 2.7.0 Use get_comment()
287 1232: * @see get_comment()
288 1233 *
289
290 1239 function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) {
291 1240: _deprecated_function( __FUNCTION__, '2.7.0', 'get_comment()' );
292 1241: return get_comment($comment_ID, ARRAY_A);
293 1242 }
294
295src/wp-includes/feed-atom-comments.php:
296 117 else : // This comment is in reply to another comment.
297 118: $parent_comment = get_comment( $comment->comment_parent );
298 119 /*
299
300src/wp-includes/feed.php:
301 289 function get_comment_guid( $comment_id = null ) {
302 290: $comment = get_comment( $comment_id );
303 291
304
305src/wp-includes/functions.php:
306 6482
307 6483: $del_comment = get_comment( $comment_id );
308 6484
309
310src/wp-includes/link-template.php:
311 1575 function get_edit_comment_link( $comment_id = 0 ) {
312 1576: $comment = get_comment( $comment_id );
313 1577
314
315 1603 function edit_comment_link( $text = null, $before = '', $after = '' ) {
316 1604: $comment = get_comment();
317 1605
318
319 4311 if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
320 4312: $id_or_email = get_comment( $id_or_email );
321 4313 }
322
323src/wp-includes/meta.php:
324 1755 case 'comment':
325 1756: $comment = get_comment( $object_id );
326 1757 if ( ! $comment ) {
327
328src/wp-includes/pluggable.php:
329 1548
330 1549: $comment = get_comment( $comment_id );
331 1550 if ( empty( $comment ) || empty( $comment->comment_post_ID ) ) {
332
333 1796
334 1797: $comment = get_comment( $comment_id );
335 1798 $post = get_post( $comment->comment_post_ID );
336
337 2701 if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
338 2702: $id_or_email = get_comment( $id_or_email );
339 2703 }
340
341src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php:
342 337 */
343 338: protected function get_comment( $id ) {
344 339 $error = new WP_Error(
345
346 349 $id = (int) $id;
347 350: $comment = get_comment( $id );
348 351 if ( empty( $comment ) ) {
349
350 378 public function get_item_permissions_check( $request ) {
351 379: $comment = $this->get_comment( $request['id'] );
352 380 if ( is_wp_error( $comment ) ) {
353
354 421 public function get_item( $request ) {
355 422: $comment = $this->get_comment( $request['id'] );
356 423 if ( is_wp_error( $comment ) ) {
357
358 712
359 713: $comment = get_comment( $comment_id );
360 714
361
362 775 public function update_item_permissions_check( $request ) {
363 776: $comment = $this->get_comment( $request['id'] );
364 777 if ( is_wp_error( $comment ) ) {
365
366 800 public function update_item( $request ) {
367 801: $comment = $this->get_comment( $request['id'] );
368 802 if ( is_wp_error( $comment ) ) {
369
370 885
371 886: $comment = get_comment( $id );
372 887
373
374 925 public function delete_item_permissions_check( $request ) {
375 926: $comment = $this->get_comment( $request['id'] );
376 927 if ( is_wp_error( $comment ) ) {
377
378 949 public function delete_item( $request ) {
379 950: $comment = $this->get_comment( $request['id'] );
380 951 if ( is_wp_error( $comment ) ) {
381
382 1000 $result = wp_trash_comment( $comment->comment_ID );
383 1001: $comment = get_comment( $comment->comment_ID );
384 1002 $response = $this->prepare_item_for_response( $comment, $request );
385
386tests/phpunit/includes/factory/class-wp-unittest-factory-for-comment.php:
387 71 public function get_object_by_id( $comment_id ) {
388 72: return get_comment( $comment_id );
389 73 }
390
391tests/phpunit/tests/avatar.php:
392 100 );
393 101: $comment = get_comment( $comment_id );
394 102 $url2 = get_avatar_url( $comment );
395
396 153 );
397 154: $comment = get_comment( $comment_id );
398 155
399
400tests/phpunit/tests/comment-submission.php:
401 748 $comment_id = wp_insert_comment( $data );
402 749: $comment = get_comment( $comment_id );
403 750
404
405tests/phpunit/tests/comment.php:
406 56
407 57: $comment = get_comment( $comments[0] );
408 58 $this->assertEquals( $comments[1], $comment->comment_parent );
409
410 74
411 75: $comment = get_comment( $comments[0] );
412 76 $this->assertEquals( $post2->ID, $comment->comment_post_ID );
413
414 91
415 92: $comment = get_comment( $comment_id );
416 93 $this->assertSame( 'pingback', $comment->comment_type );
417
418 127
419 128: $comment = get_comment( $comment_id );
420 129 $this->assertEquals( 1, $comment->user_id );
421
422 148
423 149: $comment = get_comment( $comment_id );
424 150 $this->assertSame( $updated_comment_text, $comment->comment_content );
425
426 290
427 291: $comment = get_comment( $id );
428 292
429
430 312
431 313: $comment = get_comment( $id );
432 314
433
434 333
435 334: $comment = get_comment( $id );
436 335
437
438 355
439 356: $comment = get_comment( $id );
440 357
441
442 377
443 378: $comment = get_comment( $id );
444 379
445
446 399
447 400: $comment = get_comment( $id );
448 401
449
450 419
451 420: $comment = get_comment( $id );
452 421
453
454 623
455 624: $comment = get_comment( $c1 );
456 625 $children = $comment->get_children();
457
458 640 $post = get_post( self::$post_id );
459 641: $comment = get_comment( $c );
460 642
461
462 900 // Confirm that the IP and Agent are correct on initial save.
463 901: $save = get_comment( $comment_id );
464 902 $this->assertSame( $default_data['comment_author_IP'], $save->comment_author_IP );
465
466 914 // Retrieve and check the new values.
467 915: $updated = get_comment( $comment_id );
468 916 $this->assertSame( '111.111.1.1', $updated->comment_author_IP );
469
470 960
471 961: $comment = get_comment( $comment_id );
472 962
473
474 1166
475 1167: $comment = get_comment( $c );
476 1168 $this->assertSame( 'Foo', $comment->comment_author );
477
478 1176
479 1177: $comment = get_comment( $c );
480 1178
481
482 1186
483 1187: $comment = get_comment( $c );
484 1188
485
486 1190
487 1191: $comment = get_comment( $c );
488 1192
489
490 1201
491 1202: $comment = get_comment( $c );
492 1203 $this->assertSame( 'trash', $comment->comment_approved );
493
494 1206
495 1207: $comment = get_comment( $c );
496 1208
497
498 1216
499 1217: $comment = get_comment( $c );
500 1218
501
502 1220
503 1221: $comment = get_comment( $c );
504 1222
505
506 1231
507 1232: $comment = get_comment( $c );
508 1233 $this->assertSame( 'spam', $comment->comment_approved );
509
510 1236
511 1237: $comment = get_comment( $c );
512 1238
513
514tests/phpunit/tests/comment/commentsTemplate.php:
515 848 );
516 849: $comment = get_comment( $c );
517 850
518
519tests/phpunit/tests/comment/query.php:
520 4941
521 4942: return array( get_comment( $c ) );
522 4943 }
523
524tests/phpunit/tests/comment/slashes.php:
525 51
526 52: $comment = get_comment( $comment_id );
527 53
528
529 66
530 67: $comment = get_comment( $comment_id );
531 68
532
533 96 edit_comment();
534 97: $comment = get_comment( $comment_id );
535 98
536
537 112 edit_comment();
538 113: $comment = get_comment( $comment_id );
539 114
540
541 131 );
542 132: $comment = get_comment( $comment_id );
543 133
544
545 143 );
546 144: $comment = get_comment( $comment_id );
547 145
548
549 167 );
550 168: $comment = get_comment( $comment_id );
551 169
552
553 179 );
554 180: $comment = get_comment( $comment_id );
555 181
556
557tests/phpunit/tests/comment/walker.php:
558 24 );
559 25: $comment_parent = get_comment( $comment_parent );
560 26: $comment_child = get_comment( $comment_child );
561 27
562
563tests/phpunit/tests/comment/wpBatchUpdateCommentType.php:
564 27 foreach ( $comment_ids as $comment_id ) {
565 28: $comment = get_comment( $comment_id );
566 29 $this->assertEmpty( $comment->comment_type );
567
568 40 foreach ( $comment_ids as $comment_id ) {
569 41: $updated_comment = get_comment( $comment_id );
570 42 $this->assertSame( 'comment', $updated_comment->comment_type );
571
572tests/phpunit/tests/comment/wpListComments.php:
573 149
574 150: $_comments = array( get_comment( $comments[1] ), get_comment( $comments[3] ) );
575 151
576
577tests/phpunit/tests/date/getCommentDate.php:
578 35
579 36: $GLOBALS['comment'] = get_comment( $c );
580 37 $this->assertSame( '1:51 am', get_comment_time( 'g:i a' ) );
581
582 45
583 46: $GLOBALS['comment'] = get_comment( $c );
584 47 $this->assertSame( '1:51 am', get_comment_time( '' ) );
585
586tests/phpunit/tests/date/xmlrpc.php:
587 237
588 238: $fetched_comment = get_comment( $comment_id );
589 239
590
591tests/phpunit/tests/rest-api/rest-comments-controller.php:
592 959 $request->set_param( '_fields', 'id,status' );
593 960: $obj = get_comment( self::$approved_id );
594 961 $response = $endpoint->prepare_item_for_response( $obj, $request );
595
596 980
597 981: $comment = get_comment( self::$approved_id );
598 982 // Ignore the subdomain, since get_avatar_url() randomly sets
599
600 1216 $data = $response->get_data();
601 1217: $comment = get_comment( $data['id'] );
602 1218
603
604 1248 $data = $response->get_data();
605 1249: $new_comment = get_comment( $data['id'] );
606 1250 $this->assertSame( $params['content']['raw'], $new_comment->comment_content );
607
608 1637 $author = get_user_by( 'id', $user_id );
609 1638: $comment = get_comment( $data['id'] );
610 1639 $this->assertSame( $author->display_name, $comment->comment_author );
611
612 1779
613 1780: $new_comment = get_comment( $data['id'] );
614 1781 $this->assertSame( 'Mozilla/4.0 (compatible; MSIE 5.5; AOL 4.0; Windows 95)', $new_comment->comment_agent );
615
616 1800 $data = $response->get_data();
617 1801: $new_comment = get_comment( $data['id'] );
618 1802 $this->assertSame( '127.0.0.3', $new_comment->comment_author_IP );
619
620 1861 $data = $response->get_data();
621 1862: $new_comment = get_comment( $data['id'] );
622 1863 $this->assertSame( '127.0.0.2', $new_comment->comment_author_IP );
623
624 2328 $comment = $response->get_data();
625 2329: $updated = get_comment( self::$approved_id );
626 2330 $this->assertSame( $params['content'], $comment['content']['raw'] );
627
628 2364 $data = $response->get_data();
629 2365: $comment = get_comment( $data['id'] );
630 2366
631
632 2395 public function test_update_item_no_change() {
633 2396: $comment = get_comment( self::$approved_id );
634 2397
635
636 2433 $comment = $response->get_data();
637 2434: $updated = get_comment( $comment_id );
638 2435 $this->assertSame( 'approved', $comment['status'] );
639
640 2461 $comment = $response->get_data();
641 2462: $updated = get_comment( $comment_id );
642 2463 $this->assertSame( 'approved', $comment['status'] );
643
644 2483 $comment = $response->get_data();
645 2484: $updated = get_comment( self::$approved_id );
646 2485 $this->assertSame( $params['date_gmt'], $comment['date_gmt'] );
647
648 2619 $comment = $response->get_data();
649 2620: $updated = get_comment( self::$approved_id );
650 2621 $this->assertSame( $params['content']['raw'], $updated->comment_content );
651
652 2714 $comment = $response->get_data();
653 2715: $updated = get_comment( self::$approved_id );
654 2716
655
656 2913 // Compare expected API output to WP internal values.
657 2914: $comment = get_comment( $actual_output['id'] );
658 2915 $this->assertSame( $expected_output['content']['raw'], $comment->comment_content );
659
660 2937 // Compare expected API output to WP internal values.
661 2938: $comment = get_comment( $actual_output['id'] );
662 2939 $this->assertSame( $expected_output['content']['raw'], $comment->comment_content );
663
664 3304 protected function check_comment_data( $data, $context, $links ) {
665 3305: $comment = get_comment( $data['id'] );
666 3306
667
668tests/phpunit/tests/xmlrpc/wp/editComment.php:
669 79
670 80: $this->assertSame( '1', get_comment( $comment_id )->comment_approved );
671 81
672
673 93
674 94: $this->assertSame( 'trash', get_comment( $comment_id )->comment_approved );
675 95 }
676
677tests/phpunit/tests/xmlrpc/wp/getComments.php:
678 32 foreach ( $results as $result ) {
679 33: $comment = get_comment( $result['comment_id'], ARRAY_A );
680 34 $this->assertSame( $comment['comment_post_ID'], $result['post_id'] );
681
682tests/phpunit/tests/xmlrpc/wp/newComment.php:
683 259 $result = $this->myxmlrpcserver->wp_newComment( $comment_args );
684 260: $comment = get_comment( $result );
685 261 $user_id = get_user_by( 'login', 'administrator' )->ID;