From 40d73e48d2c71ee5dab663fc1612b2e1be556436 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 19 Sep 2014 10:29:19 +0100 Subject: [PATCH] Tweak load_plugin_textdomain to be relative - this falls back to WP_LANG_DIR automatically. Can prevent "open_basedir restriction in effect". MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @claudiosmweb agree? Load_plugin_textdomain needs a relative path. If the locale isn’t found, it reverts to WP_LANG_DIR/plugins/ as you coded it. --- readme.txt | 2 ++ woocommerce.php | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index bcaf0d33fea..a4b68de9b8c 100644 --- a/readme.txt +++ b/readme.txt @@ -130,6 +130,8 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc == Changelog == +* Tweak load_plugin_textdomain to be relative - this falls back to WP_LANG_DIR automatically. Can prevent "open_basedir restriction in effect". + = 2.2.4 - 18/09/2014 = * Fix - Prevent errors when adding 'zero-rated' tax on checkout. * Fix - Fixed a varation product width inheritance bug. diff --git a/woocommerce.php b/woocommerce.php index 8a308449e74..9a0b80ce900 100644 --- a/woocommerce.php +++ b/woocommerce.php @@ -408,15 +408,26 @@ final class WooCommerce { $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce' ); $dir = trailingslashit( WP_LANG_DIR ); - // Admin Locale + /** + * Admin Locale. Looks in: + * + * - WP_LANG_DIR/woocommerce/woocommerce-admin-LOCALE.mo + * - WP_LANG_DIR/plugins/woocommerce-admin-LOCALE.mo + */ if ( is_admin() ) { load_textdomain( 'woocommerce', $dir . 'woocommerce/woocommerce-admin-' . $locale . '.mo' ); load_textdomain( 'woocommerce', $dir . 'plugins/woocommerce-admin-' . $locale . '.mo' ); } - // Global + Frontend Locale + /** + * Frontend/global Locale. Looks in: + * + * - WP_LANG_DIR/woocommerce/woocommerce-LOCALE.mo + * - woocommerce/i18n/languages/woocommerce-LOCALE.mo (which if not found falls back to:) + * - WP_LANG_DIR/plugins/woocommerce-LOCALE.mo + */ load_textdomain( 'woocommerce', $dir . 'woocommerce/woocommerce-' . $locale . '.mo' ); - load_plugin_textdomain( 'woocommerce', false, $dir . 'plugins' ); + load_plugin_textdomain( 'woocommerce', false, plugin_basename( dirname( __FILE__ ) ) . "/i18n/languages" ); } /**