_WP_Editors::print_default_editor_scripts()
- Since
- 4.8.0
- Source
wp-includes/class-wp-editor.php:934
Description
For use when the editor is going to be initialized after page load.
Compatibility
- WordPress
- since 4.8.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Performance profile
How much work a call to _WP_Editors::print_default_editor_scripts() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 17–54
- Plugin surface
- 1 hook
- Called by
- 0
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 56.
Third-party callbacks on 'print_default_editor_scripts' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
do_action()called directly
Further down the call graph this can also reach query, option, cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 8 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost _WP_Editors::print_default_editor_scripts() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 17 | user_can_richedit(), do_action(), ::wp_link_dialog() |
| always | 19 | user_can_richedit(), ::print_tinymce_scripts(), do_action(), ::wp_link_dialog() |
| always | 29–30 | user_can_richedit(), ::get_baseurl(), do_action(), ::wp_link_dialog() |
| always | 31–32 | user_can_richedit(), ::get_baseurl(), ::print_tinymce_scripts(), do_action(), ::wp_link_dialog() |
| always | 37–39 | user_can_richedit(), ::default_settings(), is_rtl(), ::_parse_init(), do_action(), ::wp_link_dialog() |
| always | 39–41 | user_can_richedit(), ::default_settings(), is_rtl(), ::_parse_init(), ::print_tinymce_scripts(), do_action(), ::wp_link_dialog() |
| always | 49–52 | user_can_richedit(), ::default_settings(), is_rtl(), ::_parse_init(), ::get_baseurl(), do_action(), ::wp_link_dialog() |
| always | 51–54 | user_can_richedit(), ::default_settings(), is_rtl(), ::_parse_init(), ::get_baseurl(), ::print_tinymce_scripts(), do_action(), ::wp_link_dialog() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 56 instructions, 17–54 executed per call, 5 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 1
One hook fires while _WP_Editors::print_default_editor_scripts() runs, in this order:
- do_action( print_default_editor_scripts )actionline 1023 (+89 into the body)
Fires when the editor scripts are loaded for later initialization, after all scripts and settings are printed.
Uses · 8
- user_can_richedit()Determines whether the user can access the visual editor.
- is_rtl()Determines whether the current locale is right-to-left (RTL).
- do_action()Calls the callback functions that have been added to an action hook.
- _WP_Editors::default_settings()Returns the default TinyMCE settings.
- _WP_Editors::_parse_init()
- _WP_Editors::get_baseurl()Returns the TinyMCE base URL.
- _WP_Editors::print_tinymce_scripts()Print (output) the main TinyMCE scripts.
- _WP_Editors::wp_link_dialog()Dialog for internal linking.
Source code
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 ) {Changelog
Introduced in 4.8.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.8.8 tag, from
src/wp-includes/class-wp-editor.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.