WordPress.org

Make WordPress Core

Ticket #6938: load_plugin_textdomain-backward-compat.diff

File load_plugin_textdomain-backward-compat.diff, 1.7 KB (added by nbachiyski, 6 years ago)
  • wp-includes/l10n.php

     
    276276 * directory. The .mo file should be named based on the domain with a 
    277277 * dash followed by a dash, and then the locale exactly. 
    278278 * 
    279  * The plugin may place all of the .mo files in another folder and set 
    280  * the $path based on the relative location from ABSPATH constant. The 
    281  * plugin may use the constant WP_PLUGIN_DIR and/or plugin_basename() to 
    282  * get path of the plugin and then add the folder which holds the .mo 
    283  * files. 
    284  * 
    285279 * @since 1.5.0 
    286280 * 
    287281 * @param string $domain Unique identifier for retrieving translated strings 
    288  * @param string $path Optional. Path of the folder where the .mo files reside. 
     282 * @param string $abs_rel_path Optional. Relative path to ABSPATH of a folder, 
     283 *      where the .mo file resides. Deprecated, but still functional until 2.7 
     284 * @param string $plugin_rel_path Optional. Relative path to WP_PLUGIN_DIR. This is the preferred argument to use. It takes precendence over $abs_rel_path 
    289285 */ 
    290 function load_plugin_textdomain($domain, $path = false) { 
     286function load_plugin_textdomain($domain, $abs_rel_path = false, $plugin_rel_path = false) { 
    291287        $locale = get_locale(); 
    292  
    293         if ( false === $path ) 
    294                 $path = ''; 
     288         
     289        if ( false !== $plugin_rel_path ) 
     290                $path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/'); 
     291        else if ( false !== $abs_rel_path) 
     292                $path = ABSPATH . trim( $abs_rel_path, '/'); 
    295293        else 
    296                 $path = '/' . trim(trim($path), '/'); 
     294                $path = WP_PLUGIN_DIR; 
    297295 
    298         $mofile = WP_PLUGIN_DIR . $path . '/'. $domain . '-' . $locale . '.mo'; 
     296        $mofile = $path . '/'. $domain . '-' . $locale . '.mo'; 
    299297        load_textdomain($domain, $mofile); 
    300298} 
    301299