| 开发者 |
webberzone
ajay |
|---|---|
| 更新时间 | 2026年10月11日 22:59 |
| 捐献地址: | 去捐款 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
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:
core/code and 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.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
1,3-5) to visually highlight using Prism's line-highlight plugin.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 pagewp-content/plugins/ directory. You should end up with a webberzone-code-block-highlighting/ folder.No. WebberZone Code Block Highlighting uses JavaScript and PHP filters to extend the native core/code block. It never swaps the block for a custom one: the block is saved with the same markup as the core Code block, the highlighting options are stored as block attributes, and the language classes, file name, line numbers and max height are added when the page is rendered.
No. Code blocks are saved with the core Code block's own markup, so deactivating simply removes the highlighting and the blocks stay valid.
Blocks last saved with version 1.2.3 or earlier carry extra markup that the core block does not recognize, and show "This block contains unexpected or invalid content" if you deactivate the plugin before they are converted. To convert them, either open and update each post with the plugin active, or convert every post at once from the Convert Code Blocks link in the banner at the top of Settings > Code Block Highlighting, or with the WP-CLI command wp wzcbh migrate-code-blocks. Back up your database first: posts are updated in place without creating revisions.
40 languages out of the box: Apache Config, Bash, C, C++, C#, CSS, Dart, Docker, F#, Go, GraphQL, Groovy, Haskell, HTML, Java, JavaScript, JSON, JSX, Kotlin, Lua, Markdown, Nginx, Objective-C, Perl, PHP, PowerShell, Python, R, Ruby, Rust, Sass, Scala, SQL, Swift, TOML, TSX, TypeScript, Vim, XML, and YAML.
Use the wzcbh_languages filter to add or remove entries from the language picker. Note: adding a language to the filter only affects the UI dropdown — the corresponding Prism.js grammar must also be available on the frontend (either bundled in frontend.js or loaded separately).
build-prism.js.includes/assets/.includes/admin/class-settings.php.npm run build:prism.wzcbh_color_scheme_css_url filter to point to any CSS file without touching the plugin source.
In client-side mode (the default), Prism.js runs in the visitor's browser and highlights your code on page load. This mode enables interactive toolbar features such as copy-to-clipboard and expand/collapse. In server-side mode, the plugin uses highlight.php to pre-render the highlighted markup on the server. No JavaScript is loaded for highlighting, which is great for performance, Core Web Vitals, and sites with strict content-security policies. Both modes share the same 21 Prism themes and produce visually identical results, so you can switch freely from Settings > Code Block Highlighting.
Yes. When server-side mode is enabled, syntax colours are baked into the HTML on the server — no Prism.js or any other JavaScript is enqueued for highlighting.
No. Theme CSS and (in client-side mode) Prism JS are only enqueued on pages that contain at least one code block. All other pages are unaffected. Use the wzcbh_force_load_assets filter to override this behaviour if needed.
Enter a comma-separated list of lines or ranges in the Highlight Lines field in the Inspector Controls sidebar (e.g. 1,3-5,8). This maps to the data-line attribute consumed by the Prism line-highlight plugin.
Yes. Use the Title field in the Inspector Controls sidebar. The label is displayed in the Prism toolbar above the code block.
The plugin ships with 21 Prism themes. The active theme is selected globally on the settings page (Settings > Code Block Highlighting). Per-block theme switching is not currently supported.
Yes. The plugin is built specifically for the Gutenberg block editor (WordPress 6.6+) and uses the native block filter APIs. It does not support the Classic Editor.
Please report security bugs found in the source code of the WebberZone Code Block Highlighting plugin through the Patchstack Vulnerability Disclosure Program. The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin.
wp wzcbh migrate-code-blocks WP-CLI command to convert code blocks saved by earlier versions in bulk.