2017 © Pedro Peláez
 

library search

Basic extensions for searching in WordPress.

image

trendwerk/search

Basic extensions for searching in WordPress.

  • Tuesday, September 5, 2017
  • by haroldangenent
  • Repository
  • 1 Watchers
  • 2 Stars
  • 223 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 6 Versions
  • 6 % Grown

The README.md

Search

Build Status codecov, (*1)

Basic extensions for searching in WordPress., (*2)

Quick links: Install | Usage | Dimensions | Example, (*3)

Note: This basic extension is not very scalable and meant for smaller databases. This package could get slow for complex searches. In that case, Elasticsearch would be a better solution., (*4)

Install

composer require trendwerk/search

Usage

  1. Initialize package
  2. Add search dimension(s)

Initialize

$search = new \Trendwerk\Search\Search();
$search->init();

This code should be run when bootstrapping your theme., (*5)

Dimensions

Currently this package supports metadata and terms as search dimensions. Dimensions can be added by using addDimension:, (*6)

$search->addDimension($dimension);
Parameter Default Required Description
$dimension null Yes Should be an instance of a class that implements Dimension\Dimension.

Meta

$metaDimension = new \Trendwerk\Search\Dimension\Meta($wpdb, [
    'key' => 'firstName',
]);

$search->addDimension($metaDimension);

Available options for constructing an instance of Meta:, (*7)

Parameter Default Required Description
key null Yes The meta_key to search for
compare = No The database comparison that should be made for the meta key. Currently supports LIKE and =. When using LIKE, make sure to include a percent symbol (%) in your key parameter as a wildcard. See Example

Terms

$search->addDimension(new \Trendwerk\Search\Dimension\Term($wpdb, [
    'taxonomy' => 'taxonomyName',
]));

Available options for constructing an instance of Term:, (*8)

Parameter Default Required Description
taxonomy null Yes The taxonomy which terms should be included in search

Example

use Trendwerk\Search\Dimension\Meta;
use Trendwerk\Search\Dimension\Term;
use Trendwerk\Search\Search;

$search = new Search();
$search->init();

$search->addDimension(new Meta($wpdb, [
    'compare' => 'LIKE',
    'key'     => 'lastNames%',
]));

$search->addDimension(new Meta($wpdb, [
    'key' => 'firstName',
]));

$search->addDimension(new Term($wpdb, [
    'taxonomy' => 'category',
]));

The Versions

05/09 2017

dev-master

9999999-dev

Basic extensions for searching in WordPress.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.6

 

The Development Requires

05/09 2017

0.2.2

0.2.2.0

Basic extensions for searching in WordPress.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.6

 

The Development Requires

02/06 2017

dev-posts-without-term

dev-posts-without-term

Basic extensions for searching in WordPress.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.6

 

The Development Requires

02/06 2017

0.2.1

0.2.1.0

Basic extensions for searching in WordPress.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.6

 

The Development Requires

24/05 2017

0.2.0

0.2.0.0

Basic extensions for searching in WordPress.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.6

 

The Development Requires

16/02 2017

0.1.0

0.1.0.0

Basic extensions for searching in WordPress.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.6

 

The Development Requires