wppaste
WordPress

_wp_customize_publish_changeset( string $new_status, string $old_status, WP_Post $changeset_post )

Since
4.7.0
Source
wp-includes/theme.php:3639
Publishes a snapshot's changes.

Parameters

$new_statusstring
New post status.
$old_statusstring
Old post status.
$changeset_postWP_Post
Changeset post object.

Cost profile

Measured from the compiled opcodes, not from a stopwatch. Every number here is identical on any machine that runs the same PHP version, and every function in core is ranked by these figures.

Cost class
Trivial

Touches nothing outside its own arguments.

Scaling
Constant

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

Instructions
10–57

Executed per call on PHP 8.4, depending on the branch taken. The body compiles to 58.

Plugin surface
1 hook

Third-party callbacks on 'customize_register' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksdo_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.

WhenInstructionsCalls it makes
always10–13none
!empty($wp_customize) && did_action() && wp_revisions_enabled()25–28did_action()->_publish_changeset_values()wp_revisions_enabled()
!empty($wp_customize) && did_action() && !wp_revisions_enabled()30–33did_action()->_publish_changeset_values()wp_revisions_enabled()->trash_changeset_post()
empty($wp_customize) && did_action() && wp_revisions_enabled()37–40changeset_uuid()did_action()->_publish_changeset_values()wp_revisions_enabled()
!empty($wp_customize) && !did_action() && wp_revisions_enabled()37–40did_action()->register_controls()do_action()->_publish_changeset_values()wp_revisions_enabled()
empty($wp_customize) && did_action() && !wp_revisions_enabled()42–45changeset_uuid()did_action()->_publish_changeset_values()wp_revisions_enabled()->trash_changeset_post()
!empty($wp_customize) && !did_action() && !wp_revisions_enabled()42–45did_action()->register_controls()do_action()->_publish_changeset_values()wp_revisions_enabled()->trash_changeset_post()
empty($wp_customize) && !did_action() && wp_revisions_enabled()49–52changeset_uuid()did_action()->register_controls()do_action()->_publish_changeset_values()wp_revisions_enabled()
empty($wp_customize) && !did_action() && !wp_revisions_enabled()54–57changeset_uuid()did_action()->register_controls()do_action()->_publish_changeset_values()wp_revisions_enabled()->trash_changeset_post()

Across PHP versions

PHPCompiledExecutedBranchesNotes
7.45810–576Compiles to the same instructions
8.15810–576Compiles to the same instructions
8.25810–576Compiles to the same instructions
8.35810–576Compiles to the same instructions
8.45810–576Compiles 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 fired · 1

One hook fires while _wp_customize_publish_changeset() runs, in this order:

  1. do_action( customize_register )actionline 3682 (+43 into the body)

    Fires once WordPress has loaded, allowing scripts and styles to be initialized.

Uses · 5

Source

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 );	}}

History

Introduced in 4.7.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 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.