Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- We send MailChimp emails out when new posts are published (or broadcasted) however the broadcast plugin made it difficult to determine the Post ID of the broadcasted posts. The patch below adds an array of blog_id=>post_id to make things easier.
- Usage:
- */
- add_action('threewp_activity_monitor_new_activity', 'handle_broadcast_posts');
- function handle_broadcast_posts( $activity )
- {
- foreach ( $activity['activity_details'] as $details )
- {
- switch_to_blog( $details['blog_id'] );
- $post = get_post( $details['post_id'] );
- ...
- restore_current_blog();
- }
- }
- /*
- Patch:
- */
- //Below
- $to_broadcasted_blogs = array(); // Array of blog names that we're broadcasting to. To be used for the activity monitor action.
- //Add
- $to_broadcasted_blog_details = array(); // Array of blog and post IDs that we're broadcasting to. To be used for the activity monitor action.
- //Below
- $to_broadcasted_blogs[] = '<a href="' . get_permalink( $new_post_id ) . '">' . get_bloginfo( 'name' ) . '</a>';
- //Add
- $to_broadcasted_blog_details[] = array('blog_id'=>$blogID, 'post_id'=>$new_post_id);
- //Below
- 'activity_strings' => array(
- '' => '%user_display_name_with_link% has broadcasted '.$post_url_and_name.' to: ' . implode( ', ', $to_broadcasted_blogs),
- ),
- //Add
- 'activity_details' => $to_broadcasted_blog_details,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement