_wp_customize_publish_changeset( string $new_status, string $old_status, WP_Post $changeset_post )
- Since
- 4.7.0
- Source
wp-includes/theme.php:3639
Parameters
$new_statusstring- New post status.
$old_statusstring- Old post status.
$changeset_postWP_Post- Changeset post object.
Performance profile
How much work a call to _wp_customize_publish_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
- 10–57
- Plugin surface
- 1 hook
- Called by
- 0
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.4, depending on the branch taken. The body compiles to 58.
Third-party callbacks on 'customize_register' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
do_action()called directly
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_publish_changeset() can have, taken from its control-flow graph on PHP 8.4.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 10–13 | none |
!empty($wp_customize) && did_action() && wp_revisions_enabled() | 25–28 | did_action()->_publish_changeset_values()wp_revisions_enabled() |
!empty($wp_customize) && did_action() && !wp_revisions_enabled() | 30–33 | did_action()->_publish_changeset_values()wp_revisions_enabled()->trash_changeset_post() |
empty($wp_customize) && did_action() && wp_revisions_enabled() | 37–40 | changeset_uuid()did_action()->_publish_changeset_values()wp_revisions_enabled() |
!empty($wp_customize) && !did_action() && wp_revisions_enabled() | 37–40 | did_action()->register_controls()do_action()->_publish_changeset_values()wp_revisions_enabled() |
empty($wp_customize) && did_action() && !wp_revisions_enabled() | 42–45 | changeset_uuid()did_action()->_publish_changeset_values()wp_revisions_enabled()->trash_changeset_post() |
!empty($wp_customize) && !did_action() && !wp_revisions_enabled() | 42–45 | did_action()->register_controls()do_action()->_publish_changeset_values()wp_revisions_enabled()->trash_changeset_post() |
empty($wp_customize) && !did_action() && wp_revisions_enabled() | 49–52 | changeset_uuid()did_action()->register_controls()do_action()->_publish_changeset_values()wp_revisions_enabled() |
empty($wp_customize) && !did_action() && !wp_revisions_enabled() | 54–57 | changeset_uuid()did_action()->register_controls()do_action()->_publish_changeset_values()wp_revisions_enabled()->trash_changeset_post() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
7.4 | 58 | 10–57 | 6 | Compiles to the same instructions |
8.1 | 58 | 10–57 | 6 | Compiles to the same instructions |
8.2 | 58 | 10–57 | 6 | Compiles to the same instructions |
8.3 | 58 | 10–57 | 6 | Compiles to the same instructions |
8.4 | 58 | 10–57 | 6 | Compiles to the same instructions |
Oldest PHP that compiles this body: 7.4. An instruction is not a fixed amount of time, so a version with the same count is not necessarily the same speed; what the count rules out is a difference in the work itself.
Hooks and filters fired · 1
One hook fires while _wp_customize_publish_changeset() runs, in this order:
- do_action( customize_register )actionline 3682 (+43 into the body)
Fires once WordPress has loaded, allowing scripts and styles to be initialized.
Uses · 5
- did_action()Retrieves the number of times an action has been fired during the current request.
- remove_action()Removes a callback function from an action hook.
- do_action()Calls the callback functions that have been added to an action hook.
- wp_revisions_enabled()Determines whether revisions are enabled for a given post.
- WP_Customize_Manager::__construct()Constructor.
Source code
function _wp_customize_publish_changeset( $new_status, $old_status, $changeset_post ) { global $wp_customize; $is_publishing_changeset = ( 'customize_changeset' === $changeset_post->post_type && 'publish' === $new_status && 'publish' !== $old_status ); if ( ! $is_publishing_changeset ) { return; } if ( empty( $wp_customize ) ) { require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $changeset_post->post_name, 'settings_previewed' => false, ) ); } if ( ! did_action( 'customize_register' ) ) { /* * When running from CLI or Cron, the customize_register action will need * to be triggered in order for core, themes, and plugins to register their * settings. Normally core will add_action( 'customize_register' ) at * priority 10 to register the core settings, and if any themes/plugins * also add_action( 'customize_register' ) at the same priority, they * will have a $wp_customize with those settings registered since they * call add_action() afterward, normally. However, when manually doing * the customize_register action after the setup_theme, then the order * will be reversed for two actions added at priority 10, resulting in * the core settings no longer being available as expected to themes/plugins. * So the following manually calls the method that registers the core * settings up front before doing the action. */ remove_action( 'customize_register', array( $wp_customize, 'register_controls' ) ); $wp_customize->register_controls(); /** This filter is documented in wp-includes/class-wp-customize-manager.php */ do_action( 'customize_register', $wp_customize ); } $wp_customize->_publish_changeset_values( $changeset_post->ID ); /* * Trash the changeset post if revisions are not enabled. Unpublished * changesets by default get garbage collected due to the auto-draft status. * When a changeset post is published, however, it would no longer get cleaned * out. This is a problem when the changeset posts are never displayed anywhere, * since they would just be endlessly piling up. So here we use the revisions * feature to indicate whether or not a published changeset should get trashed * and thus garbage collected. */ if ( ! wp_revisions_enabled( $changeset_post ) ) { $wp_customize->trash_changeset_post( $changeset_post->ID ); }}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/theme.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.