PHPackages                             tfrommen/highlightjs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. tfrommen/highlightjs

ActiveWordpress-plugin

tfrommen/highlightjs
====================

A simple Highlight.js-based syntax highlighter plugin for WordPress.

v2.1.0(3y ago)32.4kMITJavaScriptPHP &gt;=7.4

Since Jul 16Pushed 3y ago1 watchersCompare

[ Source](https://github.com/tfrommen/highlightjs)[ Packagist](https://packagist.org/packages/tfrommen/highlightjs)[ Docs](https://github.com/tfrommen/highlightjs)[ RSS](/packages/tfrommen-highlightjs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

Highlight.js Syntax Highlighter
===============================

[](#highlightjs-syntax-highlighter)

[![Version](https://camo.githubusercontent.com/8dd0bba8e9c82990c5d81c318bffd8e86e875cfbcbb414cfd2f9a3f5c464ef4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7466726f6d6d656e2f686967686c696768746a732e737667)](https://packagist.org/packages/tfrommen/highlightjs)[![Status](https://camo.githubusercontent.com/0516d1b16221bb9cbc5f57f91e1f235b1b6aaee353113f6d168996f670c9a75d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617475732d6163746976652d627269676874677265656e2e737667)](https://github.com/tfrommen/highlightjs)[![Downloads](https://camo.githubusercontent.com/3b032a8cdd33c683d8ef113c2fd795e2121a3e56a9f73397effb33e840ba2917/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7466726f6d6d656e2f686967686c696768746a732e737667)](https://packagist.org/packages/tfrommen/highlightjs)[![License](https://camo.githubusercontent.com/a2804e991712d69f11327a5d3b77ae546411adaa3351aec9f205a1b789898c2f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7466726f6d6d656e2f686967686c696768746a732e737667)](https://packagist.org/packages/tfrommen/highlightjs)

> A simple Highlight.js-based syntax highlighter plugin for WordPress.

Installation
------------

[](#installation)

Install with [Composer](https://getcomposer.org):

```
composer require tfrommen/highlightjs
```

Or:

1. [Download ZIP](https://github.com/tfrommen/highlightjs/releases/latest).
2. Upload contents to the `/wp-content/plugins/` directory on your web server.
3. Activate the plugin through the *Plugins* menu in WordPress.
4. See syntax highlighting for all code snippets wrapped in `` tags (e.g., a `core/code` block).

### Requirements

[](#requirements)

This plugin **requires PHP 7.4** or higher.

Usage
-----

[](#usage)

Please refer to the [Highlight.js documentation](https://highlightjs.org/).

### Filters

[](#filters)

In order to customize certain aspects of the plugin, it provides you with several filters. For each of these, a short description as well as a code example on how to alter the default behavior is given below. Just put the according code snippet in your theme's `functions.php` file or your *customization* plugin, or to some other appropriate place.

#### `\tfrommen\HighlightJs\FILTER_SHOULD_LOAD` (`highlightjs.should_load`)

[](#tfrommenhighlightjsfilter_should_load-highlightjsshould_load)

This filter lets you customize the condition for the plugin to load. The default value is the result of `is_singular( 'post' ) && has_block( 'code' )`, meaning the plugin only loads for single posts that include at least one `core/code` block.

If you want to load the plugin for all single posts, no matter what blocks are included in the content:

```
