Indepth Analytics Structured Metadata
Adds structured metadata tags and optional header scripts to WordPress pages.
Install in
Indepth Analytics Structured Metadata adds structured metadata tags to the <head> section of WordPress pages. The plugin outputs information about posts, pages, taxonomy archives, and search pages using custom indepth:* meta properties.
The plugin can also load an optional external header script configured by administrators from the WordPress dashboard.
Supported metadata includes:
- Content type (
indepth:type) - Featured image URL (
indepth:featured-image) - Publication date (
indepth:published-date) - Current language (
indepth:lang) - Categories and taxonomy terms (
indepth:categories) - Authors and author avatars (
indepth:authors,indepth:authors-thumbnails)
The plugin works with standard WordPress APIs and follows WordPress coding and security practices.
Features:
- Outputs
indepth:*metadata tags in the document head - Supports posts, pages, archives, and search results
- Optional taxonomy selection for category metadata
- Optional external header script loader
- Translation-ready
- Compatible with PHP 8.0 and newer
Author resolution for developers
indepth:authors and `indepth:authors-thumbnails` are built from one shared, ordered list of user IDs, so names and pictures always describe the same people in the same order. The list is resolved once per post per request (in memory only; nothing is stored in the database).
Author IDs: execution order
- Default list: the post’s
post_author, followed by the user IDs in theindepth_analytics_authorspost meta (behaviour of 1.1.0, unchanged). apply_filters( 'indepth_analytics_author_ids', int[] $author_ids, int $post_id, WP_Post $post ). The return value replaces the list. To add to it, merge with$author_ids.- Normalization: accepted values are an array of IDs or a comma-separated string. Only positive integers and digit-only strings are kept; other values (arrays, objects, floats, booleans) are discarded, never cast. IDs that do not belong to an existing user are removed. Duplicates are removed, keeping the first occurrence.
- Fallback: if nothing valid remains, the default list from step 1 is used.
A callback that calls back into the resolver for the same post receives the default list (no recursion). The order of the returned array is the order of output.
Author thumbnails: execution order (for each resolved author)
apply_filters( 'indepth_analytics_author_thumbnail', null, int $user_id, WP_User $user ). Return an image attachment ID (int or digit-only string) or an absolutehttp(s)URL; returnnullto use the default.- Attachment IDs must belong to an existing image attachment that is not trashed or private; the URL comes from
wp_get_attachment_image_url( $id, 'thumbnail' ). - URLs are sanitized with
esc_url_raw()and must be absolutehttp/httpsURLs.
- Attachment IDs must belong to an existing image attachment that is not trashed or private; the URL comes from
- Otherwise
get_avatar_url( $user_id ). - Authors without any URL are skipped in
indepth:authors-thumbnails.
Security expectations
Treat both filters as data sources only: return IDs or URLs, never HTML. The plugin validates every value it receives and escapes all output with esc_attr(). The plugin never writes to posts, users or meta.
Example: theme storing authors in its own post meta
add_filter( 'indepth_analytics_author_ids', function ( $author_ids, $post_id ) {
$ids = get_post_meta( $post_id, 'my_theme_authors', true ); // e.g. array( 12, 7 )
return is_array( $ids ) && $ids ? $ids : $author_ids;
}, 10, 2 );
Example: a third-party co-author plugin
add_filter( 'indepth_analytics_author_ids', function ( $author_ids, $post_id ) {
if ( ! function_exists( 'get_coauthors' ) ) {
return $author_ids;
}
$ids = array();
foreach ( get_coauthors( $post_id ) as $coauthor ) {
if ( $coauthor instanceof WP_User ) { // guest authors without a user account are skipped
$ids[] = $coauthor->ID;
}
}
return $ids ? $ids : $author_ids;
}, 10, 2 );
Example: attachment-based profile picture in user meta
add_filter( 'indepth_analytics_author_thumbnail', function ( $thumbnail, $user_id ) {
$attachment_id = (int) get_user_meta( $user_id, 'my_profile_picture_id', true );
return $attachment_id > 0 ? $attachment_id : $thumbnail;
}, 10, 2 );
The meta keys above are examples; use the keys your theme or plugin actually stores.
Written by Joobi from the project's own listing. See the source page
1.2.0
- Added the
indepth_analytics_author_idsfilter so themes and plugins can supply the post’s authors from any source. - Added the
indepth_analytics_author_thumbnailfilter for attachment-based or custom author pictures. indepth:authorsandindepth:authors-thumbnailsnow use one shared, validated author list (same people, same order); invalid, deleted and duplicate user IDs are ignored.- Without any integration the output is unchanged:
post_authorfollowed byindepth_analytics_authors.
1.1.0
- Reduced meta output to:
indepth:type,indepth:featured-image,indepth:published-date,indepth:lang,indepth:categories,indepth:authors,indepth:authors-thumbnails. - Removed
indepth:id,indepth:post-type,indepth:read-time,indepth:collaborators,indepth:collaborators-thumbnailsandindepth:translations. indepth:typeis now one ofhome(front page or blog home),single(posts) orpage(everything else).- Meta tags are now output on every front-end page, including search results and 404 pages.
- Added a “Settings” link to the plugin’s row on the Plugins screen.
1.0.1
- Lowered the minimum required PHP version from 8.2 to 8.0.
1.0.0
- Initial release.
- Added structured metadata output for WordPress content.
- Added taxonomy metadata support.
- Added optional external header script support.
- Added Polylang translation support.
- Added translation-ready language files.
Follow this listing's changes (Atom feed)