Print (output) all editor scripts and default settings.
Description
For use when the editor is going to be initialized after page load.
Source
public static function print_default_editor_scripts() {
$user_can_richedit = user_can_richedit();
if ( $user_can_richedit ) {
$settings = self::default_settings();
$settings['toolbar1'] = 'bold,italic,bullist,numlist,link';
$settings['wpautop'] = false;
$settings['indent'] = true;
$settings['elementpath'] = false;
if ( is_rtl() ) {
$settings['directionality'] = 'rtl';
}
/*
* In production all plugins are loaded (they are in wp-editor.js.gz).
* The 'wpview', 'wpdialogs', and 'media' TinyMCE plugins are not initialized by default.
* Can be added from js by using the 'wp-before-tinymce-init' event.
*/
$settings['plugins'] = implode(
',',
array(
'charmap',
'colorpicker',
'hr',
'lists',
'paste',
'tabfocus',
'textcolor',
'fullscreen',
'wordpress',
'wpautoresize',
'wpeditimage',
'wpemoji',
'wpgallery',
'wplink',
'wptextpattern',
)
);
$settings = self::_parse_init( $settings );
} else {
$settings = '{}';
}
?>
<script type="text/javascript">
window.wp = window.wp || {};
window.wp.editor = window.wp.editor || {};
window.wp.editor.getDefaultSettings = function() {
return {
tinymce: <?php echo $settings; ?>,
quicktags: {
buttons: 'strong,em,link,ul,ol,li,code'
}
};
};
<?php
if ( $user_can_richedit ) {
$suffix = SCRIPT_DEBUG ? '' : '.min';
$baseurl = self::get_baseurl();
?>
var tinyMCEPreInit = {
baseURL: "<?php echo $baseurl; ?>",
suffix: "<?php echo $suffix; ?>",
mceInit: {},
qtInit: {},
load_ext: function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
};
<?php
}
?>
</script>
<?php
if ( $user_can_richedit ) {
self::print_tinymce_scripts();
}
/**
* Fires when the editor scripts are loaded for later initialization,
* after all scripts and settings are printed.
*
* @since 4.8.0
*/
do_action( 'print_default_editor_scripts' );
self::wp_link_dialog();
}
Hooks
- do_action( ‘print_default_editor_scripts’ )
Fires when the editor scripts are loaded for later initialization, after all scripts and settings are printed.
Changelog
Version | Description |
---|---|
4.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.