WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

WP_Customize_Nav_Menus::save_nav_menus_created_posts() public WP 4.7.0

Publish the auto-draft posts that were created for nav menu items.

The post IDs will have been sanitized by already by WP_Customize_Nav_Menu_Items::sanitize_nav_menus_created_posts() to remove any post IDs for which the user cannot publish or for which the post is not an auto-draft.

{} Это метод класса: WP_Customize_Nav_Menus{}

Хуков нет.

Возвращает

Null. Ничего.

Использование

$WP_Customize_Nav_Menus = new WP_Customize_Nav_Menus();
$WP_Customize_Nav_Menus->save_nav_menus_created_posts( $setting );
$setting(WP_Customize_Setting) (обязательный)
Customizer setting object.

Список изменений

С версии 4.7.0 Введена.

Код WP_Customize_Nav_Menus::save_nav_menus_created_posts() WP 5.5.3

<?php
public function save_nav_menus_created_posts( $setting ) {
	$post_ids = $setting->post_value();
	if ( ! empty( $post_ids ) ) {
		foreach ( $post_ids as $post_id ) {

			// Prevent overriding the status that a user may have prematurely updated the post to.
			$current_status = get_post_status( $post_id );
			if ( 'auto-draft' !== $current_status && 'draft' !== $current_status ) {
				continue;
			}

			$target_status = 'attachment' === get_post_type( $post_id ) ? 'inherit' : 'publish';
			$args          = array(
				'ID'          => $post_id,
				'post_status' => $target_status,
			);
			$post_name     = get_post_meta( $post_id, '_customize_draft_post_name', true );
			if ( $post_name ) {
				$args['post_name'] = $post_name;
			}

			// Note that wp_publish_post() cannot be used because unique slugs need to be assigned.
			wp_update_post( wp_slash( $args ) );

			delete_post_meta( $post_id, '_customize_draft_post_name' );
		}
	}
}