| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | 4 | * Setups the objects languages and translations model |
| 8 | 5 | * |
| @@ -45,13 +42,8 @@ | ||
| 45 | 42 | return false; |
| 46 | 43 | } |
| 47 | 44 | |
| 48 | 45 | $object_id = (int) $object_id; |
| 49 | - | |
| 50 | - if ( $object_id < 0 ) { | |
| 51 | - return false; | |
| 52 | - } | |
| 53 | - | |
| 54 | 46 | $term = get_object_term_cache( $object_id, $taxonomy ); |
| 55 | 47 | |
| 56 | 48 | if ( false === $term ) { |
| 57 | 49 | // query language and translations at the same time |
| @@ -57,9 +49,8 @@ | ||
| 57 | 49 | // query language and translations at the same time |
| 58 | 50 | $taxonomies = array( $this->tax_language, $this->tax_translations ); |
| 59 | 51 | |
| 60 | 52 | // query terms |
| 61 | - $terms = array(); | |
| 62 | 53 | foreach ( wp_get_object_terms( $object_id, $taxonomies, array( 'update_term_meta_cache' => false ) ) as $t ) { |
| 63 | 54 | $terms[ $t->taxonomy ] = $t; |
| 64 | 55 | if ( $t->taxonomy == $taxonomy ) { |
| 65 | 56 | $term = $t; |
| @@ -247,8 +238,9 @@ | ||
| 247 | 238 | * @param object|array|string $lang a PLL_Language object or a comma separated list of language slug or an array of language slugs |
| 248 | 239 | * @return string where clause |
| 249 | 240 | */ |
| 250 | 241 | public function where_clause( $lang ) { |
| 242 | + global $wpdb; | |
| 251 | 243 | $tt_id = $this->tax_tt; |
| 252 | 244 | |
| 253 | 245 | // $lang is an object |
| 254 | 246 | // generally the case if the query is coming from Polylang |
| @@ -257,10 +249,9 @@ | ||
| 257 | 249 | } |
| 258 | 250 | |
| 259 | 251 | // $lang is a comma separated list of slugs ( or an array of slugs ) |
| 260 | 252 | // generally the case is the query is coming from outside with 'lang' parameter |
| 261 | - $slugs = is_array( $lang ) ? $lang : explode( ',', $lang ); | |
| 262 | - $languages = array(); | |
| 253 | + $slugs = is_array( $lang ) ? $lang : explode( ',', $lang ); | |
| 263 | 254 | foreach ( $slugs as $slug ) { |
| 264 | 255 | $languages[] = absint( $this->model->get_language( $slug )->$tt_id ); |
| 265 | 256 | } |
| 266 | 257 | |