My favorite actions are:
- threewp_broadcast_broadcasting_started
- threewp_broadcast_broadcasting_modify_post
- threewp_broadcast_broadcasting_before_restore_current_blog
The first action I use to note down whatever links I find in the post_content that are relevant to the parent blog.
The second action is to modify the post content with new data.
The third is to modify other things, like the custom fields.
The post in question you’ll find in the first parameter: $action.
$action->broadcast_data->post
or
$action->broadcast_data->new_post
You should look at broadcast / src / traits / broadcasting.php, which contains a lot of nice code, I hope. 🙂
Thanks for the super fast reply! :O
I’ll have a look and post my solution when I work it out.
Example for others interested:
add_action( 'threewp_broadcast_broadcasting_modify_post', 'my_broadcasting_modify_post', 20 );
function my_broadcasting_modify_post( $action ) {
$bcd = $action->broadcasting_data;
$parent_site_url = get_site_url( $bcd->parent_blog_id );
$child_site_url = get_site_url( $bcd->current_child_blog_id );
$modified_content = $bcd->modified_post->post_content;
$modified_content = str_replace( $parent_site_url, $child_site_url, $modified_content );
$bcd->modified_post->post_content = $modified_content;
}
I’m trying to make this into an option with a checkbox in the Broadcast metabox, but I haven’t figured out yet how to get the options to stick.