diff --git a/README.md b/README.md index 05da261..9f9d19b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Unwrap Shortlinks -Stable tag: 0.3.3 +Stable tag: 0.3.4 Tags: urls, links, classicpress -Tested up to: 6.5 +Tested up to: 6.6 Contributors: Kelson License: GPLv2 or later @@ -25,8 +25,7 @@ Automatically expands URLs at the following known link shorteners when you save * fb.me * qr.ae * aka.ms - -NOTE: tinyurl.com has been removed from the list because they are blocking automated requests. (See changelog) +* tinyurl.com ## Installation @@ -60,7 +59,10 @@ It should work going back to the classic editor and forward to the block editor. ## Changelog -### [0.3.3] +### [0.3.4] - 2024-07-07 +* tinyurl.com is accepting curl requests again, so I've added it back to the list. + +### [0.3.3] - 2023-07-22 * tinyurl.com is screening requests using Cloudflare, and a simple curl request is no longer allowed through. Removing it from the list. ### [0.3.2] - 2022-10-29 diff --git a/unwrap-shortlinks.php b/unwrap-shortlinks.php index ba993d5..b1f8472 100644 --- a/unwrap-shortlinks.php +++ b/unwrap-shortlinks.php @@ -3,7 +3,7 @@ Plugin Name: Unwrap Shortlinks Plugin URI: https://codeberg.org/kvibber/unwrap-shortlinks Description: Follow shortened links (t.co, bit.ly, etc) and expand them so that your blog post will point directly to the destination. - Version: 0.3.3 + Version: 0.3.4 Requires at least: 3.0 Requires CP: 1.0 Requires PHP: 7.0 @@ -16,7 +16,7 @@ // ini_set('display_errors', '1'); ini_set('error_reporting', E_ALL); function ktv_unwrap_shortlinks($content) { - preg_match_all('/\b(https?:\/\/(?:t\.co|bit\.ly|j\.mp|ow\.ly|is\.gd|trib\.al|buff\.ly|tmblr\.co|wp\.me|goo\.gl|dlvr\.it|fb\.me|qr\.ae|aka\.ms)\/[^\s"\'<>]+)\b/', $content, $matches, PREG_PATTERN_ORDER); + preg_match_all('/\b(https?:\/\/(?:t\.co|bit\.ly|j\.mp|ow\.ly|is\.gd|trib\.al|buff\.ly|tmblr\.co|wp\.me|goo\.gl|dlvr\.it|fb\.me|qr\.ae|aka\.ms|tinyurl\.com)\/[^\s"\'<>]+)\b/', $content, $matches, PREG_PATTERN_ORDER); foreach ($matches[1] as $link) { $getlink = ktv_unwrap_shortlinks_replace($link, 5); if ($getlink != "") @@ -37,7 +37,7 @@ function ktv_unwrap_shortlinks_replace($url, $countdown) { if ($status == 301 || $status == 302 || $status == 307 || $status == 308) { // TODO Is it also a redirector? Do we have iterations left? // If so, try to follow that one! - 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|goo\.gl|dlvr\.it|fb\.me|qr\.ae|aka\.ms)\/[^\s"\'<>]+)\b/', $finalURL) ) { + 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|goo\.gl|dlvr\.it|fb\.me|qr\.ae|aka\.ms|tinyurl\.com)\/[^\s"\'<>]+)\b/', $finalURL) ) { return ktv_unwrap_shortlinks_replace($finalURL, $countdown - 1); } else { // Otherwise, send it back up the chain!