wppaste
WordPress

_WP_Editors::parse_settings( string $editor_id, array $settings ): array

Since
3.3.0
Source
wp-includes/class-wp-editor.php:70
Parse default arguments for the editor instance.

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: true

    Whether to use wpautop().
  • $media_buttonsbool

    Whether to show the Add Media/other media buttons.
  • $default_editorstringdefault: empty

    When both TinyMCE and Quicktags are used, set which editor is shown on page load.
  • $drag_drop_uploadbooldefault: false. Requires the media modal

    Whether to enable drag & drop on the editor uploading.
  • $textarea_namestringdefault: $editor_id

    Give the textarea a unique name here. Square brackets can be used here.
  • $textarea_rowsintdefault: 20

    Number rows in the editor textarea.
  • $tabindexstring|intdefault: empty

    Tabindex 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: empty

    Intended for extra styles for both Visual and Code editors. Should include <style> tags, and can use "scoped".
  • $editor_classstringdefault: empty

    Extra classes to add to the editor textarea element.
  • $teenybooldefault: false

    Whether to output the minimal editor config. Examples include Press This and the Comment editor.
  • $dfwbool

    Deprecated in 4.1. Unused.
  • $tinymcebool|arraydefault: true

    Whether to load TinyMCE. Can be used to pass settings directly to TinyMCE using an array.
  • $quicktagsbool|arraydefault: true

    Whether 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

Reaches the database via get_post().

Scaling
Constant

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

Instructions
47–83

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

Plugin surface
1 hook

Third-party callbacks on 'wp_editor_settings' 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()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.

WhenInstructionsCalls it makes
!$set47–66apply_filters(), has_blocks(), wpautop()
$set50–69apply_filters(), has_blocks(), wpautop(), user_can_richedit()
!$set && $editor_id56–73apply_filters(), has_blocks(), wpautop(), _deprecated_argument()
$set && $editor_id59–76apply_filters(), has_blocks(), wpautop(), user_can_richedit(), _deprecated_argument()
!$set && !empty($set) && $editor_id === "content" && empty($value)62–73apply_filters(), has_blocks(), wpautop(), get_user_setting()
$set && !empty($set) && $editor_id === "content" && empty($value)65–76apply_filters(), has_blocks(), wpautop(), user_can_richedit(), get_user_setting()
!$set && $editor_id && !empty($set) && $editor_id === "content" && empty($value)71–80apply_filters(), has_blocks(), wpautop(), _deprecated_argument(), get_user_setting()
$set && $editor_id && !empty($set) && $editor_id === "content" && empty($value)74–83apply_filters(), has_blocks(), wpautop(), user_can_richedit(), _deprecated_argument(), get_user_setting()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev8747–8311
8.58747–8311
8.48747–83113 fewer instructions than PHP 8.3
8.39047–8611
8.29047–8611
8.19047–8611
7.49047–8611

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:

  1. apply_filters( wp_editor_settings )filterline 83 (+13 into the body)

    Filters the wp_editor() settings.

Uses · 7

Used by · 2

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.

  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 6.8.8 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.