Skip to content

Commit

Permalink
UPD: docs search logic
Browse files Browse the repository at this point in the history
  • Loading branch information
MjHead committed Sep 28, 2017
1 parent 2a6c604 commit c0041c6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
29 changes: 25 additions & 4 deletions includes/handlers/class-wapu-core-docs-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ public function sanitize_query( $query ) {

$query = strtolower( $query );
$exceptions = $this->args['exceptions'];
$query = str_replace( array(
'.',
',',
'\'',
'"',
':',
'\\',
'/',
), '', $query );

if ( empty( $exceptions ) || ! array_key_exists( $query, $exceptions ) ) {
return $query;
Expand Down Expand Up @@ -190,19 +199,31 @@ public function get_by_id_from_api( $id = 0 ) {
*/
public function search_by_theme_name( $query ) {

$search_in = array( $query );

if ( ! empty( $this->args['ignored-prefixes'] ) ) {
$query = str_replace( $this->args['ignored-prefixes'], '', $query );
$search_in[] = str_replace( $this->args['ignored-prefixes'], '', $query );

foreach ( $this->args['ignored-prefixes'] as $prefix ) {

if ( false === strpos( $query , $prefix ) ) {
$search_in[] = $prefix . $query;
}
}

}

foreach ( array( '_', '-', '' ) as $replace ) {
$search_in[] = str_replace( ' ', $replace, $query );
}

$replaced = str_replace( ' ', $replace, $query );
$result = $this->request_by_name( $replaced );
$search_in = array_unique( array_filter( $search_in ) );

foreach ( $search_in as $s ) {
$result = $this->request_by_name( $s );
if ( $result ) {
return $result;
}

}

}
Expand Down
4 changes: 2 additions & 2 deletions wapu-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Wapuu Core
* Plugin URI: http://www.cherryframework.com/plugins/
* Description: Core for jetimpex.com.
* Version: 1.1.8
* Version: 1.1.9
* Author: JetImpex
* Author URI: http://cherryframework.com/
* Text Domain: wapu-core
Expand Down Expand Up @@ -63,7 +63,7 @@ class Wapu_Core {
*
* @var string
*/
private $version = '1.1.8';
private $version = '1.1.9';

/**
* Core page trigger
Expand Down

0 comments on commit c0041c6

Please sign in to comment.