public static getIndexablePostTypes ( ) : array | ||
Результат | array |
/** * Hooked on save_post. Called when a post is updated. * * @param int $postID */ public static function actionSavePost($postID) { global $importer; // If we have an importer we must be doing an import - let's abort if (!empty($importer)) { return; } $post = get_post($postID); if (!in_array($post->post_status, Indexer::getIndexablePostStati())) { // The post is not indexable but might have been. Try to delete. $indexer = new Indexer(); $indexer->deletePost($post->ID); return; } if (in_array($post->post_type, Indexer::getIndexablePostTypes())) { do_action('esi_before_post_save', $post); $indexer = new Indexer(); $indexer->indexPost($post); } }
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; }