From 6fe675e9533125cbbe842404d381d315dadc001b Mon Sep 17 00:00:00 2001 From: Ronald Huereca Date: Fri, 6 Oct 2023 22:39:51 -0500 Subject: [PATCH] New action: syntax_highlighting_code_block_highlighter_init New action: `syntax_highlighting_code_block_highlighter_init` - Fires in the `render_block` function after the highlighter has been initialized. Helps fix: https://github.com/westonruter/syntax-highlighting-code-block/issues/191 --- inc/functions.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/inc/functions.php b/inc/functions.php index 31b183c1..188bf786 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -716,6 +716,15 @@ function render_block( array $attributes, string $content ): string { $highlighter->setAutodetectLanguages( $auto_detect_languages ); } + /** + * Fires after the highlighter is initialized. + * + * @param \Highlight\Highlighter $highlighter Highlighter. + * @param array $attributes Block attributes. See constant ATTRIBUTE_SCHEMA. + * @param string $content Block's original content. + */ + do_action( 'syntax_highlighting_code_block_highlighter_init', $highlighter, $attributes, $content ); + $language = $attributes['language']; // Note that the decoding here is reversed later in the escape() function.