WordPress.org

Plugin Directory

Changeset 627893


Ignore:
Timestamp:
11/20/12 21:09:52 (17 months ago)
Author:
Chouby
Message:

add 'lang' parameter in WP function 'get_terms'

Location:
polylang/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • polylang/trunk/include/admin-filters.php

    r619846 r627893  
    509509 
    510510        // STOP synchronisation if unwanted 
    511         if (!$this->options['sync']) 
     511        if (!isset($this->options['sync']) || !$this->options['sync']) 
    512512            return; 
    513513 
     
    667667        } 
    668668 
     669        // if get_terms is queried with a 'lang' parameter 
     670        if (isset($args['lang']) && $args['lang']) 
     671            return $this->_terms_clauses($clauses, $args['lang']); 
     672 
    669673        if (function_exists('get_current_screen')) 
    670674            $screen = get_current_screen(); // since WP 3.1, may not be available the first time(s) get_terms is called 
     
    837841 
    838842        // STOP synchronisation if unwanted 
    839         if (!$this->options['sync']) 
     843        if (!isset($this->options['sync']) || !$this->options['sync']) 
    840844            return; 
    841845 
  • polylang/trunk/include/base.php

    r626239 r627893  
    261261        global $wpdb; 
    262262        if (isset($lang) && $lang) { 
     263            // the query is coming from Polylang and the $lang is an object 
     264            if (is_object($lang)) 
     265                $languages = esc_sql($lang->term_id); 
     266 
     267            // the query is coming from outside with 'lang' parameter and $lang is a comma separated list of slugs (or an array of slugs) 
     268            else { 
     269                $languages = is_array($lang) ? $lang : explode(',', $lang); 
     270                $languages = "'" . implode("','", array_map( 'sanitize_title_for_query', $languages)) . "'"; 
     271                $languages = $wpdb->get_col("SELECT $wpdb->term_taxonomy.term_id FROM $wpdb->term_taxonomy 
     272                    INNER JOIN $wpdb->terms USING (term_id) WHERE taxonomy = 'language' AND $wpdb->terms.slug IN ($languages)"); // get ids from slugs 
     273                $languages = esc_sql(implode(',', $languages)); 
     274            } 
     275 
    263276            $clauses['join'] .= " LEFT JOIN $wpdb->termmeta AS pll_tm ON t.term_id = pll_tm.term_id"; 
    264             $clauses['where'] .= $wpdb->prepare(" AND pll_tm.meta_key = '_language' AND pll_tm.meta_value IN (%s)", $lang->term_id); 
     277            $clauses['where'] .= " AND pll_tm.meta_key = '_language' AND pll_tm.meta_value IN ($languages)"; 
    265278        } 
    266279        return $clauses; 
  • polylang/trunk/include/core.php

    r626239 r627893  
    532532        } 
    533533 
    534         // adds our clauses to filter by current language 
    535         return $this->_terms_clauses($clauses, $this->curlang); 
     534        // adds our clauses to filter by language 
     535        return $this->_terms_clauses($clauses, isset($args['lang']) && $args['lang'] ? $args['lang'] : $this->curlang); 
    536536    } 
    537537 
  • polylang/trunk/polylang.php

    r626239 r627893  
    33Plugin Name: Polylang 
    44Plugin URI: http://wordpress.org/extend/plugins/polylang/ 
    5 Version: 0.9.5.1 
     5Version: 0.9.5.3 
    66Author: F. Demarle 
    77Description: Adds multilingual capability to Wordpress 
     
    2727*/ 
    2828 
    29 define('POLYLANG_VERSION', '0.9.5.1'); 
     29define('POLYLANG_VERSION', '0.9.5.3'); 
    3030define('PLL_MIN_WP_VERSION', '3.1'); 
    3131 
     
    299299                flush_rewrite_rules(); // rewrite rules have been modified in 0.8.8 
    300300 
    301             if (version_compare($options['version'], '0.9', '<')) { 
    302                 if (defined('PLL_SYNC')) 
    303                     $options['sync'] = PLL_SYNC ? 1 : 0;    // the option replaces PLL_SYNC in 0.9           
    304             } 
     301            if (version_compare($options['version'], '0.9', '<')) 
     302                $options['sync'] = defined('PLL_SYNC') && !PLL_SYNC ? 0 : 1;    // the option replaces PLL_SYNC in 0.9 
    305303 
    306304            $options['version'] = POLYLANG_VERSION; 
  • polylang/trunk/readme.txt

    r626239 r627893  
    9696= 0.9.6 = 
    9797 
     98* It is now possible to query the terms by language using the WordPress function 'get_terms' 
    9899* Bug correction: search for empty string in default language displays posts in all languages when hiding the URL language information for default language  
    99100* Tests done with WordPress 3.5 beta 3 
Note: See TracChangeset for help on using the changeset viewer.