This is taken from the src/api.php file. Use doxygen to create the apidoc directory.
Using the API
Retrieve the API object by asking Broadcast for it.
$api = ThreeWP_Broadcast()->api();
Or call an API method directly.
ThreeWP_Broadcast()->api()->broadcast_children( 123, [ 10, 11, 12 ] );
The methods below refer to the post ID on the current blog.
To broadcast a post to one or more blogs, see
broadcast_children(). The posts will be linked as children.
To rebroadcast (update) the post, see
update_children(). You can also, optionally, specified an array of new blog IDs which to add the post. Linking is parent <-> child.
Broadcasting is done like so:
- A broadcasting_data (bcd) object is created with the specified post_id as the source.
- The bcd will examine the post and prepare itself, setting its internal properties.
- The bcd constructor will create and prepare the meta_box_data object, which allows plugins to do things like force broadcast to blogs or similar.
- Optionally, the prepare_broadcasting_data action is executed in order to parse the meta box, to see which options and blogs are selected. This is only done when input from the user needs to be parsed. This is not run when using the API.
- The threewp_broadcast_broadcast_post action is executed, which will broadcast the post. The queue plugin overrides this hook and stores the bcd for later.
- The bcd object is returned.
If you wish to not use the default broadcasting_data values (perhaps you don’t want taxonomies broadcasted), then you should create the bcd object yourself, modify it, and then run action.
2015-oct-12 The current linking scheme, broadcast_data, should be replaced by a Link class driven from the API. It will first use the current broadcast_data to store the linking, switching to a new database scheme later on after developers have been given the chance to upgrade to Link. There is no timetable for this, but for the sake of data integrity and ease of use, it should be done sometime.
The below isn’t really part of the API, but could be useful when coding together custom solutions.
The action each_linked_post executes a callback on each linked post.
The function ThreeWP_Broadcast()->switch_broadcast_data( $blog_or_post_id, $post_id = null ) can switch the broadcast data of two posts, making the parent the child and vice versa.