_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
- Scaling
- Constant
- Instructions
- 9–185
- Plugin surface
- 14 hooks
- Called by
- 2
Reaches the database via get_post().
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 570.
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.
2 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly - querycontent query
get_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.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 9 | none |
!$set && wp_is_mobile() | 109–125 | wp_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–131 | wp_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 === false | 136–152 | wp_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 === false | 142–158 | wp_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 === false | 142–158 | wp_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–162 | wp_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 === false | 146–162 | wp_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 === false | 148–164 | wp_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–166 | wp_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 === false | 151–165 | wp_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–168 | wp_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–168 | wp_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 === false | 152–166 | wp_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–172 | wp_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–172 | wp_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–170 | wp_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 === false | 157–171 | wp_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–174 | wp_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–174 | wp_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–175 | wp_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–178 | wp_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–176 | wp_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–179 | wp_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–180 | wp_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–181 | wp_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–185 | wp_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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 570 | 9–185 | 52 | |
| 8.5 | 570 | 9–185 | 52 | |
| 8.4 | 570 | 9–185 | 52 | 45 fewer instructions than PHP 8.3 |
| 8.3 | 615 | 9–204 | 52 | |
| 8.2 | 615 | 9–204 | 52 | |
| 8.1 | 615 | 9–204 | 52 | |
| 7.4 | 615 | 9–204 | 52 |
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:
- apply_filters( quicktags_settings )filterline 361 (+40 into the body)
Filters the Quicktags settings.
- apply_filters( teeny_mce_plugins )filterline 386 (+65 into the body)
Filters the list of teenyMCE plugins.
- apply_filters( mce_external_plugins )filterline 421 (+100 into the body)
Filters the list of TinyMCE external plugins.
- apply_filters( tiny_mce_plugins )filterline 461 (+140 into the body)
Filters the list of default TinyMCE plugins.
- apply_filters( mce_external_languages )filterline 489 (+168 into the body)
Filters the translations loaded for external TinyMCE 3.x plugins.
- apply_filters( disable_captions )filterline 567 (+246 into the body)
Filters whether to disable captions.
- apply_filters( mce_css )filterline 600 (+279 into the body)
Filters the comma-delimited list of stylesheets to load in TinyMCE.
- apply_filters( teeny_mce_buttons )filterline 638 (+317 into the body)
Filters the list of teenyMCE buttons (Code tab).
- apply_filters( mce_buttons )filterline 680 (+359 into the body)
Filters the first-row list of TinyMCE buttons (Visual tab).
- apply_filters( mce_buttons_2 )filterline 709 (+388 into the body)
Filters the second-row list of TinyMCE buttons (Visual tab).
- apply_filters( mce_buttons_3 )filterline 721 (+400 into the body)
Filters the third-row list of TinyMCE buttons (Visual tab).
- apply_filters( mce_buttons_4 )filterline 733 (+412 into the body)
Filters the fourth-row list of TinyMCE buttons (Visual tab).
- apply_filters( teeny_mce_before_init )filterline 804 (+483 into the body)
Filters the teenyMCE config before init.
- apply_filters( tiny_mce_before_init )filterline 817 (+496 into the body)
Filters the TinyMCE config before init.
Uses · 20
- is_admin()Determines whether the current request is for an administrative interface page.
- add_action()Adds a callback function to an action hook.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- set_url_scheme()Sets the scheme for a URL.
- content_url()Retrieves the URL to the content directory.
- trailingslashit()Appends a trailing slash.
- wp_json_encode()Encodes a variable into JSON, with some confidence checks.
- get_editor_stylesheets()Retrieves any registered editor stylesheet URLs.
- str_contains()Polyfill for `str_contains()` function added in PHP 8.0.
- wp_is_mobile()Test if the current browser runs on a mobile device (smart phone, tablet, etc.).
- get_post()Retrieves post data given a post ID or post object.
- sanitize_html_class()Sanitizes an HTML classname to ensure it only contains valid characters.
Show all 20
- post_type_supports()Checks a post type's support for a given feature.
- get_post_format()Retrieve the format slug for a post
- is_wp_error()Checks whether the given variable is a WordPress Error.
- get_page_template_slug()Gets the specific template filename for a given post.
- get_user_locale()Retrieves the locale of a user.
- _WP_Editors::get_baseurl()Returns the TinyMCE base URL.
- _WP_Editors::get_mce_locale()Returns the TinyMCE locale.
- _WP_Editors::default_settings()Returns the default TinyMCE settings.
Used by · 2
- _WP_Editors::editor()Outputs the HTML for a single instance of the editor.
- wp_tiny_mce()Outputs the TinyMCE editor.
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.
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.