Skip to content
New site — Virtual Media Folders now has its own home.Visit vmf.soderlind.no →

Developer Documentation

Technical reference for developers extending or contributing to Loupe - Admin Search.

Loupe - Admin Search maintains its own search indexes, separate from the main Loupe Search plugin. This allows the admin to index all post statuses relevant to editorial workflows (publish, draft, pending, private, future), whereas the main plugin only indexes published content.

Indexes are stored at {loupe_search_db_path}/admin/{entity_type}/ as SQLite databases, i.e. wp-content/loupe-search-db/admin/ by default. On sites carried over from WP Loupe, where wp-content/wp-loupe-db/ already exists and wp-content/loupe-search-db/ does not, the legacy directory is used instead — matching Loupe Search’s own fallback. They are created automatically on the first admin page load and kept in sync incrementally.

Every indexed post type gets these core fields:

Field Searchable Filterable Sortable Weight
post_title ✓ ✓ ✓ 3.0
post_content ✓ 1.0
post_excerpt ✓ 1.5
post_name ✓ 1.0
post_status ✓ —
post_date ✓ ✓ —
author_name ✓ ✓ ✓ 2.0

Taxonomy fields are added automatically for each show_ui taxonomy attached to the post type (e.g. taxonomy_category, taxonomy_post_tag):

Field Searchable Filterable Sortable Weight
taxonomy_{name} ✓ ✓ 1.5

Weights control how much each field contributes to search relevance. A weight of 3.0 means a match in post_title ranks three times higher than a match in post_content.

Any field not matched to a WP_Post property, virtual field, or taxonomy falls back to get_post_meta().

Field Searchable Filterable Sortable Weight
display_name ✓ ✓ ✓ 3.0
user_login ✓ ✓ 2.0
user_email ✓ ✓ 2.0
user_role ✓ —
Field Searchable Filterable Sortable Weight
comment_content ✓ 1.0
comment_author ✓ ✓ ✓ 2.0
comment_author_email ✓ ✓ 1.0
comment_date ✓ ✓ —
Field Searchable Filterable Sortable Weight
plugin_name ✓ ✓ ✓ 3.0
plugin_description ✓ 1.0
plugin_author ✓ ✓ 2.0
plugin_status ✓ —

Filter the indexed fields for any entity type. Use this to add custom meta fields to the search index.

Renamed from wp_loupe_admin_schema in 1.3.0. The old name still fires via apply_filters_deprecated() and will be removed in a future major release.

add_filter( 'loupe_admin_search_schema', function ( array $fields, string $entity_type ): array {
if ( 'post' === $entity_type ) {
$fields['my_custom_meta'] = [
'searchable' => true,
'filterable' => false,
'sortable' => false,
'weight' => 1.0,
];
}
return $fields;
}, 10, 2 );

After changing the schema, delete the admin index folder (loupe-search-db/admin/) to trigger a full rebuild on the next admin page load.

Search endpoint with scope parameter. Also available at the deprecated wp-loupe-admin/v1/search alias, which will be removed in a future major release.

Method: GET

Parameters:

Parameter Type Required Description
s string yes Search query
scope string no Search scope: content (default), users, plugins, comments
page integer no Page number (default 1)

Capability requirements per scope:

Scope Required Capability
content edit_posts
users list_users
plugins activate_plugins
comments moderate_comments

The plugin intercepts native WordPress admin search in three places:

  • Posts list table — via posts_pre_query filter in WP_Loupe_Admin_Query_Integration
  • Users list table — via pre_get_users in WP_Loupe_Admin_User_Query_Integration
  • Comments list table — via pre_get_comments in WP_Loupe_Admin_Comment_Query_Integration

Each integration includes a re-entrancy guard to prevent infinite loops.

When the WordPress Command Palette package is registered in admin, the wp-loupe-admin-addon script also depends on wp-commands, wp-data, and wp-element. The same script registers a dynamic command loader named wp-loupe-admin/search-results.

The loader reuses loupe-admin-search/v1/search instead of adding a separate endpoint. Available scopes are localized from the current user’s capabilities, and each scope is queried independently with a small per-scope limit. Permission failures, missing indexes, or other per-scope errors are ignored so one unavailable scope does not break the whole palette.

Returned hits are mapped to Command Palette commands with stable wp-loupe-admin/{scope}/{id} names. Selecting a result closes the palette and navigates to the result’s editUrl, falling back to viewUrl when no edit URL is available.

Terminal window
# Rebuild all admin indexes
wp loupe-admin reindex
# Show index status
wp loupe-admin status
Class Responsibility
WP_Loupe_Admin_Loader Request-scoped singleton bootstrap
WP_Loupe_Admin_Schema Field definitions per entity type
WP_Loupe_Admin_Indexer Post type indexing
WP_Loupe_Admin_User_Indexer User indexing
WP_Loupe_Admin_Comment_Indexer Comment indexing
WP_Loupe_Admin_Plugin_Indexer Plugin indexing (non-DB source)
WP_Loupe_Admin_Query_Integration posts_pre_query interception
WP_Loupe_Admin_User_Query_Integration pre_get_users interception
WP_Loupe_Admin_Comment_Query_Integration pre_get_comments interception
WP_Loupe_Admin_Rest REST API endpoint
WP_Loupe_Admin_Search Dashboard widget, admin bar, modal UI
WP_Loupe_Admin_CLI WP-CLI commands
WP_Loupe_Admin_Notice Admin notice for stale/missing indexes

Install dependencies:

Terminal window
composer install
npm install

Build JavaScript:

Terminal window
npm run build

Watch during development:

Terminal window
npm run dev:js

Run tests:

Terminal window
./vendor/bin/phpunit
npm run test:js

Generate translation files:

Terminal window
npm run i18n
  • src/js/ — Source JavaScript
  • lib/js/ — Built JavaScript
  • lib/css/ — Built CSS
  • includes/ — PHP classes
  • tests/ — PHPUnit and Vitest tests
  • scripts/ — Build scripts
  • languages/ — Translation files