Linux 软件免费装
Banner图

WebberZone Code Block Highlighting

开发者 webberzone
ajay
更新时间 2026年6月10日 23:49
捐献地址: 去捐款
PHP版本: 7.4 及以上
WordPress版本: 7.0
版权: GPLv2 or later
版权网址: 版权信息

标签

gutenberg syntax highlighting prism code highlighting code block

下载

1.1.0 1.0.0

详情介绍:

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 — 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: 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? Supported languages 40 languages including: 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, 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 Global settings Developer filters 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

安装:

WordPress admin (recommended)
  1. Go to Plugins > Add New in your WordPress admin.
  2. Search for WebberZone Code Block Highlighting.
  3. Click Install Now, then Activate.
Manual installation
  1. Download the plugin zip file.
  2. Extract it to your wp-content/plugins/ directory. You should end up with a webberzone-code-block-highlighting/ folder.
  3. Go to Plugins in your WordPress admin and activate WebberZone Code Block Highlighting.
After activation, open any post or page in the block editor, add or select a Code block, and the Code Highlighting panel will appear in the Inspector Controls sidebar.

屏幕截图:

  • Frontend code block with Prism.js syntax highlighting, line numbers, and toolbar.
  • Plugin settings page — choose a global colour scheme, default language, and more.

升级注意事项:

1.1.0 Adds server-side highlighting mode (highlight.php) with full theme parity across all 21 Prism themes, plus a "Plain Text" language picker option. 1.0.0 Initial release.

常见问题:

Does this plugin replace the core Code block?

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, so existing posts are never invalidated and the plugin can be deactivated without leaving behind broken blocks.

Will my code blocks break if I deactivate the plugin?

No. Because the plugin extends core/code rather than replacing it, deactivating simply removes the highlighting. Your code content is stored in standard WordPress block markup and remains valid.

Which programming languages are supported?

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).

How do I add a custom or additional Prism theme?

  1. Add the theme mapping in build-prism.js.
  2. Copy the generated CSS to includes/assets/.
  3. Register the slug in includes/admin/class-settings.php.
  4. Run npm run build:prism.
You can also use the wzcbh_color_scheme_css_url filter to point to any CSS file without touching the plugin source.

What is the difference between client-side and server-side highlighting?

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.

Does server-side highlighting work without JavaScript?

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.

Does Prism.js load on every page?

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.

How do I highlight specific lines in a code block?

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.

Can I show a filename or label on the code block?

Yes. Use the Title field in the Inspector Controls sidebar. The label is displayed in the Prism toolbar above the code block.

Does the plugin support dark mode or multiple themes?

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.

Is this plugin compatible with the WordPress block editor (Gutenberg)?

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.

How can I report security vulnerabilities?

Report security bugs through the Patchstack Vulnerability Disclosure Program. The Patchstack team will validate, triage, and handle any reported vulnerabilities. Report a security vulnerability.

更新日志:

1.1.0 (10 June 2026) Release Date - 10 June 2026 Release post: https://webberzone.com/announcements/code-block-highlighting-v1-1-0/ 1.0.0 (3 May 2026) Release Date - 3 May 2026 Release post: https://webberzone.com/announcements/code-block-highlighting-v1-0-0/