Add post type argument to sp_get_stats_row
This commit is contained in:
44
helpers.php
44
helpers.php
@@ -236,7 +236,7 @@ if ( !function_exists( 'sp_post_checklist' ) ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( !function_exists( 'sp_get_stats_row' ) ) {
|
if ( !function_exists( 'sp_get_stats_row' ) ) {
|
||||||
function sp_get_stats_row( $args = array() ) {
|
function sp_get_stats_row( $post_type = 'post', $args = array() ) {
|
||||||
$args = array_merge(
|
$args = array_merge(
|
||||||
array(
|
array(
|
||||||
'meta_value' => 0,
|
'meta_value' => 0,
|
||||||
@@ -250,23 +250,31 @@ if ( !function_exists( 'sp_get_stats_row' ) ) {
|
|||||||
$post->sp_team_index = array_search( $args['meta_value'], $post->sp_team );
|
$post->sp_team_index = array_search( $args['meta_value'], $post->sp_team );
|
||||||
$post->sp_result = get_post_meta( $post->ID, 'sp_result', false );
|
$post->sp_result = get_post_meta( $post->ID, 'sp_result', false );
|
||||||
endforeach;
|
endforeach;
|
||||||
$row = array(
|
|
||||||
sizeof( $posts ),
|
switch ($post_type):
|
||||||
sizeof(
|
case 'sp_team':
|
||||||
array_filter(
|
$row = array(
|
||||||
$posts,
|
sizeof( $posts ),
|
||||||
function( $var ) {
|
sizeof(
|
||||||
return max( $var->sp_result ) == $var->sp_result[ $var->sp_team_index ];
|
array_filter(
|
||||||
}
|
$posts,
|
||||||
)
|
function( $var ) {
|
||||||
),
|
return max( $var->sp_result ) == $var->sp_result[ $var->sp_team_index ];
|
||||||
99,
|
}
|
||||||
99,
|
)
|
||||||
93,
|
),
|
||||||
99,
|
99,
|
||||||
99,
|
99,
|
||||||
99
|
93,
|
||||||
);
|
99,
|
||||||
|
99,
|
||||||
|
99
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$row = array();
|
||||||
|
break;
|
||||||
|
endswitch;
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,13 +85,6 @@
|
|||||||
background-position: -209px -1px;
|
background-position: -209px -1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#poststuff #sp_kickoffdiv .inside {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
#sp_kickoffdiv #timestampdiv p {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
#sp_articlediv .wp-editor-container,
|
#sp_articlediv .wp-editor-container,
|
||||||
#sp_profilediv .wp-editor-container {
|
#sp_profilediv .wp-editor-container {
|
||||||
background-color:#fff;
|
background-color:#fff;
|
||||||
|
|||||||
17
table.php
17
table.php
@@ -63,10 +63,25 @@ function sp_table_stats_meta( $post ) {
|
|||||||
$stats = (array)get_post_meta( $post->ID, 'sp_stats', true );
|
$stats = (array)get_post_meta( $post->ID, 'sp_stats', true );
|
||||||
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
|
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
|
||||||
$data = sp_array_combine( $teams, sp_array_value( $stats, $league_id, array() ) );
|
$data = sp_array_combine( $teams, sp_array_value( $stats, $league_id, array() ) );
|
||||||
|
|
||||||
|
// Generate array of placeholder values for each team
|
||||||
$placeholders = array();
|
$placeholders = array();
|
||||||
foreach ( $teams as $team ):
|
foreach ( $teams as $team ):
|
||||||
$placeholders[ $team ] = sp_get_stats( $team, 0, $league_id );
|
$args = array(
|
||||||
|
'post_type' => 'sp_event',
|
||||||
|
'meta_key' => 'sp_team',
|
||||||
|
'meta_value' => $team,
|
||||||
|
'tax_query' => array(
|
||||||
|
array(
|
||||||
|
'taxonomy' => 'sp_league',
|
||||||
|
'field' => 'id',
|
||||||
|
'terms' => $league_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$placeholders[ $team ] = sp_get_stats_row( 'sp_team', $args );
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
sp_stats_table( $data, $placeholders, $league_id, array( 'Team', 'P', 'W', 'D', 'L', 'F', 'A', 'GD', 'Pts' ), false );
|
sp_stats_table( $data, $placeholders, $league_id, array( 'Team', 'P', 'W', 'D', 'L', 'F', 'A', 'GD', 'Pts' ), false );
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
2
team.php
2
team.php
@@ -65,7 +65,7 @@ function sp_team_stats_meta( $post ) {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$placeholders[ $league_id ] = sp_get_stats_row( $args );
|
$placeholders[ $league_id ] = sp_get_stats_row( 'sp_team', $args );
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
sp_stats_table( $data, $placeholders, 0, array( 'League', 'P', 'W', 'D', 'L', 'F', 'A', 'GD', 'Pts' ), false, 'sp_league' );
|
sp_stats_table( $data, $placeholders, 0, array( 'League', 'P', 'W', 'D', 'L', 'F', 'A', 'GD', 'Pts' ), false, 'sp_league' );
|
||||||
|
|||||||
Reference in New Issue
Block a user