Enable multiple seasons and competitions to be selected for events, calendars, lists, and tables.

This commit is contained in:
Brian Miyaji
2015-02-16 23:10:38 +11:00
parent 2b3a72054b
commit ed982d2984
8 changed files with 104 additions and 176 deletions

View File

@@ -7,7 +7,7 @@
* @author ThemeBoy
* @category Core
* @package SportsPress/Functions
* @version 1.6.1
* @version 1.6.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -1151,6 +1151,46 @@ if ( !function_exists( 'sp_get_next_event' ) ) {
}
}
if ( !function_exists( 'sp_taxonomy_field' ) ) {
function sp_taxonomy_field( $taxonomy = 'category', $post = null, $multiple = false ) {
$obj = get_taxonomy( $taxonomy );
if ( $obj ) {
$post_type = get_post_type( $post );
?>
<div class="<?php echo $post_type; ?>-<?php echo $taxonomy; ?>-field">
<p><strong><?php echo $obj->labels->singular_name; ?></strong></p>
<p>
<?php
$terms = get_the_terms( $post->ID, $taxonomy );
$term_ids = array();
if ( $terms ):
foreach ( $terms as $term ):
$term_ids[] = $term->term_id;
endforeach;
endif;
$args = array(
'taxonomy' => $taxonomy,
'name' => 'tax_input[' . $taxonomy . '][]',
'selected' => $term_ids,
'values' => 'term_id',
'class' => 'sp-has-dummy widefat',
'chosen' => true,
'placeholder' => __( 'All', 'sportspress' ),
);
if ( $multiple ) {
$args['property'] = 'multiple';
}
if ( ! sp_dropdown_taxonomies( $args ) ):
sp_taxonomy_adder( $taxonomy, $post_type, $obj->labels->add_new_item );
endif;
?>
</p>
</div>
<?php
}
}
}
/**
* Get an array of text options per context.
* @return array