WordPress plugin for shortcodes rendering <code> and <pre><code> with content converted to htmlentities & disabling wptexturize.
This WordPress plugin adds two shortcodes for rendering code:
- [code] for inline code
- [precode] for blocklevel code
These shortcodes solve 2 problems:
- Ocassional auto transformation to smart quotes. WP should not convert quotes to smart quotes between
<pre>&<code>, but sometimes it happens anyway. These shortcodes explicitly disallow the use of wptexturize. - The need to manually convert html tags, etc to htmlentities. The shortcodes convert the content to htmlentities (no quotes, utf-8)
[code]<p>This is the "code" shortcode, for in-line code. Use it in the same way as you'd use <code>.</p>[/code]
[precode]
<p>
This is the "precode" shortcode, for block-level code.
Use it in the same way as you'd use <pre><code>.
<p>
[/precode]
There are no functional attributes.
Core HTML attributes are allowed and get rendered in the resulting html. Example:
[code class="code-html" lang="fr-FR"]<h1>Le monde est a nous</h1>[/code]
- Upload short-code-shortcode folder to
wp-content/plugins/ - Activate plugin through the 'Plugins' menu in WordPress
- Fixed formatting error is README.md
- Added [code] and [precode] buttons to TinyMCE's kitchensink & Quick tags
- Added trim function to the clean_code_content method
- Initial commit