wppaste
WordPress

_WP_Editors::editor_settings( string $editor_id, array $set )

Since
3.3.0
Source
wp-includes/class-wp-editor.php:321

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.

Parameters

$editor_idstring
Unique editor identifier, e.g. 'content'.
$setarray
Array of editor arguments.

Performance profile

How much work a call to _WP_Editors::editor_settings() 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
Heavy

Reaches the database via get_post().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
9–185

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

Plugin surface
14 hooks

Third-party callbacks on 'quicktags_settings', 'teeny_mce_plugins', 'mce_external_plugins' run inside this call, and their cost is not bounded by anything here.

Called by
2

2 places in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • querycontent queryget_post()called directly

Further down the call graph this can also reach cache, option, 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 · 27 distinct outcomes

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

WhenInstructionsCalls it makes
always9none
!$set && wp_is_mobile()109–125wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), apply_filters()
!$set && wp_is_mobile()115–131wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), array_merge(), apply_filters()
!$set && wp_is_mobile() && !post_type_supports() && $page_template === false136–152wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_page_template_slug(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), apply_filters()
!$set && wp_is_mobile() && !post_type_supports() && $page_template === false142–158wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_page_template_slug(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && $page_template === false142–158wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), get_page_template_slug(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), apply_filters()
!$set && wp_is_mobile() && !post_type_supports() && $page_template !== false && empty($page_template)146–162wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_page_template_slug(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && is_wp_error() && $page_template === false146–162wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), is_wp_error(), get_page_template_slug(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && $page_template === false148–164wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), get_page_template_slug(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), array_merge(), apply_filters()
!$set && wp_is_mobile() && !post_type_supports() && $page_template !== false && !empty($page_template)150–166wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_page_template_slug(), basename(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && !is_wp_error() && $page_template === false151–165wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), is_wp_error(), sanitize_html_class(), get_page_template_slug(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), apply_filters()
!$set && wp_is_mobile() && !post_type_supports() && $page_template !== false && empty($page_template)152–168wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_page_template_slug(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), array_merge(), apply_filters()
15 further outcomes, up to 185 instructions
!$set && wp_is_mobile() && post_type_supports() && $page_template !== false && empty($page_template)152–168wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), get_page_template_slug(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && is_wp_error() && $page_template === false152–166wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), is_wp_error(), get_page_template_slug(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), array_merge(), apply_filters()
!$set && wp_is_mobile() && !post_type_supports() && $page_template !== false && !empty($page_template)156–172wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_page_template_slug(), basename(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && $page_template !== false && !empty($page_template)156–172wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), get_page_template_slug(), basename(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && is_wp_error() && $page_template !== false && empty($page_template)156–170wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), is_wp_error(), get_page_template_slug(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && !is_wp_error() && $page_template === false157–171wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), is_wp_error(), sanitize_html_class(), get_page_template_slug(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && $page_template !== false && empty($page_template)158–174wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), get_page_template_slug(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && is_wp_error() && $page_template !== false && !empty($page_template)160–174wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), is_wp_error(), get_page_template_slug(), basename(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && !is_wp_error() && $page_template !== false && empty($page_template)161–175wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), is_wp_error(), sanitize_html_class(), get_page_template_slug(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && $page_template !== false && !empty($page_template)162–178wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), get_page_template_slug(), basename(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && is_wp_error() && $page_template !== false && empty($page_template)162–176wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), is_wp_error(), get_page_template_slug(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && !is_wp_error() && $page_template !== false && !empty($page_template)165–179wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), is_wp_error(), sanitize_html_class(), get_page_template_slug(), basename(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && is_wp_error() && $page_template !== false && !empty($page_template)166–180wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), is_wp_error(), get_page_template_slug(), basename(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && !is_wp_error() && $page_template !== false && empty($page_template)167–181wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), is_wp_error(), sanitize_html_class(), get_page_template_slug(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), array_merge(), apply_filters()
!$set && wp_is_mobile() && post_type_supports() && !is_wp_error() && $page_template !== false && !empty($page_template)171–185wp_is_mobile(), apply_filters(), wp_is_mobile(), apply_filters(), apply_filters(), apply_filters(), get_post(), sanitize_html_class(), sanitize_html_class(), post_type_supports(), get_post_format(), is_wp_error(), sanitize_html_class(), get_page_template_slug(), basename(), sanitize_html_class(), get_user_locale(), strtolower(), sanitize_html_class(), array_merge(), array_merge(), apply_filters()

