Change league to division and remove sponsors

This commit is contained in:
Takumi
2013-10-24 11:56:53 +11:00
parent b6121a0487
commit 102d6d20e1
15 changed files with 121 additions and 146 deletions

View File

@@ -29,8 +29,8 @@ function sp_manage_posts_custom_column( $column, $post_id ) {
case 'sp_event': case 'sp_event':
echo get_post_meta ( $post_id, 'sp_event' ) ? sizeof( get_post_meta ( $post_id, 'sp_event' ) ) : '—'; echo get_post_meta ( $post_id, 'sp_event' ) ? sizeof( get_post_meta ( $post_id, 'sp_event' ) ) : '—';
break; break;
case 'sp_league': case 'sp_division':
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—'; echo get_the_terms ( $post_id, 'sp_division' ) ? the_terms( $post_id, 'sp_division' ) : '—';
break; break;
case 'sp_sponsor': case 'sp_sponsor':
echo get_the_terms ( $post_id, 'sp_sponsor' ) ? the_terms( $post_id, 'sp_sponsor' ) : '—'; echo get_the_terms ( $post_id, 'sp_sponsor' ) ? the_terms( $post_id, 'sp_sponsor' ) : '—';
@@ -69,21 +69,11 @@ function sp_restrict_manage_posts() {
sp_dropdown_taxonomies( $args ); sp_dropdown_taxonomies( $args );
endif; endif;
if ( in_array( $typenow, array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_list' ) ) ): if ( in_array( $typenow, array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_list' ) ) ):
$selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; $selected = isset( $_REQUEST['sp_division'] ) ? $_REQUEST['sp_division'] : null;
$args = array( $args = array(
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ), 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Divisions', 'sportspress' ) ),
'taxonomy' => 'sp_league', 'taxonomy' => 'sp_division',
'name' => 'sp_league', 'name' => 'sp_division',
'selected' => $selected
);
sp_dropdown_taxonomies( $args );
endif;
if ( in_array( $typenow, array( 'sp_team', 'sp_event', 'sp_player' ) ) ):
$selected = isset( $_REQUEST['sp_sponsor'] ) ? $_REQUEST['sp_sponsor'] : null;
$args = array(
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Sponsors', 'sportspress' ) ),
'taxonomy' => 'sp_sponsor',
'name' => 'sp_sponsor',
'selected' => $selected 'selected' => $selected
); );
sp_dropdown_taxonomies( $args ); sp_dropdown_taxonomies( $args );
@@ -141,13 +131,13 @@ function sp_save_post( $post_id ) {
break; break;
case ( 'sp_table' ): case ( 'sp_table' ):
update_post_meta( $post_id, 'sp_stats', sp_array_value( $_POST, 'sp_stats', array() ) ); update_post_meta( $post_id, 'sp_stats', sp_array_value( $_POST, 'sp_stats', 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_division', 0 ), 'sp_division' );
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
break; break;
case ( 'sp_list' ): case ( 'sp_list' ):
update_post_meta( $post_id, 'sp_stats', sp_array_value( $_POST, 'sp_stats', array() ) ); update_post_meta( $post_id, 'sp_stats', sp_array_value( $_POST, 'sp_stats', array() ) );
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); 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_division', 0 ), 'sp_division' );
sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) ); sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) );
break; break;
endswitch; endswitch;

18
division.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
function sp_division_tax_init() {
$name = __( 'Divisions', 'sportspress' );
$singular_name = __( 'Division', 'sportspress' );
$lowercase_name = __( 'divisions', 'sportspress' );
$object_type = array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff' );
$labels = sp_tax_labels( $name, $singular_name, $lowercase_name );
$args = array(
'label' => $name,
'labels' => $labels,
'public' => true,
'hierarchical' => true,
'rewrite' => array( 'slug' => 'division' ),
);
register_taxonomy( 'sp_division', $object_type, $args );
}
add_action( 'init', 'sp_division_tax_init' );
?>

