Developer API
Hooks, filters and data shapes for extending WP MyLinks.
The hooks and data shapes below are public API in WP MyLinks 1.1.0 and later: they follow semantic versioning and will not break within a major version. Anything not listed here is internal and may change without notice.
Template actions
Each fires in the standalone bio-page template and receives the current MyLink post ID.
| Hook | Where it fires |
|---|---|
wp_mylinks_head |
Inside <head>, after the plugin’s own assets and user scripts |
wp_mylinks_body_open |
Immediately after <body> |
wp_mylinks_before_links |
Before the links list |
wp_mylinks_after_links |
After the links list, inside the main element |
wp_mylinks_footer |
Inside the footer, before its closing tag |
Rendering filters
wp_mylinks_link_data( array $link, int $post_id, int $link_index )— filters one link row’s data before it renders. Return an empty value to skip the link entirely (scheduling, targeting, A/B).wp_mylinks_link_render( string $item_html, array $link, int $post_id, int $link_index )— filters one rendered link item’s escaped HTML. Return an empty string to drop the item.wp_mylinks_schema_data( array $data, int $post_id )— the Schema.org array before JSON encoding.wp_mylinks_og_meta( array $og_lines, int $post_id )— the pre-escaped Open Graph and Twitter Card meta lines.wp_mylinks_cpt_rewrite_slug( string $slug )— the internal rewrite slug (defaultmylink). Public URLs are slug-stripped either way.wpmylinks_url_params( array $params, string $base_url )— campaign parameters appended to the plugin’s own outbound links.
Admin extension surface
wp_mylinks_meta_boxes( array $boxes )— the registered metabox definitions, keyed by box id. Add, remove or amend boxes here.wp_mylinks_field_types( array $map )— the field-type string to class map. Built-in types includetext,text_url,textarea_small,select,radio,radio_inline,wysiwyg,file,oembed,group,pw_selectandcolorpicker. Classes must extendWp_Mylinks_Field.wp_mylinks_settings_tabs( array $tabs )— the settings-page tabs, keyed by tab slug. Each entry isarray( 'dashicon-slug', 'Label', $render_callable ).
Analytics
The action wp_mylinks_track_link_click( int $post_id, string $url, string $hash, int $count ) fires after a link click is recorded by the built-in counter.
| Meta key | Shape |
|---|---|
wp_mylinks_count_visits |
Integer page views, incremented per non-bot render. |
wp_mylinks_link_clicks |
An array of md5( link URL ) to integer count. wp_mylinks_get_link_clicks_total( $post_id ) sums it. |
Example: skip a link with a filter
// Drop any link pointing at example.com before it renders.
add_filter( 'wp_mylinks_link_data', function ( $link, $post_id, $index ) {
if ( ! empty( $link['url'] ) && false !== strpos( $link['url'], 'example.com' ) ) {
return ''; // returning empty skips this row
}
return $link;
}, 10, 3 );