Skip to content

Commit 040e601

Browse files
authored
Rest: Use utility function everywhere (#1461)
1 parent fdf9848 commit 040e601

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

includes/class-comment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ public static function comment_query( $query ) {
717717
}
718718

719719
// Do not exclude likes and reposts on REST requests.
720-
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
720+
if ( \wp_is_serving_rest_request() ) {
721721
return;
722722
}
723723

includes/collection/class-replies.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static function get_collection( $wp_object ) {
7878
$id = self::get_id( $wp_object );
7979

8080
if ( is_wp_error( $id ) ) {
81-
return defined( 'REST_REQUEST' ) && REST_REQUEST ? $id : null;
81+
return \wp_is_serving_rest_request() ? $id : null;
8282
}
8383

8484
$replies = array(
@@ -106,15 +106,15 @@ public static function get_collection_page( $wp_object, $page, $part_of = null )
106106
// Build initial arguments for fetching approved comments.
107107
$args = self::build_args( $wp_object );
108108
if ( is_wp_error( $args ) ) {
109-
return defined( 'REST_REQUEST' ) && REST_REQUEST ? $args : null;
109+
return \wp_is_serving_rest_request() ? $args : null;
110110
}
111111

112112
// Retrieve the partOf if not already given.
113113
$part_of = $part_of ?? self::get_id( $wp_object );
114114

115115
// If the collection page does not exist.
116116
if ( is_wp_error( $part_of ) ) {
117-
return defined( 'REST_REQUEST' ) && REST_REQUEST ? $part_of : null;
117+
return \wp_is_serving_rest_request() ? $part_of : null;
118118
}
119119

120120
// Get to total replies count.

0 commit comments

Comments
 (0)