Skip to content

Instantly share code, notes, and snippets.

@rheinardkorf
Last active June 2, 2023 05:14
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rheinardkorf/aec4d46d3833d2f7a6a27c4481ba0b44 to your computer and use it in GitHub Desktop.
Save rheinardkorf/aec4d46d3833d2f7a6a27c4481ba0b44 to your computer and use it in GitHub Desktop.
Example usage of JS editor API WordPress 4.8+
// Remember to wp_enqueue_editor(); inside PHP.
// Add editor
wp.editor.initialize(
'test-editor',
{
tinymce: {
wpautop:true,
plugins : 'charmap colorpicker compat3x directionality fullscreen hr image lists media paste tabfocus textcolor wordpress wpautoresize wpdialogs wpeditimage wpemoji wpgallery wplink wptextpattern wpview',
toolbar1: 'formatselect bold italic | bullist numlist | blockquote | alignleft aligncenter alignright | link unlink | wp_more | spellchecker'
},
quicktags: true
}
);
// Remove editor
wp.editor.remove('test-editor');
@anandsiddharth
Copy link

It didn't work, please write the full example including html

@theenoahmason
Copy link

Awesome @rheinardkorf!

@Web-Medias
Copy link

Very good !
Except I have after that a toolbar with the shorthand buttons with the 'quicktags' property setted to 'true' and ability to switch between View & Text (code).
Okay done...
The quicktags to false removes as well the shorthand, but View-Text are removed too !
You save me an hour @rheinardkorf ;)

@rheinardkorf
Copy link
Author

Glad that helped you @Web-Medias ... I completely forgot about this snippet :)

@ashwinispsm
Copy link

how to remove h1 tag form this api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment