Changeset 462940
- Timestamp:
- 11/15/2011 04:38:36 AM (14 years ago)
- Location:
- root-relative-urls/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (3 diffs)
-
sb_root_relative_urls.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
root-relative-urls/trunk/readme.txt
r457443 r462940 62 62 Unfortunately no, this plugin is designed to correct new content as it is entered via the administration panel. It will still work with your current site, 63 63 but it will not alter links you have already embedded. Because of this inherent defect in Wordpress, this plugin would have no idea if http://example.com/ was a link 64 to your staging environment or an external URL, especially if you are accessing the site from http://localhost/. In the future we may implement a find/replace 65 feature to aid the transformations, but for now this is up to you to correct existing content. See the link above from interconnectit.com for more information on that process. 64 to your staging environment or an external URL, especially if you are accessing the site from http://localhost/. 65 66 I'm currently working with Brian DiChiara on a solution for find/replace of previous absolute urls into root-relative slashes. You may still continue to use the link above from interconnectit.com for more information on that process, but we should have the feature included by Nov 20th, 2011. 66 67 67 68 = Should I use this plugin if I only have one production site and I make all of my changes in production? = … … 76 77 will need to patch a Wordpress core file - or wait until the Wordpress core team implements this fix - http://core.trac.wordpress.org/attachment/ticket/18910/ms-blogs.php.patch 77 78 78 Until then this plugin will not work out of the box for MU installs. 79 Until then this plugin will not work out of the box for MU installs. I have discovered an approach for resolving this problem without a core hack but I will need to research it before implementing the update. It will be a big ol nasty hack but it will work. 79 80 80 81 … … 91 92 == Changelog == 92 93 94 = 1.2 = 95 96 * Discovered an issue with wp-cron. I've disabled the warnings for now, but I'm not really sure about the potential fallout from the http_host not properly being set in some circumstances. 97 * Updated plugin to massage rss content urls back to absolute site urls. This shouldn't need to even happen but unfortunately feedburner and feedblitz don't follow the html spec :( Google Reader and a bunch of others do however, so there is hope of fixing this problem on feedburner & feedblitz's end. 98 * Despite this ticket being not yet patched: http://core.trac.wordpress.org/ticket/19210 I have fixed the previous bugs related to comments_link_feed() or comment_link() functions. 99 * Found an interesting post from way back in 2003, when a woman by the name of Shirley Kaiser went through a similar pursuit to change MovableType from absolute only urls to root relative urls. 2003!!! Almost a decade ago someone else had to show an entire platform the power and flexibility of root relative urls! - (http://brainstormsandraves.com/archives/2003/09/07/relative_vs_absolute_urls/) 100 93 101 = 1.1 = 94 102 * Converted plugin to be < php5.3 compatible by removing usage of function references -
root-relative-urls/trunk/sb_root_relative_urls.php
r457443 r462940 9 9 Author: Marcus E. Pope, marcuspope 10 10 Author URI: http://www.marcuspope.com 11 Version: 1. 011 Version: 1.2 12 12 13 13 Copyright 2011 Marcus E. Pope (email : me@marcuspope.com) … … 35 35 //munges absolute urls provided to the wysiwyg editor to be root relative instead of absolute 36 36 //generally displays urls throughout the admin area as root relative instead of absolute 37 38 static $massage = false; 39 37 40 static function add_actions($tag_arry, $func, $p = 10, $a = 1) { 38 41 //allows for multiple tags to bind to the same funciton call … … 60 63 //used in export functions or RSS feeds. Or because they are literally checked against the domain of URLs stored 61 64 //in the database - a needless process for any website. 62 $url = parse_url($url);65 $url = @parse_url($url); 63 66 $relative = ltrim(@$url['path'], '/') . (isset($url['query']) ? "?" . $url['query'] : ''); 64 return MP_WP_Root_Relative_URLS::scheme( 'http://' . $_SERVER['HTTP_HOST'] . (!empty($relative) ? '/' . $relative: '') );67 return MP_WP_Root_Relative_URLS::scheme( 'http://' . @$_SERVER['HTTP_HOST'] . (!empty($relative) ? '/' . $relative: '') ); 65 68 } 66 69 … … 75 78 } 76 79 80 static function enable_content_massage() { 81 //this is only called when an external feed is being called 82 //this lets the content filter know that we should convert root relative urls back in to absolute urls since 83 //some external sources don't understand the html spec 84 self::$massage = true; 85 86 //massage global post object 87 global $post; 88 $post->post_content = self::massage_external_content($post->post_content); 89 $post->post_excerpt= self::massage_external_content($post->post_excerpt); 90 } 91 92 static function massage_external_content($a) { 93 //Here is where we fix the root relative content urls into absolute urls using the current host name 94 //this shouldn't be required but companies like feedburner and feedblitz don't understand the web :( 95 if (self::$massage == true) { 96 $a = preg_replace_callback('#(<[^>]+(?:href|src)\s*?=\s*?[\'"])(\/)#i', array("MP_WP_Root_Relative_URLS", "do_absolute_massage_cb"), $a); 97 } 98 return $a; 99 } 100 101 static function do_absolute_massage_cb($a) { 102 //callback handler that does the physical insertion of absolute domain into root relative urls 103 return $a[1] . self::scheme('http://' . @$_SERVER['HTTP_HOST'] . $a[2]); 104 } 105 77 106 static function proper_root_relative_url($url) { 78 107 //This method is used for urls that can be acceptably reformatted into root-relative urls without causing issues 79 108 //related to other deficiencies in the wp core. 80 $url = parse_url($url); 81 return '/' . ltrim(@$url['path'], '/') . (isset($url['query']) ? "?" . $url['query'] : ''); 109 110 if (self::$massage) { 111 //massage back to absolute because we're rendering a feed and the platform mixes url procurment methods between the delivery methods 112 //despite offering _rss specific filters 113 return MP_WP_Root_Relative_URLS::dynamic_absolute_url($url); 114 } else { 115 $url = @parse_url($url); 116 return '/' . ltrim(@$url['path'], '/') . (isset($url['query']) ? "?" . $url['query'] : ''); 117 } 82 118 } 83 119 … … 152 188 array( 153 189 'get_bloginfo_rss', 154 'the_permalink_rss' 190 'the_permalink_rss', 191 'get_post_comments_feed_link', 192 'get_the_author_url', 193 'get_comment_author_url', 194 'get_comment_link' 155 195 ), 156 196 array( … … 161 201 2 //supply second parameter for type checking 162 202 ); 163 203 204 //Used to indicate that an atom feed is being generated so it's ok to massage the content urls for absolute format 205 MP_WP_Root_Relative_URLS::add_actions( 206 array( 207 'atom_ns', 208 'attom_comments_ns', 209 'rss2_ns', 210 'rss2_comments_ns', 211 'rdf_ns' 212 ), 213 array( 214 'MP_WP_Root_Relative_URLS', 215 'enable_content_massage' 216 ) 217 ); 218 219 MP_WP_Root_Relative_URLS::add_actions( 220 array( 221 'the_excerpt_rss', 222 'the_content_feed', 223 ), 224 array( 225 'MP_WP_Root_Relative_URLS', 226 'massage_external_content' 227 ) 228 ); 229 164 230 //HACK: This plugin actually won't work for MU Sites until either of the following conditions are true: 165 231 //1. Wordpress core team publishes this patch - http://core.trac.wordpress.org/attachment/ticket/18910/ms-blogs.php.patch
Note: See TracChangeset
for help on using the changeset viewer.