editor-toolkit
Tools
Open Source
PHP
WordPress
Editor Toolkit
A helper class for WordPress which enables entering content in the TinyMCE editor as discrete blocks. On the frontend, blocks can be manipulated extensively before being rendered. For example, HTML elements with classes and ids can be wrapped around a block.
Usage
This class needs to be integrated with a theme, ideally using the after_setup_theme
hook:
function foo_theme_setup() {
// Required: Include the main file
require_once('editor-toolkit/editor-toolkit.php');
// Recommended: Make the instance variable global
global $edtoolkit;
// Required: Instantiate the class
// If needed, specify path to class and post types
$edtoolkit = new Editor_Toolkit( array('directory' => 'editor-toolkit', 'post_types' => array('page') ) );
// Optional: Create shorter aliases to the render methods
// Otherwise, use `$edtoolkit->get_block()` and `$edtoolkit->the_block()` directly
function get_block($request, $post = NULL) {
global $edtoolkit;
return $edtoolkit->get_block($request, $post);
}
function the_block($request, $post = NULL) {
global $edtoolkit;
echo $edtoolkit->the_block($request, $post);
}
}
add_action('after_setup_theme', 'foo_theme_setup');
In a template, reference and output a block by number: