PluginProbe ʕ •ᴥ•ʔ
Search Regex / trunk
Search Regex vtrunk
trunk 1.4.12 1.4.13 1.4.14 1.4.15 1.4.16 2.0 2.0.1 2.1 2.2 2.2.1 2.3 2.3.1 2.3.2 2.3.3 2.4 2.4.1 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1 3.1.1 3.1.2 3.2 3.3 3.3.0 3.3.1 3.4 3.4.1 3.4.2
search-regex / includes / sql / join / class-taxonomy.php
search-regex / includes / sql / join Last commit date
class-comment.php 5 months ago class-join.php 4 months ago class-meta.php 5 months ago class-post.php 5 months ago class-taxonomy.php 5 months ago class-term-description.php 4 months ago class-term.php 5 months ago class-user.php 5 months ago
class-taxonomy.php
50 lines
1 <?php
2
3 namespace SearchRegex\Sql\Join;
4
5 use SearchRegex\Sql;
6
7 /**
8 * Joins taxonomy table
9 */
10 class Taxonomy extends Join {
11 /**
12 * Constructor
13 *
14 * @param string $term_type Type of taxonomy.
15 */
16 public function __construct( $term_type ) {
17 $this->column = $term_type;
18 }
19
20 public function get_select() {
21 global $wpdb;
22
23 return new Sql\Select\Select( Sql\Value::table( $wpdb->prefix . 'term_taxonomy' ), Sql\Value::column( 'taxonomy' ) );
24 }
25
26 public function get_from() {
27 global $wpdb;
28
29 return new Sql\From( Sql\Value::safe_raw( sprintf( 'INNER JOIN %sterm_taxonomy AS tt ON (%sterms.term_id = tt.term_id)', $wpdb->prefix, $wpdb->prefix ) ) );
30 }
31
32 public function get_join_column() {
33 return 'tt.taxonomy';
34 }
35
36 public function get_join_value( $value ) {
37 $tax = get_taxonomy( $value );
38
39 if ( $tax ) {
40 return $tax->label;
41 }
42
43 return "$value";
44 }
45
46 public function get_table() {
47 return '';
48 }
49 }
50