DocumentationReference

Filters

The 28 hooks the plugin exposes, what each one changes, and worked examples of the ones people reach for most.

The plugin exposes 28 filters. The list is generated from the source, so it is what is actually in the code.

Everything here is a WordPress filter: add a callback, return a modified value. Nothing requires a class to be extended or a file to be replaced.

Scanning

FilterWhat it changes
wsak_allow_content_fallbackWhether a page may be checked against its stored content when the server cannot fetch the rendered page.
wsak_browser_rulesThe checks the browser pass performs.
wsak_builder_contentThe rendered output to scan for a page built by a page builder, rather than its stored post content.
wsak_loopback_worksThe verdict on whether this site can make HTTP requests to itself. Return null to let the plugin find out.
wsak_page_htmlThe HTML a scan runs against, before any rule sees it.
wsak_page_source_sslverifyWhether the loopback request verifies TLS. Useful on staging with a self-signed certificate.
wsak_post_typesThe post types the plugin knows about.
wsak_readability_minimum_wordsHow many words a page needs before its reading level is measured.
wsak_rulesThe server-pass ruleset.
wsak_scannable_post_typesListing a site's content with what is known about each piece.
wsak_template_representativesChecking the theme once, instead of once per post.
wsak_vague_link_phrasesThe phrases treated as link text that does not say where it goes, such as "click here".

Fixing

FilterWhat it changes
wsak_can_dismissWhether a given user may dismiss a given finding as a false positive.
wsak_can_dismiss_site_wideDeciding about one piece of markup everywhere it appears.
wsak_enabled_site_fixesSwitching site-wide fixes on and off, and running the ones that are on.
wsak_may_upload_pdfStopping PDFs being added without anybody thinking about them.
wsak_site_fixesThe site-wide fixes the plugin knows about.
wsak_skip_link_appliesA skip link, for themes that have none.

Reporting

FilterWhat it changes
wsak_next_stepThe one thing worth doing next.
wsak_report_dataThe data behind the report, before it is rendered or exported.
wsak_report_formatsThe formats a report can be exported as.
wsak_scan_scoreScan result.
wsak_simplified_summaryThe plain-language summary shown for a page.
wsak_statement_htmlAccessibility statement rendering.

Admin and access

FilterWhat it changes
wsak_column_post_typesAccessibility state, in the lists people already look at.
wsak_menu_positionWhere the plugin sits in the admin menu.
wsak_role_capabilitiesCustom capabilities.
wsak_servicesPlugin orchestrator.

Worked examples

Scan a custom post type

add_filter( 'wsak_post_types', function ( array $types ): array {
    $types[] = 'product';

    return $types;
} );

Only post types the current user may edit are ever offered, so this grants nobody access they did not already have.

Force a site-wide fix on

add_filter( 'wsak_enabled_site_fixes', function ( array $enabled ): array {
    $enabled[] = 'skip-link';

    return array_unique( $enabled );
} );

Let only administrators dismiss findings everywhere

add_filter( 'wsak_can_dismiss_site_wide', function ( bool $can, int $user_id ): bool {
    return user_can( $user_id, 'manage_options' );
}, 10, 2 );

Let an editor run scans without seeing the whole report

The two capabilities exist to make exactly this distinction.

add_filter( 'wsak_role_capabilities', function ( array $map ): array {
    $map['author'] = array( 'wsak_run_scan' );

    return $map;
} );

Capabilities are granted when the filter runs and revoked on uninstall, so a role added here is cleaned up properly.

Work with a page builder the plugin does not know

add_filter( 'wsak_builder_content', function ( string $html, int $post_id ): string {
    if ( ! my_builder_handles( $post_id ) ) {
        return $html;
    }

    return my_builder_render( $post_id );
}, 10, 2 );

Allow scanning on a staging box with a self-signed certificate

add_filter( 'wsak_page_source_sslverify', '__return_false' );

Staging only. Turning off certificate verification in production is a bad trade.

Add a check of your own

add_filter( 'wsak_rules', function ( array $rules ): array {
    $rules[] = new My_Rule();

    return $rules;
} );

A rule implements the plugin’s Rule interface: an id, a WCAG success criterion, a severity, whether it can be settled automatically, and the check itself. Read an existing rule in src/Scanner/Rules/ before writing one — they are short, and they are the best documentation of the interface.

The browser pass works the same way through wsak_browser_rules, with one difference: a finding naming a check outside the registered list is discarded rather than stored, because the browser is treated as an untrusted caller.

Last updated . Something here wrong or missing? Tell us and we will fix it.