Blocks
Blocks class.
Namespace: WebberZone\Code_Block_Highlighting\Frontend
Since: 1.0.0
Source: includes/frontend/class-blocks.php line 24
Methods
__construct()
Constructor.
Since: 1.0.0
Line: 32
public function __construct( );
enqueue_editor_assets()
Enqueue editor script and pass language data.
Since: 1.0.0
Line: 44
public function enqueue_editor_assets( ): void;
Returns: void
enqueue_editor_canvas_styles()
Enqueue editor layout styles and inject the active Prism theme into the block editor iframe canvas.
enqueue_block_editor_assets only loads styles into the outer editor shell.
Since WordPress 6.0 the editing canvas runs in an iframe, styles must be
registered via enqueue_block_assets to appear inside it.
The block editor’s .block-editor-block-list__layout pre rule (specificity
0,1,1) overrides Prism’s pre[class*="language-"] (also 0,1,1) by source
order. To beat it, only the background and color declarations are
extracted from the active Prism theme file and re-injected inline with
.block-editor-block-list__layout prepended, raising specificity to 0,2,1.
Layout properties (margin, padding, position, overflow) are intentionally
excluded to avoid disrupting the editor’s block positioning.
Only runs in the admin context to avoid duplicating the frontend enqueue
that Styles_Handler already handles via wp_enqueue_scripts.
Since: 1.1.0
Line: 108
public function enqueue_editor_canvas_styles( ): void;
Returns: void
register_rest_routes()
Register REST API routes.
Since: 1.1.0
Line: 189
public function register_rest_routes( ): void;
Returns: void
save_default_settings()
Save default block settings via REST API.
Since: 1.1.0
Line: 231
public function save_default_settings( WP_REST_Request $request ): WP_REST_Response;
| Type | Name | Description |
|---|---|---|
\WP_REST_Request | $request | The REST request. |
Returns: WP_REST_Response
render_code_block()
Filter the rendered HTML of core/code blocks to inject highlighting attributes.
In client mode (Prism.js): injects language classes and data-attributes so the
Prism JS bundle can highlight in the browser.
In server mode (highlight.php): runs the highlighter server-side and replaces the
innerHTML before the page is sent; no Prism JS is loaded.
Since: 1.0.0
Line: 276
public function render_code_block( string $block_content, array $block ): string;
Type Name Description string$block_contentThe rendered block HTML. array$block
Returns: string
get_languages() static
Get the list of supported Prism.js languages.
The array key must match a valid Prism language alias.
See https://prismjs.com/#supported-languages
Since: 1.0.0
Line: 874
static public function get_languages( ): array;
Returns: array — string>