_WP_Editors::parse_settings( string $editor_id, array $settings ): array
- Since
- 3.3.0
- Source
wp-includes/class-wp-editor.php:70
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- HTML ID for the textarea and TinyMCE and Quicktags instances.
Should not contain square brackets. $settingsarray- Array of editor arguments.
$wpautopbooldefault: trueWhether to use wpautop().$media_buttonsboolWhether to show the Add Media/other media buttons.$default_editorstringdefault: emptyWhen both TinyMCE and Quicktags are used, set which editor is shown on page load.$drag_drop_uploadbooldefault: false. Requires the media modalWhether to enable drag & drop on the editor uploading.$textarea_namestringdefault: $editor_idGive the textarea a unique name here. Square brackets can be used here.$textarea_rowsintdefault: 20Number rows in the editor textarea.$tabindexstring|intdefault: emptyTabindex value to use.$tabfocus_elementsstringdefault: ':prev,:next'The previous and next element ID to move the focus to when pressing the Tab key in TinyMCE.$editor_cssstringdefault: emptyIntended for extra styles for both Visual and Code editors. Should include<style>tags, and can use "scoped".$editor_classstringdefault: emptyExtra classes to add to the editor textarea element.$teenybooldefault: falseWhether to output the minimal editor config. Examples include Press This and the Comment editor.$dfwboolDeprecated in 4.1. Unused.$tinymcebool|arraydefault: trueWhether to load TinyMCE. Can be used to pass settings directly to TinyMCE using an array.$quicktagsbool|arraydefault: trueWhether to load Quicktags. Can be used to pass settings directly to Quicktags using an array.
Return value
array- Parsed arguments array.
Performance profile
How much work a call to _WP_Editors::parse_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
- 47–83
- Plugin surface
- 1 hook
- 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 87.
Third-party callbacks on 'wp_editor_settings' 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()one call below _WP_Editors::parse_settings()
Further down the call graph this can also reach 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::parse_settings() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!$set | 47–66 | apply_filters(), has_blocks(), wpautop() |
$set | 50–69 | apply_filters(), has_blocks(), wpautop(), user_can_richedit() |
!$set && $editor_id | 56–73 | apply_filters(), has_blocks(), wpautop(), _deprecated_argument() |
$set && $editor_id | 59–76 | apply_filters(), has_blocks(), wpautop(), user_can_richedit(), _deprecated_argument() |
!$set && !empty($set) && $editor_id === "content" && empty($value) | 62–73 | apply_filters(), has_blocks(), wpautop(), get_user_setting() |
$set && !empty($set) && $editor_id === "content" && empty($value) | 65–76 | apply_filters(), has_blocks(), wpautop(), user_can_richedit(), get_user_setting() |
!$set && $editor_id && !empty($set) && $editor_id === "content" && empty($value) | 71–80 | apply_filters(), has_blocks(), wpautop(), _deprecated_argument(), get_user_setting() |
$set && $editor_id && !empty($set) && $editor_id === "content" && empty($value) | 74–83 | apply_filters(), has_blocks(), wpautop(), user_can_richedit(), _deprecated_argument(), get_user_setting() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 87 | 47–83 | 11 | |
| 8.5 | 87 | 47–83 | 11 | |
| 8.4 | 87 | 47–83 | 11 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 90 | 47–86 | 11 | |
| 8.2 | 90 | 47–86 | 11 | |
| 8.1 | 90 | 47–86 | 11 | |
| 7.4 | 90 | 47–86 | 11 |
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::parse_settings() runs, in this order:
- apply_filters( wp_editor_settings )filterline 83 (+13 into the body)
Filters the wp_editor() settings.
Uses · 7
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_parse_args()Merges user defined arguments into defaults array.
- has_blocks()Determines whether a post or content string has blocks.
- user_can_richedit()Determines whether the user can access the visual editor.
- str_contains()Polyfill for `str_contains()` function added in PHP 8.0.
- _deprecated_argument()Marks a function argument as deprecated and inform when it has been used.
- get_user_setting()Retrieves user interface setting value based on setting name.
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 parse_settings( $editor_id, $settings ) { /** * Filters the wp_editor() settings. * * @since 4.0.0 * * @see _WP_Editors::parse_settings() * * @param array $settings Array of editor arguments. * @param string $editor_id Unique editor identifier, e.g. 'content'. Accepts 'classic-block' * when called from block editor's Classic block. */ $settings = apply_filters( 'wp_editor_settings', $settings, $editor_id ); $set = wp_parse_args( $settings, array( // Disable autop if the current post has blocks in it. 'wpautop' => ! has_blocks(), 'media_buttons' => true, 'default_editor' => '', 'drag_drop_upload' => false, 'textarea_name' => $editor_id, 'textarea_rows' => 20, 'tabindex' => '', 'tabfocus_elements' => ':prev,:next', 'editor_css' => '', 'editor_class' => '', 'teeny' => false, '_content_editor_dfw' => false, 'tinymce' => true, 'quicktags' => true, ) ); self::$this_tinymce = ( $set['tinymce'] && user_can_richedit() ); if ( self::$this_tinymce ) { if ( str_contains( $editor_id, '[' ) ) { self::$this_tinymce = false; _deprecated_argument( 'wp_editor()', '3.9.0', 'TinyMCE editor IDs cannot have brackets.' ); } } self::$this_quicktags = (bool) $set['quicktags']; if ( self::$this_tinymce ) { self::$has_tinymce = true; } if ( self::$this_quicktags ) { self::$has_quicktags = true; } if ( empty( $set['editor_height'] ) ) { return $set; } if ( 'content' === $editor_id && empty( $set['tinymce']['wp_autoresize_on'] ) ) { // A cookie (set when a user resizes the editor) overrides the height. $cookie = (int) get_user_setting( 'ed_size' ); if ( $cookie ) { $set['editor_height'] = $cookie; } } if ( $set['editor_height'] < 50 ) { $set['editor_height'] = 50; } elseif ( $set['editor_height'] > 5000 ) { $set['editor_height'] = 5000; } return $set; }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.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.