Content Editor

The content-editor lets you add a Content Editor Field.

Content Editor

Parameters

Here are the parameters in adding content-editor.

id
string | required

a unique slug-like string to use as an id and also as index in saving data in database.

label
string | optional

the label of the field.

description
string | optional

the description of the field and display under the label.

section
string | requiredl

the section where the field will be displayed.

default
string | optional

the default value of the field.

priority
integer | optional

determines the order of fields in section.

uploader
boolean | optional | default: false

add a media uploader button.

toolbars
array | optional

allowing to add controls in toolbars.

Note: here are the list of toolbars available [ 'bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'hr', 'alignleft', 'aligncenter', 'alignright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv', 'formatselect', 'underline', 'alignjustify', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help' ]

Example


Yano::field( 'content-editor', [
   'id'          => 'editor1',
   'label'       => 'Write Your Content',
   'description' => 'Description Here.',
   'section'     => 'section_id',
   'priority'    => 1,
] );

Example with default value! note: default value can only be supplied of string or html.


Yano::field( 'content-editor', [
   'id'          => 'editor1',
   'label'       => 'Write Your Content',
   'description' => 'Description Here.',
   'section'     => 'section_id',
   'default'     => 'Hello World',
   'priority'    => 1,
] );

Example with uploader! note: uploader can be supplied only in boolean.


Yano::field( 'content-editor', [
   'id'          => 'editor1',
   'label'       => 'Write Your Content',
   'description' => 'Description Here.',
   'section'     => 'section_id',
   'default'     => 'Hello World',
   'priority'    => 1,
   'uploader'    => true
] );

Example with toolbars! here are the list of toolbars available bold, italic, strikethrough, bullist, numlist, blockquote, hr, alignleft, aligncenter, alignright, link, unlink, wp_more, spellchecker, fullscreen, wp_adv, formatselect, underline, alignjustify, forecolor, pastetext, removeformat, charmap, outdent, indent, undo, redo, wp_help.


Yano::field( 'content-editor', [
   'id'          => 'editor1',
   'label'       => 'Write Your Content',
   'description' => 'Description Here.',
   'section'     => 'section_id',
   'default'     => 'Hello World',
   'priority'    => 1,
   'uploader'    => true,
   'toolbars'    => [ 'bold', 'italic' ]
] );

Usage

The get_theme_mod() function is recommended to retrieve data.


// Return a string
echo get_theme_mod('editor1');