class-wpml-wp-taxonomy-query.php
857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
class WPML_WP_Taxonomy_Query {
private $taxonomies_query_vars;
public function __construct( $wp_api ) {
$wp_taxonomies = $wp_api->get_wp_taxonomies();
$this->taxonomies_query_vars = array();
foreach ( $wp_taxonomies as $k => $v ) {
if ( $k === 'category' ) {
continue;
}
if ( $k == 'post_tag' && ! $v->query_var ) {
$tag_base = $wp_api->get_option( 'tag_base', 'tag' );
$v->query_var = $tag_base;
}
if ( $v->query_var ) {
$this->taxonomies_query_vars[ $k ] = $v->query_var;
}
}
}
public function get_query_vars() {
return $this->taxonomies_query_vars;
}
public function find( $taxonomy ) {
$tax = false;
if ( isset( $this->taxonomies_query_vars ) && is_array( $this->taxonomies_query_vars ) ) {
$tax = array_search( $taxonomy, $this->taxonomies_query_vars );
}
return $tax;
}
}