Comment
9 years ago
Link
9 years ago
Media
9 years ago
Post
9 years ago
User
9 years ago
ActionColumnHelper.php
9 years ago
Actions.php
9 years ago
AjaxValue.php
9 years ago
CustomField.php
9 years ago
Meta.php
9 years ago
Placeholder.php
9 years ago
Taxonomy.php
9 years ago
UsedByMenu.php
9 years ago
WooCommercePlaceholder.php
9 years ago
Taxonomy.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * Taxonomy column, displaying terms from a taxonomy for any object type (i.e. posts) |
| 9 | * supporting WordPress' native way of handling terms. |
| 10 | * |
| 11 | * @since 2.0 |
| 12 | */ |
| 13 | class AC_Column_Taxonomy extends AC_Column { |
| 14 | |
| 15 | public function __construct() { |
| 16 | $this->set_type( 'column-taxonomy' ); |
| 17 | $this->set_label( __( 'Taxonomy', 'codepress-admin-columns' ) ); |
| 18 | } |
| 19 | |
| 20 | public function get_taxonomy() { |
| 21 | return $this->get_option( 'taxonomy' ); |
| 22 | } |
| 23 | |
| 24 | // Display |
| 25 | |
| 26 | public function get_value( $post_id ) { |
| 27 | return implode( __( ', ' ), ac_helper()->taxonomy->get_term_links( get_the_terms( $post_id, $this->get_taxonomy() ), get_post_type( $post_id ) ) ); |
| 28 | } |
| 29 | |
| 30 | public function get_raw_value( $post_id ) { |
| 31 | $terms = wp_get_post_terms( $post_id, $this->get_taxonomy(), array( 'fields' => 'ids' ) ); |
| 32 | |
| 33 | if ( ! $terms || is_wp_error( $terms ) ) { |
| 34 | return false; |
| 35 | } |
| 36 | |
| 37 | return $terms; |
| 38 | } |
| 39 | |
| 40 | // Settings |
| 41 | |
| 42 | public function register_settings() { |
| 43 | $this->add_setting( new AC_Settings_Column_Taxonomy( $this ) ); |
| 44 | } |
| 45 | |
| 46 | } |
| 47 |