-
Notifications
You must be signed in to change notification settings - Fork 62
Filter Hooks
Michael Beckwith edited this page Oct 11, 2022
·
20 revisions
The available filters and how to use them to customize the behavior.
Filters are a way to alter data during the lifecycle of a request.
The plugin has an exclude mechanism to not display certain post types in the admin UI.
By default, the following post types are disabled:
- nav_menu_item
- revision
- algolia_task
- algolia_log
- kr_request_token
- kr_access_token
- deprecated_log
- async-scan-result
- scanresult
For example, if you have a plugin that is introducing a custom content type, but it is meant to be used internally and you don't want to expose it for indexing.
<?php
function mb_exclude_custom_post_type( array $exclude ) {
$exclude[] = 'custom_post_type';
return $exclude;
}
add_filter( 'algolia_excluded_post_types', 'mb_exclude_custom_post_type' );Your custom_post_type will no longer appear for indexing in the indexing screen. This will also disable tasks being generated for that content type.
Here is the list of all available Filters.
| Filter Name | Params |
|---|---|
| algolia_autocomplete_config | $config |
| algolia_autocomplete_input_selector | string $input_selector, defaults to "input[name='s']:not('.no-autocomplete')" |
| algolia_excluded_post_types | array $exclude, defaults to array( 'nav_menu_item', revision' ) |
| algolia_excluded_taxonomies | array $exclude, defaults to array( 'nav_menu', link_category', 'post_format' ) |
| algolia_should_index_searchable_post | bool $should_index, WP_Post $post |
| algolia_searchable_post_{$post_type}_shared_attributes | array $shared_attributes, WP_Post $post |
| algolia_searchable_posts_index_settings | array $settings |
| algolia_searchable_post_shared_attributes | array $shared_attributes, WP_Post $post |
| algolia_searchable_post_content | string $content |
| algolia_searchable_posts_index_synonyms | array $synonyms |
| algolia_should_force_settings_update | bool $should_force_update (default: false), string $index_id |
| algolia_should_index_post | bool $should_index, WP_Post $post |
| algolia_post_shared_attributes | array $shared_attributes, WP_Post $post |
| algolia_post_{$post_type}_shared_attributes | array $shared_attributes, WP_Post $post |
| algolia_post_content | string $content |
| algolia_post_records | array $records, WP_Post $post |
| algolia_post_{$post_type}_records | array $records, WP_Post |
| algolia_posts_index_settings | array $settings, string $post_type |
| algolia_posts_{$post_type}_index_settings | array $settings |
| algolia_posts_index_synonyms | array $synonyms, string $post_type |
| algolia_posts_{$post_type}_index_synonyms | array $synonyms |
| algolia_should_index_term | bool $should_index, WP_Term/object $term |
| algolia_term_record | array $record, WP_Term/object$term |
| algolia_term_{$taxonomy}_record | array $record, WP_Term/object $term |
| algolia_terms_index_settings | array $settings |
| algolia_terms_{$taxonomy}_index_settings | array $settings |
| algolia_terms_index_synonyms | array $synonyms, string $taxonomy |
| algolia_terms_{$taxonomy}_index_synonyms | array $synonyms |
| algolia_should_index_user | bool $should_index, WP_User $user |
| algolia_user_record | array $record, WP_User $user |
| algolia_users_index_settings | array $settings |
| algolia_users_index_synonyms | array $synonyms |
| algolia_index_replicas | array $replicas, Algolia_Index $index |
| algolia_{$index_id}_index_replicas | array $replicas, Algolia_Index $index |
| algolia_config | array $config |
| algolia_indexing_batch_size | int $batch_size (default: 100) |
| algolia_{$index_id}_indexing_batch_size | int $batch_size |
| algolia_templates_path | string $path (default: 'algolia/') |
| algolia_template_locations | array $locations |
| algolia_default_template | string $template, string $file |
| algolia_search_params | array $params |
| algolia_search_order_by | string $attribute_name |
| algolia_search_order | string $order |
| algolia_should_override_search_with_instantsearch | bool $bool (default: depending on configuration) |
| algolia_post_images_sizes | array $sizes (default: only the 'thumbnail' size) |
| algolia_get_post_images | array $images (default: only the info about the 'thumbnail' size) |
| algolia_get_synced_indices_ids | array $ids |
| algolia_strip_patterns | array $noise_patterns (default: regular expressions to strip comments, cdata, script, style, code, and pre) |
| algolia_searchable_post_types | array $post_types |
| algolia_native_search_index_id | string $index_id |
| algolia_should_require_search_client | bool $bool, (default: true, loads the included Algolia search client library) |