_WP_Editors::get_mce_locale(): string
- Since
- 4.8.0
- Source
wp-includes/class-wp-editor.php:1035
Compatibility
- WordPress
- since 4.8.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.
Return value
string
Performance profile
How much work a call to _WP_Editors::get_mce_locale() 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
- 4–17
- Plugin surface
- None
- Called by
- 3
Reaches the database via get_user_by().
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 19.
Nothing here hands control to plugin code.
3 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- querycontent query
get_user_by()one call below _WP_Editors::get_mce_locale()
Further down the call graph this can also reach hook, 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 · 3 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost _WP_Editors::get_mce_locale() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 4 | none |
empty($mce_locale) | 13 | get_user_locale() |
!empty($mce_locale) | 17 | get_user_locale(), strtolower() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 18 | 4–16 | 2 | 1 fewer instruction than PHP 8.5 |
| 8.5 | 19 | 4–17 | 2 | |
| 8.4 | 19 | 4–17 | 2 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 22 | 4–20 | 2 | |
| 8.2 | 22 | 4–20 | 2 | |
| 8.1 | 22 | 4–20 | 2 | |
| 7.4 | 22 | 4–20 | 2 |
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.
Uses · 1
- get_user_locale()Retrieves the locale of a user.
Used by · 3
- _WP_Editors::default_settings()Returns the default TinyMCE settings.
- _WP_Editors::editor_settings()
- _WP_Editors::wp_mce_translation()Translates the default TinyMCE strings and returns them as JSON encoded object ready to be loaded with tinymce.addI18n(), or as JS snippet that should run after tinymce.js is loaded.
Source code
public static function get_mce_locale() { if ( empty( self::$mce_locale ) ) { $mce_locale = get_user_locale(); self::$mce_locale = empty( $mce_locale ) ? 'en' : strtolower( substr( $mce_locale, 0, 2 ) ); // ISO 639-1. } return self::$mce_locale; }Changelog
Introduced in 4.8.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 6.9.7 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.