Skip to content

Commit

Permalink
Attempt to fix quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaydsouza committed Dec 11, 2024
1 parent 0df0eb5 commit 0857b13
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions better-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@
* @copyright 2009-2025 Ajay D'Souza
*
* @wordpress-plugin
* Plugin Name: Better Search
* Plugin Name: Better Search Pro
* Plugin URI: https://webberzone.com/plugins/better-search/
* Description: Replace the default WordPress search with a contextual search. Search results are sorted by relevancy ensuring a better visitor search experience.
* Version: 4.0.3
* Version: 4.0.4-beta1
* Update URI: https://api.freemius.com
* Author: WebberZone
* Author URI: https://webberzone.com/
* Text Domain: better-search
* License: GPL-2.0+
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /languages
* GitHub Plugin URI: https://github.com/WebberZone/better-search/
*
* @fs_premium_only /includes/pro/
*/

namespace WebberZone\Better_Search;
Expand Down
11 changes: 6 additions & 5 deletions includes/class-better-search-core-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,19 +541,17 @@ public function get_match_sql( $search_query, $args = array() ) {
$weight_title = $args['weight_title'] ?? bsearch_get_option( 'weight_title' );
$weight_content = $args['weight_content'] ?? bsearch_get_option( 'weight_content' );
$boolean_mode = $this->is_boolean_mode ? ' IN BOOLEAN MODE' : '';
$search_query = wp_specialchars_decode( $search_query );
$search_query = wp_specialchars_decode( $search_query, ENT_QUOTES );

$field_score = '';

// Create the base MATCH part of the FIELDS clause.
if ( $this->use_fulltext ) {
// Prepare the query once and use it with prepared arguments.
$field_score = $wpdb->prepare(
"(MATCH({$wpdb->posts}.post_title) AGAINST (%s {$boolean_mode}) * %d) + " . // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
"(MATCH({$wpdb->posts}.post_content) AGAINST (%s {$boolean_mode}) * %d)", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$search_query,
"(MATCH({$wpdb->posts}.post_title) AGAINST ('{$search_query}' {$boolean_mode}) * %d) + " . // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
"(MATCH({$wpdb->posts}.post_content) AGAINST ('{$search_query}' {$boolean_mode}) * %d)", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$weight_title,
$search_query,
$weight_content
);
}
Expand Down Expand Up @@ -753,6 +751,8 @@ public function posts_search( $where, $query ) {
}

foreach ( (array) $search_terms as $term ) {
$term = str_replace( array( "'", '"', '"', '\+', '\-' ), '', $term );

// If there is an $exclusion_prefix, terms prefixed with it should be excluded.
$exclude = $exclusion_prefix && ( substr( $term, 0, 1 ) === $exclusion_prefix );
if ( $exclude ) {
Expand All @@ -775,6 +775,7 @@ public function posts_search( $where, $query ) {
// Let's do a LIKE search for all other fields.
$searchand = '';
foreach ( (array) $search_terms as $term ) {
$term = str_replace( array( "'", '"', '"', '\+', '\-' ), '', $term );
$clause = array();

// If there is an $exclusion_prefix, terms prefixed with it should be excluded.
Expand Down

0 comments on commit 0857b13

Please sign in to comment.