Skip to content

Commit

Permalink
Exclude posts from post types not shown in REST when fixing insecure …
Browse files Browse the repository at this point in the history
…content from the admin
  • Loading branch information
kmgalanakis committed Aug 2, 2023
1 parent df6ab38 commit 58a0cdd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion includes/classes/class-fixinsecurecontent.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ public static function get_instance() {
* @return int
*/
public function count_post_to_check( string $post_type, int $posts_per_page, int $post_offset ): int {
// Exclude post from post types not shown in REST when counting insecure content to fix from the admin UI.
$post_types = get_post_types( array( 'show_in_rest' => true ) );

$args = array(
'posts_per_page' => $posts_per_page,
'post_type' => 'all' === $post_type ? 'any' : $post_type,
'post_type' => 'all' === $post_type ? $post_types : $post_type,
'offset' => $post_offset,
'nopaging' => true,
);
Expand Down Expand Up @@ -117,6 +120,11 @@ public function fix( $include, $all, $post_type, $posts_per_page, $post_offset,
} else {
$total = 0;

// Exclude post from post types not shown in REST when fixing insecure content from the admin UI.
if ( ! defined( 'WP_CLI' ) && 'any' === $post_type ) {
$post_type = get_post_types( array( 'show_in_rest' => true ) );
}

// Loop through all posts and fix content.
while ( true ) {
$args = array(
Expand Down

0 comments on commit 58a0cdd

Please sign in to comment.