Plugin Directory

Changeset 678680


Ignore:
Timestamp:
03/09/2013 01:23:58 PM (13 years ago)
Author:
MarcusPope
Message:

added support for WMPL and wp-include scripts

Location:
root-relative-urls/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • root-relative-urls/trunk/readme.txt

    r678674 r678680  
    108108
    109109== 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
    110115= 1.9 =
    111116* 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  
    3535    //munges absolute urls provided to the wysiwyg editor to be root relative instead of absolute
    3636    //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
    4040    static function add_actions($tag_arry, $func, $p = 10, $a = 1) {
    4141        //allows for multiple tags to bind to the same funciton call
     
    8484    static function enable_content_massage() {
    8585        //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
    8787        //some external sources don't understand the html spec
    8888        self::$massage = true;
    89        
     89
    9090        //massage global post object
    9191        global $post;
     
    9393        $post->post_excerpt= self::massage_external_content($post->post_excerpt);
    9494    }
    95    
     95
    9696    static function massage_external_content($a) {
    9797        //Here is where we fix the root relative content urls into absolute urls using the current host name
     
    102102        return $a;
    103103    }
    104    
     104
    105105    static function do_absolute_massage_cb($a) {
    106106        //callback handler that does the physical insertion of absolute domain into root relative urls
    107107        return $a[1] . self::scheme('http://' . @$_SERVER['HTTP_HOST'] . $a[2]);
    108108    }
    109    
     109
    110110    static function proper_root_relative_url($url) {
    111111        //This method is used for urls that can be acceptably reformatted into root-relative urls without causing issues
    112112        //related to other deficiencies in the wp core.
    113        
     113
    114114        if (self::$massage) {
    115115            //massage back to absolute because we're rendering a feed and the platform mixes url procurment methods between the delivery methods
     
    138138
    139139    static function root_relative_url($url, $html) {
    140        
     140
    141141        //bugfix: wp3.5 started using root relative urls... I guess they're doing it wrong? o_O #riot
    142142        if ($url[0] == "/") return $html;
    143        
     143
    144144        //in case they missed one ;)
    145145        $p = parse_url($url);
    146146        $root = $p['scheme'] . "://" . $p['host'];
    147147        $html = str_ireplace($root, '', $html);
    148         return $html;       
    149     }
    150    
     148        return $html;
     149    }
     150
    151151    static function root_relative_image_urls($html, $id, $caption, $title, $align, $url, $size, $alt) {
    152152        //Same as media_send_to_editor but images are handled separately
     
    166166        }
    167167    }
    168    
     168
    169169    static function fix_upload_paths($o) {
    170170        //Fixes attachment urls when user has customized the base url and/or upload folder in Admin > Settings > Media : Uploading Files
     
    173173        return $o;
    174174    }
    175    
     175
    176176    static function init() {
    177177        //Setup all hooks / filters for either dynamically replacing the host part of a URL with the current host
     
    229229            2  //supply second parameter for type checking
    230230        );
    231        
     231
    232232        //Used to indicate that an atom feed is being generated so it's ok to massage the content urls for absolute format
    233233        MP_WP_Root_Relative_URLS::add_actions(
     
    244244            )
    245245        );
    246        
     246
    247247        MP_WP_Root_Relative_URLS::add_actions(
    248248            array(
     
    255255            )
    256256        );
    257        
     257
    258258        //HACK: This plugin actually won't work for MU Sites until either of the following conditions are true:
    259259            //1. Wordpress core team publishes this patch - http://core.trac.wordpress.org/attachment/ticket/18910/ms-blogs.php.patch
     
    307307            1
    308308        );
     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
    309329    }
    310330}
Note: See TracChangeset for help on using the changeset viewer.