Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions search-meter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Text Domain: search-meter
Domain Path: /languages

$Revision: 2843167 $
$Revision: 2542977 $


INSTRUCTIONS
Expand Down Expand Up @@ -279,23 +279,28 @@ function tguy_sm_save_search($posts) {
// Setting to true will record duplicates (the fact that it's a dupe will be recorded in the
// details). This will mess up the stats, but could be useful for troubleshooting.
$record_duplicates = apply_filters('search_meter_record_duplicates', false);

// Get all details of this search
// Filter search string
$search_string = $wp_query->query_vars['s'];
$len = (strlen($search_string) > 0);
$www = ('www' === substr($search_string, 0, 3));
$slashes = (false !== strpos($search_string, '/'));

if (is_search()
&& !is_paged() // not the second or subsequent page of a previously-counted search
&& !tguy_is_admin_interface() // not using the administration console
&& (0 === $tguy_sm_save_count || $record_duplicates)
&& (tguy_sm_array_value($_SERVER, 'HTTP_REFERER')) // proper referrer (otherwise could be search engine, cache...)
&& ($len or $www or $slashes)
) {
$options = get_option('tguy_search_meter');

// Break out if we're supposed to ignore admin searches
if (tguy_sm_array_value($options, 'sm_ignore_admin_search') && current_user_can("manage_options")) {
return $posts; // EARLY EXIT
}

// Get all details of this search
// search string is the raw query
$search_string = $wp_query->query_vars['s'];

// search terms is the words in the query
$search_terms = $search_string;
$search_terms = preg_replace('/[," ]+/', ' ', $search_terms);
Expand Down