From bcde369804040cfedab91e99cb6e7830f8bd0b61 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Tue, 24 Nov 2015 10:58:59 -0500 Subject: [PATCH] removed html tags from search context with jquery --- js/app.js | 28 +++++++--------------------- js/custom/pageSetup.js | 28 +++++++--------------------- search.php | 6 +++--- 3 files changed, 17 insertions(+), 45 deletions(-) diff --git a/js/app.js b/js/app.js index dd8db19..c690b98 100644 --- a/js/app.js +++ b/js/app.js @@ -30,7 +30,7 @@ $(document).ready(function () { } // }); - var start, context, end, arrival, currentDate, currentDate2, requiredDate, requiredDate1, minDays, departure, stay, d, dd, m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&', + var start, context, context2, end, arrival, currentDate, currentDate2, requiredDate, requiredDate1, minDays, departure, stay, d, dd, m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&', crookedRiver = 'ZhWXD46i2%2fq319vcR%2fcw69rZvA2bz%2fttOOxO9t1%2fBJ0%3d&', adults, kids, @@ -218,25 +218,11 @@ $(document).ready(function () { $('.searchform').css("right", "5px"); $("li a.search").css("visibility", "visible"); }); - $('.search-result-container p.search_result_context').find('br').remove().text(); - - - - - - + $('.search-result-container p.search_result_context:contains("
")').remove(); + $('.search-result-container p.search_result_context').text(function () { + return $(this).text().replace(/(<([^>]+)>)/ig, ""); + }); - - - - - - - - - - - - - + + }); diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index 9cc0c91..5dac5a9 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -21,7 +21,7 @@ $(document).ready(function () { } // }); - var start, context, end, arrival, currentDate, currentDate2, requiredDate, requiredDate1, minDays, departure, stay, d, dd, m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&', + var start, context, context2, end, arrival, currentDate, currentDate2, requiredDate, requiredDate1, minDays, departure, stay, d, dd, m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&', crookedRiver = 'ZhWXD46i2%2fq319vcR%2fcw69rZvA2bz%2fttOOxO9t1%2fBJ0%3d&', adults, kids, @@ -209,25 +209,11 @@ $(document).ready(function () { $('.searchform').css("right", "5px"); $("li a.search").css("visibility", "visible"); }); - $('.search-result-container p.search_result_context').find('br').remove().text(); - - - - - - + $('.search-result-container p.search_result_context:contains("
")').remove(); + $('.search-result-container p.search_result_context').text(function () { + return $(this).text().replace(/(<([^>]+)>)/ig, ""); + }); - - - - - - - - - - - - - + + }); diff --git a/search.php b/search.php index 2002624..1795b61 100644 --- a/search.php +++ b/search.php @@ -37,9 +37,9 @@ // Load content as plain text global $wp_query, $post; - + $content = (!post_password_required($post) ? strip_tags(preg_replace(array("/\r?\n/", '@<\s*(p|br\s*/?)\s*>@'), array(' ', "\n"), apply_filters('the_content', $post->post_content))) : ''); - + // Search content for terms $terms = $wp_query->query_vars['search_terms']; if ( preg_match_all('/'.str_replace('/', '\/', join('|', $terms)).'/i', $content, $matches, PREG_OFFSET_CAPTURE) ) { @@ -75,7 +75,7 @@ // Highlight matches $context = nl2br(preg_replace('/'.str_replace('/', '\/', join('|', $terms)).'/i', '$0', $output)); - + ?>

-- 2.17.1