WordPress.org

Plugin Directory

Changeset 864711


Ignore:
Timestamp:
02/25/14 13:25:40 (3 years ago)
Author:
Intermedi8
Message:
  • bugfix: refactored get_term and wp_get_object_terms filters to get rid of PHP warnings (thanks to _stevenvd_ and _miso00_ for reporting this)
Location:
im8-qtranslate-woocommerce/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • im8-qtranslate-woocommerce/trunk/im8-qtranslate-woocommerce.php

    r859349 r864711  
    44 * Plugin URI: http://wordpress.org/plugins/im8-qtranslate-woocommerce/ 
    55 * Description: Front-end integration of qTranslate into WooCommerce. 
    6  * Version: 1.1 
     6 * Version: 1.2 
    77 * Author: intermedi8 
    88 * Author URI: http://intermedi8.de 
     
    3838     * @type    string 
    3939     */ 
    40     protected $version = '1.1'; 
     40    protected $version = '1.2'; 
    4141 
    4242 
     
    253253     */ 
    254254    protected function add_filters() { 
    255         if (function_exists('__')) { 
    256             $filters = array( 
    257                 'get_term' => 10, 
     255        if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) { 
     256            $filters = array( 
    258257                'the_title_attribute' => 10, 
    259258                'woocommerce_attribute' => 10, 
     
    267266                'woocommerce_order_product_title' => 10, 
    268267                'woocommerce_variation_option_name' => 10, 
    269                 'wp_get_object_terms' => 10, 
    270268                // since WooCommerce 2.1 
    271269                'woocommerce_cart_item_name' => 10, 
    272270                'woocommerce_order_item_name' => 10, 
    273271            ); 
    274             $filters = apply_filters('im8qtranslatewoocommerce_gettext_filters', $filters); 
    275             foreach ($filters as $id => $priority) 
    276                 add_filter($id, '__', $priority); 
    277         } // if (function_exists('__')) 
     272            $filters = apply_filters('im8qtranslatewoocommerce_translate_string_filters', $filters); 
     273            foreach ($filters as $id => $priority) 
     274                add_filter($id, 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage', $priority); 
     275 
     276            $filters = array( 
     277                'get_term' => 10, 
     278            ); 
     279            $filters = apply_filters('im8qtranslatewoocommerce_translate_term_filters', $filters); 
     280            foreach ($filters as $id => $priority) 
     281                add_filter($id, array($this, 'translate_term'), $priority); 
     282 
     283            $filters = array( 
     284                'wp_get_object_terms' => 10, 
     285            ); 
     286            $filters = apply_filters('im8qtranslatewoocommerce_translate_terms_filters', $filters); 
     287            foreach ($filters as $id => $priority) 
     288                add_filter($id, array($this, 'translate_terms'), $priority); 
     289        } // if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) 
    278290 
    279291        if (function_exists('qtrans_convertURL')) { 
     
    327339 
    328340    /** 
     341     * Translate term name into current (or default) language. 
     342     * 
     343     * @see     add_filters() 
     344     * @param   object $term Term object 
     345     * @return  object 
     346     */ 
     347    function translate_term($term) { 
     348        if ( 
     349            isset($term) 
     350            && isset($term->name) 
     351        ) 
     352            $term->name = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($term->name); 
     353 
     354        return $term; 
     355    } // function translate_term 
     356 
     357 
     358    /** 
     359     * Translate term names into current (or default) language. 
     360     * 
     361     * @see     add_filters() 
     362     * @param   array $terms Term objects 
     363     * @return  array 
     364     */ 
     365    function translate_terms($terms) { 
     366        if (is_array($terms) && count($terms)) 
     367            foreach ($terms as $key => $term) 
     368                $terms[$key] = $this->translate_term($term); 
     369 
     370        return $terms; 
     371    } // function translate_terms 
     372 
     373 
     374    /** 
    329375     * Add `lang` query var to given URL. 
    330376     * 
  • im8-qtranslate-woocommerce/trunk/readme.txt

    r859349 r864711  
    3939== Changelog == 
    4040 
     41= 1.2 = 
     42* bugfix: refactored `get_term` and `wp_get_object_terms` filters to get rid of PHP warnings (thanks to _stevenvd_ and _miso00_ for reporting this) 
     43 
    4144= 1.1 = 
    4245* added some missing filters for product/item names (thanks to _Dobbydoo_ for the hint) 
Note: See TracChangeset for help on using the changeset viewer.