View File

@@ -131,8 +131,7 @@ function sp_event_edit_columns() {
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'title' => __( 'Event', 'sportspress' ), 'title' => __( 'Event', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' ), 'sp_division' => __( 'Divisions', 'sportspress' ),
'sp_sponsor' => __( 'Sponsors', 'sportspress' ),
'sp_kickoff' => __( 'Kick-off', 'sportspress' ) 'sp_kickoff' => __( 'Kick-off', 'sportspress' )
); );
return $columns; return $columns;

View File

@@ -210,7 +210,7 @@ if ( !function_exists( 'sp_post_checklist' ) ) {
$parents = get_post_ancestors( $post ); $parents = get_post_ancestors( $post );
if ( $filter ): if ( $filter ):
$filter_values = (array)get_post_meta( $post->ID, $filter, false ); $filter_values = (array)get_post_meta( $post->ID, $filter, false );
$terms = (array)get_the_terms( $post->ID, 'sp_league' ); $terms = (array)get_the_terms( $post->ID, 'sp_division' );
foreach ( $terms as $term ): foreach ( $terms as $term ):
if ( is_object( $term ) && property_exists( $term, 'term_id' ) ) if ( is_object( $term ) && property_exists( $term, 'term_id' ) )
$filter_values[] = $term->term_id; $filter_values[] = $term->term_id;

Binary file not shown.

View File

@@ -2,8 +2,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: SportsPress 0.1\n" "Project-Id-Version: SportsPress 0.1\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-08-23 19:38+1000\n" "POT-Creation-Date: 2013-08-25 13:40+1000\n"
"PO-Revision-Date: 2013-08-23 19:38+1000\n" "PO-Revision-Date: 2013-08-25 13:41+1000\n"
"Last-Translator: ThemeBoy <translate@themeboy.com>\n" "Last-Translator: ThemeBoy <translate@themeboy.com>\n"
"Language-Team: ThemeBoy <translate@themeboy.com>\n" "Language-Team: ThemeBoy <translate@themeboy.com>\n"
"Language: ja\n" "Language: ja\n"
@@ -28,9 +28,8 @@ msgstr "試合終了"
msgid "M j, Y @ G:i" msgid "M j, Y @ G:i"
msgstr "Y年n月j日 @ G:i" msgstr "Y年n月j日 @ G:i"
#: ../actions.php:54 ../actions.php:64 ../actions.php:74 ../actions.php:84 #: ../actions.php:54 ../actions.php:64 ../actions.php:74 ../helpers.php:73
#: ../helpers.php:73 ../helpers.php:93 ../list.php:46 ../list.php:57 #: ../helpers.php:93 ../list.php:46 ../list.php:57 ../table.php:44
#: ../table.php:44
#, php-format #, php-format
msgid "All %s" msgid "All %s"
msgstr "すべての%s" msgstr "すべての%s"
@@ -46,16 +45,19 @@ msgstr "チーム"
msgid "Positions" msgid "Positions"
msgstr "ポジション" msgstr "ポジション"
#: ../actions.php:74 ../event.php:134 ../league.php:3 ../list.php:27 #: ../actions.php:74 ../division.php:3 ../event.php:134 ../list.php:27
#: ../list.php:46 ../player.php:141 ../staff.php:44 ../table.php:26 #: ../list.php:46 ../player.php:141 ../staff.php:44 ../table.php:26
#: ../table.php:44 ../team.php:33 #: ../table.php:44 ../team.php:33
msgid "Leagues" msgid "Divisions"
msgstr "リーグ" msgstr "リーグレベル"
#: ../actions.php:84 ../event.php:135 ../player.php:142 ../sponsor.php:3 #: ../division.php:4 ../player.php:46 ../team.php:80
#: ../team.php:34 msgid "Division"
msgid "Sponsors" msgstr "リーグレベル"
msgstr "スポンサー"
#: ../division.php:5
msgid "divisions"
msgstr "リーグレベル"
#: ../event.php:3 ../settings.php:86 #: ../event.php:3 ../settings.php:86
msgid "Events" msgid "Events"
@@ -104,7 +106,7 @@ msgstr "チーム"
msgid "Player" msgid "Player"
msgstr "選手" msgstr "選手"
#: ../event.php:136 ../globals.php:12 ../globals.php:13 ../globals.php:14 #: ../event.php:135 ../globals.php:12 ../globals.php:13 ../globals.php:14
msgid "Kick-off" msgid "Kick-off"
msgstr "キックオフ" msgstr "キックオフ"
@@ -200,14 +202,6 @@ msgstr "(タイトルなし)"
msgid "Total" msgid "Total"
msgstr "合計" msgstr "合計"
#: ../league.php:4 ../player.php:46 ../team.php:81
msgid "League"
msgstr "リーグ"
#: ../league.php:5
msgid "leagues"
msgstr "リーグ"
#: ../list.php:3 #: ../list.php:3
msgid "Player Lists" msgid "Player Lists"
msgstr "選手名鑑" msgstr "選手名鑑"
@@ -312,6 +306,10 @@ msgstr "警告"
msgid "Red Cards" msgid "Red Cards"
msgstr "退場" msgstr "退場"
#: ../sponsor.php:3
msgid "Sponsors"
msgstr "スポンサー"
#: ../sponsor.php:4 #: ../sponsor.php:4
msgid "Sponsor" msgid "Sponsor"
msgstr "スポンサー" msgstr "スポンサー"
@@ -339,3 +337,12 @@ msgstr "順位表"
#: ../team.php:5 #: ../team.php:5
msgid "teams" msgid "teams"
msgstr "チーム" msgstr "チーム"
#~ msgid "Leagues"
#~ msgstr "リーグ"
#~ msgid "League"
#~ msgstr "リーグ"
#~ msgid "leagues"
#~ msgstr "リーグ"

View File

@@ -1,18 +0,0 @@
<?php
function sp_league_tax_init() {
$name = __( 'Leagues', 'sportspress' );
$singular_name = __( 'League', 'sportspress' );
$lowercase_name = __( 'leagues', 'sportspress' );
$object_type = array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff' );
$labels = sp_tax_labels( $name, $singular_name, $lowercase_name );
$args = array(
'label' => $name,
'labels' => $labels,
'public' => true,
'hierarchical' => true,
'rewrite' => array( 'slug' => 'league' ),
);
register_taxonomy( 'sp_league', $object_type, $args );
}
add_action( 'init', 'sp_league_tax_init' );
?>

View File

@@ -24,7 +24,7 @@ function sp_list_edit_columns() {
'title' => __( 'Title' ), 'title' => __( 'Title' ),
'sp_player' => __( 'Players', 'sportspress' ), 'sp_player' => __( 'Players', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' ) 'sp_division' => __( 'Divisions', 'sportspress' )
); );
return $columns; return $columns;
} }
@@ -36,17 +36,17 @@ function sp_list_meta_init() {
} }
function sp_list_player_meta( $post ) { function sp_list_player_meta( $post ) {
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 ); $division_id = sp_get_the_term_id( $post->ID, 'sp_division', 0 );
$team_id = get_post_meta( $post->ID, 'sp_team', true ); $team_id = get_post_meta( $post->ID, 'sp_team', true );
?> ?>
<div> <div>
<p class="sp-tab-select"> <p class="sp-tab-select">
<?php <?php
$args = array( $args = array(
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ), 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Divisions', 'sportspress' ) ),
'taxonomy' => 'sp_league', 'taxonomy' => 'sp_division',
'name' => 'sp_league', 'name' => 'sp_division',
'selected' => $league_id 'selected' => $division_id
); );
sp_dropdown_taxonomies( $args ); sp_dropdown_taxonomies( $args );
?> ?>
@@ -75,9 +75,9 @@ function sp_list_player_meta( $post ) {
function sp_list_stats_meta( $post ) { function sp_list_stats_meta( $post ) {
$players = (array)get_post_meta( $post->ID, 'sp_player', false ); $players = (array)get_post_meta( $post->ID, 'sp_player', false );
$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 ); $division_id = sp_get_the_term_id( $post->ID, 'sp_division', 0 );
$team_id = get_post_meta( $post->ID, 'sp_team', true ); $team_id = get_post_meta( $post->ID, 'sp_team', true );
$data = sp_array_combine( $players, sp_array_value( $stats, $league_id, array() ) ); $data = sp_array_combine( $players, sp_array_value( $stats, $division_id, array() ) );
// Generate array of placeholder values for each player // Generate array of placeholder values for each player
$placeholders = array(); $placeholders = array();
@@ -92,9 +92,9 @@ function sp_list_stats_meta( $post ) {
), ),
'tax_query' => array( 'tax_query' => array(
array( array(
'taxonomy' => 'sp_league', 'taxonomy' => 'sp_division',
'field' => 'id', 'field' => 'id',
'terms' => $league_id 'terms' => $division_id
) )
) )
); );
@@ -108,6 +108,6 @@ function sp_list_stats_meta( $post ) {
// Add first column label // Add first column label
array_unshift( $columns, __( 'Player', 'sportspress' ) ); array_unshift( $columns, __( 'Player', 'sportspress' ) );
sp_stats_table( $data, $placeholders, $league_id, $columns, false ); sp_stats_table( $data, $placeholders, $division_id, $columns, false );
} }
?> ?>

