Advertisement
valuser

newsbaby2

Jan 22nd, 2015
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: newsbaby Blog AddThis
  4. Plugin URI: http://tsourclace.dev
  5. Description: Connect newsbaby Blog with newsbaby via AddThis
  6. Version: 1.1
  7. Author: News Baby
  8. Author URI: http://tsourclace.dev
  9. */
  10.  
  11. //taking a link from a news aggregration site at news.tsourclace.dev
  12. //to the users 'Home Place' subdomain as in 'pblog' custom meta
  13.  
  14.  
  15. add_action('plugins_loaded', 'newsbaby_blog_addthis', -1);
  16.  
  17. function newsbaby_blog_addthis() {
  18.  
  19. if(isset($_GET['myplugin']))
  20. {
  21. if ( ! is_user_logged_in() ) {
  22. //echo 'You are not logged in.';
  23. $redirect = "http://tsourclace.dev/wp-login.php?redirect_to=".urlencode($_SERVER['REQUEST_URI']);
  24. wp_redirect($redirect);
  25. header("Status: 302");
  26. die;
  27. }
  28.  
  29. global $current_user;
  30. global $blog_id;
  31. global $switched;
  32. global $wpdb;
  33. global $bp;
  34.  
  35. $user_id = $current_user->ID;
  36. $key = 'pblog';
  37. $single = true;
  38. $user_pblog = get_user_meta( $user_id, $key, $single );
  39. $post_content = $_REQUEST['url'];
  40. $apost_content = make_clickable($post_content);
  41. $post_title = $_REQUEST['title'];
  42. $tags = 'rl-News';
  43. $tag_to_strip = $_REQUEST['tag'];
  44. $sub = "rl-";
  45. $category_ids = array(29);
  46.  
  47. $t = explode('/', $tag_to_strip);
  48. if ($t[3]) {;
  49. $tags = $sub.$t[3];
  50. }
  51.  
  52. $site ='test';
  53.  
  54. $blog_id = $user_pblog;
  55. $result = switch_to_blog($blog_id);
  56. $wpdb->set_blog_id($blog_id);
  57.  
  58. $activity_id = bp_activity_add( array(
  59. 'action' => 'A link from NewsSite',
  60. 'content' => $apost_content,
  61. 'component' => false,
  62. 'type' => new_blog_post,
  63. 'primary_link' => 'false',
  64. 'user_id' => $user_id,
  65. 'item_id' => false,
  66. 'secondary_item_id' => false,
  67. 'recorded_time' => bp_core_current_time(),
  68. 'hide_sitewide' => false,
  69. 'is_spam' => false
  70. ), );
  71. die;
  72. }
  73. }
  74. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement