WebberZone Code Block Highlighting
Syntax highlighting for the Gutenberg Code block — Prism.js, 21 themes, 40+ languages, plus an optional server-side highlighting mode.
Install in
WebberZone Code Block Highlighting is the easiest way to add syntax highlighting to your WordPress site. It extends the native Gutenberg core/code block with Prism.js highlighting in the browser, or optional server-side highlighting with highlight.php — no shortcodes, no block replacement, no risk of breaking existing posts.
Simply activate the plugin and your code blocks will instantly display beautiful, readable syntax highlighting on the frontend. Choose from 40+ programming languages and 21 colour themes, all controlled from the block editor’s Inspector Controls sidebar.
Two highlighting modes
Pick the rendering mode that best fits your site from the settings page:
- Client-side (default) — Prism.js highlights your code in the browser. Best for interactive features such as copy-to-clipboard and expand/collapse.
- Server-side (highlight.php) — Code is pre-highlighted on the server with highlight.php, so no Prism.js or any other JavaScript is loaded for highlighting, except on pages with a code block too large for the server, which Prism.js highlights in the browser. Ideal for performance, Core Web Vitals, AMP-style setups, and strict content-security policies.
Both modes use the same 21 Prism themes and produce visually identical output, so you can switch between client-side and server-side rendering at any time without changing how your code blocks look.
Why use this plugin?
- Safe by design — Works as a filter on top of
core/codeand saves blocks with core’s own markup. Existing posts are never invalidated. Deactivate the plugin and your blocks are still valid standard WordPress code blocks. - Zero configuration — Activate and start writing. No setup wizard, no shortcodes.
- No highlighting JavaScript in server mode — Server-side mode pre-renders syntax colours on the server. No Prism.js or any other JavaScript is enqueued for highlighting, except on pages with a block too large for the server.
- Smart asset loading — Theme CSS (and, in client mode, Prism JS) only load on pages that actually contain code blocks. Pages without code stay fast.
- Per-block controls — Set language, theme, line numbers, word wrap, title, highlighted lines, and max height individually for each block.
- Developer-friendly — Filters to add languages, override themes, and force asset loading.
Supported languages
42 languages including: Apache Config, Bash, C, C++, C#, CSS, Dart, Diff, Docker, F#, Go, GraphQL, Groovy, Haskell, HTML, Java, JavaScript, JSON, JSX, Kotlin, Kujo, Lua, Markdown, Nginx, Objective-C, Perl, PHP, PowerShell, Python, R, Ruby, Rust, Sass, Scala, SQL, Swift, TOML, TSX, TypeScript, Vim, XML, YAML. Use the wzcbh_languages filter to add or remove entries from the language picker.
Included themes (21)
A11y Dark, Coldark Cold (Light), Coldark Dark, Dracula, Duotone Dark, Duotone Light, GitHub (Light), Gruvbox Dark, Gruvbox Light, Lucario, Material Dark, Material Light, Night Owl, Nord, One Dark, One Light, Shades of Purple, Solarized Dark, Synthwave ’84, VS Code Dark+, Xonokai (Monokai).
Per-block features
- Language selector — Choose the programming language from the sidebar; applies the correct Prism grammar automatically.
- Line numbers — Toggle line numbers per block, with a configurable start line.
- File title / label — Add an optional filename or label displayed in the code block toolbar.
- Highlight lines — Specify lines or ranges (e.g.
1,3-5) to visually highlight using Prism’s line-highlight plugin. - Max height with expand/collapse — Set a maximum height in pixels; an expand/collapse toolbar button appears automatically.
- Word wrap — Toggle soft word wrapping per block.
Global settings
- Highlighting mode — client-side (Prism.js) or server-side (highlight.php)
- Default colour scheme (theme)
- Default language
- Default line numbers toggle and start value
- Default word wrap
- Copy-to-clipboard button
- Show language label in toolbar
- Font size
Developer filters
wzcbh_languages— Filter the language list array (slug => label)wzcbh_color_scheme_css_url— Override the Prism theme CSS URLwzcbh_force_load_assets— Force Prism assets to load on every page
GDPR
WebberZone Code Block Highlighting does not collect personal data, set cookies, or communicate with any external services.
Contribute
The plugin is open source and available on GitHub. Pull requests for bug fixes and new features are welcome. Please use the WordPress.org support forum for support and GitHub Issues for confirmed bug reports.
Translations
Help translate WebberZone Code Block Highlighting into your language on WordPress.org. See the Translator Handbook for guidance.
Other plugins by WebberZone
- Contextual Related Posts — Display fast, intelligent related posts to keep visitors on your site longer
- Top 10 — Track daily and total visits and display popular and trending posts
- WebberZone Snippetz — Manage custom HTML, CSS and JS snippets across your site
- Knowledge Base — Create a knowledge base or FAQ section on your WordPress site
- Better Search — Contextual search results sorted by relevance
- Auto-Close — Automatically close comments, pingbacks, trackbacks and manage revisions
- Popular Authors — Display popular authors in a WordPress widget
- Followed Posts — Show related posts based on what your visitors have already read
- WebberZone Link Warnings — Add accessible warnings for external links and target=”_blank” links
Written by Joobi from the project's own listing. See the source page
1.4.0
Release date: 22 November 2026
Release post: https://webberzone.com/announcements/code-block-highlighting-v1-4/
Added
- Dark mode color scheme. Pick a second theme for dark mode and it switches automatically, following the visitor’s device setting or your site’s dark mode switch. A block’s own color scheme still wins. Use the new
wzcbh_dark_mode_selectorfilter to set the selector from code. - Diff highlighting. A new Show as diff toggle colors lines starting with + and – as added and removed while keeping the block’s language highlighting, in both client-side and server-side modes. Diff is also available as a language for whole patches, and diff snippets download as
.diff. - Kujo language support in the language picker, with
.kujosnippet downloads, in both client-side and server-side modes. - In server-side mode, code blocks too large to highlight on the server now fall back to Prism.js highlighting in the browser instead of plain text. Prism.js loads only on pages that need it. Turn this off with the new
wzcbh_server_prism_fallbackfilter; blocks larger thanwzcbh_prism_fallback_max_bytes(default 512KB) stay plain text. - Per-page limit on the code sent to the browser fallback, filterable with the new
wzcbh_prism_fallback_page_budget(default 1MB; 0 turns it off). Blocks beyond it stay plain text. - Per-page limit on the amount of code highlighted on the server, so pages with many large code blocks no longer slow down. Blocks beyond the limit use the browser fallback. The limit and the fallback apply to front-end pages only; feeds, the REST API, AJAX, WP-CLI and admin screens keep the previous behavior. The limit is filterable with the new
wzcbh_server_highlight_request_budget(default 256KB; 0 turns it off). - Per-page limit on server-side language detection, so pages with many untagged code blocks no longer slow down when uncached. Blocks beyond the limit show as plain text and are detected on a later visit. Front-end pages only; filterable with the new
wzcbh_auto_detect_request_limit(default 25; 0 turns it off).
Changed
- Uninstalling the plugin now also removes cached language detection results and Convert Code Blocks results on every site.
- Settings passed to the frontend scripts are now encoded with stricter JSON escaping.
- On front-end pages, setting
wzcbh_server_highlight_max_bytesto 0 now sends every server-side block with a language to the browser fallback instead of showing it as plain text. Also returnfalsefromwzcbh_server_prism_fallbackto keep plain text.
Fixed
- A very large custom start line number caused a fatal error in server-side mode when line numbers were on. The start line is now limited to 1,000,000 and the max height to 100,000 pixels.
- In server-side mode, HTML entities typed as code text, such as
<, showed as the character they stand for in blocks that were not highlighted. - The download button kept an executable extension such as
.exeor.batfrom the block’s file name. Such an extension is now replaced with the language’s extension, and other file names download as before. The list is filterable with the newwzcbh_download_blocked_extensions. - A malformed
langattribute on a code element could stop Prism.js highlighting every code block on the page. - Code containing the text
language-textwas changed in blocks set to Plain text. - Crafted code block markup saved by a user allowed to post unfiltered HTML could turn part of one attribute into a new one, such as an event handler, when the plugin added its own attributes. The code block’s tags are now parsed per the HTML standard, and event handler attributes are removed from them.
- In server-side mode, a closing code tag inside an HTML comment or other raw text in the saved markup ended the code block early, and the rest of that markup was output unescaped.
- Converting code blocks from the Convert Code Blocks screen or with WP-CLI could turn malformed attribute markup into a different attribute. Such markup is now left as it is.
- Draft, private and password-protected synced patterns made the plugin’s styles and scripts load on pages that did not need them.
- Backslashes were stripped from settings values when they were saved from the settings page or setup wizard.
- A single-value setting that received an array, for example from a modified form submission, could trigger a PHP warning on save.
Earlier versions
For the changelog of earlier versions, please refer to the releases page on GitHub.
Follow this listing's changes (Atom feed)