King Composer support

This snippet for Broadcast shows how to get the obsolete and unsupported King Composer page editor plugin to correctly broadcast.

The plugin also requires the Shortcode Attachments add-on to handle the image shortcodes.

/**
	@brief		Allow add-ons to preparse custom field content.
	@since		2020-02-05 10:19:51
**/
function king_threewp_broadcast_broadcasting_started( $action )
{
	// An array of custom field names that should be modified. The array should be the same for preparsing and parsing.
	$custom_fields = [
		'kc_raw_content',
	];

	$bcd = $action->broadcasting_data;		// Convenience
	foreach( $custom_fields as $custom_field )
	{
		ThreeWP_Broadcast()->debug( 'Preparsing custom field %s', $custom_field );
		$preparse_action = new \threewp_broadcast\actions\preparse_content();
		$preparse_action->broadcasting_data = $action->broadcasting_data;
		$preparse_action->content = $bcd->custom_fields()->get_single( $custom_field );
		$preparse_action->id = 'custom_field_' . $custom_field;
		$preparse_action->execute();
	}
}
add_action( 'threewp_broadcast_broadcasting_started', 'king_threewp_broadcast_broadcasting_started' );

/**
	@brief		Allow add-ons to parse custom field content.
	@since		2020-02-05 10:19:51
**/
function king_threewp_broadcast_broadcasting_before_restore_current_blog( $action )
{
	// An array of custom field names that should be modified. The array should be the same for preparsing and parsing.
	$custom_fields = [
		'kc_raw_content',
	];

	$bcd = $action->broadcasting_data;		// Convenience
	foreach( $custom_fields as $custom_field )
	{
		ThreeWP_Broadcast()->debug( 'Parsing custom field %s', $custom_field );
		$parse_action = new \threewp_broadcast\actions\parse_content();
		$parse_action->broadcasting_data = $action->broadcasting_data;
		$parse_action->content = $bcd->custom_fields()->get_single( $custom_field );
		$parse_action->id = 'custom_field_' . $custom_field;
		$parse_action->execute();
		$new_value = $parse_action->content;
		$bcd->custom_fields()->child_fields()->update_meta( $custom_field, $new_value );
		ThreeWP_Broadcast()->debug( 'New value for custom field %s is %s', $custom_field, $new_value );
	}

	$content = $bcd->modified_post->post_content;
	global $wpdb;
	$wpdb->update( $wpdb->posts, [ 'post_content_filtered' => $content ], [ 'ID' => $bcd->new_post( 'ID' ) ] );
}
add_action( 'threewp_broadcast_broadcasting_before_restore_current_blog', 'king_threewp_broadcast_broadcasting_before_restore_current_blog' );

add_filter( 'the_content', function( $content )
{
	return kc_do_shortcode( $content );
} );