Enable multiple seasons and competitions to be selected for events, calendars, lists, and tables.
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
content: "\f182";
|
||||
}
|
||||
.sp-icon-league:before {
|
||||
content: "\f313";
|
||||
content: "\f481";
|
||||
}
|
||||
.sp-icon-friendly:before {
|
||||
content: "\f328";
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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 {
|
||||
<input type="text" class="sp-datepicker-to" name="sp_date_to" value="<?php echo $date_to ? $date_to : date_i18n( 'Y-m-d' ); ?>" size="10">
|
||||
</p>
|
||||
</div>
|
||||
<p><strong><?php _e( 'Competition', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'show_option_all' => __( '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;
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
|
||||
<p class="sp-tab-select">
|
||||
<?php
|
||||
$args = array(
|
||||
'show_option_all' => __( '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;
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Venue', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'show_option_all' => __( '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;
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
sp_taxonomy_field( $taxonomy, $post, true );
|
||||
}
|
||||
?>
|
||||
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<?php
|
||||
@@ -134,9 +92,6 @@ class SP_Meta_Box_Calendar_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' );
|
||||
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_venue', 0 ), 'sp_venue' );
|
||||
update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 0 ) );
|
||||
update_post_meta( $post_id, 'sp_date', sp_array_value( $_POST, 'sp_date', 0 ) );
|
||||
update_post_meta( $post_id, 'sp_date_from', sp_array_value( $_POST, 'sp_date_from', null ) );
|
||||
|
||||
@@ -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,8 @@ class SP_Meta_Box_Event_Details {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$taxonomies = get_object_taxonomies( 'sp_event' );
|
||||
$minutes = get_post_meta( $post->ID, 'sp_minutes', true );
|
||||
$taxonomies = apply_filters( 'sportspress_event_taxonomies', array( 'sp_league' => null, 'sp_season' => null, 'sp_venue' => 'sp_event' ) );
|
||||
?>
|
||||
<div class="sp-event-minutes-field">
|
||||
<p><strong><?php _e( 'Full Time', 'sportspress' ); ?></strong></p>
|
||||
@@ -30,34 +30,35 @@ class SP_Meta_Box_Event_Details {
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
foreach ( $taxonomies as $taxonomy => $post_type ) {
|
||||
$obj = get_taxonomy( $taxonomy ); if ( $obj ) {
|
||||
?>
|
||||
<div class="sp-event-<?php echo $taxonomy; ?>-field">
|
||||
<p><strong><?php echo $obj->labels->singular_name; ?></strong></p>
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => $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 );
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
if ( 'sp_venue' == $taxonomy ) continue;
|
||||
sp_taxonomy_field( $taxonomy, $post, true );
|
||||
}
|
||||
?>
|
||||
<div class="sp-event-sp_venue-field">
|
||||
<p><strong><?php _e( 'Venue', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<?php
|
||||
$terms = get_the_terms( $post->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' ) );
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,16 +66,12 @@ class SP_Meta_Box_Event_Details {
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_minutes', sp_array_value( $_POST, 'sp_minutes', get_option( 'sportspress_event_minutes', 90 ) ) );
|
||||
$taxonomies = apply_filters( 'sportspress_event_taxonomies', array( 'sp_league' => 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' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php _e( 'Competition', 'sportspress' ); ?></strong></p>
|
||||
<p class="sp-tab-select">
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => '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;
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
|
||||
<p class="sp-tab-select">
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => '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;
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
sp_taxonomy_field( $taxonomy, $post, true );
|
||||
}
|
||||
?>
|
||||
<?php if ( apply_filters( 'sportspress_list_team_selector', true ) ) { ?>
|
||||
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
|
||||
<p class="sp-tab-select">
|
||||
@@ -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() ) );
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php _e( 'Competition', 'sportspress' ); ?></strong></p>
|
||||
<p class="sp-tab-select">
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => '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;
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
|
||||
<p class="sp-tab-select">
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => '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;
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
sp_taxonomy_field( $taxonomy, $post, true );
|
||||
}
|
||||
?>
|
||||
<p><strong>
|
||||
<?php _e( 'Teams', 'sportspress' ); ?>
|
||||
</strong></p>
|
||||
@@ -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() ) );
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user