Tags::get_options()
Description #
Return options of a tags field.
Source #
File: lib/form/class-tags.php
private function get_options() {
$options = $this->get( 'options' );
if ( is_string( $options ) && 'terms' === $options ) {
$options = array();
if ( ! empty( $this->value() ) ) {
$value = $this->value();
$tax_args = array(
'taxonomy' => $this->get( 'terms_args.taxonomy' ),
'hide_empty' => false,
'count' => true,
'number' => 20,
);
if ( ! empty( $value ) ) {
$tax_args['include'] = $value;
}
$terms = get_terms( $tax_args );
if ( $terms ) {
foreach ( $terms as $tag ) {
$options[] = array(
'term_id' => $tag->term_id,
'name' => $tag->name,
'description' => $tag->description,
'count' => $tag->count,
);
}
}
}
return $options;
} elseif ( is_string( $options ) && 'posts' === $options ) {
return wp_list_pluck( get_posts( $this->get( 'posts_args', array() ) ), 'post_title', 'ID' );
}
return array();
}
Expand full source code Collapse full source code View on GitHub: lib/form/class-tags.php:93
Add your comment