# Pre-Publish Check for Vague Link Text

> Lists links whose text is "click here", "read more", "here" or a bare URL in the block editor's pre-publish panel, so authors can rewrite them to describe where they lead.

- Type: PHP
- Runs: Admin only
- Category: [Accessibility](https://wpide.com/library/category/accessibility/)
- Tags: links, block-editor, wcag
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/a11y-prepublish-vague-links/

## Code

```php
add_action( 'enqueue_block_editor_assets', function () {
    wp_register_script( 'wpide-vague-links', '', array( 'wp-plugins', 'wp-editor', 'wp-element', 'wp-data' ), null, true );
    wp_enqueue_script( 'wpide-vague-links' );
    wp_add_inline_script( 'wpide-vague-links', <<<'JS'
(function (wp) {
    var el = wp.element.createElement;
    var Panel = (wp.editor && wp.editor.PluginPrePublishPanel) || (wp.editPost && wp.editPost.PluginPrePublishPanel);
    if (!Panel) { return; }
    var vague = ['click here', 'here', 'read more', 'more', 'link', 'this', 'learn more', 'this page', 'continue'];
    function Check() {
        var html = wp.data.useSelect(function (select) { return select('core/editor').getEditedPostContent(); }, []);
        var doc = new DOMParser().parseFromString(html || '', 'text/html');
        var found = [];
        doc.querySelectorAll('a[href]').forEach(function (a) {
            var text = (a.textContent || '').trim().toLowerCase().replace(/[.!:]+$/, '');
            if (vague.indexOf(text) !== -1 || /^https?:\/\//.test(text) || (!text && !a.querySelector('img[alt]:not([alt=""])'))) {
                found.push((a.textContent || '').trim() || '(no text)');
            }
        });
        return el(Panel, { title: 'Link text', initialOpen: found.length > 0 },
            found.length ? el('div', null, el('p', null, 'These links do not say where they lead:'), el('ul', null, found.map(function (t, i) { return el('li', { key: i }, t); })))
                         : el('p', null, 'All links have descriptive text.'));
    }
    wp.plugins.registerPlugin('wpide-vague-links', { render: Check });
})(window.wp);
JS
    );
} );
```

## Notes

Add phrases in your language to the vague list in the script.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Pre-Publish Check for Vague Link Text" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