View File

@@ -35,7 +35,7 @@ function sp_player_team_meta( $post ) {
function sp_player_stats_meta( $post ) { function sp_player_stats_meta( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false ); $teams = (array)get_post_meta( $post->ID, 'sp_team', false );
$leagues = (array)get_the_terms( $post->ID, 'sp_league' ); $divisions = (array)get_the_terms( $post->ID, 'sp_division' );
$stats = (array)get_post_meta( $post->ID, 'sp_stats', true ); $stats = (array)get_post_meta( $post->ID, 'sp_stats', true );
// Get column names from settings // Get column names from settings
@@ -43,21 +43,21 @@ function sp_player_stats_meta( $post ) {
$columns = sp_get_eos_keys( $stats_settings['player'] ); $columns = sp_get_eos_keys( $stats_settings['player'] );
// Add first column label // Add first column label
array_unshift( $columns, __( 'League', 'sportspress' ) ); array_unshift( $columns, __( 'Division', 'sportspress' ) );
// Generate array of all league ids // Generate array of all division ids
$league_ids = array( 0 ); $division_ids = array( 0 );
foreach ( $leagues as $key => $value ): foreach ( $divisions as $key => $value ):
if ( is_object( $value ) && property_exists( $value, 'term_id' ) ) if ( is_object( $value ) && property_exists( $value, 'term_id' ) )
$league_ids[] = $value->term_id; $division_ids[] = $value->term_id;
endforeach; endforeach;
// Get all teams populated with overall stats where availabled // Get all teams populated with overall stats where availabled
$data = sp_array_combine( $league_ids, sp_array_value( $stats, 0, array() ) ); $data = sp_array_combine( $division_ids, sp_array_value( $stats, 0, array() ) );
// Generate array of placeholder values for each league // Generate array of placeholder values for each division
$placeholders = array(); $placeholders = array();
foreach ( $league_ids as $league_id ): foreach ( $division_ids as $division_id ):
$args = array( $args = array(
'post_type' => 'sp_event', 'post_type' => 'sp_event',
'meta_query' => array( 'meta_query' => array(
@@ -67,33 +67,33 @@ function sp_player_stats_meta( $post ) {
) )
) )
); );
if ( $league_id ): if ( $division_id ):
$args['tax_query'] = array( $args['tax_query'] = array(
array( array(
'taxonomy' => 'sp_league', 'taxonomy' => 'sp_division',
'field' => 'id', 'field' => 'id',
'terms' => $league_id 'terms' => $division_id
) )
); );
endif; endif;
$placeholders[ $league_id ] = sp_get_stats_row( 'sp_player', $args ); $placeholders[ $division_id ] = sp_get_stats_row( 'sp_player', $args );
endforeach; endforeach;
?> ?>
<p><strong><?php _e( 'Overall', 'sportspress' ); ?></strong></p> <p><strong><?php _e( 'Overall', 'sportspress' ); ?></strong></p>
<?php <?php
sp_stats_table( $data, $placeholders, 0, $columns, true, 'sp_league' ); sp_stats_table( $data, $placeholders, 0, $columns, true, 'sp_division' );
// Leagues // Divisions
foreach ( $teams as $team ): foreach ( $teams as $team ):
if ( !$team ) continue; if ( !$team ) continue;
// Get all leagues populated with stats where availabled // Get all divisions populated with stats where availabled
$data = sp_array_combine( $league_ids, sp_array_value( $stats, $team, array() ) ); $data = sp_array_combine( $division_ids, sp_array_value( $stats, $team, array() ) );
// Generate array of placeholder values for each league // Generate array of placeholder values for each division
$placeholders = array(); $placeholders = array();
foreach ( $league_ids as $league_id ): foreach ( $division_ids as $division_id ):
$args = array( $args = array(
'post_type' => 'sp_event', 'post_type' => 'sp_event',
'meta_query' => array( 'meta_query' => array(
@@ -108,19 +108,19 @@ function sp_player_stats_meta( $post ) {
), ),
'tax_query' => array( 'tax_query' => array(
array( array(
'taxonomy' => 'sp_league', 'taxonomy' => 'sp_division',
'field' => 'id', 'field' => 'id',
'terms' => $league_id 'terms' => $division_id
) )
) )
); );
$placeholders[ $league_id ] = sp_get_stats_row( 'sp_player', $args ); $placeholders[ $division_id ] = sp_get_stats_row( 'sp_player', $args );
endforeach; endforeach;
?> ?>
<p><strong><?php echo get_the_title( $team ); ?></strong></p> <p><strong><?php echo get_the_title( $team ); ?></strong></p>
<?php <?php
sp_stats_table( $data, $placeholders, $team, $columns, true, 'sp_league' ); sp_stats_table( $data, $placeholders, $team, $columns, true, 'sp_division' );
?> ?>
<?php <?php
@@ -138,8 +138,7 @@ function sp_player_edit_columns() {
'title' => __( 'Name', 'sportspress' ), 'title' => __( 'Name', 'sportspress' ),
'sp_position' => __( 'Positions', 'sportspress' ), 'sp_position' => __( 'Positions', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' ), 'sp_division' => __( 'Divisions', 'sportspress' )
'sp_sponsor' => __( 'Sponsors', 'sportspress' )
); );
return $columns; return $columns;
} }

View File

@@ -1,6 +1,6 @@
=== SportsPress - flexible sports management === === SportsPress - flexible sports management ===
Contributors: themeboy Contributors: themeboy
Tags: sports, sports journalism, teams, team management, fixtures, results, standings, league table, leagues, reporting, themeboy, wordpress sports, configurable, variable, widgets Tags: sports, sports journalism, teams, team management, fixtures, results, standings, league tables, divisions, reporting, themeboy, wordpress sports, configurable, variable, widgets
Requires at least: 3.5 Requires at least: 3.5
Tested up to: 3.6 Tested up to: 3.6
Stable tag: 1.0 Stable tag: 1.0

View File

@@ -1,18 +0,0 @@
<?php
function sp_sponsor_tax_init() {
$name = __( 'Sponsors', 'sportspress' );
$singular_name = __( 'Sponsor', 'sportspress' );
$lowercase_name = __( 'sponsors', 'sportspress' );
$object_type = array( 'sp_team', 'sp_event', 'sp_player', 'sp_tournament' );
$labels = sp_tax_labels( $name, $singular_name, $lowercase_name );
$args = array(
'label' => $name,
'labels' => $labels,
'public' => true,
'hierarchical' => true,
'rewrite' => array( 'slug' => 'sponsor' ),
);
register_taxonomy( 'sp_sponsor', $object_type, $args );
}
add_action( 'init', 'sp_sponsor_tax_init' );
?>

View File

@@ -42,9 +42,8 @@ require_once dirname( __FILE__ ) . '/table.php';
require_once dirname( __FILE__ ) . '/list.php'; require_once dirname( __FILE__ ) . '/list.php';
// Taxonomies // Taxonomies
require_once dirname( __FILE__ ) . '/league.php'; require_once dirname( __FILE__ ) . '/division.php';
require_once dirname( __FILE__ ) . '/position.php'; require_once dirname( __FILE__ ) . '/position.php';
require_once dirname( __FILE__ ) . '/sponsor.php';
// Styles // Styles
include_once dirname( __FILE__ ) . '/styles.php' ; include_once dirname( __FILE__ ) . '/styles.php' ;

View File

@@ -41,7 +41,7 @@ function sp_staff_edit_columns() {
'title' => __( 'Name', 'sportspress' ), 'title' => __( 'Name', 'sportspress' ),
'sp_position' => __( 'Positions', 'sportspress' ), 'sp_position' => __( 'Positions', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' ), 'sp_division' => __( 'Divisions', 'sportspress' ),
); );
return $columns; return $columns;
} }

