Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: newsbaby Blog AddThis
- Plugin URI: http://tsourclace.dev
- Description: Connect newsbaby Blog with newsbaby via AddThis
- Version: 1.1
- Author: News Baby
- Author URI: http://tsourclace.dev
- */
- //taking a link from a news aggregration site at news.tsourclace.dev
- //to the users 'Home Place' subdomain as in 'pblog' custom meta
- add_action('plugins_loaded', 'newsbaby_blog_addthis', -1);
- function newsbaby_blog_addthis() {
- if(isset($_GET['myplugin']))
- {
- if ( ! is_user_logged_in() ) {
- //echo 'You are not logged in.';
- $redirect = "http://tsourclace.dev/wp-login.php?redirect_to=".urlencode($_SERVER['REQUEST_URI']);
- wp_redirect($redirect);
- header("Status: 302");
- die;
- }
- global $current_user;
- global $blog_id;
- global $switched;
- global $wpdb;
- global $bp;
- $user_id = $current_user->ID;
- $key = 'pblog';
- $single = true;
- $user_pblog = get_user_meta( $user_id, $key, $single );
- $post_content = $_REQUEST['url'];
- $apost_content = make_clickable($post_content);
- $post_title = $_REQUEST['title'];
- $tags = 'rl-News';
- $tag_to_strip = $_REQUEST['tag'];
- $sub = "rl-";
- $category_ids = array(29);
- $t = explode('/', $tag_to_strip);
- if ($t[3]) {;
- $tags = $sub.$t[3];
- }
- $site ='test';
- $blog_id = $user_pblog;
- $result = switch_to_blog($blog_id);
- $wpdb->set_blog_id($blog_id);
- $activity_id = bp_activity_add( array(
- 'action' => 'A link from NewsSite',
- 'content' => $apost_content,
- 'component' => false,
- 'type' => new_blog_post,
- 'primary_link' => 'false',
- 'user_id' => $user_id,
- 'item_id' => false,
- 'secondary_item_id' => false,
- 'recorded_time' => bp_core_current_time(),
- 'hide_sitewide' => false,
- 'is_spam' => false
- ), );
- die;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement