Skip to content

Commit

Permalink
Use posts member of WP_Query instead of get_posts method
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter authored and thelovekesh committed Jul 7, 2024
1 parent 546b0d2 commit 9961198
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bin/add-test-widgets-to-sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ function amp_media( $type, $count = 3 ) {
)
);
}
return $query->get_posts();
return $query->posts;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion bin/create-embed-test-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ function amp_get_media_items_ids( $type, $image_count = 3 ) {
)
);
}
return implode( ',', $query->get_posts() );
return implode( ',', $query->posts );
}

/**
Expand Down
4 changes: 2 additions & 2 deletions includes/validation/class-amp-validated-url-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ public static function delete_stylesheets_postmeta_batch( $count, $before ) {
'posts_per_page' => $count,
]
);
foreach ( $query->get_posts() as $post_id ) {
foreach ( $query->posts as $post_id ) {
if ( delete_post_meta( $post_id, self::STYLESHEETS_POST_META_KEY ) ) {
$deleted++;
}
Expand Down Expand Up @@ -1037,7 +1037,7 @@ public static function garbage_collect_validated_urls( $count = 100, $before = '
],
]
);
foreach ( $query->get_posts() as $post ) {
foreach ( $query->posts as $post ) {
if ( ! self::is_post_safe_to_garbage_collect( $post ) ) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Support/SupportData.php
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ public function get_amp_urls() {
];

$query = new WP_Query( $query_args );
$amp_validated_posts = $query->get_posts();
$amp_validated_posts = $query->posts;

foreach ( $amp_validated_posts as $amp_validated_post ) {
$validation_data = $this->process_raw_post_errors( $amp_validated_post );
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/ScannableURLProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ private function get_author_page_urls( $offset, $number ) {
'posts_per_page' => 1,
]
);
if ( count( $authored_post_query->get_posts() ) > 0 ) {
if ( count( $authored_post_query->posts ) > 0 ) {
$author_page_urls[] = get_author_posts_url( $author->ID, $author->user_nicename );
}
}
Expand Down Expand Up @@ -376,7 +376,7 @@ private function get_date_page() {
'order' => 'DESC',
]
);
$posts = $query->get_posts();
$posts = $query->posts;

$latest_post = array_shift( $posts );
if ( ! $latest_post ) {
Expand Down
2 changes: 1 addition & 1 deletion tests/php/src/Validation/ScannableURLProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ public function test_get_date_page() {
'fields' => 'ids',
]
);
foreach ( $query->get_posts() as $deleted_post ) {
foreach ( $query->posts as $deleted_post ) {
wp_delete_post( $deleted_post );
}
$this->assertNull( $this->call_private_method( $this->scannable_url_provider, 'get_date_page' ) );
Expand Down

0 comments on commit 9961198

Please sign in to comment.