From: Steve Sutton Date: Mon, 29 Oct 2018 17:04:18 +0000 (-0400) Subject: Update the query additions for wmta member search X-Git-Tag: v1.0.39^2~4 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=4ae3430d7b29cb65dc0fea2fd9d648abc5ab033f;p=WP-Themes%2Fwmta.git Update the query additions for wmta member search Move these queries into the main plugin. --- diff --git a/functions.php b/functions.php index 5731fb7..0324e84 100644 --- a/functions.php +++ b/functions.php @@ -408,45 +408,43 @@ function new_mail_from_name($old) { return 'WMTA'; } -add_filter('glm-member-db-front-search-query', function( $queryParts ){ - if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) { - $textSearch = addslashes(filter_var($_REQUEST['s'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)); - // Split the search by spaces - $sub_parts = explode( ' ', $textSearch ); - $name_part = $desc_part = $city_part = array(); - foreach ( $sub_parts as $part ) { - $name_part[] = " name SOUNDS LIKE '%$part%' OR name LIKE '%$part%'"; - $desc_part[] = " T.descr SOUNDS LIKE '%$part%' OR T.descr LIKE '%$part%'"; - $city_part[] = " name SOUNDS LIKE '%$part%' OR name LIKE '%$part%'"; - } - // echo '
$sub_parts: ' . print_r( $sub_parts, true ) . '
'; - $query_parts = " ( - ( - SELECT true - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members - WHERE id = T.member - AND ("; - if ( $name_part ) { - $query_parts .= implode( ' OR ', $name_part ); - } - $query_parts .= ") - ) OR "; - if ( $desc_part ) { - $query_parts .= implode( ' OR ', $desc_part ); - } - $query_parts .= "OR T.city IN ( - SELECT id - FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "cities - WHERE "; - if ( $city_part ) { - $query_parts .= implode( ' OR ', $city_part ); - } - // $query_parts .= " name SOUNDS LIKE '%$textSearch%' OR name LIKE '%$textSearch%'"; - - $query_parts .= ") - )"; - $queryParts[] = $query_parts; - } - // echo '
$queryParts: ' . print_r( $queryParts, true ) . '
'; - return $queryParts; -}); +// add_filter('glm-member-db-front-search-query', function( $queryParts ){ +// return $queryParts; +// if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) { +// $textSearch = addslashes(stripslashes(filter_var($_REQUEST['s'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES))); +// // echo '
$textSearch: ' . print_r( $textSearch, true ) . '
'; +// $subParts = array(); +// // $subParts[] = " match(member_name) against('$textSearch')"; +// // Split the search by spaces +// // $sub_parts = explode( ' ', $textSearch ); +// // $name_part = $desc_part = $city_part = array(); +// // foreach ( $sub_parts as $part ) { +// //$name_part[] = " name SOUNDS LIKE '%$part%' OR name LIKE '%$part%'"; +// // $name_part[] = " match(name) against('$part')"; +// // $desc_part[] = " T.descr SOUNDS LIKE '%$part%' OR T.descr LIKE '%$part%'"; +// // $city_part[] = " name SOUNDS LIKE '%$part%' OR name LIKE '%$part%'"; +// // } +// // echo '
$sub_parts: ' . print_r( $sub_parts, true ) . '
'; +// // $query_parts = " ( +// // ( +// // SELECT true +// // FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members +// // WHERE id = T.member +// // AND ("; +// // $query_parts = " ( "; +// // if ( $name_part ) { +// // $query_parts .= implode( ' OR ', $name_part ); +// // } +// // $query_parts .= ") +// // ) OR "; +// // if ( $desc_part ) { +// // $query_parts .= implode( ' OR ', $desc_part ); +// // } +// $subParts[] = " T.city IN ( SELECT id FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "cities WHERE name SOUNDS LIKE '%$textSearch%' OR name LIKE '%$textSearch%' ) "; +// // $subParts[] = " ( T.descr SOUNDS LIKE '%$textSearch%' OR T.descr LIKE '%$textSearch%' )"; +// $queryParts[] = '( '.implode( ' OR ', $subParts ).' )'; +// // $queryParts[] = $query_parts; +// } +// // echo '
$queryParts: ' . print_r( $queryParts, true ) . '
'; +// return $queryParts; +// }); diff --git a/inc/custom.php b/inc/custom.php index 3435cb0..b9ad0be 100644 --- a/inc/custom.php +++ b/inc/custom.php @@ -126,11 +126,11 @@ add_filter('pre_get_posts', 'change_wp_search_size'); // Hook our custom functio function display_memberfindme_directory() { // Show MemberFindMe shortcode from Directory page - //$_REQUEST['textSearch'] = $_REQUEST['s']; - $_REQUEST['s'] = stripslashes( $_REQUEST['s'] ); + // $_REQUEST['s'] = stripslashes( $_REQUEST['s'] ); + $_REQUEST['textSearch'] = $_REQUEST['s']; $_REQUEST['action'] = 'list'; $_REQUEST['event_name'] = $_REQUEST['s']; - echo do_shortcode('[glm-members-list view="grid"]'); + echo do_shortcode('[glm-members-list view="grid" text-search="'.stripslashes($_REQUEST['s']).'"]'); if( isset($_REQUEST['event_name']) && !empty($_REQUEST['event_name'])){ echo do_shortcode('[glm-members-event-list limit="10"]'); echo 'View All Events';