Markdown Renderer for GitHub Hooks Reference
This reference lists the public WordPress hooks exposed by Markdown Renderer for GitHub. Use these hooks from a theme, site-specific plugin, or add-on plugin when you need to customize rendering, multilingual behavior, asset loading, SEO output, settings, metadata, or performance features without editing the plugin.
Hook callbacks should keep WordPress conventions: return the same type documented by the filter, escape output when you generate markup, and keep expensive work out of high-frequency rendering hooks.
Quick Reference
Rendering and Output
| Hook | Type | Signature | Purpose |
|---|---|---|---|
gfmr_pre_render_markdown | Filter | string $content, array $context | Modify Markdown before the renderer builds HTML. |
gfmr_render_markdown | Filter | string $output, string $content, array $context | Modify final shortcode/content-rendered HTML. |
gfmr_after_render | Action | string $output, string $content, array $context | Run side effects after Markdown rendering completes. |
gfmr_block_attributes | Filter | array $attributes | Adjust block attributes before block rendering. |
gfmr_block_render_output | Filter | string $output, array $attributes, string $content | Modify rendered block HTML. |
gfmr_iframe_safe_mode | Filter | bool $enabled | Enable or disable iframe safe mode in block configuration. |
Diagrams, Syntax Highlighting, and Performance
| Hook | Type | Signature | Purpose |
|---|---|---|---|
gfmr_chart_image_ssr_enabled | Filter | bool $enabled | Enable or disable front-end Chart.js image baking. |
gfmr_use_prerendered_diagrams | Filter | bool $use_prerendered, array $attributes | Force or bypass baked diagram HTML for a block. |
gfmr_shiki_languages | Filter | array $languages | Extend the list of Shiki languages. |
gfmr_shiki_themes | Filter | array $themes | Extend available Shiki themes. |
gfmr_worker_line_threshold | Filter | int $threshold | Set the minimum code line count for Worker rendering. |
gfmr_worker_config | Filter | array $worker_config | Modify Worker Manager settings. |
gfmr_enable_workers | Filter | bool $enabled | Enable or disable Web Workers for syntax highlighting. |
gfmr_enable_service_worker | Filter | bool $enabled | Enable or disable the vendor-caching Service Worker. |
gfmr_exclude_heavy_pages_from_prerender | Filter | bool $enabled | Exclude heavy diagram pages from browser prerender rules. |
gfmr_compression_health_assets | Filter | array $assets | Customize bundles checked by the compression Site Health test. |
Multilingual and Language Switcher
| Hook | Type | Signature | Purpose |
|---|---|---|---|
gfmr_multilingual_enabled | Filter | bool $enabled | Enable or disable multilingual features. |
gfmr_multilingual_enqueue_assets | Filter | bool $enqueue | Control multilingual asset loading. |
gfmr_multilingual_url_enabled | Filter | bool $enabled | Enable or disable path-based multilingual URL rewriting. |
gfmr_multilingual_taxonomy_current_language | Filter | string $language, int $post_id, array $settings | Override current language detection for multilingual taxonomy logic. |
gfmr_language_switcher_enabled | Filter | bool $enabled, string $context, array $args | Disable the language switcher before HTML is generated. |
gfmr_language_flag_map | Filter | array $map | Customize language-code to flag mapping. |
gfmr_language_name_map | Filter | array $names | Customize language-code to display-name mapping. |
gfmr_featured_image_post_types | Filter | array $post_types | Select post types that support per-language featured images. |
gfmr_featured_image_thirdparty_multilingual_active | Filter | bool $active | Override third-party multilingual plugin detection for featured images. |
SEO and Schema
| Hook | Type | Signature | Purpose |
|---|---|---|---|
gfmr_meta_description_enabled | Filter | bool $enabled | Enable or disable per-language meta descriptions. |
gfmr_meta_description_post_types | Filter | array $post_types | Select post types that support per-language descriptions. |
gfmr_meta_description | Filter | string $description, WP_Post $post, string $lang | Modify the resolved meta description. |
gfmr_meta_description_fallback_to_default | Filter | bool $fallback | Control fallback to the default language description. |
gfmr_meta_description_output_og | Filter | bool $output | Control og:description output. |
gfmr_meta_description_output_twitter | Filter | bool $output | Control twitter:description output. |
gfmr_meta_description_thirdparty_multilingual_active | Filter | bool $active | Override third-party multilingual plugin detection. |
gfmr_meta_description_seo_plugin_active | Filter | bool $active | Override SEO plugin conflict detection. |
gfmr_meta_description_theme_handles | Filter | bool $active | Override theme-level meta description detection. |
gfmr_schema_data | Filter | array $schema, WP_Post $post | Modify generated structured data. |
gfmr_breadcrumb_schema | Filter | array $list, WP_Post $post | Modify generated breadcrumb schema. |
Settings, Extensions, Metadata, and Licensing
| Hook | Type | Signature | Purpose |
|---|---|---|---|
gfmr_loaded | Action | string $version | Initialize add-ons after the plugin loads. |
gfmr_registered_addons | Filter | array $addons | Register add-ons with the extension API. |
gfmr_feature_flags | Filter | array $flags | Register or override feature flags. |
gfmr_frontend_config | Filter | array $config_data | Extend localized front-end configuration. |
gfmr_enqueue_assets | Action | string $context | Enqueue add-on assets for frontend or admin. |
gfmr_settings_tabs_list | Filter | array $tabs | Add or modify settings tabs. |
gfmr_settings_tabs | Action | string $page_slug, array $tabs | Render settings tab UI. |
gfmr_settings_sections | Action | string $page_slug, string $tab_id | Render custom settings sections for a tab. |
gfmr_post_list_column_post_types | Filter | array $post_types | Choose post types that receive the GFMR language column. |
gfmr_metadata_saved | Action | int $post_id, array $metadata | React after code block metadata is saved. |
gfmr_metadata_get_metadata | Filter | array $metadata, int $post_id | Modify stored code block metadata when read. |
gfmr_is_pro_active | Filter | bool $active | Tell free-version code that Pro features are active. |
gfmr_pro_feature_registered | Action | string $feature_id, array $feature | React when a Pro feature is registered. |
gfmr_pro_feature_unregistered | Action | string $feature_id | React when a Pro feature is removed. |
gfmr_pro_license_changed | Action | No parameters | React after Pro license state changes. |
Common Examples
Disable the Language Switcher
This filter runs before language-switcher HTML is generated, so it avoids unnecessary rendering work.
add_filter(
'gfmr_language_switcher_enabled',
function ( bool $enabled, string $context, array $args ): bool {
if ( is_singular( 'docs' ) && 'header' === $context ) {
return false;
}
return $enabled;
},
10,
3
);Customize Mermaid or Chart Output
Use the block output filter when you need to add wrapper attributes around rendered diagram content. Always return sanitized HTML.
add_filter(
'gfmr_block_render_output',
function ( string $output, array $attributes, string $content ): string {
if ( false === strpos( $content, '```mermaid' ) ) {
return $output;
}
return '<div class="docs-diagram-frame">' . $output . '</div>';
},
10,
3
);To bypass baked diagram HTML for a particular block, use gfmr_use_prerendered_diagrams.
add_filter(
'gfmr_use_prerendered_diagrams',
function ( bool $use_prerendered, array $attributes ): bool {
if ( ! empty( $attributes['forceLiveDiagramRender'] ) ) {
return false;
}
return $use_prerendered;
},
10,
2
);Register a Shiki Language or Theme
add_filter(
'gfmr_shiki_languages',
function ( array $languages ): array {
$languages[] = 'toml';
return array_values( array_unique( $languages ) );
}
);
add_filter(
'gfmr_shiki_themes',
function ( array $themes ): array {
$themes['docs-dark'] = 'github-dark-dimmed';
return $themes;
}
);Tune Worker-Based Syntax Highlighting
The Worker threshold controls when long code blocks move off the main thread.
add_filter(
'gfmr_worker_line_threshold',
function (): int {
return 12;
}
);Filter Rendered Markdown Output
add_filter(
'gfmr_render_markdown',
function ( string $output, string $content, array $context ): string {
if ( empty( $context['post_id'] ) ) {
return $output;
}
return str_replace(
'class="gfmr-markdown-container"',
'class="gfmr-markdown-container docs-rendered-markdown"',
$output
);
},
10,
3
);Add Schema Metadata
add_filter(
'gfmr_schema_data',
function ( array $schema, WP_Post $post ): array {
if ( has_term( 'reference', 'category', $post ) ) {
$schema['about'] = 'Developer documentation';
}
return $schema;
},
10,
2
);Register an Add-On
add_filter(
'gfmr_registered_addons',
function ( array $addons ): array {
$addons['my-company-docs'] = array(
'name' => 'My Company Docs Enhancer',
'version' => '1.0.0',
'author' => 'My Company',
);
return $addons;
}
);