Changeset 678680
- Timestamp:
- 03/09/2013 01:23:58 PM (13 years ago)
- Location:
- root-relative-urls/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (1 diff)
-
sb_root_relative_urls.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
root-relative-urls/trunk/readme.txt
r678674 r678680 108 108 109 109 == Changelog == 110 111 = 2.0 = 112 113 * Enhancement: Added support for wp-include and WPML Multilingual CMS plugin. Thanks to @tfmtfm for the patch. 114 110 115 = 1.9 = 111 116 * Bug fix: Added more hooks to fix other urls. Thanks to @lcyconsulting for the solution. -
root-relative-urls/trunk/sb_root_relative_urls.php
r678674 r678680 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 38 static $massage = false; 39 40 40 static function add_actions($tag_arry, $func, $p = 10, $a = 1) { 41 41 //allows for multiple tags to bind to the same funciton call … … 84 84 static function enable_content_massage() { 85 85 //this is only called when an external feed is being called 86 //this lets the content filter know that we should convert root relative urls back in to absolute urls since 86 //this lets the content filter know that we should convert root relative urls back in to absolute urls since 87 87 //some external sources don't understand the html spec 88 88 self::$massage = true; 89 89 90 90 //massage global post object 91 91 global $post; … … 93 93 $post->post_excerpt= self::massage_external_content($post->post_excerpt); 94 94 } 95 95 96 96 static function massage_external_content($a) { 97 97 //Here is where we fix the root relative content urls into absolute urls using the current host name … … 102 102 return $a; 103 103 } 104 104 105 105 static function do_absolute_massage_cb($a) { 106 106 //callback handler that does the physical insertion of absolute domain into root relative urls 107 107 return $a[1] . self::scheme('http://' . @$_SERVER['HTTP_HOST'] . $a[2]); 108 108 } 109 109 110 110 static function proper_root_relative_url($url) { 111 111 //This method is used for urls that can be acceptably reformatted into root-relative urls without causing issues 112 112 //related to other deficiencies in the wp core. 113 113 114 114 if (self::$massage) { 115 115 //massage back to absolute because we're rendering a feed and the platform mixes url procurment methods between the delivery methods … … 138 138 139 139 static function root_relative_url($url, $html) { 140 140 141 141 //bugfix: wp3.5 started using root relative urls... I guess they're doing it wrong? o_O #riot 142 142 if ($url[0] == "/") return $html; 143 143 144 144 //in case they missed one ;) 145 145 $p = parse_url($url); 146 146 $root = $p['scheme'] . "://" . $p['host']; 147 147 $html = str_ireplace($root, '', $html); 148 return $html; 149 } 150 148 return $html; 149 } 150 151 151 static function root_relative_image_urls($html, $id, $caption, $title, $align, $url, $size, $alt) { 152 152 //Same as media_send_to_editor but images are handled separately … … 166 166 } 167 167 } 168 168 169 169 static function fix_upload_paths($o) { 170 170 //Fixes attachment urls when user has customized the base url and/or upload folder in Admin > Settings > Media : Uploading Files … … 173 173 return $o; 174 174 } 175 175 176 176 static function init() { 177 177 //Setup all hooks / filters for either dynamically replacing the host part of a URL with the current host … … 229 229 2 //supply second parameter for type checking 230 230 ); 231 231 232 232 //Used to indicate that an atom feed is being generated so it's ok to massage the content urls for absolute format 233 233 MP_WP_Root_Relative_URLS::add_actions( … … 244 244 ) 245 245 ); 246 246 247 247 MP_WP_Root_Relative_URLS::add_actions( 248 248 array( … … 255 255 ) 256 256 ); 257 257 258 258 //HACK: This plugin actually won't work for MU Sites until either of the following conditions are true: 259 259 //1. Wordpress core team publishes this patch - http://core.trac.wordpress.org/attachment/ticket/18910/ms-blogs.php.patch … … 307 307 1 308 308 ); 309 310 # fix links to javascript loaded with wp_enqueue_script where the files are located in wp-include (e.g. wp_enqueue_script( 'comment-reply' ); 311 # @credit: @tfmtfm 312 add_filter( 313 'script_loader_src', 314 array( 315 'MP_WP_Root_Relative_URLS', 316 'proper_root_relative_url' 317 ) 318 ); 319 320 # support links generated by the WPML plugin (i.e. for the multi-lingual support) 321 add_filter( 322 'WPML_filter_link', 323 array( 324 'MP_WP_Root_Relative_URLS', 325 'proper_root_relative_url' 326 ) 327 ); 328 309 329 } 310 330 }
Note: See TracChangeset
for help on using the changeset viewer.