• Hello,

    Thanks for your plugin ! I had some problems to match keywords with special characters like [ ] so I made a small modification => I’ve escaped the “keyword” before the preg_match test (line 264 of class-search-keyword-redirect.php) :
    $keyword = preg_quote($keyword);

    Hope you could add this to your code ??

    Cheers,
    Diego

Viewing 1 replies (of 1 total)
  • Thread Starter schubling

    (@schubling)

    Rectification.. you could replace the “loop through each keyword” by checking directly if the search query is a key of the redirection array.

    This is the updated function “search_keyword_redirect” :

    	/**
    	 * Attempt to match keywords to search query and redirect on match
    	 *
    	 * @since    0.1.0
    	 */
    	public function search_keyword_redirect() {
    
    		if ( ! is_search() ) {
    			return;
    		} // not a search
    
    		// get options
    		$redirects = get_option( 'ww_keyword_redirects' );
    		
    		// check if options exist
    		if ( ! empty( $redirects ) ) {
    
    			if (array_key_exists(get_search_query(), $redirects)){
    				// redirect to url
    				wp_redirect( $redirects[get_search_query()][0] );
    				exit();
    			}
    
    			// no keywords matched
    			unset( $redirects );
    
    			return;
    
    		} else {
    
    			return; // no redirects
    
    		}
    
    	} // END search_keyword_redirect()

    Regards,
    Diego

Viewing 1 replies (of 1 total)
  • The topic ‘Escape search’ is closed to new replies.