public static function isCompatible(Wp_Query $wpQuery)
{
$q = $wpQuery->query_vars;
$unsupportedQueryArgs = ['suppress_filters', 'has_password', 'post_password', 'preview', 'fields'];
foreach ($q as $key => $value) {
if ($value && in_array($key, $unsupportedQueryArgs)) {
return false;
}
}
if ($q['fields'] == 'ids' || $q['fields'] == 'id=>parent') {
return false;
}
if (!empty($q['post_status'])) {
if (is_string($q['post_status'])) {
$q['post_status'] = explode(' ', str_replace(',', ' ', $q['post_status']));
}
$ips = Indexer::getIndexablePostStati();
foreach ($q['post_status'] as $value) {
if (!in_array($value, $ips)) {
return false;
}
}
}
if (!empty($q['post_type']) && $q['post_type'] !== 'any') {
if (is_string($q['post_type'])) {
$q['post_type'] = explode(' ', str_replace(',', ' ', $q['post_type']));
}
$ipt = Indexer::getIndexablePostTypes();
foreach ($q['post_type'] as $value) {
if (!in_array($value, $ipt)) {
return false;
}
}
}
return true;
}