Hooks, Filters & Constants

This page lists the public API of WP Coder and WP Coder Pro: functions you can call from a theme or plugin, shortcodes, hooks, and wp-config.php constants. Items marked PRO exist only in WP Coder Pro — guard them with function_exists() in code that may run with the free plugin.


Functions#

Function Returns Available
wpcoder_get_repeater( $value ) PRO The rows of a Repeater attribute as an array. Always
wpcoder_mmd( $markdown ) HTML rendered from Markdown. Always
wpc_get_breadcrumbs( $args = [] ) PRO Breadcrumb HTML. See Breadcrumbs. With Enable Breadcrumbs on
wpc_get_icon( $type, $id ) PRO The Extra Icon of a term ('tax') or post ('post'). See Extra Icon. With Enable Extra Icon on
wpc_get_sidebar( $id ) PRO Prints a widget area registered by Register Sidebar (nothing when the area is not registered or empty). Always

wpc_get_breadcrumbs() and wpc_get_icon() exist only while their tool is on. In code shared between sites, guard them:

if ( function_exists( 'wpc_get_breadcrumbs' ) ) {
    echo wpc_get_breadcrumbs();
}

Shortcodes#

Shortcode Purpose
[wp_code id="12"] Render a snippet. Add attribute values: [wp_code id="12" heading="Hi"].
[wp_code title="Hero"] Render a snippet found by its title.
[wp_code id="12"]Text[/wp_code] Pass content — the snippet reads {{$shortcode_content}}.
[WP-Coder id="12"] The older form, still supported.
[wpc_sidebar id="shop-sidebar"] PRO Print a widget area registered by the Register Sidebar tool.

In a theme template:

echo do_shortcode( '' );

Actions#

wpcoder_purge_page_cache PRO#

Fires whenever WP Coder purges page caches — when a snippet is created, updated or deleted, or on Clear Page Cache — just before it purges the caches it knows. Add your own cache here (a CDN, a host cache):

add_action( 'wpcoder_purge_page_cache', function () {
    if ( function_exists( 'my_host_purge_everything' ) ) {
        my_host_purge_everything();
    }
} );

Filters#

wow_coder_lock_window PRO#

Seconds an edit lock lasts without a heartbeat from the other editor. Default 150.

add_filter( 'wow_coder_lock_window', fn() => 300 );

wow_coder_sanitize_svg#

Return false to accept an uploaded SVG without sanitising it. Receives true and the upload $file array. Only for trusted, single-admin sites.

wow_coder_blank_template_dropped_assets PRO#

The asset handles the Blank Template leaves out of a page. Receives $drop (array of handles), $type ('style' or 'script') and $todo (the handles about to be printed). Return the list to drop:

add_filter( 'wow_coder_blank_template_dropped_assets', function ( $drop, $type ) {
    // Keep the theme's font stylesheet on Blank pages.
    return array_diff( $drop, [ 'my-theme-fonts' ] );
}, 10, 2 );

Change the breadcrumb options before the trail is built, or the array of links before output. See Breadcrumbs.

testable_roles PRO#

The roles offered in the Test Users menu. Receives the roles array of WP_Roles.

add_filter( 'testable_roles', function ( $roles ) {
    return array_intersect_key( $roles, array_flip( [ 'subscriber', 'customer' ] ) );
} );

AI Assistant filters PRO#

Only when the AI Assistant is enabled (WPCODER_ENABLE_AI):

  • wow_coder_ai_capability — capability for the AI endpoints; receives the default and the context ('content' or 'snippet').
  • wow_coder_ai_rate_limit / wow_coder_ai_rate_window — requests per user per window (default 60 per 600 seconds; 0 disables the limit).
  • wow_coder_ai_max_prompt_chars — the longest prompt accepted.

Constants (wp-config.php)#

Constant Effect
define( 'WPCODER_SAFE_MODE', true ); Both plugins. Safe Mode for everyone: no snippet PHP and no Global PHP run. For when you can’t log in. Remove it when the snippet is fixed. See PHP Errors & Safe Mode.
define( 'WPCODER_ENABLE_AI', true ); PRO Shows the AI Assistant: its Tools tab, the “Generate with AI” panel in the snippet editor and the AI panel in the block editor. Off by default.
define( 'DISALLOW_UNFILTERED_HTML', true ); WordPress constant. Nobody can open WP Coder or WP Coder Pro — they require unfiltered_html.

Files and data#

  • Snippets — the database table {prefix}wow_coder, shared by both plugins; Pro’s revisions in {prefix}wow_coder_revisions.
  • Generated files — wp-content/uploads/wp-coder/: each snippet’s CSS, JS and PHP and Global PHP (in Pro also the combined per-page files and the icon sprite icons.svg). Include this folder in backups. Missing snippet files are written again from the database; in Pro, after restoring a site without the folder, also run Tools → Developer → Rebuild Combined Files.
  • Settings — options _wp_coder_snippets (Snippets page) and _wp_coder_tools (Tools page).
  • Capability — every screen and save of both plugins requires manage_options and unfiltered_html.