From b0bcaabff84940f3d58cc69eee52bb5bd97e23a6 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 26 Apr 2017 13:38:14 -0400 Subject: [PATCH] Moving these filters from the fields plugin. They belong in the theme so they are for only brewbakers. --- functions.php | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index b5747a3..e4a8056 100644 --- a/functions.php +++ b/functions.php @@ -39,9 +39,48 @@ add_filter('glm-member-db-front-search-query', function( $queryParts ) { OR (C.parent in($catSelectedForQuery) AND M.category = C.id) ) "; } + // Check to see if Pre-Owned is not set. If it is not set then only get + // listings without the Pre-Owned + if ( !isset( $_REQUEST['pre_owned'] ) ) { + $queryParts[] = " T.id IN ( + SELECT ref_dest + FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_field_data + WHERE field_data != 'Yes' + AND field_id = (SELECT id + FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_fields + WHERE field_name = 'Pre-Owned') + ) "; + } return $queryParts; }); - + add_filter('glm-member-db-front-search-query-orderby', function($originalOrderBy){ + // Order by clause for Just Arrived. + $orderBy = " ( + SELECT CASE WHEN field_data = 'Yes' THEN 0 ELSE 1 end + FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_field_data + WHERE field_id = (SELECT id + FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_fields + WHERE field_name = 'Just Arrived') + AND ref_dest = T.id) "; + // Order by clause for Red Hot Deal. + $orderBy .= ", ( + SELECT CASE WHEN field_data = 'Yes' THEN 0 ELSE 1 end + FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_field_data + WHERE field_id = (SELECT id + FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_fields + WHERE field_name = 'Red Hot Deal') + AND ref_dest = T.id) "; + // Order by clause for Coming Soon. + $orderBy .= ", ( + SELECT CASE WHEN field_data = 'Yes' THEN 0 ELSE 1 end + FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_field_data + WHERE field_id = (SELECT id + FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_fields + WHERE field_name = 'Coming Soon') + AND ref_dest = T.id) "; + $orderBy .= ", $originalOrderBy DESC "; + return $orderBy; +}); add_filter('glm_blocks', function() { if(function_exists('fetch_all_glm_blocks')) { $blocks = fetch_all_glm_blocks(); @@ -55,7 +94,7 @@ add_filter('glm_block_image', function($id) { echo get_the_post_thumbnail($id, 'glm-block-image'); }); add_filter('get_form_permalink', function($id) { - echo get_permalink($id); + echo get_permalink($id); }); -- 2.17.1