WP Code Pre

Description

This simple plugin was created because of security concerns related to using PHP preg_replace directly. With transition to PHP7, it’s advised to use preg_replace_callback instead.

This plugin uses built-in supported feature of PHP-“highlight_string”. This plugin filters post content for <pre> </pre> and helps display html and other source code.

To display source code in your posts, surround source code with pre tags. Plugin will filter for pre tags and add inline styles that may be modified using your wordpress theme’s css stylesheet.

For WordPress versions 5.0 and above, HTML pre tags can be used within html block or, classic block.

Screenshots

  • Code preview on blog post or page
  • Typing code in text tab of WordPress Admin area when writing Post.

Installation

  1. Download the plugin
  2. Upload the wp-code-pre.zip folder to your site’s wp-content/plugins directory
  3. Activate the plugin in the WordPress Admin Panel
  4. Surround source code with <pre> </pre> tags, when writing in blog posts using Gutenberg with classic block and “Edit as HTML” or, html block

FAQ

Why there aren’t any options to modify in admin?
This plugin simply filters for pre tags.

Contributors & Developers

“WP Code Pre” is open source software. The following people have contributed to this plugin.

Contributors

Translate “WP Code Pre” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

1.0

  • First version of the plugin.

1.0.1

  • Updated readme to reflect updates to version 5.0