WP_Customize_Manager::establish_loaded_changeset()
- Since
- 4.9.0
- Source
wp-includes/class-wp-customize-manager.php:624
Description
This method runs right at after_setup_theme and applies the 'customize_changeset_branching' filter to determine whether concurrent changesets are allowed. Then if the Customizer is not initialized with a changeset_uuid param, this method will determine which UUID should be used. If changeset branching is disabled, then the most saved changeset will be loaded by default. Otherwise, if there are no existing saved changesets or if changeset branching is enabled, then a new UUID will be generated.
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.
Performance profile
How much work a call to WP_Customize_Manager::establish_loaded_changeset() 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
- Trivial
- Scaling
- Constant
- Instructions
- 7–57
- Plugin surface
- None
- Called by
- 1
Touches nothing outside its own arguments.
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 57.
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 one call costs · 18 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Customize_Manager::establish_loaded_changeset() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!empty($value) | 7–9 | is_admin() |
!empty($value) && is_admin() && $pagenow === "customize.php" | 14 | is_admin(), ->changeset_post_id(), ->set_changeset_lock() |
empty($value) && ->branching() && !empty($changeset_uuid) | 15–17 | ->branching(), is_admin() |
empty($value) && ->branching() && empty($changeset_uuid) | 18–20 | ->branching(), wp_generate_uuid4(), is_admin() |
empty($value) && !->branching() && !->is_theme_active() && !empty($changeset_uuid) | 18–20 | ->branching(), ->is_theme_active(), is_admin() |
empty($value) && !->branching() && !->is_theme_active() && empty($changeset_uuid) | 21–23 | ->branching(), ->is_theme_active(), wp_generate_uuid4(), is_admin() |
empty($value) && ->branching() && !empty($changeset_uuid) && is_admin() && $pagenow === "customize.php" | 22 | ->branching(), is_admin(), ->changeset_post_id(), ->set_changeset_lock() |
empty($value) && ->branching() && empty($changeset_uuid) && is_admin() && $pagenow === "customize.php" | 25 | ->branching(), wp_generate_uuid4(), is_admin(), ->changeset_post_id(), ->set_changeset_lock() |
empty($value) && !->branching() && !->is_theme_active() && !empty($changeset_uuid) && is_admin() && $pagenow === "customize.php" | 25 | ->branching(), ->is_theme_active(), is_admin(), ->changeset_post_id(), ->set_changeset_lock() |
empty($value) && !->branching() && !->is_theme_active() && empty($changeset_uuid) && is_admin() && $pagenow === "customize.php" | 28 | ->branching(), ->is_theme_active(), wp_generate_uuid4(), is_admin(), ->changeset_post_id(), ->set_changeset_lock() |
empty($value) && !->branching() && ->is_theme_active() && empty($unpublished_changeset_post) && !empty($changeset_uuid) | 40–42 | ->branching(), ->is_theme_active(), get_post_stati(), array_diff(), post_status(), array_shift(), is_admin() |
empty($value) && !->branching() && ->is_theme_active() && empty($unpublished_changeset_post) && empty($changeset_uuid) | 43–45 | ->branching(), ->is_theme_active(), get_post_stati(), array_diff(), post_status(), array_shift(), wp_generate_uuid4(), is_admin() |
6 further outcomes, up to 57 instructions
empty($value) && !->branching() && ->is_theme_active() && !empty($unpublished_changeset_post) && !empty($changeset_uuid) | 46–49 | ->branching(), ->is_theme_active(), get_post_stati(), array_diff(), post_status(), array_shift(), wp_is_uuid(), is_admin() |
empty($value) && !->branching() && ->is_theme_active() && empty($unpublished_changeset_post) && !empty($changeset_uuid) && is_admin() && $pagenow === "customize.php" | 47 | ->branching(), ->is_theme_active(), get_post_stati(), array_diff(), post_status(), array_shift(), is_admin(), ->changeset_post_id(), ->set_changeset_lock() |
empty($value) && !->branching() && ->is_theme_active() && !empty($unpublished_changeset_post) && empty($changeset_uuid) | 49–52 | ->branching(), ->is_theme_active(), get_post_stati(), array_diff(), post_status(), array_shift(), wp_is_uuid(), wp_generate_uuid4(), is_admin() |
empty($value) && !->branching() && ->is_theme_active() && empty($unpublished_changeset_post) && empty($changeset_uuid) && is_admin() && $pagenow === "customize.php" | 50 | ->branching(), ->is_theme_active(), get_post_stati(), array_diff(), post_status(), array_shift(), wp_generate_uuid4(), is_admin(), ->changeset_post_id(), ->set_changeset_lock() |
empty($value) && !->branching() && ->is_theme_active() && !empty($unpublished_changeset_post) && !empty($changeset_uuid) && is_admin() && $pagenow === "customize.php" | 53–54 | ->branching(), ->is_theme_active(), get_post_stati(), array_diff(), post_status(), array_shift(), wp_is_uuid(), is_admin(), ->changeset_post_id(), ->set_changeset_lock() |
empty($value) && !->branching() && ->is_theme_active() && !empty($unpublished_changeset_post) && empty($changeset_uuid) && is_admin() && $pagenow === "customize.php" | 56–57 | ->branching(), ->is_theme_active(), get_post_stati(), array_diff(), post_status(), array_shift(), wp_is_uuid(), wp_generate_uuid4(), is_admin(), ->changeset_post_id(), ->set_changeset_lock() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 57 instructions, 7–57 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 · 9
- get_post_stati()Gets a list of post statuses.
- wp_is_uuid()Validates that a UUID is valid.
- wp_generate_uuid4()Generates a random UUID (version 4).
- is_admin()Determines whether the current request is for an administrative interface page.
- WP_Customize_Manager::branching()Whether the changeset branching is allowed.
- WP_Customize_Manager::is_theme_active()Checks if the current theme is active.
- WP_Customize_Manager::get_changeset_posts()Gets changeset posts.
- WP_Customize_Manager::set_changeset_lock()Marks the changeset post as being currently edited by the current user.
- WP_Customize_Manager::changeset_post_id()Gets the changeset post ID for the loaded changeset.
Used by · 1
- WP_Customize_Manager::changeset_uuid()Gets the changeset UUID.
Source code
public function establish_loaded_changeset() { global $pagenow; if ( empty( $this->_changeset_uuid ) ) { $changeset_uuid = null; if ( ! $this->branching() && $this->is_theme_active() ) { $unpublished_changeset_posts = $this->get_changeset_posts( array( 'post_status' => array_diff( get_post_stati(), array( 'auto-draft', 'publish', 'trash', 'inherit', 'private' ) ), 'exclude_restore_dismissed' => false, 'author' => 'any', 'posts_per_page' => 1, 'order' => 'DESC', 'orderby' => 'date', ) ); $unpublished_changeset_post = array_shift( $unpublished_changeset_posts ); if ( ! empty( $unpublished_changeset_post ) && wp_is_uuid( $unpublished_changeset_post->post_name ) ) { $changeset_uuid = $unpublished_changeset_post->post_name; } } // If no changeset UUID has been set yet, then generate a new one. if ( empty( $changeset_uuid ) ) { $changeset_uuid = wp_generate_uuid4(); } $this->_changeset_uuid = $changeset_uuid; } if ( is_admin() && 'customize.php' === $pagenow ) { $this->set_changeset_lock( $this->changeset_post_id() ); } }Changelog
Introduced in 4.9.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.7.7 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.