WordPress.org

Ready to get started?Download WordPress

Forums

Google+ Crossposting
Some additions (10 posts)

  1. birgerking
    Member
    Posted 2 years ago #

    Hi Sebastian,
    thanks for this great plugin. I've made some changes, to catch the title only, which I seperate through a line break from the content:

    // set title for post
    		// TODO Make this a setting?
    		if ($activity->title) {
    			$post_title = preg_match("/^(.*)\n/", $activity->title, $matches);
    			$post_title = $matches[0];
    		} else if ($att_title) {
    			$post_title = preg_match("/^(.*)\n/", $att_title, $matches);
    			$post_title = $matches[0];

    Here are the features I would love to see:

    • Create posts with URL to Google+ directly, to avoid double content and user frustation
    • Delete the first line (which creates the post title) from the content

    Rgds,
    Birger

    http://wordpress.org/extend/plugins/g-crossposting/

  2. Sebastian
    Member
    Plugin Author

    Posted 2 years ago #

    Interesting idea, we should really implement that. Not sure if I can manage this week as I'm very busy with work.

    Another user also suggested to make the length of the title configurable. I expect you would agree on that?!

  3. birgerking
    Member
    Posted 2 years ago #

    Hi Sebastian,
    would be great to adjust the length of the title!
    Are you able to update your plugin in the new year?

    Best wishes for 2012!
    :)

    Rgds,
    Birger

  4. Sebastian
    Member
    Plugin Author

    Posted 2 years ago #

    I just released a new version 1.1.0 of the plugin allowing to set the length of post titles. Either download the new version directly or wait for your WordPress backend to notify about the update being available.

  5. birgerking
    Member
    Posted 2 years ago #

    Hi Sebastian! Thanks for the update! Thank's to your Plugin I finished my blogs's Google+ transformation. Take a look here: http://birgerh.de

    Now every post from Google+ is shown with a title made of the G+ post first line. The Blog's post is directly linked to the Google+ post. Here is how I did it. It's pretty easy but needs core template changes:

    A.) First line creates post title
    Change the "set title for post" section of gplus-crosspost.php using this code:

    // set title for post
    		if ($activity->title) {
    			$post_title = preg_match('/^(.*)\n/', $activity->title, $matches);
    			$post_title = $matches[0];
    		} else if ($att_title) {
    			$post_title = preg_match('/^(.*)\n/', $att_title, $matches);
    			$post_title = $matches[0];
    		} else {
    			$post_title = 'Google+ post: No title available…';
    		}

    Thanks the length limiter build in by Sebastian, thee title works perfect now.

    B. Link posts directly to Google+
    This is a major change and you need to know some of template files like functions.php, archive.php, blog.php, etc. You have change at least three (3) files:

    Be aware of changes! Always backup files of the original code!

    Step 1: Edit gplus-crosspost.php - Add the "title_url" add_post_meta to the "create post and add some meta information" section below "set title for post"

    // create post and add some meta information we might need later
    		$post_id = wp_insert_post($new_post);
    		if ($post_id) {
    			add_post_meta($post_id, 'g_crossposting_posturl', $activity->url, TRUE);
    			add_post_meta($post_id, 'title_url', $activity->url, TRUE);
    			add_post_meta($post_id, 'g_crossposting_postid', $activity->id, TRUE);
    		}

    We use the "title_url" meta tag to safe the orginal Google+ post URL and use the URL.

    Step 2: Edit your templates functions.php - Update the functions.php within your template folder with the following code:

    /**************************************************/
    /*           print post permalink                 */
    /**************************************************/
    function print_post_permalink() {
    global $post;
    $thePostID = $post->ID;
    $post_id = get_post($thePostID);
    $perm = get_permalink($post_id);
    $post_keys = array(); $post_val = array();
    $post_keys = get_post_custom_keys($thePostID);
    if (!empty($post_keys)) {
    foreach ($post_keys as $pkey) {
    if ($pkey=='title_url') {
    $post_val = get_post_custom_values($pkey);
    }
    }
    if (empty($post_val)) {
    $link = $perm;
    } else {
    $link = $post_val[0];
    }
    } else {
    $link = $perm;
    }
    echo $link;
    }

    This function switches the URL when the meta tag "title_url" is used in posts. Like the Google+ posts where we added the tag in step one (1). Thanks for this to AgentWP's post where I took the original code from: http://www.agentwp.com/how-to-link-wordpress-post-title-to-an-external-url

    Step 3: Edit archive.php and other - Search for "<?php the_permalink(); ?>" whithin your templates files. Change these using your new function:
    <?php print_post_permalink(); ?>">
    I had to change this in my templates home.php and archive.php - but this might be different for your template.

    Update all files and reload your blog.
    Create a post on Google+ and trigger the Google+ Crosspost Plugin's manual check. Every post imported now is marked with the meta tag "title_url" from Step 1. Your template recognizes the post's "title_url" tag and shows the original URL thanks to the function build in Step 2. Note: There is still a post saved to your blog. When your template is using "the_permalink" (instead of the "print_post_permalink" shown in Step 3) everything is still working, only showing the post created in your blog.

    Birger

  6. Ria
    Member
    Posted 2 years ago #

    Nice work, Birger!

    Sebastian, do you plan to include this in the next update?

  7. finid
    Member
    Posted 2 years ago #

    It would be really cool if this plugin can be extended to cross-post (export) automatically or manually from the website to Google+, and to give users the opportunity to choose whether they want a 1-way or 2-way cross-posting. That is from website to Google+, the reverse or bi-directional.

  8. Sebastian
    Member
    Plugin Author

    Posted 2 years ago #

    @Ria: What Birger did is pure templating. I can't put that into the plugin. You have to do that on your theme.

    @finid: That's impossible at the moment, because Google has not yet released an API allowing to create new posts on G+. There are some dirty JavaScript hacks, but nothing I want to base the module on. So we have to wait for it. But I think as soon as that becomes available, I will try to make it work.

  9. finid
    Member
    Posted 2 years ago #

    Thank you.

  10. ripvansabre
    Member
    Posted 2 years ago #

    I'm confused about titles on G+ and how they get titled when cross posted with the plugin. Best way to show you is to refer you to my blog and the cross-posted entry here: http://ripvansabre.dyndns.org/Scattershooting/?p=9195

    I thought the blog entry title would be simply 'Google+ title' but as you can see it's the whole g+ posting. Am I doing something wrong?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic