🚨 This plugin has been deprecated. Please move the to Findkit plugin as soon as possible.
https://github.com/findkit/wp-findkit
WordPress plugin for Valu Search.
This plugin has two features
- Instructs the Valu Search Crawler on how to crawl and scrape the site
- Sends live updates to the Valu Search Index as content creators add, update and delete pages
This plugin does not provide any UI. It just exposes some config options and filters for developers.
It's on Packagist
composer require valu/wp-valu-search
If not using composer download a .zip from the releases page and extract it
to wp-content/plugins
.
The plugin adds a script tag to pages on your site.
If you wish to test the plugin behaviour on your site after installing it, simply refresh page, and look for script tag with id="valu-search"
.
Live updates are sent optimistically whenever the plugin thinks the content might have changed on a page. The cloud backend then does a scraping request on the page to determine what the update actually was (add, update, delete) if any.
To enable the real time updates add provided credentials to the wp-config:
define("VALU_SEARCH_USERNAME", "username");
define("VALU_SEARCH_API_SECRET", "****"); // Used to be called VALU_SEARCH_UPDATE_API_KEY
define("VALU_SEARCH_ENABLE_LIVE_UPDATES", true);
There's a filter for controlling the update process.
In the event of changing posts/pages permalink the new url gets indexed, but the old url remains in the index until the next full site crawl.
/old-url --> /new-url // new url is indexed
In the event that the changed page was of a hierarchical post type, only the updated page gets reindexed. Other pages that depend on slug of the changed page, eg. child pages get updated during next full crawl.
/old-url --> /new-url // new-url is indexed
/old-url/sub-page --> /new-url/sub-page // new-url/sub-page is not indexed.
The search endpoint access can be limited using a JWT authentication. This plugin
can automatically generate JWT tokens for the @valu/react-valu-search
package.
The token are generated only for logged in users but it can be customized with
valu_search_allow_search_jwt
filter.
Add this to wp-config.php
to enable it:
define("VALU_SEARCH_API_SECRET", "****");
define("VALU_SEARCH_AUTHENTICATED_SEARCH", true);
This feature requires PHP-JWT to be installed.
Parameters
$selector
(string) CSS selector for picking the content elements$post
(WP_Post) the post of the page being indexed
Multiple selectors can be separated by comma. Ex. .content,.main
Parameters
$selector
(string) CSS selector for picking the content elements$post
(WP_Post) the post of the page being indexed
Multiple selectors can be separated by comma. Ex. .content,.main
Matching html content is indexed separately from previous valu_search_content_selector
.
Content is not highlighted in the search ui, but behaves exactly like other content
including being searchable and language analyzed.
Parameters
$selector
(string) CSS selector for removing elements$post
(WP_Post) The post of the page being indexed
Remove content from selected elements.
Parameters
$show
(boolean) whether to index the page at all$post
(WP_Post) the post of the page being indexed
$show
is false if post status is not public OR if the post is archive.
Parameters
$title
(string) if the post being indexed is archive, the archive title otherwise the post title$post
(WP_Post) the post of the page being indexed
By default HTML entities in $title
are decoded using html_entity_decode. To use HTML entities in titles filter $title
through htmlentities.
Parameters
$created
(date) the created date of page being indexed$post
(WP_Post) the post of the page being indexed
Parameters
$modified
(date) the modified date of page being indexed$post
(WP_Post) the post of the page being indexed
Parameters
$tags
(string[]) Array of tags$post
(WP_Post) the post of the page being indexed
List of tags the page gets indexed with. By default the post type, taxonomy
terms, static wordpress
and public
/ private
tags are added. These tags
can be used to build custom filtering UIs.
Parameters
$custom_fields_associative_array
(array("keyword"=>[], "date"=>[], "number"=>[]);) Associative array containing all custom fields associative arrays$post
(WP_Post) the post of the page being indexed
Custom fields related to the page.
Parameters
$custom_fields_date_associative_array
([]) Associative_array containing custom date field key value pairs$post
(WP_Post) the post of the page being indexed
Custom date fields related to the page. e.g. eventStart, eventEnd
Parameters
$custom_fields_keyword_associative_array
([]) Associative_array containing custom keyword field key value pairs$post
(WP_Post) the post of the page being indexed
Custom keyword fields related to the page. e.g. productPreview, productId
Parameters
$custom_fields_number_associative_array
([]) Associative_array containing custom keyword field key value pairs$post
(WP_Post) the post of the page being indexed
Custom number fields related to the page. e.g. productPrice
Parameters
$superwords
(string[]) Array of superwords$post
(WP_Post) the post of the page being indexed
List of superwords indexed with the page. By default empty array. Superwords can be used to mark page as an important search result for the superwords given. Search results with matching superwords are shown first in results.
$meta
(assoc array)$post
(WP_Post) the post of the page being indexed
The full data rendered to the meta tag.
See all available fields on https://search.valu.pro/page-meta
$meta
(assoc array)$post
(WP_Post) the post of the page being indexed
Global options for the crawler exposed on yoursite.example/valu-search.json
.
See all available fields on https://search.valu.pro/site-meta
Parameters
$should_update
(boolean) defaults to value ofphp_sapi_name() !== 'cli'
$post
(WP_Post) the post of the page being updated
Return false to prevent the page from being updated.
$show_notices
(boolean) defaults to false
Return true to enable notices about live updates in wp-admin
Action is fired everytime live update request is done
$response
return type ofwp_remote_request()
(array|WP_Error)
Enqueues a post live update to be sent at the end of the WordPress request in
the shutdown
action. Can be called multiple times and the update will be
batched.
Immediately live update the given posts.