| @@ -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 |
| @@ -162,16 +154,15 @@ | ||
| 162 | 154 | $term = $this->get_object_term( $id, $this->tax_translations ); |
| 163 | 155 | |
| 164 | 156 | if ( ! empty( $term ) ) { |
| 165 | 157 | $d = maybe_unserialize( $term->description ); |
| 166 | - if ( is_array( $d ) ) { | |
| 167 | - $slug = array_search( $id, $this->get_translations( $id ) ); // In case some plugin stores the same value with different key. | |
| 168 | - unset( $d[ $slug ] ); | |
| 169 | - } | |
| 158 | + $slug = array_search( $id, $this->get_translations( $id ) ); // in case some plugin stores the same value with different key | |
| 159 | + unset( $d[ $slug ] ); | |
| 170 | 160 | |
| 171 | 161 | if ( empty( $d ) ) { |
| 172 | 162 | wp_delete_term( (int) $term->term_id, $this->tax_translations ); |
| 173 | - } else { | |
| 163 | + } | |
| 164 | + else { | |
| 174 | 165 | wp_update_term( (int) $term->term_id, $this->tax_translations, array( 'description' => maybe_serialize( $d ) ) ); |
| 175 | 166 | } |
| 176 | 167 | } |
| 177 | 168 | } |
| @@ -279,25 +270,9 @@ | ||
| 279 | 270 | */ |
| 280 | 271 | public function get_objects_in_language( $lang ) { |
| 281 | 272 | global $wpdb; |
| 282 | 273 | $tt_id = $this->tax_tt; |
| 283 | - | |
| 284 | - $last_changed = wp_cache_get_last_changed( 'terms' ); | |
| 285 | - $cache_key = "polylang:get_objects_in_language:{$lang->$tt_id}:{$last_changed}"; | |
| 286 | - $cache = wp_cache_get( $cache_key, 'terms' ); | |
| 287 | - | |
| 288 | - if ( false === $cache ) { | |
| 289 | - $object_ids = $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $lang->$tt_id ) ); | |
| 290 | - wp_cache_set( $cache_key, $object_ids, 'terms' ); | |
| 291 | - } else { | |
| 292 | - $object_ids = (array) $cache; | |
| 293 | - } | |
| 294 | - | |
| 295 | - if ( ! $object_ids ) { | |
| 296 | - return array(); | |
| 297 | - } | |
| 298 | - | |
| 299 | - return $object_ids; | |
| 274 | + return $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $lang->$tt_id ) ); | |
| 300 | 275 | } |
| 301 | 276 | |
| 302 | 277 | /** |
| 303 | 278 | * Check if a user can synchronize translations |