Content Editor

The Content Editor controller allows users to write a formatted custom text and HTML tags, along with media files.

Demonstration

 
Handy::control( 'content-editor', [
    'id'          => 'content_editor_id',
    'section'     => 'layout_section',
    'label'       => esc_html__( 'Content Editor Control', 'textdomain' ),
    'description' => esc_html__( 'Description Here', 'textdomain' ),
    'priority'    => 1
]);

TIP

Here's an example using the default parameter.

 
Handy::control( 'content-editor', [
    'id'          => 'content_editor_id',
    'section'     => 'layout_section',
    'default'     => 'Content…',
    'label'       => esc_html__( 'Content Editor Control', 'textdomain' ),
    'description' => esc_html__( 'Description Here', 'textdomain' ),
    'priority'    => 1
]);

TIP

Here's an example using the uploader and toolbars parameters. Note the uploader value only accepts a boolean data type, while toolbars only accepts 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 and wp_help.

 
Handy::control( 'content-editor', [
    'id'          => 'content_editor_id',
    'section'     => 'layout_section',
    'default'     => 'Content…',
    'label'       => esc_html__( 'Content Editor Control', 'textdomain' ),
    'description' => esc_html__( 'Description Here', 'textdomain' ),
    'priority'    => 1,
    'uploader'    => true, 
    'toolbars'    => [ 'bold', 'italic', 'bullist', 'undo', 'redo' ]
]);

Basic Usage

 
// Return a string.
$value = get_theme_mod( 'content_editor_id' );

Parameters

NameDescription
id

string required

The unique slug like string used as an ID and also as an index name in storing data in a database.

section

string required

The ID of the section in which the control will be displayed.

default

string optional

The predetermined value of the control. Default empty.

uploader

boolean optional

The flag that indicates whether to show the media uploader. Default false.

toolbars

array optional

The content editor’s supported toolbars. Accepts only 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 and wp_help. Default empty array.

label

string optional

The label or title of the control to show in the UI. Default empty.

description

string optional

The description of the control to show in the UI. Default empty.

priority

integer optional

The order of control appears in the section. Default 0.

validations

array optional

The set of validations used to validate the value of the control. For further details, read validations. Default empty.

active_callback

callable optional

A callback function that determines the visibility of a control, whether to show or hide depending on a condition. For further details, read active_callback. Default empty.

sanitize_callback

callable optional

A callback function that sanitizes the value of control before storing it in the database. Note that this is only optional since each control is already well sanitized. For further details, read sanitize_callback. Default empty.