This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev5709–18552
8.55709–18552
8.45709–1855245 fewer instructions than PHP 8.3
8.36159–20452
8.26159–20452
8.16159–20452
7.46159–20452

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

14 hooks fire while _WP_Editors::editor_settings() runs, in this order:

  1. apply_filters( quicktags_settings )filterline 361 (+40 into the body)

    Filters the Quicktags settings.

  2. apply_filters( teeny_mce_plugins )filterline 386 (+65 into the body)

    Filters the list of teenyMCE plugins.

  3. apply_filters( mce_external_plugins )filterline 421 (+100 into the body)

    Filters the list of TinyMCE external plugins.

  4. apply_filters( tiny_mce_plugins )filterline 461 (+140 into the body)

    Filters the list of default TinyMCE plugins.

  5. apply_filters( mce_external_languages )filterline 489 (+168 into the body)

    Filters the translations loaded for external TinyMCE 3.x plugins.

  6. apply_filters( disable_captions )filterline 567 (+246 into the body)

    Filters whether to disable captions.

  7. apply_filters( mce_css )filterline 600 (+279 into the body)

    Filters the comma-delimited list of stylesheets to load in TinyMCE.

  8. apply_filters( teeny_mce_buttons )filterline 638 (+317 into the body)

    Filters the list of teenyMCE buttons (Code tab).

  9. apply_filters( mce_buttons )filterline 680 (+359 into the body)

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

  10. apply_filters( mce_buttons_2 )filterline 709 (+388 into the body)

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

  11. apply_filters( mce_buttons_3 )filterline 721 (+400 into the body)

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

  12. apply_filters( mce_buttons_4 )filterline 733 (+412 into the body)

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

  13. apply_filters( teeny_mce_before_init )filterline 804 (+483 into the body)

    Filters the teenyMCE config before init.

  14. apply_filters( tiny_mce_before_init )filterline 817 (+496 into the body)

    Filters the TinyMCE config before init.

Uses · 20

Show all 20

Used by · 2

Source code

	public static function editor_settings( $editor_id, $set ) {		if ( empty( self::$first_init ) ) {			if ( is_admin() ) {				add_action( 'admin_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 );				add_action( 'admin_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 );				add_action( 'admin_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 );			} else {				add_action( 'wp_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 );				add_action( 'wp_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 );				add_action( 'wp_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 );			}		} 		if ( self::$this_quicktags ) { 			$qt_init = array(				'id'      => $editor_id,				'buttons' => '',			); 			if ( is_array( $set['quicktags'] ) ) {				$qt_init = array_merge( $qt_init, $set['quicktags'] );			} 			if ( empty( $qt_init['buttons'] ) ) {				$qt_init['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close';			} 			if ( $set['_content_editor_dfw'] ) {				$qt_init['buttons'] .= ',dfw';			} 			/**			 * Filters the Quicktags settings.			 *			 * @since 3.3.0			 *			 * @param array  $qt_init   Quicktags settings.			 * @param string $editor_id Unique editor identifier, e.g. 'content'.			 */			$qt_init = apply_filters( 'quicktags_settings', $qt_init, $editor_id ); 			self::$qt_settings[ $editor_id ] = $qt_init; 			self::$qt_buttons = array_merge( self::$qt_buttons, explode( ',', $qt_init['buttons'] ) );		} 		if ( self::$this_tinymce ) { 			if ( empty( self::$first_init ) ) {				$baseurl     = self::get_baseurl();				$mce_locale  = self::get_mce_locale();				$ext_plugins = ''; 				if ( $set['teeny'] ) { 					/**					 * Filters the list of teenyMCE plugins.					 *					 * @since 2.7.0					 * @since 3.3.0 The `$editor_id` parameter was added.					 *					 * @param array  $plugins   An array of teenyMCE plugins.					 * @param string $editor_id Unique editor identifier, e.g. 'content'.					 */					$plugins = apply_filters(						'teeny_mce_plugins',						array(							'colorpicker',							'lists',							'fullscreen',							'image',							'wordpress',							'wpeditimage',							'wplink',						),						$editor_id					);				} else {

Changelog

Introduced in 3.3.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.0.4 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.