WordPress.org

Plugin Directory

Changeset 867058


Ignore:
Timestamp:
02/28/14 17:23:02 (4 years ago)
Author:
Intermedi8
Message:
  • added filters for shipping and subtotal display
  • added filters for gateway texts (also used for emails)
  • adapted filters for tax texts
  • compatible up to WooCommerce 2.1.3
Location:
im8-qtranslate-woocommerce/trunk
Files:
2 edited

Legend:

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

    r864711 r867058  
    44 * Plugin URI: http://wordpress.org/plugins/im8-qtranslate-woocommerce/ 
    55 * Description: Front-end integration of qTranslate into WooCommerce. 
    6  * Version: 1.2 
     6 * Version: 1.3 
    77 * Author: intermedi8 
    88 * Author URI: http://intermedi8.de 
     
    3838     * @type    string 
    3939     */ 
    40     protected $version = '1.2'; 
     40    protected $version = '1.3'; 
    4141 
    4242 
     
    181181     * Wrapper for get_option(). 
    182182     * 
    183      * @param   string $key Option name. 
    184      * @param   mixed $default Return value for missing key. 
    185      * @return  mixed|$default Option value. 
     183     * @param   string $key Option name 
     184     * @param   mixed $default Return value for missing key 
     185     * @return  mixed|$default Option value 
    186186     */ 
    187187    protected function get_option($key = null, $default = false) { 
     
    209209     * 
    210210     * @hook    in_plugin_update_message-{$file} 
    211      * @param   array $plugin_data Plugin metadata. 
    212      * @param   array $r Metadata about the available plugin update. 
     211     * @param   array $plugin_data Plugin metadata 
     212     * @param   array $r Metadata about the available plugin update 
    213213     * @return  void 
    214214     */ 
     
    258258                'woocommerce_attribute' => 10, 
    259259                'woocommerce_attribute_label' => 10, 
     260                'woocommerce_cart_item_name' => 10, 
    260261                'woocommerce_cart_tax_totals' => 10, 
    261262                'woocommerce_gateway_description' => 10, 
    262263                'woocommerce_gateway_title' => 10, 
    263264                'woocommerce_in_cart_product_title' => 10, 
     265                'woocommerce_page_title' => 10, 
     266                'woocommerce_order_item_name' => 10, 
     267                'woocommerce_order_product_title' => 10, 
     268                'woocommerce_order_shipping_to_display' => 10, 
     269                'woocommerce_order_subtotal_to_display' => 10, 
     270                'woocommerce_variation_option_name' => 10, 
     271            ); 
     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 
     290            $filters = array( 
    264291                'woocommerce_order_tax_totals' => 10, 
    265                 'woocommerce_page_title' => 10, 
    266                 'woocommerce_order_product_title' => 10, 
    267                 'woocommerce_variation_option_name' => 10, 
    268                 // since WooCommerce 2.1 
    269                 'woocommerce_cart_item_name' => 10, 
    270                 'woocommerce_order_item_name' => 10, 
    271             ); 
    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); 
     292            ); 
     293            $filters = apply_filters('im8qtranslatewoocommerce_translate_tax_totals_filters', $filters); 
     294            foreach ($filters as $id => $priority) 
     295                add_filter($id, array($this, 'translate_tax_totals'), $priority); 
     296 
     297            $filters = array( 
     298                'option_woocommerce_bacs_settings' => 10, 
     299                'option_woocommerce_cheque_settings' => 10, 
     300            ); 
     301            $filters = apply_filters('im8qtranslatewoocommerce_translate_gateway_settings_filters', $filters); 
     302            foreach ($filters as $id => $priority) 
     303                add_filter($id, array($this, 'translate_gateway_settings'), $priority); 
    289304        } // if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) 
    290305 
     
    309324        if (function_exists('qtrans_getLanguage')) { 
    310325            $filters = array( 
    311                 // since WooCommerce 2.1 
    312326                'woocommerce_get_endpoint_url' => 10, 
    313327            ); 
     
    317331 
    318332            $filters = array( 
    319                 'woocommerce_params' => 10, 
    320                 // since WooCommerce 2.1 
    321333                'wc_add_to_cart_params' => 10, 
    322334                'wc_cart_fragments_params' => 10, 
    323335                'wc_cart_params' => 10, 
    324336                'wc_checkout_params' => 10, 
     337                'woocommerce_params' => 10, 
    325338            ); 
    326339            $filters = apply_filters('im8qtranslatewoocommerce_woocommerce_params_filters', $filters); 
     
    370383        return $terms; 
    371384    } // function translate_terms 
     385 
     386 
     387    /** 
     388     * Translate tax labels into current (or default) language. 
     389     * 
     390     * @see     add_filters() 
     391     * @param   array $tax Tax totals array 
     392     * @return  array 
     393     */ 
     394    function translate_tax_totals($tax_totals) { 
     395        foreach ($tax_totals as $key => $tax_total) 
     396            if (isset($tax_total->label)) 
     397                $tax_totals[$key]->label = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($tax_total->label); 
     398 
     399        return $tax_totals; 
     400    } // function translate_taxt_totals 
     401 
     402 
     403    /** 
     404     * Translate gateway settings into current (or default) language. 
     405     * 
     406     * @see     add_filters() 
     407     * @param   array $settings Settings array 
     408     * @return  array 
     409     */ 
     410    function translate_gateway_settings($settings) { 
     411        if (is_array($settings)) 
     412            foreach (array( 
     413                'title', 
     414                'description', 
     415                'instructions', 
     416            ) as $key) 
     417                if (isset($settings[$key])) 
     418                    $settings[$key] = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($settings[$key]); 
     419 
     420        return $settings; 
     421    } // function translate_gateway_settings 
    372422 
    373423 
  • im8-qtranslate-woocommerce/trunk/readme.txt

    r864711 r867058  
    2121* Automatically keep the current language when doing AJAX requests 
    2222* Automatically send emails in the current language 
    23 * **Automatically adapt new WooCommerce endpoints** (since 2.1.0) and redirects to the current language 
     23* **Automatically adapt new WooCommerce endpoints** (since 2.1) and redirects to the current language 
    2424* Ad-free (of course, donations are welcome) 
    2525 
     
    3939== Changelog == 
    4040 
     41= 1.3 = 
     42* added filters for shipping and subtotal display 
     43* added filters for gateway texts (also used for emails) 
     44* adapted filters for tax texts 
     45* compatible up to WooCommerce 2.1.3 
     46 
    4147= 1.2 = 
    4248* bugfix: refactored `get_term` and `wp_get_object_terms` filters to get rid of PHP warnings (thanks to _stevenvd_ and _miso00_ for reporting this) 
Note: See TracChangeset for help on using the changeset viewer.