From 809a7ac01601215feacbb77b724df9dbadeb4c5c Mon Sep 17 00:00:00 2001 From: Noel Light-Hilary Date: Wed, 14 Jul 2021 12:56:45 +0100 Subject: [PATCH] Review improvement --- src/OowpQuery.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/OowpQuery.php b/src/OowpQuery.php index 37a5aa5..a7d4ffd 100644 --- a/src/OowpQuery.php +++ b/src/OowpQuery.php @@ -29,11 +29,7 @@ function __construct($query = '') // 'attachment' which can cause crashes on ?preview=true if a file title matches a render-able post's. if (!isset($query['post_type']) || (!is_array($query['post_type']) && !array_key_exists($query['post_type'], $wp_post_types))) { - $query['post_type'] = array_values(get_post_types()); - $attachmentTypeIndex = array_search('attachment', $query['post_type'], true); - if ($attachmentTypeIndex !== false) { - array_splice($query['post_type'], $attachmentTypeIndex, 1); - } + $query['post_type'] = array_values(array_diff(get_post_types(), array('attachment'))); } parent::__construct($query);