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.0
- 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;
- $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);
- $post_id = wp_insert_post( array(
- 'post_author' => $user_id,
- 'post_title' => $post_title,
- 'post_content' => $apost_content,
- 'post_category' => $category_ids,
- 'tags_input' => $tags,
- 'post_status' => 'publish'
- ), $wp_error );
- echo 'Shared successfully to your Home Place with tags: '.$tags;
- die;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement