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: 42
public function __construct( );
enqueue_editor_assets()
Enqueue editor script and pass language data.
Since: 1.0.0
Line: 54
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.
Only background/color are extracted and re-injected with
.block-editor-block-list__layout prepended, to beat the editor’s own pre rule on
specificity (0,2,1 vs 0,1,1) without disrupting block layout.
Since: 1.1.0
Line: 107
public function enqueue_editor_canvas_styles( ): void;
Returns: void
register_rest_routes()
Register REST API routes.
Since: 1.1.0
Line: 162
public function register_rest_routes( ): void;
Returns: void
save_default_settings()
Save default block settings via REST API.
Since: 1.1.0
Line: 204
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: 249
public function render_code_block( string $block_content, array $block ): string;
| Type | Name | Description |
|---|---|---|
string |
$block_content |
The 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: 1220
static public function get_languages( ): array;
Returns: array — string>