*/ public $db_fields = [ 'parent' => 'parent', 'id' => 'term_id', ]; /** * @var string */ public $field = null; /** * Class constructor. * * @param array $args Optional arguments. */ public function __construct( $args = null ) { if ( $args && isset( $args['field'] ) ) { $this->field = $args['field']; } } /** * Start the element output. * * @param string $output Passed by reference. Used to append additional content. * @param WP_Term $object Term data object. * @param int $depth Depth of term in reference to parents. * @param array $args Optional arguments. * @param int $current_object_id Current object ID. * @return void */ public function start_el( &$output, $object, $depth = 0, $args = [], $current_object_id = 0 ) { $pad = str_repeat( ' ', $depth * 3 ); $tax = get_taxonomy( $args['taxonomy'] ); if ( ! $tax ) { return; } if ( $this->field ) { $value = $object->{$this->field}; } else { $value = $tax->hierarchical ? $object->term_id : $object->name; } if ( empty( $object->term_id ) && ! $tax->hierarchical ) { $value = ''; } $cat_name = apply_filters( 'list_cats', $object->name, $object ); $output .= "\t\n"; } }