Do not broadcast equivalent posts

During normal broadcasting, if the post refers to other posts – common in ACF relationship fields – the missing, equivalent posts will be automatically broadcasted.

This can be a problem if the post has many relationships, which can finally cause a timeout.

Use this snippet to prevent equivalent posts from being broadcasted when the post is first created.

Broadcasting the post later will allow the equivalent posts to be broadcasted also.

/**
	@brief		Remember whether a new child was created.
	@since		2020-09-29 07:35:27
**/
function gob_threewp_broadcast_broadcasting_after_update_post( $action )
{
	global $get_or_broadcast;
	// If new child created, do NOT! broadcast and related children.
	$get_or_broadcast = ! $action->broadcasting_data->new_child_created;
	ThreeWP_Broadcast()->debug( 'Setting get_or_broadcast to %s', $get_or_broadcast );
}
add_action( 'threewp_broadcast_broadcasting_after_update_post', 'gob_threewp_broadcast_broadcasting_after_update_post' );

/**
	@brief		Reply whether to broadcast an equivalent child post or not.
	@since		2020-09-29 07:35:42
**/
function gob_threewp_broadcast_get_or_broadcast( $action )
{
	global $get_or_broadcast;
	ThreeWP_Broadcast()->debug( 'Replying with get_or_broadcast: %s', $get_or_broadcast );
	$action->broadcast_child_post = $get_or_broadcast;
}
add_action( 'threewp_broadcast_get_or_broadcast', 'gob_threewp_broadcast_get_or_broadcast' );