Plugin Directory

Changeset 2747387


Ignore:
Timestamp:
06/24/2022 05:21:55 AM (3 years ago)
Author:
Kelson
Message:

tagging version 0.3.0

Location:
unwrap-shortlinks
Files:
2 edited
3 copied

Legend:

Unmodified
Added
Removed
  • unwrap-shortlinks/tags/0.3.0/readme.md

    r2741401 r2747387  
    11# Unwrap Shortlinks
    22
    3 Stable tag: 0.2.4 
     3Stable tag: 0.3.0
    44Tags: urls, links, classicpress 
    55Requires at least: 3.0 
     
    3232* fb.me
    3333* qr.ae
     34* aka.ms
    3435
    3536## Installation
     
    4142### What if the destination redirects to another link?
    4243
    43 At the moment it'll stop at the first one to avoid infinite redirect loops. But if the destination is another known shortener (say you had a t.co link that redirected to a bit.ly link), the next time you save the post, it will follow that one to its destination. TODO: I plan to make it follow a limited chain of known shorteners.
     44If the destination is another known URL shortener (ex. t.co pointing to bit.ly pointing to wp.me pointing to a blog post), it'll keep going up to 5 levels (to avoid infinite loops!) or until it gets a URL that isn't on the list.
    4445
    4546### How do I add a shortener to the list?
     
    6566## Changelog
    6667
     68### [0.3.0] - 2022-06-23
     69* Follow link trails, add aka.ms.
     70
    6771### [0.2.4] - 2022-06-13
    6872* Fix bugs with plaintext URLs at the end of a block.
     
    7680
    7781[Source on Codeberg](https://codeberg.org/kvibber/unwrap-shortlinks). 
    78 [Plugin page at WordPress](https://wordpress.org/plugins/unwrap-shortlinks/).
     82[Plugin page at WordPress](https://wordpress.org/plugins/unwrap-shortlinks/). 
     83[Plugin page at ClassicPress](https://directory.classicpress.net/plugins/unwrap-shortlinks).
    7984
    8085(c) 2016-2022 [Kelson Vibber](https://kvibber.com/)
  • unwrap-shortlinks/tags/0.3.0/unwrap-shortlinks.php

    r2741401 r2747387  
    44 Plugin URI: https://codeberg.org/kvibber/unwrap-shortlinks
    55 Description: Follow shortened links (t.co, bit.ly, etc) and expand them so that your blog post will point directly to the destination.
    6  Version: 0.2.4
     6 Version: 0.3.0
    77 Author: Kelson Vibber
    88 Author URI: https://kvibber.com
     
    1414
    1515function ktv_unwrap_shortlinks($content) {
    16     preg_match_all('/\b(https?:\/\/(?:t\.co|bit\.ly|j\.mp|ow\.ly|is\.gd|trib\.al|buff\.ly|tmblr\.co|wp\.me|tinyurl\.com|goo\.gl|dlvr\.it|fb\.me|qr\.ae)\/[^\s"\'<>]+)\b/', $content, $matches, PREG_PATTERN_ORDER);
     16    preg_match_all('/\b(https?:\/\/(?:t\.co|bit\.ly|j\.mp|ow\.ly|is\.gd|trib\.al|buff\.ly|tmblr\.co|wp\.me|tinyurl\.com|goo\.gl|dlvr\.it|fb\.me|qr\.ae|aka\.ms)\/[^\s"\'<>]+)\b/', $content, $matches, PREG_PATTERN_ORDER);
    1717    foreach ($matches[1] as $link) {
    18         $getlink = ktv_unwrap_shortlinks_replace($link);
     18        $getlink = ktv_unwrap_shortlinks_replace($link, 5);
    1919        if ($getlink != "")
    2020            $content = str_replace($link, $getlink, $content);
     
    2525
    2626
    27 function ktv_unwrap_shortlinks_replace($url) {
     27function ktv_unwrap_shortlinks_replace($url, $countdown) {
    2828    // make a head request and don't follow redirection, just look at the response.
    2929    $response = wp_remote_head( $url ); //, array( 'redirection' => 0 ) );
     
    3131    $finalURL = wp_remote_retrieve_header( $response, 'location' );
    3232   
    33     // If it was a redirect, return the next URL.
     33    // If it was a redirect, get the next URL
    3434    if ($status == 301 || $status == 302 || $status == 307 || $status == 308) {
    35         return esc_url($finalURL);
     35        // TODO Is it also a redirector? Do we have iterations left?
     36        // If so, try to follow that one!
     37        if( $countdown > 0 && preg_match('/\b(https?:\/\/(?:t\.co|bit\.ly|j\.mp|ow\.ly|is\.gd|trib\.al|buff\.ly|tmblr\.co|wp\.me|tinyurl\.com|goo\.gl|dlvr\.it|fb\.me|qr\.ae|aka\.ms)\/[^\s"\'<>]+)\b/', $finalURL) ) {
     38            return ktv_unwrap_shortlinks_replace($finalURL, $countdown - 1);
     39        } else {
     40            // Otherwise, send it back up the chain!
     41            return esc_url($finalURL);
     42        }
    3643    }
    3744    // We didn't get anything, or it didn't redirect, so let's return a blank.
  • unwrap-shortlinks/trunk/readme.md

    r2741401 r2747387  
    11# Unwrap Shortlinks
    22
    3 Stable tag: 0.2.4 
     3Stable tag: 0.3.0
    44Tags: urls, links, classicpress 
    55Requires at least: 3.0 
     
    3232* fb.me
    3333* qr.ae
     34* aka.ms
    3435
    3536## Installation
     
    4142### What if the destination redirects to another link?
    4243
    43 At the moment it'll stop at the first one to avoid infinite redirect loops. But if the destination is another known shortener (say you had a t.co link that redirected to a bit.ly link), the next time you save the post, it will follow that one to its destination. TODO: I plan to make it follow a limited chain of known shorteners.
     44If the destination is another known URL shortener (ex. t.co pointing to bit.ly pointing to wp.me pointing to a blog post), it'll keep going up to 5 levels (to avoid infinite loops!) or until it gets a URL that isn't on the list.
    4445
    4546### How do I add a shortener to the list?
     
    6566## Changelog
    6667
     68### [0.3.0] - 2022-06-23
     69* Follow link trails, add aka.ms.
     70
    6771### [0.2.4] - 2022-06-13
    6872* Fix bugs with plaintext URLs at the end of a block.
     
    7680
    7781[Source on Codeberg](https://codeberg.org/kvibber/unwrap-shortlinks). 
    78 [Plugin page at WordPress](https://wordpress.org/plugins/unwrap-shortlinks/).
     82[Plugin page at WordPress](https://wordpress.org/plugins/unwrap-shortlinks/). 
     83[Plugin page at ClassicPress](https://directory.classicpress.net/plugins/unwrap-shortlinks).
    7984
    8085(c) 2016-2022 [Kelson Vibber](https://kvibber.com/)
  • unwrap-shortlinks/trunk/unwrap-shortlinks.php

    r2741401 r2747387  
    44 Plugin URI: https://codeberg.org/kvibber/unwrap-shortlinks
    55 Description: Follow shortened links (t.co, bit.ly, etc) and expand them so that your blog post will point directly to the destination.
    6  Version: 0.2.4
     6 Version: 0.3.0
    77 Author: Kelson Vibber
    88 Author URI: https://kvibber.com
     
    1414
    1515function ktv_unwrap_shortlinks($content) {
    16     preg_match_all('/\b(https?:\/\/(?:t\.co|bit\.ly|j\.mp|ow\.ly|is\.gd|trib\.al|buff\.ly|tmblr\.co|wp\.me|tinyurl\.com|goo\.gl|dlvr\.it|fb\.me|qr\.ae)\/[^\s"\'<>]+)\b/', $content, $matches, PREG_PATTERN_ORDER);
     16    preg_match_all('/\b(https?:\/\/(?:t\.co|bit\.ly|j\.mp|ow\.ly|is\.gd|trib\.al|buff\.ly|tmblr\.co|wp\.me|tinyurl\.com|goo\.gl|dlvr\.it|fb\.me|qr\.ae|aka\.ms)\/[^\s"\'<>]+)\b/', $content, $matches, PREG_PATTERN_ORDER);
    1717    foreach ($matches[1] as $link) {
    18         $getlink = ktv_unwrap_shortlinks_replace($link);
     18        $getlink = ktv_unwrap_shortlinks_replace($link, 5);
    1919        if ($getlink != "")
    2020            $content = str_replace($link, $getlink, $content);
     
    2525
    2626
    27 function ktv_unwrap_shortlinks_replace($url) {
     27function ktv_unwrap_shortlinks_replace($url, $countdown) {
    2828    // make a head request and don't follow redirection, just look at the response.
    2929    $response = wp_remote_head( $url ); //, array( 'redirection' => 0 ) );
     
    3131    $finalURL = wp_remote_retrieve_header( $response, 'location' );
    3232   
    33     // If it was a redirect, return the next URL.
     33    // If it was a redirect, get the next URL
    3434    if ($status == 301 || $status == 302 || $status == 307 || $status == 308) {
    35         return esc_url($finalURL);
     35        // TODO Is it also a redirector? Do we have iterations left?
     36        // If so, try to follow that one!
     37        if( $countdown > 0 && preg_match('/\b(https?:\/\/(?:t\.co|bit\.ly|j\.mp|ow\.ly|is\.gd|trib\.al|buff\.ly|tmblr\.co|wp\.me|tinyurl\.com|goo\.gl|dlvr\.it|fb\.me|qr\.ae|aka\.ms)\/[^\s"\'<>]+)\b/', $finalURL) ) {
     38            return ktv_unwrap_shortlinks_replace($finalURL, $countdown - 1);
     39        } else {
     40            // Otherwise, send it back up the chain!
     41            return esc_url($finalURL);
     42        }
    3643    }
    3744    // We didn't get anything, or it didn't redirect, so let's return a blank.
Note: See TracChangeset for help on using the changeset viewer.