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 |