From 5515b50fd7dd61682529fa91cae89bbc356fcfd9 Mon Sep 17 00:00:00 2001 From: Keith Solomon Date: Thu, 30 Jan 2025 15:55:11 -0600 Subject: [PATCH] =?UTF-8?q?=E2=8F=AA=20rollback:=20working=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource-filter.php | 59 ++------------------------------------------- 1 file changed, 2 insertions(+), 57 deletions(-) diff --git a/resource-filter.php b/resource-filter.php index 504eb15..95229c1 100644 --- a/resource-filter.php +++ b/resource-filter.php @@ -74,66 +74,13 @@ class ResourceFilterPlugin { public function filterResources() { check_ajax_referer('resource_filter_nonce', 'nonce'); - // $query_args = [ - // 'post_type' => 'resource', - // 'posts_per_page' => -1, - // 'tax_query' => [], - // 's' => isset($_POST['search']) ? sanitize_text_field($_POST['search']) : '', - // ]; - - $search_term = isset($_POST['search']) ? sanitize_text_field($_POST['search']) : ''; - $query_args = [ 'post_type' => 'resource', 'posts_per_page' => -1, - 'tax_query' => ['relation' => 'OR'], // Allows matching by search OR taxonomy - 'meta_query' => [ - 'relation' => 'OR', - [ - 'key' => 'post_title', - 'value' => $search_term, - 'compare' => 'LIKE' - ], - [ - 'key' => 'post_content', - 'value' => $search_term, - 'compare' => 'LIKE' - ] - ] + 'tax_query' => [], + 's' => isset($_POST['search']) ? sanitize_text_field($_POST['search']) : '', ]; - if (!empty($search_term)) { - $query_args['tax_query'][] = [ - 'taxonomy' => 'resource_type', - 'field' => 'name', // Search by the name of the taxonomy term - 'terms' => $search_term, - 'operator' => 'LIKE' - ]; - - $query_args['tax_query'][] = [ - 'taxonomy' => 'resource_subject', - 'field' => 'name', - 'terms' => $search_term, - 'operator' => 'LIKE' - ]; - } - - if (!empty($_POST['resource_type'])) { - $query_args['tax_query'][] = [ - 'taxonomy' => 'resource_type', - 'field' => 'slug', - 'terms' => sanitize_text_field($_POST['resource_type']) - ]; - } - - if (!empty($_POST['resource_subject'])) { - $query_args['tax_query'][] = [ - 'taxonomy' => 'resource_subject', - 'field' => 'slug', - 'terms' => sanitize_text_field($_POST['resource_subject']) - ]; - } - if (!empty($_POST['resource_type']) || !empty($_POST['resource_subject'])) { $query_args['tax_query']['relation'] = 'AND'; @@ -168,8 +115,6 @@ class ResourceFilterPlugin { echo '

No resources found.

'; } - print_r($query_args); - wp_reset_postdata(); // Prepare response JSON