Skip to content

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

HookTypeSignaturePurpose
gfmr_pre_render_markdownFilterstring $content, array $contextModify Markdown before the renderer builds HTML.
gfmr_render_markdownFilterstring $output, string $content, array $contextModify final shortcode/content-rendered HTML.
gfmr_after_renderActionstring $output, string $content, array $contextRun side effects after Markdown rendering completes.
gfmr_block_attributesFilterarray $attributesAdjust block attributes before block rendering.
gfmr_block_render_outputFilterstring $output, array $attributes, string $contentModify rendered block HTML.
gfmr_iframe_safe_modeFilterbool $enabledEnable or disable iframe safe mode in block configuration.

Diagrams, Syntax Highlighting, and Performance

HookTypeSignaturePurpose
gfmr_chart_image_ssr_enabledFilterbool $enabledEnable or disable front-end Chart.js image baking.
gfmr_use_prerendered_diagramsFilterbool $use_prerendered, array $attributesForce or bypass baked diagram HTML for a block.
gfmr_shiki_languagesFilterarray $languagesExtend the list of Shiki languages.
gfmr_shiki_themesFilterarray $themesExtend available Shiki themes.
gfmr_worker_line_thresholdFilterint $thresholdSet the minimum code line count for Worker rendering.
gfmr_worker_configFilterarray $worker_configModify Worker Manager settings.
gfmr_enable_workersFilterbool $enabledEnable or disable Web Workers for syntax highlighting.
gfmr_enable_service_workerFilterbool $enabledEnable or disable the vendor-caching Service Worker.
gfmr_exclude_heavy_pages_from_prerenderFilterbool $enabledExclude heavy diagram pages from browser prerender rules.
gfmr_compression_health_assetsFilterarray $assetsCustomize bundles checked by the compression Site Health test.

Multilingual and Language Switcher

HookTypeSignaturePurpose
gfmr_multilingual_enabledFilterbool $enabledEnable or disable multilingual features.
gfmr_multilingual_enqueue_assetsFilterbool $enqueueControl multilingual asset loading.
gfmr_multilingual_url_enabledFilterbool $enabledEnable or disable path-based multilingual URL rewriting.
gfmr_multilingual_taxonomy_current_languageFilterstring $language, int $post_id, array $settingsOverride current language detection for multilingual taxonomy logic.
gfmr_language_switcher_enabledFilterbool $enabled, string $context, array $argsDisable the language switcher before HTML is generated.
gfmr_language_flag_mapFilterarray $mapCustomize language-code to flag mapping.
gfmr_language_name_mapFilterarray $namesCustomize language-code to display-name mapping.
gfmr_featured_image_post_typesFilterarray $post_typesSelect post types that support per-language featured images.
gfmr_featured_image_thirdparty_multilingual_activeFilterbool $activeOverride third-party multilingual plugin detection for featured images.

SEO and Schema

HookTypeSignaturePurpose
gfmr_meta_description_enabledFilterbool $enabledEnable or disable per-language meta descriptions.
gfmr_meta_description_post_typesFilterarray $post_typesSelect post types that support per-language descriptions.
gfmr_meta_descriptionFilterstring $description, WP_Post $post, string $langModify the resolved meta description.
gfmr_meta_description_fallback_to_defaultFilterbool $fallbackControl fallback to the default language description.
gfmr_meta_description_output_ogFilterbool $outputControl og:description output.
gfmr_meta_description_output_twitterFilterbool $outputControl twitter:description output.
gfmr_meta_description_thirdparty_multilingual_activeFilterbool $activeOverride third-party multilingual plugin detection.
gfmr_meta_description_seo_plugin_activeFilterbool $activeOverride SEO plugin conflict detection.
gfmr_meta_description_theme_handlesFilterbool $activeOverride theme-level meta description detection.
gfmr_schema_dataFilterarray $schema, WP_Post $postModify generated structured data.
gfmr_breadcrumb_schemaFilterarray $list, WP_Post $postModify generated breadcrumb schema.

Settings, Extensions, Metadata, and Licensing

HookTypeSignaturePurpose
gfmr_loadedActionstring $versionInitialize add-ons after the plugin loads.
gfmr_registered_addonsFilterarray $addonsRegister add-ons with the extension API.
gfmr_feature_flagsFilterarray $flagsRegister or override feature flags.
gfmr_frontend_configFilterarray $config_dataExtend localized front-end configuration.
gfmr_enqueue_assetsActionstring $contextEnqueue add-on assets for frontend or admin.
gfmr_settings_tabs_listFilterarray $tabsAdd or modify settings tabs.
gfmr_settings_tabsActionstring $page_slug, array $tabsRender settings tab UI.
gfmr_settings_sectionsActionstring $page_slug, string $tab_idRender custom settings sections for a tab.
gfmr_post_list_column_post_typesFilterarray $post_typesChoose post types that receive the GFMR language column.
gfmr_metadata_savedActionint $post_id, array $metadataReact after code block metadata is saved.
gfmr_metadata_get_metadataFilterarray $metadata, int $post_idModify stored code block metadata when read.
gfmr_is_pro_activeFilterbool $activeTell free-version code that Pro features are active.
gfmr_pro_feature_registeredActionstring $feature_id, array $featureReact when a Pro feature is registered.
gfmr_pro_feature_unregisteredActionstring $feature_idReact when a Pro feature is removed.
gfmr_pro_license_changedActionNo parametersReact 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.

php
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.

php
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.

php
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

php
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.

php
add_filter(
    'gfmr_worker_line_threshold',
    function (): int {
        return 12;
    }
);

Filter Rendered Markdown Output

php
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

php
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

php
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;
    }
);