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( int $post_id )

Delete auto-draft posts associated with the supplied changeset.


Description Description


Parameters Parameters

$post_id

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


Top ↑

Source 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 $post_id ) {
		if ( ! empty( $post_id ) && 'auto-draft' === get_post_status( $post_id ) ) {
			wp_delete_post( $post_id, true );
		}
	}
	add_action( 'delete_post', '_wp_delete_customize_changeset_dependent_auto_drafts' );
}

Top ↑

Changelog Changelog

Changelog
Version Description
4.8.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.