View File

@@ -23,7 +23,7 @@ function sp_table_edit_columns() {
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'title' => __( 'Title' ), 'title' => __( 'Title' ),
'sp_team' => __( 'Teams', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' ), 'sp_division' => __( 'Divisions', 'sportspress' ),
); );
return $columns; return $columns;
} }
@@ -35,22 +35,22 @@ function sp_table_meta_init() {
} }
function sp_table_team_meta( $post ) { function sp_table_team_meta( $post ) {
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 ); $division_id = sp_get_the_term_id( $post->ID, 'sp_division', 0 );
?> ?>
<div> <div>
<p class="sp-tab-select"> <p class="sp-tab-select">
<?php <?php
$args = array( $args = array(
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ), 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Divisions', 'sportspress' ) ),
'taxonomy' => 'sp_league', 'taxonomy' => 'sp_division',
'name' => 'sp_league', 'name' => 'sp_division',
'selected' => $league_id 'selected' => $division_id
); );
sp_dropdown_taxonomies( $args ); sp_dropdown_taxonomies( $args );
?> ?>
</p> </p>
<?php <?php
sp_post_checklist( $post->ID, 'sp_team', 'block', 'sp_league' ); sp_post_checklist( $post->ID, 'sp_team', 'block', 'sp_division' );
sp_post_adder( 'sp_team' ); sp_post_adder( 'sp_team' );
?> ?>
</div> </div>
@@ -61,8 +61,8 @@ function sp_table_team_meta( $post ) {
function sp_table_stats_meta( $post ) { function sp_table_stats_meta( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false ); $teams = (array)get_post_meta( $post->ID, 'sp_team', false );
$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 ); $division_id = sp_get_the_term_id( $post->ID, 'sp_division', 0 );
$data = sp_array_combine( $teams, sp_array_value( $stats, $league_id, array() ) ); $data = sp_array_combine( $teams, sp_array_value( $stats, $division_id, array() ) );
// Generate array of placeholder values for each team // Generate array of placeholder values for each team
$placeholders = array(); $placeholders = array();
@@ -77,9 +77,9 @@ function sp_table_stats_meta( $post ) {
), ),
'tax_query' => array( 'tax_query' => array(
array( array(
'taxonomy' => 'sp_league', 'taxonomy' => 'sp_division',
'field' => 'id', 'field' => 'id',
'terms' => $league_id 'terms' => $division_id
) )
) )
); );
@@ -93,6 +93,6 @@ function sp_table_stats_meta( $post ) {
// Add first column label // Add first column label
array_unshift( $columns, __( 'Team', 'sportspress' ) ); array_unshift( $columns, __( 'Team', 'sportspress' ) );
sp_stats_table( $data, $placeholders, $league_id, $columns, false ); sp_stats_table( $data, $placeholders, $division_id, $columns, false );
} }
?> ?>

