Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_wp_delete_customize_changeset_dependent_auto_drafts() WordPress Function

The _wp_delete_customize_changeset_dependent_auto_drafts() function is used to delete any auto-drafts that are associated with a changeset. This is useful when changesets are being deleted, as any auto-drafts that were created as part of the changeset can also be safely deleted.

_wp_delete_customize_changeset_dependent_auto_drafts( int $post_id ) #

Deletes auto-draft posts associated with the supplied changeset.


Parameters

$post_id

(int)(Required)Post ID for the customize_changeset.


Top ↑

Source

File: wp-includes/nav-menu.php

function _wp_delete_customize_changeset_dependent_auto_drafts( $post_id ) {
	$post = get_post( $post_id );

	if ( ! $post || 'customize_changeset' !== $post->post_type ) {
		return;
	}

	$data = json_decode( $post->post_content, true );
	if ( empty( $data['nav_menus_created_posts']['value'] ) ) {
		return;
	}
	remove_action( 'delete_post', '_wp_delete_customize_changeset_dependent_auto_drafts' );
	foreach ( $data['nav_menus_created_posts']['value'] as $stub_post_id ) {
		if ( empty( $stub_post_id ) ) {
			continue;
		}
		if ( 'auto-draft' === get_post_status( $stub_post_id ) ) {
			wp_delete_post( $stub_post_id, true );
		} elseif ( 'draft' === get_post_status( $stub_post_id ) ) {
			wp_trash_post( $stub_post_id );
			delete_post_meta( $stub_post_id, '_customize_changeset_uuid' );
		}
	}
	add_action( 'delete_post', '_wp_delete_customize_changeset_dependent_auto_drafts' );
}


Top ↑

Changelog

Changelog
VersionDescription
4.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.