diff --git a/Functions/Functions.php b/Functions/Functions.php index 992abfd..0208742 100644 --- a/Functions/Functions.php +++ b/Functions/Functions.php @@ -70,6 +70,7 @@ public function findBlockForm() echo '' . esc_html__('Select a post type you wish to search in', 'block-finder') . ''; echo ''; echo '' . esc_html__('-- Select post type --', 'block-finder') . ''; + echo '' . esc_html__('All Post Types', 'block-finder') . ''; // Add this line foreach ($gutenberg_post_types as $post_type) { echo '' . esc_html($post_type->label) . ''; } @@ -112,11 +113,25 @@ public function blockQuery() ]; $found_elements = []; - $args = [ - 'post_type' => [$post_type], - 'nopaging' => true, - 'posts_per_page' => -1, - ]; + + if ($post_type === 'all') { + $post_types = get_post_types(['public' => true], 'names'); + $gutenberg_post_types = array_filter($post_types, function ($post_type_name) { + return post_type_supports($post_type_name, 'editor'); + }); + + $args = [ + 'post_type' => array_values($gutenberg_post_types), + 'nopaging' => true, + 'posts_per_page' => -1, + ]; + } else { + $args = [ + 'post_type' => [$post_type], + 'nopaging' => true, + 'posts_per_page' => -1, + ]; + } $query = new \WP_Query($args);