Display total columns per team
This commit is contained in:
@@ -139,7 +139,7 @@ class SP_Admin_Meta_Boxes {
|
|||||||
add_meta_box( 'sp_shortcodediv', __( 'Shortcodes', 'sportspress' ), 'SP_Meta_Box_Team_Shortcode::output', 'sp_team', 'side', 'default' );
|
add_meta_box( 'sp_shortcodediv', __( 'Shortcodes', 'sportspress' ), 'SP_Meta_Box_Team_Shortcode::output', 'sp_team', 'side', 'default' );
|
||||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Team_Details::output', 'sp_team', 'side', 'default' );
|
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Team_Details::output', 'sp_team', 'side', 'default' );
|
||||||
if ( isset( $post ) && isset( $post->ID ) ):
|
if ( isset( $post ) && isset( $post->ID ) ):
|
||||||
if ( get_the_terms( $post->ID, 'sp_league' ) && get_the_terms( $post->ID, 'sp_season' ) ) add_meta_box( 'sp_columnssdiv', __( 'Table Columns', 'sportspress' ), 'SP_Meta_Box_Team_Columns::output', 'sp_team', 'normal', 'high' );
|
add_meta_box( 'sp_columnssdiv', __( 'Table Columns', 'sportspress' ), 'SP_Meta_Box_Team_Columns::output', 'sp_team', 'normal', 'high' );
|
||||||
add_meta_box( 'sp_listsdiv', __( 'Player Lists', 'sportspress' ), 'SP_Meta_Box_Team_Lists::output', 'sp_team', 'normal', 'high' );
|
add_meta_box( 'sp_listsdiv', __( 'Player Lists', 'sportspress' ), 'SP_Meta_Box_Team_Lists::output', 'sp_team', 'normal', 'high' );
|
||||||
endif;
|
endif;
|
||||||
add_meta_box( 'sp_editordiv', __( 'Profile', 'sportspress' ), 'SP_Meta_Box_Team_Editor::output', 'sp_team', 'normal', 'low' );
|
add_meta_box( 'sp_editordiv', __( 'Profile', 'sportspress' ), 'SP_Meta_Box_Team_Editor::output', 'sp_team', 'normal', 'low' );
|
||||||
@@ -155,7 +155,7 @@ class SP_Admin_Meta_Boxes {
|
|||||||
add_meta_box( 'sp_columnsdiv', __( 'Columns', 'sportspress' ), 'SP_Meta_Box_Player_Columns::output', 'sp_player', 'side', 'default' );
|
add_meta_box( 'sp_columnsdiv', __( 'Columns', 'sportspress' ), 'SP_Meta_Box_Player_Columns::output', 'sp_player', 'side', 'default' );
|
||||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Player_Details::output', 'sp_player', 'side', 'default' );
|
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Player_Details::output', 'sp_player', 'side', 'default' );
|
||||||
add_meta_box( 'sp_metricsdiv', __( 'Metrics', 'sportspress' ), 'SP_Meta_Box_Player_Metrics::output', 'sp_player', 'side', 'default' );
|
add_meta_box( 'sp_metricsdiv', __( 'Metrics', 'sportspress' ), 'SP_Meta_Box_Player_Metrics::output', 'sp_player', 'side', 'default' );
|
||||||
if ( isset( $post ) && isset( $post->ID ) && get_the_terms( $post->ID, 'sp_league' ) && get_the_terms( $post->ID, 'sp_season' ) ):
|
if ( isset( $post ) && isset( $post->ID ) ):
|
||||||
add_meta_box( 'sp_statisticsdiv', __( 'Statistics', 'sportspress' ), 'SP_Meta_Box_Player_Statistics::output', 'sp_player', 'normal', 'high' );
|
add_meta_box( 'sp_statisticsdiv', __( 'Statistics', 'sportspress' ), 'SP_Meta_Box_Player_Statistics::output', 'sp_player', 'normal', 'high' );
|
||||||
endif;
|
endif;
|
||||||
add_meta_box( 'sp_editordiv', __( 'Profile', 'sportspress' ), 'SP_Meta_Box_Player_Editor::output', 'sp_player', 'normal', 'low' );
|
add_meta_box( 'sp_editordiv', __( 'Profile', 'sportspress' ), 'SP_Meta_Box_Player_Editor::output', 'sp_player', 'normal', 'low' );
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ class SP_Meta_Box_Table_Data {
|
|||||||
else:
|
else:
|
||||||
?>
|
?>
|
||||||
<tr class="sp-row alternate">
|
<tr class="sp-row alternate">
|
||||||
<td colspan="<?php $colspan = sizeof( $columns ) + 1; echo $colspan; ?>">
|
<td colspan="<?php $colspan = sizeof( $columns ) + 2; echo $colspan; ?>">
|
||||||
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ); ?>
|
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ); ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class SP_Meta_Box_Team_Columns {
|
|||||||
* Output the metabox
|
* Output the metabox
|
||||||
*/
|
*/
|
||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
|
$team = new SP_Team( $post );
|
||||||
$leagues = get_the_terms( $post->ID, 'sp_league' );
|
$leagues = get_the_terms( $post->ID, 'sp_league' );
|
||||||
$league_num = sizeof( $leagues );
|
$league_num = sizeof( $leagues );
|
||||||
|
|
||||||
@@ -26,24 +27,18 @@ class SP_Meta_Box_Team_Columns {
|
|||||||
if ( $leagues ): foreach ( $leagues as $league ):
|
if ( $leagues ): foreach ( $leagues as $league ):
|
||||||
|
|
||||||
$league_id = $league->term_id;
|
$league_id = $league->term_id;
|
||||||
|
?>
|
||||||
if ( $league_num > 1 ):
|
<p><strong><?php echo $league->name; ?></strong></p>
|
||||||
?>
|
<?php
|
||||||
<p><strong><?php echo $league->name; ?></strong></p>
|
|
||||||
<?php
|
|
||||||
endif;
|
|
||||||
|
|
||||||
$team = new SP_Team( $post );
|
|
||||||
|
|
||||||
list( $columns, $data, $placeholders, $merged, $leagues_seasons ) = $team->columns( $league_id, true );
|
list( $columns, $data, $placeholders, $merged, $leagues_seasons ) = $team->columns( $league_id, true );
|
||||||
|
|
||||||
self::table( $league_id, $columns, $data, $placeholders, $merged, $leagues_seasons );
|
self::table( $league_id, $columns, $data, $placeholders, $merged, $leagues_seasons );
|
||||||
|
|
||||||
endforeach; else:
|
endforeach; endif;
|
||||||
|
?>
|
||||||
printf( __( 'Select %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) );
|
<p><strong><?php _e( 'Total', 'sportspress' ); ?></strong></p>
|
||||||
|
<?php
|
||||||
endif;
|
list( $columns, $data, $placeholders, $merged, $leagues_seasons ) = $team->columns( 0, true );
|
||||||
|
self::table( 0, $columns, $data, $placeholders, $merged, $leagues_seasons );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,7 +58,15 @@ class SP_Meta_Box_Team_Columns {
|
|||||||
<table class="widefat sp-data-table sp-team-column-table sp-select-all-range">
|
<table class="widefat sp-data-table sp-team-column-table sp-select-all-range">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="check-column"><input class="sp-select-all" type="checkbox"></th>
|
<?php if ( $league_id ): ?>
|
||||||
|
<th class="check-column">
|
||||||
|
<?php if ( sizeof( $data ) > 1 ): ?>
|
||||||
|
<input class="sp-select-all" type="checkbox">
|
||||||
|
<?php else: ?>
|
||||||
|
<input class="sp-select-all" type="checkbox" disabled>
|
||||||
|
<?php endif; ?>
|
||||||
|
</th>
|
||||||
|
<?php endif; ?>
|
||||||
<th><?php _e( 'Season', 'sportspress' ); ?></th>
|
<th><?php _e( 'Season', 'sportspress' ); ?></th>
|
||||||
<?php foreach ( $columns as $label ): ?>
|
<?php foreach ( $columns as $label ): ?>
|
||||||
<th><?php echo $label; ?></th>
|
<th><?php echo $label; ?></th>
|
||||||
@@ -74,15 +77,25 @@ class SP_Meta_Box_Team_Columns {
|
|||||||
<?php
|
<?php
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ( $data as $div_id => $div_stats ):
|
foreach ( $data as $div_id => $div_stats ):
|
||||||
if ( !$div_id ) continue;
|
|
||||||
$div = get_term( $div_id, 'sp_season' );
|
$div = get_term( $div_id, 'sp_season' );
|
||||||
?>
|
?>
|
||||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||||
|
<?php if ( $league_id ): ?>
|
||||||
|
<td>
|
||||||
|
<?php if ( $div_id ): ?>
|
||||||
|
<input type="checkbox" name="sp_leagues[<?php echo $league_id; ?>][<?php echo $div_id; ?>]" id="sp_leagues_<?php echo $league_id; ?>_<?php echo $div_id; ?>" value="1" <?php checked( sp_array_value( $seasons, $div_id, 0 ), 1 ); ?>>
|
||||||
|
<?php else: ?>
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
|
<?php endif; ?>
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" name="sp_leagues[<?php echo $league_id; ?>][<?php echo $div_id; ?>]" id="sp_leagues_<?php echo $league_id; ?>_<?php echo $div_id; ?>" value="1" <?php checked( sp_array_value( $seasons, $div_id, 0 ), 1 ); ?>>
|
<label for="sp_leagues_<?php echo $league_id; ?>_<?php echo $div_id; ?>">
|
||||||
</td>
|
<?php
|
||||||
<td>
|
if ( 'WP_Error' == get_class( $div ) ) _e( 'Total', 'sportspress' );
|
||||||
<label for="sp_leagues_<?php echo $league_id; ?>_<?php echo $div_id; ?>"><?php echo $div->name; ?></label>
|
else echo $div->name;
|
||||||
|
?>
|
||||||
|
</label>
|
||||||
</td>
|
</td>
|
||||||
<?php foreach( $columns as $column => $label ):
|
<?php foreach( $columns as $column => $label ):
|
||||||
$value = sp_array_value( sp_array_value( $data, $div_id, array() ), $column, 0 );
|
$value = sp_array_value( sp_array_value( $data, $div_id, array() ), $column, 0 );
|
||||||
|
|||||||
@@ -95,18 +95,25 @@ class SP_League_Table extends SP_Custom_Post{
|
|||||||
'order' => 'DESC',
|
'order' => 'DESC',
|
||||||
'tax_query' => array(
|
'tax_query' => array(
|
||||||
'relation' => 'AND',
|
'relation' => 'AND',
|
||||||
array(
|
),
|
||||||
'taxonomy' => 'sp_league',
|
|
||||||
'field' => 'id',
|
|
||||||
'terms' => $league_id
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'taxonomy' => 'sp_season',
|
|
||||||
'field' => 'id',
|
|
||||||
'terms' => $div_id
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( $league_id ):
|
||||||
|
$args['tax_query'][] = array(
|
||||||
|
'taxonomy' => 'sp_league',
|
||||||
|
'field' => 'id',
|
||||||
|
'terms' => $league_id
|
||||||
|
);
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if ( $league_id ):
|
||||||
|
$args['tax_query'][] = array(
|
||||||
|
'taxonomy' => 'sp_season',
|
||||||
|
'field' => 'id',
|
||||||
|
'terms' => $div_id
|
||||||
|
);
|
||||||
|
endif;
|
||||||
|
|
||||||
$events = get_posts( $args );
|
$events = get_posts( $args );
|
||||||
|
|
||||||
// Event loop
|
// Event loop
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ class SP_Team extends SP_Custom_Post {
|
|||||||
endif;
|
endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
|
$div_ids[] = 0;
|
||||||
|
$season_names[ 0 ] = __( 'Total', 'sportspress' );
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
// Get all seasons populated with data where available
|
// Get all seasons populated with data where available
|
||||||
@@ -119,18 +122,25 @@ class SP_Team extends SP_Custom_Post {
|
|||||||
),
|
),
|
||||||
'tax_query' => array(
|
'tax_query' => array(
|
||||||
'relation' => 'AND',
|
'relation' => 'AND',
|
||||||
array(
|
),
|
||||||
'taxonomy' => 'sp_league',
|
|
||||||
'field' => 'id',
|
|
||||||
'terms' => $league_id
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'taxonomy' => 'sp_season',
|
|
||||||
'field' => 'id',
|
|
||||||
'terms' => $div_id
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( $league_id ):
|
||||||
|
$args['tax_query'][] = array(
|
||||||
|
'taxonomy' => 'sp_league',
|
||||||
|
'field' => 'id',
|
||||||
|
'terms' => $league_id
|
||||||
|
);
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if ( $div_id ):
|
||||||
|
$args['tax_query'][] = array(
|
||||||
|
'taxonomy' => 'sp_season',
|
||||||
|
'field' => 'id',
|
||||||
|
'terms' => $div_id
|
||||||
|
);
|
||||||
|
endif;
|
||||||
|
|
||||||
$events = get_posts( $args );
|
$events = get_posts( $args );
|
||||||
|
|
||||||
foreach( $events as $event ):
|
foreach( $events as $event ):
|
||||||
|
|||||||
Reference in New Issue
Block a user