PluginProbe
Polylang / 2.5.2
Polylang v2.5.2
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | include/translated-term.php +6 -14 2.92.5.2 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 4 * Setups the taxonomies languages and translations model
8 5 *
@@ -17,10 +14,9 @@
17 14 *
18 15 * @param object $model
19 16 */
20 17 public function __construct( &$model ) {
21 - $this->object_type = 'term'; // For taxonomies
22 - $this->type = 'term'; // For capabilities
18 + $this->object_type = 'term';
23 19 $this->tax_language = 'term_language';
24 20 $this->tax_translations = 'term_translations';
25 21 $this->tax_tt = 'tl_term_taxonomy_id';
26 22
@@ -87,9 +83,9 @@
87 83 }
88 84
89 85 // get_term_by still not cached in WP 3.5.1 but internally, the function is always called by term_id
90 86 elseif ( is_string( $value ) && $taxonomy ) {
91 - $term_id = get_term_by( 'slug', $value, $taxonomy )->term_id;
87 + $term_id = wpcom_vip_get_term_by( 'slug', $value, $taxonomy )->term_id;
92 88 }
93 89
94 90 // Get the language and make sure it is a PLL_Language object
95 91 return isset( $term_id ) && ( $lang = $this->get_object_term( $term_id, 'term_language' ) ) ? $this->model->get_language( $lang->term_id ) : false;
@@ -130,10 +126,10 @@
130 126 wp_delete_object_term_relationships( $id, 'term_translations' );
131 127
132 128 if ( ! doing_action( 'pre_delete_term' ) && $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( * ) FROM $wpdb->terms WHERE term_id = %d;", $id ) ) ) {
133 129 // Always keep a group for terms to allow relationships remap when importing from a WXR file
134 - $translations = array( $slug => $id );
135 - wp_insert_term( $group = uniqid( 'pll_' ), 'term_translations', array( 'description' => maybe_serialize( $translations ) ) );
130 + $translations[ $slug ] = $id;
131 + wp_insert_term( $group = uniqid( 'pll_' ), 'term_translations', array( 'description' => serialize( $translations ) ) );
136 132 wp_set_object_terms( $id, $group, 'term_translations' );
137 133 }
138 134 }
139 135
@@ -140,16 +136,14 @@
140 136 /**
141 137 * A join clause to add to sql queries when filtering by language is needed directly in query
142 138 *
143 139 * @since 1.2
144 - * @since 2.6 The `$alias` parameter was added.
145 140 *
146 - * @param string $alias Alias for $wpdb->terms table
147 141 * @return string join clause
148 142 */
149 - public function join_clause( $alias = 't' ) {
143 + public function join_clause() {
150 144 global $wpdb;
151 - return " INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id = $alias.term_id";
145 + return " INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id = t.term_id";
152 146 }
153 147
154 148 /**
155 149 * Cache language and translations when terms are queried by get_terms
@@ -160,10 +154,8 @@
160 154 * @param array $taxonomies queried taxonomies
161 155 * @return array unmodified $terms
162 156 */
163 157 public function _prime_terms_cache( $terms, $taxonomies ) {
164 - $term_ids = array();
165 -
166 158 if ( is_array( $terms ) && $this->model->is_translated_taxonomy( $taxonomies ) ) {
167 159 foreach ( $terms as $term ) {
168 160 $term_ids[] = is_object( $term ) ? $term->term_id : (int) $term;
169 161 }