Change div to league and pos to position

This commit is contained in:
ThemeBoy
2013-12-26 06:26:55 +11:00
parent 05a80bb727
commit 3e99dc70a2
14 changed files with 93 additions and 93 deletions

View File

@@ -142,7 +142,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_div' => __( 'Divisions', 'sportspress' ), 'sp_league' => __( 'Leagues', 'sportspress' ),
'sp_kickoff' => __( 'Kick-off', 'sportspress' ) 'sp_kickoff' => __( 'Kick-off', 'sportspress' )
); );
return $columns; return $columns;

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_div' => __( 'Divisions', 'sportspress' ) 'sp_league' => __( 'Leagues', 'sportspress' )
); );
return $columns; return $columns;
} }
@@ -41,17 +41,17 @@ function sp_list_meta_init( $post ) {
} }
function sp_list_player_meta( $post ) { function sp_list_player_meta( $post ) {
$division_id = sp_get_the_term_id( $post->ID, 'sp_div', 0 ); $league_id = sp_get_the_term_id( $post->ID, 'sp_league', 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_none' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Division', 'sportspress' ) ), 'show_option_none' => sprintf( __( 'Select %s', 'sportspress' ), __( 'League', 'sportspress' ) ),
'taxonomy' => 'sp_div', 'taxonomy' => 'sp_league',
'name' => 'sp_div', 'name' => 'sp_league',
'selected' => $division_id 'selected' => $league_id
); );
sp_dropdown_taxonomies( $args ); sp_dropdown_taxonomies( $args );
?> ?>

View File

