WP_Customize_Manager::changeset_data(): array
- Since
- 4.7.0, 4.9.0
- Source
wp-includes/class-wp-customize-manager.php:1157
Compatibility
- WordPress
- since 4.9.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
array- Changeset data.
Performance profile
How much work a call to WP_Customize_Manager::changeset_data() 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–47
- Plugin surface
- None
- Called by
- 1
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 54.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- querycontent query
get_post()one call below WP_Customize_Manager::changeset_data() - hookthird-party callbacks
do_action()one call below WP_Customize_Manager::changeset_data()
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 · 9 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Customize_Manager::changeset_data() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
isset($value) | 4 | none |
!isset($value) | 11 | ->changeset_post_id() |
!->autosaved() | 13 | ->changeset_post_id(), ->autosaved() |
->autosaved() && !is_user_logged_in() | 16 | ->changeset_post_id(), ->autosaved(), is_user_logged_in() |
!isset($value) && !->autosaved() | 23–24 | ->changeset_post_id(), ->autosaved(), ->get_changeset_post_data(), is_wp_error() |
->autosaved() && is_user_logged_in() | 24 | ->changeset_post_id(), ->autosaved(), is_user_logged_in(), get_current_user_id(), wp_get_post_autosave() |
!isset($value) && ->autosaved() && !is_user_logged_in() | 26–27 | ->changeset_post_id(), ->autosaved(), is_user_logged_in(), ->get_changeset_post_data(), is_wp_error() |
!isset($value) && ->autosaved() && is_user_logged_in() | 34–36 | ->changeset_post_id(), ->autosaved(), is_user_logged_in(), get_current_user_id(), wp_get_post_autosave(), ->get_changeset_post_data(), is_wp_error() |
!isset($value) && ->autosaved() && is_user_logged_in() | 44–47 | ->changeset_post_id(), ->autosaved(), is_user_logged_in(), get_current_user_id(), wp_get_post_autosave(), ->get_changeset_post_data(), is_wp_error(), ->get_changeset_post_data(), is_wp_error() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 54 instructions, 4–47 executed per call, 8 branches. The work does not change between versions.
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 · 7
- is_user_logged_in()Determines whether the current visitor is a logged in user.
- wp_get_post_autosave()Retrieves the autosaved data of the specified post.
- get_current_user_id()Gets the current user's ID.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- WP_Customize_Manager::changeset_post_id()Gets the changeset post ID for the loaded changeset.
- WP_Customize_Manager::autosaved()Gets whether data from a changeset's autosaved revision should be loaded if it exists.
- WP_Customize_Manager::get_changeset_post_data()Gets the data stored in a changeset post.
Used by · 1
- WP_Customize_Manager::unsanitized_post_values()Gets dirty pre-sanitized setting values in the current customized state.
Source code
public function changeset_data() { if ( isset( $this->_changeset_data ) ) { return $this->_changeset_data; } $changeset_post_id = $this->changeset_post_id(); if ( ! $changeset_post_id ) { $this->_changeset_data = array(); } else { if ( $this->autosaved() && is_user_logged_in() ) { $autosave_post = wp_get_post_autosave( $changeset_post_id, get_current_user_id() ); if ( $autosave_post ) { $data = $this->get_changeset_post_data( $autosave_post->ID ); if ( ! is_wp_error( $data ) ) { $this->_changeset_data = $data; } } } // Load data from the changeset if it was not loaded from an autosave. if ( ! isset( $this->_changeset_data ) ) { $data = $this->get_changeset_post_data( $changeset_post_id ); if ( ! is_wp_error( $data ) ) { $this->_changeset_data = $data; } else { $this->_changeset_data = array(); } } } return $this->_changeset_data; }Changelog
Introduced in 4.7.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-customize-manager.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.