Skip to content

Commit

Permalink
Searches containing special chars.
Browse files Browse the repository at this point in the history
Fixes #554
  • Loading branch information
mikejolley committed Nov 3, 2015
1 parent 9436861 commit 63b2481
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 7 additions & 2 deletions wp-job-manager-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) . ")";
Expand Down

0 comments on commit 63b2481

Please sign in to comment.