diff --git a/assets/css/admin.css b/assets/css/admin.css index dcc5baa5..28b2e2cc 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -8,7 +8,7 @@ } .post-state-format.post-format-league:before, .post-format-icon.post-format-league:before, a.post-state-format.format-league:before { - content: "\f313"; + content: "\f481"; } .post-state-format.post-format-friendly:before, .post-format-icon.post-format-friendly:before, a.post-state-format.format-friendly:before { diff --git a/assets/css/menu.css b/assets/css/menu.css index 9a075217..cc9e1339 100644 --- a/assets/css/menu.css +++ b/assets/css/menu.css @@ -63,7 +63,7 @@ content: "\f182"; } .sp-icon-league:before { - content: "\f313"; + content: "\f481"; } .sp-icon-friendly:before { content: "\f328"; diff --git a/assets/js/admin/sportspress-admin.js b/assets/js/admin/sportspress-admin.js index e2bfe5e5..2f1c6c33 100644 --- a/assets/js/admin/sportspress-admin.js +++ b/assets/js/admin/sportspress-admin.js @@ -133,14 +133,6 @@ jQuery(document).ready(function($){ // Activate self-cloning $(".sp-clone:last").find("select").change(); - // Dummy controller - $(".sp-has-dummy").change(function() { - val = $(this).val(); - if ( val == -1 ) val = 0; - name = $(this).attr("name"); - $(".sp-dummy."+name+"-dummy").val(val).trigger("change"); - }); - // Custom value editor $(".sp-data-table .sp-default-value").click(function() { $(this).hide().siblings(".sp-custom-value").show().find(".sp-custom-value-input").focus(); @@ -422,11 +414,11 @@ jQuery(document).ready(function($){ $(".post-type-sp_event #post-formats-select input.post-format").change(function() { layout = $(".post-type-sp_event #post-formats-select input:checked").val(); if ( layout == "friendly" ) { - $(".sp-event-sp_league-field").hide().find("select").prop("disabled", true); - $(".sp-event-sp_season-field").show().find("select").prop("disabled", false); + $(".sp_event-sp_league-field").hide().find("select").prop("disabled", true); + $(".sp_event-sp_season-field").show().find("select").prop("disabled", false); } else { - $(".sp-event-sp_league-field").show().find("select").prop("disabled", false); - $(".sp-event-sp_season-field").show().find("select").prop("disabled", false); + $(".sp_event-sp_league-field").show().find("select").prop("disabled", false); + $(".sp_event-sp_season-field").show().find("select").prop("disabled", false); } }); diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php index 283d2c47..0abd1962 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-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 @@ -19,13 +19,11 @@ class SP_Meta_Box_Calendar_Details { * Output the metabox */ public static function output( $post ) { + $taxonomies = get_object_taxonomies( 'sp_calendar' ); $status = get_post_meta( $post->ID, 'sp_status', true ); $date = get_post_meta( $post->ID, 'sp_date', true ); $date_from = get_post_meta( $post->ID, 'sp_date_from', true ); $date_to = get_post_meta( $post->ID, 'sp_date_to', true ); - $league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 ); - $season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 ); - $venue_id = sp_get_the_term_id( $post->ID, 'sp_venue', 0 ); $team_id = get_post_meta( $post->ID, 'sp_team', true ); $order = get_post_meta( $post->ID, 'sp_order', true ); ?> @@ -59,51 +57,11 @@ class SP_Meta_Box_Calendar_Details {

-

-

- __( '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 {

$post_type ) { - $obj = get_taxonomy( $taxonomy ); if ( $obj ) { - ?> -
-

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' ) ); + } + ?> +

+
+ null, 'sp_season' => null, 'sp_venue' => 'sp_event' ) ); - foreach ( $taxonomies as $taxonomy => $post_type ) { - $value = sp_array_value( $_POST, $taxonomy, -1 ); - if ( 0 == $value) { - $teams = sp_array_value( $_POST, 'sp_team', array() ); - $team = reset( $teams ); - $value = sp_get_the_term_id( $team, $taxonomy ); - } - wp_set_post_terms( $post_id, $value, $taxonomy ); - update_post_meta( $post_id, $taxonomy, $value ); + $venues = array_filter( sp_array_value( sp_array_value( $_POST, 'tax_input', array() ), 'sp_venue', array() ) ); + if ( empty( $venues ) ) { + $teams = sp_array_value( $_POST, 'sp_team', array() ); + $team = reset( $teams ); + $venue = sp_get_the_term_id( $team, 'sp_venue' ); + wp_set_post_terms( $post_id, $venue, 'sp_venue' ); } } } diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-details.php index 03abf2d6..b865dffc 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-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 @@ -19,8 +19,7 @@ class SP_Meta_Box_List_Details { * Output the metabox */ public static function output( $post ) { - $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_list' ); $team_id = get_post_meta( $post->ID, 'sp_team', true ); $grouping = get_post_meta( $post->ID, 'sp_grouping', true ); $orderby = get_post_meta( $post->ID, 'sp_orderby', true ); @@ -32,36 +31,11 @@ class SP_Meta_Box_List_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; - ?> -

+

@@ -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; + ?> +

+
+