name = 'term'; $this->label = __( 'Term', 'cfs' ); } function html( $field ) { global $wpdb; $selected_posts = array(); $available_posts = array(); $taxonomies = array(); if ( ! empty( $field->options['taxonomies'] ) ) { foreach ( $field->options['taxonomies'] as $taxonomy ) { $taxonomies[] = $taxonomy; } } else { $taxonomies = get_taxonomies( array( 'public' => true ) ); } $args = array( 'taxonomy' => $taxonomies, 'hide_empty' => false, 'fields' => 'ids', 'orderby' => 'name', 'order' => 'ASC' ); $args = apply_filters( 'cfs_field_term_query_args', $args, array( 'field' => $field ) ); // Use older `get_terms` function signature for older versions of WP if ( version_compare( get_bloginfo('version'), '4.5', '<' ) ) { $taxonomy = $args['taxonomy']; unset( $args['taxonomy'] ); $query = get_terms( $taxonomy, $args ); } else { $query = get_terms( $args ); } foreach ( $query as $term_id ) { $term = get_term( $term_id ); $available_posts[] = (object) array( 'term_id' => $term->term_id, 'taxonomy' => $term->taxonomy, 'name' => $term->name, ); } if ( ! empty( $field->value ) ) { $results = $wpdb->get_results( "SELECT term_id, name FROM $wpdb->terms WHERE term_id IN ($field->value) ORDER BY FIELD(term_id,$field->value)" ); foreach ( $results as $result ) { $selected_posts[ $result->term_id ] = $result; } } ?>
term_id ] ) ) ? ' class="used"' : ''; ?>
title="name; ?>">name, $term->term_id, $field ); ?>
name, $term->term_id, $field ); ?>
true ); $choices = apply_filters( 'cfs_field_term_taxonomies', get_taxonomies( $args ) ); ?>

create_field( array( 'type' => 'select', 'input_name' => "cfs[fields][$key][options][taxonomies]", 'options' => array( 'multiple' => '1', 'choices' => $choices ), 'value' => $this->get_option( $field, 'taxonomies' ), )); ?>