| @@ -14,10 +14,9 @@ | ||
| 14 | 14 | * |
| 15 | 15 | * @param object $model |
| 16 | 16 | */ |
| 17 | 17 | public function __construct( &$model ) { |
| 18 | - $this->object_type = 'term'; // For taxonomies | |
| 19 | - $this->type = 'term'; // For capabilities | |
| 18 | + $this->object_type = 'term'; | |
| 20 | 19 | $this->tax_language = 'term_language'; |
| 21 | 20 | $this->tax_translations = 'term_translations'; |
| 22 | 21 | $this->tax_tt = 'tl_term_taxonomy_id'; |
| 23 | 22 | |
| @@ -84,9 +83,9 @@ | ||
| 84 | 83 | } |
| 85 | 84 | |
| 86 | 85 | // get_term_by still not cached in WP 3.5.1 but internally, the function is always called by term_id |
| 87 | 86 | elseif ( is_string( $value ) && $taxonomy ) { |
| 88 | - $term_id = get_term_by( 'slug', $value, $taxonomy )->term_id; | |
| 87 | + $term_id = wpcom_vip_get_term_by( 'slug', $value, $taxonomy )->term_id; | |
| 89 | 88 | } |
| 90 | 89 | |
| 91 | 90 | // Get the language and make sure it is a PLL_Language object |
| 92 | 91 | return isset( $term_id ) && ( $lang = $this->get_object_term( $term_id, 'term_language' ) ) ? $this->model->get_language( $lang->term_id ) : false; |
| @@ -127,10 +126,10 @@ | ||
| 127 | 126 | wp_delete_object_term_relationships( $id, 'term_translations' ); |
| 128 | 127 | |
| 129 | 128 | if ( ! doing_action( 'pre_delete_term' ) && $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( * ) FROM $wpdb->terms WHERE term_id = %d;", $id ) ) ) { |
| 130 | 129 | // Always keep a group for terms to allow relationships remap when importing from a WXR file |
| 131 | - $translations = array( $slug => $id ); | |
| 132 | - 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 ) ) ); | |
| 133 | 132 | wp_set_object_terms( $id, $group, 'term_translations' ); |
| 134 | 133 | } |
| 135 | 134 | } |
| 136 | 135 | |
| @@ -137,16 +136,14 @@ | ||
| 137 | 136 | /** |
| 138 | 137 | * A join clause to add to sql queries when filtering by language is needed directly in query |
| 139 | 138 | * |
| 140 | 139 | * @since 1.2 |
| 141 | - * @since 2.6 The `$alias` parameter was added. | |
| 142 | 140 | * |
| 143 | - * @param string $alias Alias for $wpdb->terms table | |
| 144 | 141 | * @return string join clause |
| 145 | 142 | */ |
| 146 | - public function join_clause( $alias = 't' ) { | |
| 143 | + public function join_clause() { | |
| 147 | 144 | global $wpdb; |
| 148 | - 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"; | |
| 149 | 146 | } |
| 150 | 147 | |
| 151 | 148 | /** |
| 152 | 149 | * Cache language and translations when terms are queried by get_terms |
| @@ -157,10 +154,8 @@ | ||
| 157 | 154 | * @param array $taxonomies queried taxonomies |
| 158 | 155 | * @return array unmodified $terms |
| 159 | 156 | */ |
| 160 | 157 | public function _prime_terms_cache( $terms, $taxonomies ) { |
| 161 | - $term_ids = array(); | |
| 162 | - | |
| 163 | 158 | if ( is_array( $terms ) && $this->model->is_translated_taxonomy( $taxonomies ) ) { |
| 164 | 159 | foreach ( $terms as $term ) { |
| 165 | 160 | $term_ids[] = is_object( $term ) ? $term->term_id : (int) $term; |
| 166 | 161 | } |