Advertisement
Guest User

Untitled

a guest
Aug 26th, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. <?php
  2. /*
  3. 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.
  4.  
  5. Usage:
  6. */
  7. add_action('threewp_activity_monitor_new_activity', 'handle_broadcast_posts');
  8. function handle_broadcast_posts( $activity )
  9. {
  10.     foreach ( $activity['activity_details'] as $details )
  11.     {
  12.         switch_to_blog( $details['blog_id'] );
  13.        
  14.         $post = get_post( $details['post_id'] );
  15.         ...
  16.        
  17.         restore_current_blog();
  18.     }
  19. }
  20.  
  21. /*
  22. Patch:
  23. */
  24.  
  25. //Below
  26. $to_broadcasted_blogs = array();                // Array of blog names that we're broadcasting to. To be used for the activity monitor action.
  27. //Add
  28. $to_broadcasted_blog_details = array();         // Array of blog and post IDs that we're broadcasting to. To be used for the activity monitor action.
  29.  
  30. //Below
  31. $to_broadcasted_blogs[] = '<a href="' . get_permalink( $new_post_id ) . '">' . get_bloginfo( 'name' ) . '</a>';
  32. //Add
  33. $to_broadcasted_blog_details[] = array('blog_id'=>$blogID, 'post_id'=>$new_post_id);
  34.  
  35. //Below
  36. 'activity_strings' => array(
  37.     '' => '%user_display_name_with_link% has broadcasted '.$post_url_and_name.' to: ' . implode( ', ', $to_broadcasted_blogs),
  38. ),
  39. //Add
  40. 'activity_details' => $to_broadcasted_blog_details,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement