AriLinks has one shortcode, six filters, two actions and one REST route. It has no blocks, widgets or WP-CLI commands.
Shortcode
| Shortcode | Attributes | What it does |
|---|---|---|
[arilinks_skip]…[/arilinks_skip] | None | Keeps the enclosed content free of automatic links. Shortcodes inside it are still run. The link report respects it too. |
Filters
| Filter | Parameters | What it does |
|---|---|---|
arilinks_is_allowed | bool $allowed, WP_Post $post | Last word on whether a post gets automatic links in the current request. Runs after the built-in checks (single view of the main post, not in the admin or feeds, not password protected). |
arilinks_pre_filter | string|null $pre, string $content, WP_Post $post | Return a string to use as the linked HTML and skip processing. Return null to let AriLinks process the content. |
arilinks_rule_applies | bool $applies, array $rule, WP_Post|null $post | Decide whether one rule applies to a post. Runs after the rule's own content type, page and self-link checks. |
arilinks_link_attributes | array $attrs, array $rule, WP_Post|null $post | Change the attributes of an automatic link (name => value). href is escaped with esc_url(), the others with esc_attr(). |
arilinks_editor_keywords_cap | string $cap | Capability needed to use Keywords that link here in the editor. Default edit_others_posts. |
arilinks_rule_conditions | array $conditions, array $input | For add-ons: extra conditions to store with a rule when it is saved from the Add link form. Only used when a callback is attached. The result is stored as JSON in the rule's conditions field. |
The $rule array holds the rule's columns: id, keyword, variants (one per line), url, target_post, post_types, nofollow, new_tab, case_sensitive, max_per_post, only_posts and conditions, plus _url, the resolved target address.
add_filter( 'arilinks_is_allowed', function ( $allowed, $post ) {
return $allowed && ! has_category( 'news', $post );
}, 10, 2 );
add_filter( 'arilinks_link_attributes', function ( $attrs, $rule, $post ) {
$attrs['title'] = $rule['keyword'];
return $attrs;
}, 10, 3 );
Actions
| Action | Parameters | When it runs |
|---|---|---|
arilinks_after_process | WP_Post $post, string $content, string $out | After AriLinks has linked a post's content, with the original and the linked HTML. Not run when arilinks_pre_filter returned a string. |
arilinks_rule_form_fields | array|null $rule | Inside the Add link form table, after Only on these pages. Print extra <tr> rows here. $rule is null for a new link. |
PHP helper
AriLinks_Frontend::link_html( $html, $post = null ) adds automatic links to HTML that belongs to the post being viewed on its single page, using the same rules and checks as the post content. It does not run arilinks_pre_filter or arilinks_after_process. With no $post, it uses the current post. It returns the HTML unchanged when the post is not allowed to get links.
REST route
| Route | Method | Parameters | Response |
|---|---|---|---|
/wp-json/arilinks/v1/click | POST | id (required, integer): the rule ID | {"ok":true} with status 200; {"ok":false} with status 400 when id is 0 or click tracking is off. |
The route is public. The front-end script calls it when a visitor clicks an automatic link with the left or middle mouse button. Requests with an empty user agent or one that looks like a bot return 200 without counting. Each visitor and link is counted at most once every 20 seconds; the rate-limit key is a hash of the IP address and rule ID made with the site's salt, and expires after 20 seconds.
Link markup
An automatic link looks like this:
<a href="https://example.com/running-shoes/" class="arilink" data-arilink="12" target="_blank" rel="nofollow noopener">running shoes</a>
classis the CSS class setting, left out when it is empty.data-arilinkholds the rule ID and is only added while click tracking is on. The click script is only loaded on pages that contain such a link.target="_blank"andrel="noopener"come from Open in a new tab;rel="nofollow"from Add rel="nofollow".
Data stored
| Where | Name | What it holds |
|---|---|---|
| Tables | {prefix}arilinks_rules | Link rules and their click totals. |
| Tables | {prefix}arilinks_stats | Clicks per rule per day. |
| Tables | {prefix}arilinks_index, {prefix}arilinks_edges | The link report: counts per page and which page links to which. |
| Options | arilinks_settings, arilinks_db_version, arilinks_rules_version, arilinks_index_version | Settings and version markers. |
| Transient | arilinks_active_rules | Cached active rules with their target addresses, for up to a day. |
| Transient | arilinks_c_{hash} | Click rate limit per visitor and link, for 20 seconds. |
| Post meta | _arilinks_off | Set when Do not add automatic links on this page is ticked. |
With Uninstall ticked in Settings, deleting the plugin removes all of these. On multisite, each site follows its own setting.
Still stuck?
Our helpdesk answers on working days, Norwegian time. Include your WordPress version, PHP version and the page address.