ActionScheduler_wpPostStore::save_post_array()protectedWC 1.0

Save post array.

Метод класса: ActionScheduler_wpPostStore{}

Хуков нет.

Возвращает

int. Returns the post ID.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->save_post_array( $post_array );
$post_array(массив) (обязательный)
Post array.

Код ActionScheduler_wpPostStore::save_post_array() WC 8.7.0

protected function save_post_array( $post_array ) {
	add_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10, 1 );
	add_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10, 5 );

	$has_kses = false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' );

	if ( $has_kses ) {
		// Prevent KSES from corrupting JSON in post_content.
		kses_remove_filters();
	}

	$post_id = wp_insert_post( $post_array );

	if ( $has_kses ) {
		kses_init_filters();
	}

	remove_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10 );
	remove_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10 );

	if ( is_wp_error( $post_id ) || empty( $post_id ) ) {
		throw new RuntimeException( __( 'Unable to save action.', 'woocommerce' ) );
	}
	return $post_id;
}