@@ -20,7 +20,7 @@ add_action( 'init', 'sp_player_cpt_init' );
function sp_player_meta_init( $post ) { function sp_player_meta_init( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false ); $teams = (array)get_post_meta( $post->ID, 'sp_team', false );
$divisions = (array)get_the_terms( $post->ID, 'sp_div' ); $leagues = (array)get_the_terms( $post->ID, 'sp_league' );
remove_meta_box( 'submitdiv', 'sp_player', 'side' ); remove_meta_box( 'submitdiv', 'sp_player', 'side' );
add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'sp_player', 'side', 'high' ); add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'sp_player', 'side', 'high' );
@@ -28,7 +28,7 @@ function sp_player_meta_init( $post ) {
add_meta_box( 'postimagediv', __( 'Photo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_player', 'side', 'high' ); add_meta_box( 'postimagediv', __( 'Photo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_player', 'side', 'high' );
add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sp_player_team_meta', 'sp_player', 'side', 'high' ); add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sp_player_team_meta', 'sp_player', 'side', 'high' );
if ( $teams && $teams != array(0) && $divisions && $divisions != array(0) ): if ( $teams && $teams != array(0) && $leagues && $leagues != array(0) ):
add_meta_box( 'sp_statsdiv', __( 'Statistics', 'sportspress' ), 'sp_player_stats_meta', 'sp_player', 'normal', 'high' ); add_meta_box( 'sp_statsdiv', __( 'Statistics', 'sportspress' ), 'sp_player_stats_meta', 'sp_player', 'normal', 'high' );
endif; endif;
@@ -43,7 +43,7 @@ function sp_player_team_meta( $post ) {
function sp_player_stats_meta( $post ) { function sp_player_stats_meta( $post ) {
$team_ids = (array)get_post_meta( $post->ID, 'sp_team', false ); $team_ids = (array)get_post_meta( $post->ID, 'sp_team', false );
$divisions = (array)get_the_terms( $post->ID, 'sp_div' ); $leagues = (array)get_the_terms( $post->ID, 'sp_league' );
$stats = (array)get_post_meta( $post->ID, 'sp_metrics', true ); $stats = (array)get_post_meta( $post->ID, 'sp_metrics', true );
// Equation Operating System // Equation Operating System
@@ -52,9 +52,9 @@ function sp_player_stats_meta( $post ) {
// Get labels from metric variables // Get labels from metric variables
$metric_labels = (array)sp_get_var_labels( 'sp_metric' ); $metric_labels = (array)sp_get_var_labels( 'sp_metric' );
// Generate array of all division ids // Generate array of all league ids
$div_ids = array(); $div_ids = array();
foreach ( $divisions as $key => $value ): foreach ( $leagues as $key => $value ):
if ( is_object( $value ) && property_exists( $value, 'term_id' ) ) if ( is_object( $value ) && property_exists( $value, 'term_id' ) )
$div_ids[] = $value->term_id; $div_ids[] = $value->term_id;
endforeach; endforeach;
@@ -78,7 +78,7 @@ function sp_player_stats_meta( $post ) {
$data = array(); $data = array();
// Get all divisions populated with stats where available // Get all leagues populated with stats where available
$data[ $team_id ] = sp_array_combine( $div_ids, $stats[ $team_id ] ); $data[ $team_id ] = sp_array_combine( $div_ids, $stats[ $team_id ] );
// Get equations from statistics variables // Get equations from statistics variables
@@ -109,7 +109,7 @@ function sp_player_stats_meta( $post ) {
), ),
'tax_query' => array( 'tax_query' => array(
array( array(
'taxonomy' => 'sp_div', 'taxonomy' => 'sp_league',
'field' => 'id', 'field' => 'id',
'terms' => $div_id 'terms' => $div_id
) )
@@ -133,7 +133,7 @@ function sp_player_stats_meta( $post ) {
endif; endif;
endforeach; endforeach;
// Generate array of placeholder values for each division // Generate array of placeholder values for each league
$placeholders[ $team_id ][ $div_id ] = array(); $placeholders[ $team_id ][ $div_id ] = array();
foreach ( $equations as $key => $value ): foreach ( $equations as $key => $value ):
@@ -175,9 +175,9 @@ function sp_player_edit_columns() {
$columns = array( $columns = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'title' => __( 'Name', 'sportspress' ), 'title' => __( 'Name', 'sportspress' ),
'sp_pos' => __( 'Positions', 'sportspress' ), 'sp_position' => __( 'Positions', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ),
'sp_div' => __( 'Divisions', 'sportspress' ) 'sp_league' => __( 'Leagues', 'sportspress' )
); );
return $columns; return $columns;
} }

View File

@@ -40,9 +40,9 @@ function sp_staff_edit_columns() {
$columns = array( $columns = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'title' => __( 'Name', 'sportspress' ), 'title' => __( 'Name', 'sportspress' ),
'sp_pos' => __( 'Positions', 'sportspress' ), 'sp_position' => __( 'Positions', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ),
'sp_div' => __( 'Divisions', 'sportspress' ), 'sp_league' => __( 'Leagues', '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_div' => __( 'Divisions', 'sportspress' ), 'sp_league' => __( 'Leagues', 'sportspress' ),
); );
return $columns; return $columns;
} }
@@ -40,22 +40,22 @@ function sp_table_meta_init( $post ) {
} }
function sp_table_team_meta( $post, $test ) { function sp_table_team_meta( $post, $test ) {
$division_id = sp_get_the_term_id( $post->ID, 'sp_div', 0 ); $league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
?> ?>
<div> <div>
<p class="sp-tab-select"> <p class="sp-tab-select">
<?php <?php
$args = array( $args = array(
'show_option_none' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Division', 'sportspress' ) ), 'show_option_none' => sprintf( __( 'Select %s', 'sportspress' ), __( 'League', 'sportspress' ) ),
'taxonomy' => 'sp_div', 'taxonomy' => 'sp_league',
'name' => 'sp_div', 'name' => 'sp_league',
'selected' => $division_id 'selected' => $league_id
); );
sp_dropdown_taxonomies( $args ); sp_dropdown_taxonomies( $args );
?> ?>
</p> </p>
<?php <?php
sp_post_checklist( $post->ID, 'sp_team', 'block', 'sp_div' ); sp_post_checklist( $post->ID, 'sp_team', 'block', 'sp_league' );
sp_post_adder( 'sp_team' ); sp_post_adder( 'sp_team' );
?> ?>
</div> </div>

View File

@@ -19,14 +19,14 @@ function sp_team_cpt_init() {
add_action( 'init', 'sp_team_cpt_init' ); add_action( 'init', 'sp_team_cpt_init' );
function sp_team_meta_init( $post ) { function sp_team_meta_init( $post ) {
$divisions = (array)get_the_terms( $post->ID, 'sp_div' ); $leagues = (array)get_the_terms( $post->ID, 'sp_league' );
remove_meta_box( 'submitdiv', 'sp_team', 'side' ); remove_meta_box( 'submitdiv', 'sp_team', 'side' );
add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'sp_team', 'side', 'high' ); add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'sp_team', 'side', 'high' );
remove_meta_box( 'postimagediv', 'sp_team', 'side' ); remove_meta_box( 'postimagediv', 'sp_team', 'side' );
add_meta_box( 'postimagediv', __( 'Logo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_team', 'side', 'high' ); add_meta_box( 'postimagediv', __( 'Logo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_team', 'side', 'high' );
if ( $divisions && $divisions != array(0) ): if ( $leagues && $leagues != array(0) ):
add_meta_box( 'sp_statsdiv', __( 'Statistics', 'sportspress' ), 'sp_team_stats_meta', 'sp_team', 'normal', 'high' ); add_meta_box( 'sp_statsdiv', __( 'Statistics', 'sportspress' ), 'sp_team_stats_meta', 'sp_team', 'normal', 'high' );
endif; endif;
} }
@@ -36,14 +36,14 @@ function sp_team_edit_columns() {
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'sp_logo' => '&nbsp;', 'sp_logo' => '&nbsp;',
'title' => __( 'Team', 'sportspress' ), 'title' => __( 'Team', 'sportspress' ),
'sp_div' => __( 'Divisions', 'sportspress' ) 'sp_league' => __( 'Leagues', '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 ) {
$divisions = (array)get_the_terms( $post->ID, 'sp_div' ); $leagues = (array)get_the_terms( $post->ID, 'sp_league' );
$stats = (array)get_post_meta( $post->ID, 'sp_stats', true ); $stats = (array)get_post_meta( $post->ID, 'sp_stats', true );
// Equation Operating System // Equation Operating System
@@ -55,14 +55,14 @@ function sp_team_stats_meta( $post ) {
// Get labels from outcome variables // Get labels from outcome variables
$outcome_labels = (array)sp_get_var_labels( 'sp_outcome' ); $outcome_labels = (array)sp_get_var_labels( 'sp_outcome' );
// Generate array of all division ids // Generate array of all league ids
$div_ids = array(); $div_ids = array();
foreach ( $divisions as $key => $value ): foreach ( $leagues as $key => $value ):
if ( is_object( $value ) && property_exists( $value, 'term_id' ) ) if ( is_object( $value ) && property_exists( $value, 'term_id' ) )
$div_ids[] = $value->term_id; $div_ids[] = $value->term_id;
endforeach; endforeach;
// Get all divisions populated with stats where available // Get all leagues populated with stats where available
$data = sp_array_combine( $div_ids, $stats ); $data = sp_array_combine( $div_ids, $stats );
// Get equations from statistics variables // Get equations from statistics variables
@@ -96,7 +96,7 @@ function sp_team_stats_meta( $post ) {
), ),
'tax_query' => array( 'tax_query' => array(
array( array(
'taxonomy' => 'sp_div', 'taxonomy' => 'sp_league',
'field' => 'id', 'field' => 'id',
'terms' => $div_id 'terms' => $div_id
) )
@@ -130,7 +130,7 @@ function sp_team_stats_meta( $post ) {
endforeach; endforeach;
endforeach; endforeach;
// Generate array of placeholder values for each division // Generate array of placeholder values for each league
$placeholders[ $div_id ] = array(); $placeholders[ $div_id ] = array();
foreach ( $equations as $key => $value ): foreach ( $equations as $key => $value ):
$placeholders[ $div_id ][ $key ] = $eos->solveIF( str_replace( ' ', '', $value ), $totals ); $placeholders[ $div_id ][ $key ] = $eos->solveIF( str_replace( ' ', '', $value ), $totals );

View File

@@ -1,18 +0,0 @@
<?php
function sp_div_term_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_div', $object_type, $args );
}
add_action( 'init', 'sp_div_term_init' );
?>

18
admin/terms/league.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
function sp_league_term_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_term_init' );
?>

View File

@@ -1,5 +1,5 @@
<?php <?php
function sp_pos_term_init() { function sp_position_term_init() {
$name = __( 'Positions', 'sportspress' ); $name = __( 'Positions', 'sportspress' );
$singular_name = __( 'Position', 'sportspress' ); $singular_name = __( 'Position', 'sportspress' );
$lowercase_name = __( 'position', 'sportspress' ); $lowercase_name = __( 'position', 'sportspress' );
@@ -12,9 +12,9 @@ function sp_pos_term_init() {
'hierarchical' => true, 'hierarchical' => true,
'rewrite' => array( 'slug' => 'position' ) 'rewrite' => array( 'slug' => 'position' )
); );
register_taxonomy( 'sp_pos', $object_type, $args ); register_taxonomy( 'sp_position', $object_type, $args );
register_taxonomy_for_object_type( 'sp_pos', 'sp_player' ); register_taxonomy_for_object_type( 'sp_position', 'sp_player' );
register_taxonomy_for_object_type( 'sp_pos', 'sp_staff' ); register_taxonomy_for_object_type( 'sp_position', 'sp_staff' );
} }
add_action( 'init', 'sp_pos_term_init' ); add_action( 'init', 'sp_position_term_init' );
?> ?>

View File

@@ -7,7 +7,7 @@ function sp_table_shortcode( $atts, $content = null, $code = "" ) {
'div' => 0 'div' => 0
), $atts ) ); ), $atts ) );
// Get all teams in the division // Get all teams in the league
$args = array( $args = array(
'post_type' => 'sp_team', 'post_type' => 'sp_team',
'numberposts' => -1, 'numberposts' => -1,
@@ -16,7 +16,7 @@ function sp_table_shortcode( $atts, $content = null, $code = "" ) {
); );
if ( $div ) { if ( $div ) {
$args['tax_query'][] = array( $args['tax_query'][] = array(
'taxonomy' => 'sp_div', 'taxonomy' => 'sp_league',
'terms' => $div, 'terms' => $div,
'field' => 'term_id' 'field' => 'term_id'
); );

View File

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

View File

@@ -22,13 +22,13 @@ function sp_admin_menu() {
// Remove "Add Event" link under Events // Remove "Add Event" link under Events
unset( $submenu['edit.php?post_type=sp_event'][10] ); unset( $submenu['edit.php?post_type=sp_event'][10] );
// Remove "Divisions" link under Events // Remove "Leagues" link under Events
unset( $submenu['edit.php?post_type=sp_event'][15] ); unset( $submenu['edit.php?post_type=sp_event'][15] );
// Remove "Divisions" link under Players // Remove "Leagues" link under Players
unset( $submenu['edit.php?post_type=sp_player'][15] ); unset( $submenu['edit.php?post_type=sp_player'][15] );
// Remove "Divisions" link under Staff // Remove "Leagues" link under Staff
unset( $submenu['edit.php?post_type=sp_staff'][15] ); unset( $submenu['edit.php?post_type=sp_staff'][15] );
} }
add_action( 'admin_menu', 'sp_admin_menu' ); add_action( 'admin_menu', 'sp_admin_menu' );
@@ -39,8 +39,8 @@ function sp_manage_posts_custom_column( $column, $post_id ) {
case 'sp_logo': case 'sp_logo':
edit_post_link( get_the_post_thumbnail( $post_id, 'sp_icon' ), '', '', $post_id ); edit_post_link( get_the_post_thumbnail( $post_id, 'sp_icon' ), '', '', $post_id );
break; break;
case 'sp_pos': case 'sp_position':
echo get_the_terms ( $post_id, 'sp_pos' ) ? the_terms( $post_id, 'sp_pos' ) : '—'; echo get_the_terms ( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
break; break;
case 'sp_team': case 'sp_team':
$result = get_post_meta( $post_id, 'sp_result', false ); $result = get_post_meta( $post_id, 'sp_result', false );
@@ -71,8 +71,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_div': case 'sp_league':
echo get_the_terms ( $post_id, 'sp_div' ) ? the_terms( $post_id, 'sp_div' ) : '—'; echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
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' ) : '—';
@@ -101,21 +101,21 @@ function sp_restrict_manage_posts() {
// wp_dropdown_pages( $args ); // wp_dropdown_pages( $args );
endif; endif;
if ( in_array( $typenow, array( 'sp_player', 'sp_staff' ) ) ): if ( in_array( $typenow, array( 'sp_player', 'sp_staff' ) ) ):
$selected = isset( $_REQUEST['sp_pos'] ) ? $_REQUEST['sp_pos'] : null; $selected = isset( $_REQUEST['sp_position'] ) ? $_REQUEST['sp_position'] : null;
$args = array( $args = array(
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Positions', 'sportspress' ) ), 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Positions', 'sportspress' ) ),
'taxonomy' => 'sp_pos', 'taxonomy' => 'sp_position',
'name' => 'sp_pos', 'name' => 'sp_position',
'selected' => $selected 'selected' => $selected
); );
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_div'] ) ? $_REQUEST['sp_div'] : null; $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
$args = array( $args = array(
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Divisions', 'sportspress' ) ), 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ),
'taxonomy' => 'sp_div', 'taxonomy' => 'sp_league',
'name' => 'sp_div', 'name' => 'sp_league',
'selected' => $selected 'selected' => $selected
); );
sp_dropdown_taxonomies( $args ); sp_dropdown_taxonomies( $args );
@@ -208,13 +208,13 @@ function sp_save_post( $post_id ) {
break; break;
case ( 'sp_table' ): case ( 'sp_table' ):
update_post_meta( $post_id, 'sp_teams', sp_array_value( $_POST, 'sp_teams', array() ) ); update_post_meta( $post_id, 'sp_teams', sp_array_value( $_POST, 'sp_teams', array() ) );
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_div', 0 ), 'sp_div' ); wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
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_players', sp_array_value( $_POST, 'sp_players', array() ) ); update_post_meta( $post_id, 'sp_players', sp_array_value( $_POST, 'sp_players', 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_div', 0 ), 'sp_div' ); wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
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;

View File

@@ -243,7 +243,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_div' ); $terms = (array)get_the_terms( $post->ID, 'sp_league' );
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;
@@ -457,7 +457,7 @@ if ( !function_exists( 'sp_league_table' ) ) {
$i = 0; $i = 0;
foreach ( $data as $team_id => $team_stats ): foreach ( $data as $team_id => $team_stats ):
if ( !$team_id ) continue; if ( !$team_id ) continue;
$div = get_term( $team_id, 'sp_div' ); $div = get_term( $team_id, 'sp_league' );
?> ?>
<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'; ?>">
<td> <td>
@@ -497,7 +497,7 @@ if ( !function_exists( 'sp_player_table' ) ) {
$i = 0; $i = 0;
foreach ( $data as $player_id => $player_stats ): foreach ( $data as $player_id => $player_stats ):
if ( !$player_id ) continue; if ( !$player_id ) continue;
$div = get_term( $player_id, 'sp_div' ); $div = get_term( $player_id, 'sp_league' );
?> ?>
<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'; ?>">
<td> <td>
@@ -526,7 +526,7 @@ if ( !function_exists( 'sp_team_stats_table' ) ) {
<table class="widefat sp-data-table"> <table class="widefat sp-data-table">
<thead> <thead>
<tr> <tr>
<th><?php _e( 'Division', 'sportspress' ); ?></th> <th><?php _e( 'League', 'sportspress' ); ?></th>
<?php foreach ( $columns as $label ): ?> <?php foreach ( $columns as $label ): ?>
<th><?php echo $label; ?></th> <th><?php echo $label; ?></th>
<?php endforeach; ?> <?php endforeach; ?>
@@ -538,13 +538,13 @@ if ( !function_exists( 'sp_team_stats_table' ) ) {
if ( empty( $data ) ): if ( empty( $data ) ):
?> ?>
<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'; ?>">
<td><strong><?php printf( __( 'Select %s', 'sportspress' ), __( 'Division', 'sportspress' ) ); ?></strong></td> <td><strong><?php printf( __( 'Select %s', 'sportspress' ), __( 'League', 'sportspress' ) ); ?></strong></td>
</tr> </tr>
<?php <?php
else: else:
foreach ( $data as $div_id => $div_stats ): foreach ( $data as $div_id => $div_stats ):
if ( !$div_id ) continue; if ( !$div_id ) continue;
$div = get_term( $div_id, 'sp_div' ); $div = get_term( $div_id, 'sp_league' );
?> ?>
<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'; ?>">
<td> <td>
@@ -574,7 +574,7 @@ if ( !function_exists( 'sp_player_metrics_table' ) ) {
<table class="widefat sp-data-table"> <table class="widefat sp-data-table">
<thead> <thead>
<tr> <tr>
<th><?php _e( 'Division', 'sportspress' ); ?></th> <th><?php _e( 'League', 'sportspress' ); ?></th>
<?php foreach ( $columns as $label ): ?> <?php foreach ( $columns as $label ): ?>
<th><?php echo $label; ?></th> <th><?php echo $label; ?></th>
<?php endforeach; ?> <?php endforeach; ?>
@@ -592,7 +592,7 @@ if ( !function_exists( 'sp_player_metrics_table' ) ) {
endif; endif;
foreach ( $team_stats as $div_id => $div_stats ): foreach ( $team_stats as $div_id => $div_stats ):
if ( !$div_id ) continue; if ( !$div_id ) continue;
$div = get_term( $div_id, 'sp_div' ); $div = get_term( $div_id, 'sp_league' );
?> ?>
<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'; ?>">
<td> <td>
@@ -777,7 +777,7 @@ if ( !function_exists( 'sportspress_render_option_field' ) ) {
if ( !function_exists( 'sp_get_table' ) ) { if ( !function_exists( 'sp_get_table' ) ) {
function sp_get_table( $post_id, $breakdown = false ) { function sp_get_table( $post_id, $breakdown = false ) {
$div_id = sp_get_the_term_id( $post_id, 'sp_div', 0 ); $div_id = sp_get_the_term_id( $post_id, 'sp_league', 0 );
$team_ids = (array)get_post_meta( $post_id, 'sp_team', false ); $team_ids = (array)get_post_meta( $post_id, 'sp_team', false );
$table_stats = (array)get_post_meta( $post_id, 'sp_teams', true ); $table_stats = (array)get_post_meta( $post_id, 'sp_teams', true );
@@ -790,7 +790,7 @@ if ( !function_exists( 'sp_get_table' ) ) {
// Get labels from outcome variables // Get labels from outcome variables
$outcome_labels = (array)sp_get_var_labels( 'sp_outcome' ); $outcome_labels = (array)sp_get_var_labels( 'sp_outcome' );
// Get all divisions populated with stats where available // Get all leagues populated with stats where available
$tempdata = sp_array_combine( $team_ids, $table_stats ); $tempdata = sp_array_combine( $team_ids, $table_stats );
// Create entry for each team in totals // Create entry for each team in totals
@@ -831,7 +831,7 @@ if ( !function_exists( 'sp_get_table' ) ) {
'posts_per_page' => -1, 'posts_per_page' => -1,
'tax_query' => array( 'tax_query' => array(
array( array(
'taxonomy' => 'sp_div', 'taxonomy' => 'sp_league',
'field' => 'id', 'field' => 'id',
'terms' => $div_id 'terms' => $div_id
) )
@@ -978,7 +978,7 @@ if ( !function_exists( 'sp_get_table' ) ) {
if ( !function_exists( 'sp_get_list' ) ) { if ( !function_exists( 'sp_get_list' ) ) {
function sp_get_list( $post_id, $breakdown = false ) { function sp_get_list( $post_id, $breakdown = false ) {
$div_id = sp_get_the_term_id( $post_id, 'sp_div', 0 ); $div_id = sp_get_the_term_id( $post_id, 'sp_league', 0 );
$team_id = get_post_meta( $post_id, 'sp_team', true ); $team_id = get_post_meta( $post_id, 'sp_team', true );
$player_ids = (array)get_post_meta( $post_id, 'sp_player', false ); $player_ids = (array)get_post_meta( $post_id, 'sp_player', false );
$stats = (array)get_post_meta( $post_id, 'sp_players', true ); $stats = (array)get_post_meta( $post_id, 'sp_players', true );
@@ -989,7 +989,7 @@ if ( !function_exists( 'sp_get_list' ) ) {
// Get labels from result variables // Get labels from result variables
$columns = (array)sp_get_var_labels( 'sp_metric' ); $columns = (array)sp_get_var_labels( 'sp_metric' );
// Get all divisions populated with stats where available // Get all leagues populated with stats where available
$tempdata = sp_array_combine( $player_ids, $stats ); $tempdata = sp_array_combine( $player_ids, $stats );
// Get equations from statistics variables // Get equations from statistics variables
@@ -1027,7 +1027,7 @@ if ( !function_exists( 'sp_get_list' ) ) {
'posts_per_page' => -1, 'posts_per_page' => -1,
'tax_query' => array( 'tax_query' => array(
array( array(
'taxonomy' => 'sp_div', 'taxonomy' => 'sp_league',
'field' => 'id', 'field' => 'id',
'terms' => $div_id 'terms' => $div_id
) )

View File

@@ -46,8 +46,8 @@ require_once dirname( __FILE__ ) . '/admin/post-types/list.php';
require_once dirname( __FILE__ ) . '/admin/post-types/staff.php'; require_once dirname( __FILE__ ) . '/admin/post-types/staff.php';
// Terms // Terms
require_once dirname( __FILE__ ) . '/admin/terms/div.php'; require_once dirname( __FILE__ ) . '/admin/terms/league.php';
require_once dirname( __FILE__ ) . '/admin/terms/pos.php'; require_once dirname( __FILE__ ) . '/admin/terms/position.php';
// Shortcodes // Shortcodes
// require_once dirname( __FILE__ ) . '/classes/shortcodes/table.php'; // require_once dirname( __FILE__ ) . '/classes/shortcodes/table.php';