2017 © Pedro Peláez
 

wordpress-plugin highlightjs

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

image

tfrommen/highlightjs

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

  • Tuesday, July 25, 2017
  • by tfrommen
  • Repository
  • 1 Watchers
  • 1 Stars
  • 195 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 7 % Grown

The README.md

Highlight.js Syntax Highlighter

Version Status Downloads License, (*1)

A simple Highlight.js-based syntax highlighter plugin for WordPress., (*2)

Installation

Install with Composer:, (*3)

composer require tfrommen/highlightjs

Or:, (*4)

  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., (*5)

Usage

Please refer to the Highlight.js documentation., (*6)

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., (*7)

\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., (*8)

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

<?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:, (*10)

<?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, (*11)

This code is licensed under the MIT License., (*12)

The included Highlight.js is released under the BSD License., (*13)

The Versions

25/07 2017

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

  • php >=5.4

 

code syntax highlight highlightjs

25/07 2017

v1.1.0

1.1.0.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4

 

code syntax highlight highlightjs

16/07 2017

v1.0.0

1.0.0.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4

 

code syntax highlight highlightjs