From ed982d2984ad535c36085c33f0bd1b2d56047742 Mon Sep 17 00:00:00 2001
From: Brian Miyaji
-
- __( 'All', 'sportspress' ), - 'taxonomy' => 'sp_league', - 'name' => 'sp_league', - 'selected' => $league_id, - 'values' => 'term_id' - ); - if ( ! sp_dropdown_taxonomies( $args ) ): - sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) ); - endif; - ?> -
--
- __( 'All', 'sportspress' ), - 'taxonomy' => 'sp_season', - 'name' => 'sp_season', - 'selected' => $season_id, - 'values' => 'term_id' - ); - if ( ! sp_dropdown_taxonomies( $args ) ): - sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) ); - endif; - ?> -
--
- __( 'All', 'sportspress' ), - 'taxonomy' => 'sp_venue', - 'name' => 'sp_venue', - 'selected' => $venue_id, - 'values' => 'term_id' - ); - if ( ! sp_dropdown_taxonomies( $args ) ): - sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) ); - endif; - ?> -
+
ID, 'sp_minutes', true ); - $taxonomies = apply_filters( 'sportspress_event_taxonomies', array( 'sp_league' => null, 'sp_season' => null, 'sp_venue' => 'sp_event' ) ); ?>
@@ -30,34 +30,35 @@ class SP_Meta_Box_Event_Details {
labels->singular_name; ?>
-- $taxonomy, - 'name' => $taxonomy, - 'class' => 'sp-has-dummy', - 'selected' => sp_get_the_term_id_or_meta( $post->ID, $taxonomy ), - 'values' => 'term_id', - 'show_option_none' => __( '— Not set —', 'sportspress' ), - 'chosen' => true, - ); - if ( in_array( $taxonomy, apply_filters( 'sportspress_event_auto_taxonomies', array( 'sp_venue' ) ) ) ) { - $args['show_option_all'] = __( '(Auto)', 'sportspress' ); - } - if ( ! sp_dropdown_taxonomies( $args ) ) { - sp_taxonomy_adder( $taxonomy, $post_type, $obj->labels->add_new_item ); - } - ?> -
-+
+ ID, 'sp_venue' ); + $args = array( + 'taxonomy' => 'sp_venue', + 'name' => 'tax_input[sp_venue][]', + 'class' => 'sp-has-dummy', + 'selected' => sp_get_the_term_id_or_meta( $post->ID, 'sp_venue' ), + 'values' => 'term_id', + 'show_option_none' => __( '— Not set —', 'sportspress' ), + 'chosen' => true, + ); + if ( in_array( 'sp_venue', apply_filters( 'sportspress_event_auto_taxonomies', array( 'sp_venue' ) ) ) ) { + $args['show_option_all'] = __( '(Auto)', 'sportspress' ); + } + if ( ! sp_dropdown_taxonomies( $args ) ) { + sp_taxonomy_adder( 'sp_venue', 'sp_event', __( 'Add New', 'sportspress' ) ); + } + ?> +
+-
- 'sp_league', - 'name' => 'sp_league', - 'show_option_all' => __( 'All', 'sportspress' ), - 'selected' => $league_id, - 'values' => 'term_id', - ); - if ( ! sp_dropdown_taxonomies( $args ) ): - sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) ); - endif; - ?> -
--
- 'sp_season', - 'name' => 'sp_season', - 'show_option_all' => __( 'All', 'sportspress' ), - 'selected' => $season_id, - 'values' => 'term_id', - ); - if ( ! sp_dropdown_taxonomies( $args ) ): - sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) ); - endif; - ?> -
+
@@ -129,8 +103,6 @@ class SP_Meta_Box_List_Details { */ public static function save( $post_id, $post ) { update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); - wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' ); - wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' ); update_post_meta( $post_id, 'sp_grouping', sp_array_value( $_POST, 'sp_grouping', array() ) ); update_post_meta( $post_id, 'sp_orderby', sp_array_value( $_POST, 'sp_orderby', array() ) ); update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', array() ) ); diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-details.php index 094a0148..73d931dd 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-details.php @@ -5,7 +5,7 @@ * @author ThemeBoy * @category Admin * @package SportsPress/Admin/Meta_Boxes - * @version 1.6 + * @version 1.6.2 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly @@ -20,8 +20,7 @@ class SP_Meta_Box_Table_Details { */ public static function output( $post ) { wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' ); - $league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 ); - $season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 ); + $taxonomies = get_object_taxonomies( 'sp_table' ); $select = get_post_meta( $post->ID, 'sp_select', true ); if ( ! $select ) { global $pagenow; @@ -29,36 +28,11 @@ class SP_Meta_Box_Table_Details { } ?>
-
- 'sp_league', - 'name' => 'sp_league', - 'show_option_all' => __( 'All', 'sportspress' ), - 'selected' => $league_id, - 'values' => 'term_id', - ); - if ( ! sp_dropdown_taxonomies( $args ) ): - sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) ); - endif; - ?> -
--
- 'sp_season', - 'name' => 'sp_season', - 'show_option_all' => __( 'All', 'sportspress' ), - 'selected' => $season_id, - 'values' => 'term_id', - ); - if ( ! sp_dropdown_taxonomies( $args ) ): - sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) ); - endif; - ?> -
+@@ -80,8 +54,6 @@ class SP_Meta_Box_Table_Details { * Save meta box data */ public static function save( $post_id, $post ) { - wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' ); - wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' ); update_post_meta( $post_id, 'sp_select', sp_array_value( $_POST, 'sp_select', array() ) ); sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); } diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index 4e754ad7..07da9d5f 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -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 ); + ?> +
labels->singular_name; ?>
++ 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; + ?> +
+