Display a code editor area using the built-in WP Core Codemirror library. Multiple languages highlights are available: Text/HTML, Javascript, CSS, PHP mixed & PHP plain.
Setting name | Description |
Default Value | Appears when creating a new post |
Placeholder | Appears within the input |
Editor mode | Syntax highlight: text/html, javascript, application/x-json, css, application/x-httpd-php or text/x-php |
Show Lines | Whether to show line numbers to the left of the editor |
Indent Unit | How many spaces a block (whatever that means in the edited language) should be indented |
Character Limit | Leave blank for no limit |
Rows | Sets the textarea height |
Max rows | Sets the textarea max height |
HTML Entities | Whenever to return value as HTML entities |
Value can then be retrieved using the common get_field()
function. The returned data are decoded HTML entities. Usage example:
$code_editor = get_field('code_editor');
/**
* <div class="my-class">
* <p>Lorem ipsum dolor sit amet.</p>
* <p>Praesent sapien massa, convallis.</p>
* </div>
*
* <div class="my-class-2">
* <p>Lorem ipsum dolor sit amet.</p>
* <p>Praesent sapien massa, convallis.</p>
* </div>
*/