Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

highlight.js Syntax Highlighter

Version Status Downloads License

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. Include code snippets wrapped in <pre><code> tags.

Requirements

This plugin requires PHP 5.4 or higher, but you really should be using PHP 7 or higher, as we all know.

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' ), meaning the plugin only loads for single posts.

Usage Example:

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

About

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

Topics

Resources

License

Packages

No packages published

Languages