Skip to content

Instantly share code, notes, and snippets.

@webhasan
Last active June 22, 2020 16:51
Show Gist options
  • Save webhasan/44aa034d5ffc9be05eec91f8c357d0a2 to your computer and use it in GitHub Desktop.
Save webhasan/44aa034d5ffc9be05eec91f8c357d0a2 to your computer and use it in GitHub Desktop.
User WordPress tinymce including media uploader in JavaScript
// also need to enqueue script and style for tinymce
// by wp_enqueue_editor(); in php side
let {tinymce: tinymceObj, quicktags: quicktagsObj} = wp.editor.getDefaultSettings();
// textarea-id = id of the field
wp.editor.initialize('textarea-id', {
tinymce: {
...tinymceObj,
"toolbar1": "formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,unlink,wp_more,spellchecker,wp_add_media,wp_adv",
"toolbar2": "strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help",
"plugins": "charmap,colorpicker,hr,lists,media,paste,tabfocus,textcolor,fullscreen,wordpress,wpautoresize,wpeditimage,wpemoji,wpgallery,wplink,wpdialogs,wptextpattern,wpview",
},
quicktags: quicktagsObj
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment