WP Manifestindependent plugin directory
manifest / editor / highlightjs

Highlight.js Syntax Highlighter WP Registry grade A. No security issues foundWP RegistryNo security issues foundOpen the reportA

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

★ 3stars
2.5kcomposer installs
v2.1.0latest · 3 years ago

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/tfrommen/highlightjs/archive/refs/heads/main.zip

On Packagist as tfrommen/highlightjs:

composer require tfrommen/highlightjs
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

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

Installation

Install with Composer:

composer require tfrommen/highlightjs

Or:

  1. Download ZIP.
  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 <pre><code> tags (e.g., a core/code block).

Requirements

This plugin requires PHP 7.4 or higher.

Usage

Please refer to the Highlight.js documentation.

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)

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:

<?php
/**
 * Filters the condition for the plugin to load.
 *
 * @param bool $should_load Whether or not the plugin should load.
 */
add_filter( \tfrommen\HighlightJs\FILTER_SHOULD_LOAD, function () {

    return is_singlular( 'post' );
} );

If you want to load the plugin for all requests, you can use the __return_true WordPress function:

<?php
/**
 * Filters the condition for the plugin to load.
 *
 * @param bool $should_load Whether or not the plugin should load.
 */
add_filter( \tfrommen\HighlightJs\FILTER_SHOULD_LOAD, '__return_true' );

License

Copyright (c) 2017 Thorsten Frommen

This code is licensed under the MIT License.

The included Highlight.js is released under the BSD License.

Releases

4 releases.

Tag
Published
v2.1.0 latest
Mar 16, 2023 3 years ago
Feb 11, 2023 3 years ago
Jul 25, 2017 9 years ago
Jul 15, 2017 9 years ago

These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.

A grade

Security

Highlight.js Syntax Highlighter 2.1.0 · audited by WP Registry

No security issues found.

Audited release
2.1.0
Findings
none
Worst severity
—
Content hash
b60f021c372b6794c8f336ee…

WP Registry hashes the installable build and reports on that exact bytes-for-bytes copy. Embargoed findings are withheld until they are disclosed, so a clean verdict means nothing public is outstanding. WP Manifest does not audit code itself.