Inventory_Presser_Photo_Numberer::set_post_parent( WP_Post $prepared_post, WP_REST_Request $request )

set_post_parent


Description Description

The REST API does not support post_parent by default, so we have to move the <code>parent</code> value from the request into the prepared post in this filter callback.


Top ↑

Parameters Parameters

$prepared_post

(WP_Post) (Required)

$request

(WP_REST_Request) (Required)


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class-photo-numberer.php

	public function set_post_parent( $prepared_post, $request )
	{
		if( ! empty( $prepared_post->post_parent ) )
		{
			return $prepared_post;
		}

		if( 'attachment' != $prepared_post->post_type )
		{
			return $prepared_post;
		}

		$post_parent = $request->get_param( 'parent' );
		if( empty( $post_parent ) )
		{
			return $prepared_post;
		}

		$prepared_post->post_parent = $post_parent;
		return $prepared_post;
	}