Skip to content

Instantly share code, notes, and snippets.

@melvinstanly
Last active September 5, 2018 07:09
Show Gist options
  • Save melvinstanly/7ecf251fb698deea640d4c1482bf8bba to your computer and use it in GitHub Desktop.
Save melvinstanly/7ecf251fb698deea640d4c1482bf8bba to your computer and use it in GitHub Desktop.
tinyMCE related codes
jQuery(document).ready(function($) {
var divBodyConfig = {
selector: '.tinymce-body',
menubar: false,
inline: true,
plugins: [
'link',
'textcolor',
'lists',
// 'powerpaste',
// 'linkchecker',
// 'contextmenu',
// 'autolink',
// 'tinymcespellchecker'
],
toolbar: [
'undo redo | bold italic underline | fontselect fontsizeselect',
'forecolor backcolor | alignleft aligncenter alignright alignfull | numlist bullist outdent indent'
],
valid_elements: 'p[style],strong,em,span[style],a[href],ul,ol,li',
valid_styles: {
'*': 'font-size,font-family,color,text-decoration,text-align'
},
// powerpaste_word_import: 'clean',
// powerpaste_html_import: 'clean',
content_css: [
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
]
};
tinymce.init(divBodyConfig);
});
<?php
// Enqueue tinyMCE scripts
add_action( 'admin_enqueue_scripts', 'enqueue_scripts', 11 );
function enqueue_scripts(){
wp_register_script( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.php', array() );
wp_register_script( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce.min.js", array());
wp_enqueue_script('wp-tinymce');
wp_enqueue_script('wp-tinymce-root');
wp_register_script( 'custom-js',plugins_url( '/js/custom-tinymce-script.js', __FILE__ ), array('wp-tinymce-root')); // create js file with the given name and at given path
wp_enqueue_script('custom-js');
}
?>
<div class="container" style="width:100%;height:100%;padding:0;margin:0;">
<div class="wrapper" style="margin:auto;width:90%;border:2px solid gray;background-color:white;">
<div class="content">
<div class="tinymce-body">This is a sample editable text </div>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment