diff --git a/readme.txt b/readme.txt index e4fdee93e..f39951f5c 100644 --- a/readme.txt +++ b/readme.txt @@ -146,6 +146,7 @@ You can view (and contribute) translations via the [translate.wordpress.org](htt * Fix - Handle WP 4.3 signup notification. * Fix - Map mime types to those that WordPress knows. * Fix - Alert text color. +* Fix - Searches containing special chars. * Tweak - Improved uploader error handling and updated library. * Tweak - Improve job_manager_user_can_post_job and job_manager_user_can_edit_job capability handling in job-submit.php * Tweak - Clear transients in batches of 500. diff --git a/wp-job-manager-functions.php b/wp-job-manager-functions.php index d3a8aadba..aa9036b69 100644 --- a/wp-job-manager-functions.php +++ b/wp-job-manager-functions.php @@ -147,11 +147,16 @@ function get_job_listings_keyword_search( $args ) { global $wpdb, $job_manager_keyword; // Query matching ids to avoid more joins - $post_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value LIKE '%" .esc_sql( $job_manager_keyword ) . "%'" ); + $post_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value LIKE '%" . esc_sql( $job_manager_keyword ) . "%'" ); $conditions = array(); $conditions[] = "{$wpdb->posts}.post_title LIKE '%" . esc_sql( $job_manager_keyword ) . "%'"; - $conditions[] = "{$wpdb->posts}.post_content RLIKE '[[:<:]]" . esc_sql( $job_manager_keyword ) . "[[:>:]]'"; + + if ( ctype_alnum( $job_manager_keyword ) ) { + $conditions[] = "{$wpdb->posts}.post_content RLIKE '[[:<:]]" . esc_sql( $job_manager_keyword ) . "[[:>:]]'"; + } else { + $conditions[] = "{$wpdb->posts}.post_content LIKE '%" . esc_sql( $job_manager_keyword ) . "%'"; + } if ( $post_ids ) { $conditions[] = "{$wpdb->posts}.ID IN (" . esc_sql( implode( ',', $post_ids ) ) . ")";