• I wanted Tweetbacks to also find links that used WordPress’ default URLs, as if the Permalinks setting hadn’t been changed. For example: mysite.com/blog/?p=123. I did this so that my ‘Tweet This’ links could be shorter without using a 3rd-party service.

    Here’s the patch for tweetbacks.php version 1.5:
    [modification of function yoast_get_tweetback()]

    *** 505,510 ****
    --- 505,511 ----
            require_once(ABSPATH . WPINC . '/rss.php');
    
            $permalink = get_permalink($post_id);
    +       $defaultlink = get_option('home') . '/?p=' . $post->ID;
    
            $shorturls = get_post_meta($post_id,"shorturls",true);
            $oldshorturls = $shorturls;
    ***************
    *** 524,529 ****
    --- 525,535 ----
                    $shorturls['permalink'] = $permalink;
            }
    
    +       // Add the raw permalink of the post itself, e.g. /blog/?p=123
    +       if (!isset($shorturls['defaultlink'])) {
    +               $shorturls['defaultlink'] = $defaultlink;
    +       }
    +
            if (!isset($shorturls['tinyurl'])) {
                    $result = $snoopy->fetch("https://tinyurl.com/api-create.php?url=".$permalink);
                    if ($result && strpos($snoopy->response_code,"200") !== false && $snoopy->results!="" && strpos($snoopy->results,"https://tinyurl.com") === 0) {

    Here’s what I put in comments.php for my theme:

    <a href="https://twitter.com/home?status=<?php the_title_attribute();?>:+<?php echo get_option('home');?>/%3Fp%3D<?php the_ID(); ?>">Tweet this post</a>

    Works a treat.

    ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter thefluffanutta

    (@thefluffanutta)

    Sorry, made a typo on first modified line. Should have been this:

    + $defaultlink = get_option('home') . '/?p=' . $post_id;

    This would be really useful to have in the default package, as for those with short hostnames they’re like pre-shortened URLs with no service needed. Joost?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Tweetbacks] [Patch] Find non-rewritten permalinks’ is closed to new replies.