_WP_Editors::editor_js()
- Since
- 3.3.0
- Source
wp-includes/class-wp-editor.php:1576
Compatibility
- WordPress
- since 3.3.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::editor_js() 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
- Light
- Scaling
- Scales with input
- Instructions
- 75–117
- Plugin surface
- 3 hooks
- Called by
- 0
Touches nothing outside its own arguments.
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 144.
Third-party callbacks on 'before_wp_tiny_mce', 'wp_tiny_mce_init', 'after_wp_tiny_mce' 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 option, cache, serialize, query 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::editor_js() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
$value && is_admin() | 75–100 | ::get_baseurl(), do_action(), ::_parse_init(), do_action(), is_admin(), ::wp_link_dialog(), do_action() |
$value && is_admin() | 77–98 | ::get_baseurl(), do_action(), ::_parse_init(), do_action(), is_admin(), do_action() |
!$value && is_admin() | 79–110 | ::get_baseurl(), do_action(), ::_parse_init(), ::print_tinymce_scripts(), do_action(), is_admin(), ::wp_link_dialog(), do_action() |
!$value && is_admin() | 81–108 | ::get_baseurl(), do_action(), ::_parse_init(), ::print_tinymce_scripts(), do_action(), is_admin(), do_action() |
$value && !is_admin() | 82–107 | ::get_baseurl(), do_action(), ::_parse_init(), do_action(), is_admin(), admin_url(), ::wp_link_dialog(), do_action() |
$value && !is_admin() | 84–105 | ::get_baseurl(), do_action(), ::_parse_init(), do_action(), is_admin(), admin_url(), do_action() |
!$value && !is_admin() | 86–117 | ::get_baseurl(), do_action(), ::_parse_init(), ::print_tinymce_scripts(), do_action(), is_admin(), admin_url(), ::wp_link_dialog(), do_action() |
!$value && !is_admin() | 88–115 | ::get_baseurl(), do_action(), ::_parse_init(), ::print_tinymce_scripts(), do_action(), is_admin(), admin_url(), do_action() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 144 | 75–117 | 14 | |
| 8.5 | 144 | 75–117 | 14 | |
| 8.4 | 144 | 75–117 | 14 | 15 fewer instructions than PHP 8.3 |
| 8.3 | 159 | 81–132 | 14 | |
| 8.2 | 159 | 81–132 | 14 | |
| 8.1 | 159 | 81–132 | 14 | |
| 7.4 | 159 | 81–132 | 14 |
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 · 3
3 hooks fire while _WP_Editors::editor_js() runs, in this order:
- do_action( before_wp_tiny_mce )actionline 1620 (+44 into the body)
Fires immediately before the TinyMCE settings are printed.
- do_action( wp_tiny_mce_init )actionline 1659 (+83 into the body)
Fires after tinymce.js is loaded, but before any TinyMCE editor instances are created.
- do_action( after_wp_tiny_mce )actionline 1745 (+169 into the body)
Fires after any core TinyMCE editor instances are created.
Uses · 7
- do_action()Calls the callback functions that have been added to an action hook.
- is_admin()Determines whether the current request is for an administrative interface page.
- admin_url()Retrieves the URL to the admin area for the current site.
- _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 editor_js() { global $tinymce_version; $tmce_on = ! empty( self::$mce_settings ); $mce_init = ''; $qt_init = ''; if ( $tmce_on ) { foreach ( self::$mce_settings as $editor_id => $init ) { $options = self::_parse_init( $init ); $mce_init .= "'$editor_id':{$options},"; } $mce_init = '{' . trim( $mce_init, ',' ) . '}'; } else { $mce_init = '{}'; } if ( ! empty( self::$qt_settings ) ) { foreach ( self::$qt_settings as $editor_id => $init ) { $options = self::_parse_init( $init ); $qt_init .= "'$editor_id':{$options},"; } $qt_init = '{' . trim( $qt_init, ',' ) . '}'; } else { $qt_init = '{}'; } $ref = array( 'plugins' => implode( ',', self::$plugins ), 'theme' => 'modern', 'language' => self::$mce_locale, ); $suffix = SCRIPT_DEBUG ? '' : '.min'; $baseurl = self::get_baseurl(); $version = 'ver=' . $tinymce_version; /** * Fires immediately before the TinyMCE settings are printed. * * @since 3.2.0 * * @param array $mce_settings TinyMCE settings array. */ do_action( 'before_wp_tiny_mce', self::$mce_settings ); ?> <script> tinyMCEPreInit = { baseURL: "<?php echo $baseurl; ?>", suffix: "<?php echo $suffix; ?>", <?php if ( self::$drag_drop_upload ) { echo 'dragDropUpload: true,'; } ?> mceInit: <?php echo $mce_init; ?>, qtInit: <?php echo $qt_init; ?>, ref: <?php echo self::_parse_init( $ref ); ?>, load_ext: function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');} }; </script> <?php if ( $tmce_on ) { self::print_tinymce_scripts(); if ( self::$ext_plugins ) { // Load the old-format English strings to prevent unsightly labels in old style popups. echo "<script src='{$baseurl}/langs/wp-langs-en.js?$version'></script>\n"; } } /** * Fires after tinymce.js is loaded, but before any TinyMCE editor * instances are created. * * @since 3.9.0Changelog
Introduced in 3.3.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 7.1.0 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.