wppaste
WordPress

wp_tinymce_inline_scripts()

Since
5.0.0
Source
wp-includes/script-loader.php:525
Adds inline scripts required for the TinyMCE in the block editor.

Description

These TinyMCE init settings are used to extend and override the default settings from _WP_Editors::default_settings() for the Classic block.

Compatibility

WordPress
since 5.0.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_tinymce_inline_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
Light

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
110–124

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 170.

Plugin surface
9 hooks

Third-party callbacks on 'wp_editor_settings', 'tiny_mce_plugins', 'disable_captions' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()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 · 2 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_tinymce_inline_scripts() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always110–118apply_filters(), apply_filters(), array_unique(), apply_filters(), apply_filters(), apply_filters(), apply_filters(), apply_filters(), apply_filters(), wp_json_encode(), apply_filters(), includes_url(), wp_json_encode(), ->add_inline_script()
!empty($editor_settings)119–124apply_filters(), apply_filters(), array_unique(), apply_filters(), apply_filters(), apply_filters(), apply_filters(), apply_filters(), apply_filters(), wp_json_encode(), array_merge(), apply_filters(), includes_url(), wp_json_encode(), ->add_inline_script()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev170110–12416
8.5170110–12416
8.4170110–1241621 fewer instructions than PHP 8.3
8.3191128–14216
8.2191128–14216
8.1191128–14216
7.4191128–14216

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 · 9

9 hooks fire while wp_tinymce_inline_scripts() runs, in this order:

  1. apply_filters( wp_editor_settings )filterline 529 (+4 into the body)

    Filters the wp_editor() settings.

  2. apply_filters( tiny_mce_plugins )filterline 553 (+28 into the body)

    Filters the list of default TinyMCE plugins.

  3. apply_filters( disable_captions )filterline 559 (+34 into the body)

    Filters whether to disable captions.

  4. apply_filters( mce_buttons )filterline 582 (+57 into the body)

    Filters the first-row list of TinyMCE buttons (Visual tab).

  5. apply_filters( mce_buttons_2 )filterline 599 (+74 into the body)

    Filters the second-row list of TinyMCE buttons (Visual tab).

  6. apply_filters( mce_buttons_3 )filterline 601 (+76 into the body)

    Filters the third-row list of TinyMCE buttons (Visual tab).

  7. apply_filters( mce_buttons_4 )filterline 603 (+78 into the body)

    Filters the fourth-row list of TinyMCE buttons (Visual tab).

  8. apply_filters( mce_external_plugins )filterline 605 (+80 into the body)

    Filters the list of TinyMCE external plugins.

  9. apply_filters( tiny_mce_before_init )filterline 626 (+101 into the body)

    Filters the TinyMCE config before init.

Uses · 3

Source code

function wp_tinymce_inline_scripts() {	global $wp_scripts; 	/** This filter is documented in wp-includes/class-wp-editor.php */	$editor_settings = apply_filters( 'wp_editor_settings', array( 'tinymce' => true ), 'classic-block' ); 	$tinymce_plugins = array(		'charmap',		'colorpicker',		'hr',		'lists',		'media',		'paste',		'tabfocus',		'textcolor',		'fullscreen',		'wordpress',		'wpautoresize',		'wpeditimage',		'wpemoji',		'wpgallery',		'wplink',		'wpdialogs',		'wptextpattern',		'wpview',	); 	/** This filter is documented in wp-includes/class-wp-editor.php */	$tinymce_plugins = apply_filters( 'tiny_mce_plugins', $tinymce_plugins, 'classic-block' );	$tinymce_plugins = array_unique( $tinymce_plugins ); 	$disable_captions = false;	// Runs after `tiny_mce_plugins` but before `mce_buttons`.	/** This filter is documented in wp-admin/includes/media.php */	if ( apply_filters( 'disable_captions', '' ) ) {		$disable_captions = true;	} 	$toolbar1 = array(		'formatselect',		'bold',		'italic',		'bullist',		'numlist',		'blockquote',		'alignleft',		'aligncenter',		'alignright',		'link',		'unlink',		'wp_more',		'spellchecker',		'wp_add_media',		'wp_adv',	); 	/** This filter is documented in wp-includes/class-wp-editor.php */	$toolbar1 = apply_filters( 'mce_buttons', $toolbar1, 'classic-block' ); 	$toolbar2 = array(		'strikethrough',		'hr',		'forecolor',		'pastetext',		'removeformat',		'charmap',		'outdent',		'indent',		'undo',		'redo',		'wp_help',	); 	/** This filter is documented in wp-includes/class-wp-editor.php */	$toolbar2 = apply_filters( 'mce_buttons_2', $toolbar2, 'classic-block' );	/** This filter is documented in wp-includes/class-wp-editor.php */	$toolbar3 = apply_filters( 'mce_buttons_3', array(), 'classic-block' );	/** This filter is documented in wp-includes/class-wp-editor.php */	$toolbar4 = apply_filters( 'mce_buttons_4', array(), 'classic-block' );	/** This filter is documented in wp-includes/class-wp-editor.php */

Changelog

Introduced in 5.0.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 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/script-loader.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.