View File

@@ -30,30 +30,29 @@ function sp_team_edit_columns() {
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'sp_icon' => '&nbsp;', 'sp_icon' => '&nbsp;',
'title' => __( 'Team', 'sportspress' ), 'title' => __( 'Team', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' ), 'sp_division' => __( 'Divisions', 'sportspress' )
'sp_sponsor' => __( 'Sponsors', 'sportspress' )
); );
return $columns; return $columns;
} }
add_filter( 'manage_edit-sp_team_columns', 'sp_team_edit_columns' ); add_filter( 'manage_edit-sp_team_columns', 'sp_team_edit_columns' );
function sp_team_stats_meta( $post ) { function sp_team_stats_meta( $post ) {
$leagues = (array)get_the_terms( $post->ID, 'sp_league' ); $divisions = (array)get_the_terms( $post->ID, 'sp_division' );
$stats = (array)get_post_meta( $post->ID, 'sp_stats', true ); $stats = (array)get_post_meta( $post->ID, 'sp_stats', true );
// Generate array of all league ids // Generate array of all division ids
$league_ids = array( 0 ); $division_ids = array( 0 );
foreach ( $leagues as $key => $value ): foreach ( $divisions as $key => $value ):
if ( is_object( $value ) && property_exists( $value, 'term_id' ) ) if ( is_object( $value ) && property_exists( $value, 'term_id' ) )
$league_ids[] = $value->term_id; $division_ids[] = $value->term_id;
endforeach; endforeach;
// Get all leagues populated with stats where available // Get all divisions populated with stats where available
$data = sp_array_combine( $league_ids, sp_array_value( $stats, 0, array() ) ); $data = sp_array_combine( $division_ids, sp_array_value( $stats, 0, array() ) );
// Generate array of placeholder values for each league // Generate array of placeholder values for each division
$placeholders = array(); $placeholders = array();
foreach ( $league_ids as $league_id ): foreach ( $division_ids as $division_id ):
$args = array( $args = array(
'post_type' => 'sp_event', 'post_type' => 'sp_event',
'meta_query' => array( 'meta_query' => array(
@@ -64,13 +63,13 @@ function sp_team_stats_meta( $post ) {
), ),
'tax_query' => array( 'tax_query' => array(
array( array(
'taxonomy' => 'sp_league', 'taxonomy' => 'sp_division',
'field' => 'id', 'field' => 'id',
'terms' => $league_id 'terms' => $division_id
) )
) )
); );
$placeholders[ $league_id ] = sp_get_stats_row( 'sp_team', $args ); $placeholders[ $division_id ] = sp_get_stats_row( 'sp_team', $args );
endforeach; endforeach;
// Get column names from settings // Get column names from settings
@@ -78,9 +77,9 @@ function sp_team_stats_meta( $post ) {
$columns = sp_get_eos_keys( $stats_settings['team'] ); $columns = sp_get_eos_keys( $stats_settings['team'] );
// Add first column label // Add first column label
array_unshift( $columns, __( 'League', 'sportspress' ) ); array_unshift( $columns, __( 'Division', 'sportspress' ) );
sp_stats_table( $data, $placeholders, 0, $columns, false, 'sp_league' ); sp_stats_table( $data, $placeholders, 0, $columns, false, 'sp_division' );
sp_nonce(); sp_nonce();
} }
?> ?>