Change div to league and pos to position
This commit is contained in:
@@ -142,7 +142,7 @@ function sp_event_edit_columns() {
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Event', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_div' => __( 'Divisions', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_kickoff' => __( 'Kick-off', 'sportspress' )
|
||||
);
|
||||
return $columns;
|
||||
|
||||
@@ -24,7 +24,7 @@ function sp_list_edit_columns() {
|
||||
'title' => __( 'Title' ),
|
||||
'sp_player' => __( 'Players', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_div' => __( 'Divisions', 'sportspress' )
|
||||
'sp_league' => __( 'Leagues', 'sportspress' )
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
@@ -41,17 +41,17 @@ function sp_list_meta_init( $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 );
|
||||
?>
|
||||
<div>
|
||||
<p class="sp-tab-select">
|
||||
<?php
|
||||
$args = array(
|
||||
'show_option_none' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Division', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_div',
|
||||
'name' => 'sp_div',
|
||||
'selected' => $division_id
|
||||
'show_option_none' => sprintf( __( 'Select %s', 'sportspress' ), __( 'League', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $league_id
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?>
|
||||
|
||||
@@ -20,7 +20,7 @@ add_action( 'init', 'sp_player_cpt_init' );
|
||||
|
||||
function sp_player_meta_init( $post ) {
|
||||
$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' );
|
||||
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( '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' );
|
||||
endif;
|
||||
|
||||
@@ -43,7 +43,7 @@ function sp_player_team_meta( $post ) {
|
||||
|
||||
function sp_player_stats_meta( $post ) {
|
||||
$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 );
|
||||
|
||||
// Equation Operating System
|
||||
@@ -52,9 +52,9 @@ function sp_player_stats_meta( $post ) {
|
||||
// Get labels from metric variables
|
||||
$metric_labels = (array)sp_get_var_labels( 'sp_metric' );
|
||||
|
||||
// Generate array of all division ids
|
||||
// Generate array of all league ids
|
||||
$div_ids = array();
|
||||
foreach ( $divisions as $key => $value ):
|
||||
foreach ( $leagues as $key => $value ):
|
||||
if ( is_object( $value ) && property_exists( $value, 'term_id' ) )
|
||||
$div_ids[] = $value->term_id;
|
||||
endforeach;
|
||||
@@ -78,7 +78,7 @@ function sp_player_stats_meta( $post ) {
|
||||
|
||||
$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 ] );
|
||||
|
||||
// Get equations from statistics variables
|
||||
@@ -109,7 +109,7 @@ function sp_player_stats_meta( $post ) {
|
||||
),
|
||||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => 'sp_div',
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'id',
|
||||
'terms' => $div_id
|
||||
)
|
||||
@@ -133,7 +133,7 @@ function sp_player_stats_meta( $post ) {
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
// Generate array of placeholder values for each division
|
||||
// Generate array of placeholder values for each league
|
||||
$placeholders[ $team_id ][ $div_id ] = array();
|
||||
foreach ( $equations as $key => $value ):
|
||||
|
||||
@@ -175,9 +175,9 @@ function sp_player_edit_columns() {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Name', 'sportspress' ),
|
||||
'sp_pos' => __( 'Positions', 'sportspress' ),
|
||||
'sp_position' => __( 'Positions', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_div' => __( 'Divisions', 'sportspress' )
|
||||
'sp_league' => __( 'Leagues', 'sportspress' )
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ function sp_staff_edit_columns() {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Name', 'sportspress' ),
|
||||
'sp_pos' => __( 'Positions', 'sportspress' ),
|
||||
'sp_position' => __( 'Positions', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_div' => __( 'Divisions', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ function sp_table_edit_columns() {
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_div' => __( 'Divisions', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
@@ -40,22 +40,22 @@ function sp_table_meta_init( $post ) {
|
||||
}
|
||||
|
||||
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>
|
||||
<p class="sp-tab-select">
|
||||
<?php
|
||||
$args = array(
|
||||
'show_option_none' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Division', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_div',
|
||||
'name' => 'sp_div',
|
||||
'selected' => $division_id
|
||||
'show_option_none' => sprintf( __( 'Select %s', 'sportspress' ), __( 'League', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $league_id
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</p>
|
||||
<?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' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
@@ -19,14 +19,14 @@ function sp_team_cpt_init() {
|
||||
add_action( 'init', 'sp_team_cpt_init' );
|
||||
|
||||
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' );
|
||||
add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'sp_team', 'side', 'high' );
|
||||
remove_meta_box( 'postimagediv', 'sp_team', 'side' );
|
||||
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' );
|
||||
endif;
|
||||
}
|
||||
@@ -36,14 +36,14 @@ function sp_team_edit_columns() {
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_logo' => ' ',
|
||||
'title' => __( 'Team', 'sportspress' ),
|
||||
'sp_div' => __( 'Divisions', 'sportspress' )
|
||||
'sp_league' => __( 'Leagues', 'sportspress' )
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
add_filter( 'manage_edit-sp_team_columns', 'sp_team_edit_columns' );
|
||||
|
||||
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 );
|
||||
|
||||
// Equation Operating System
|
||||
@@ -55,14 +55,14 @@ function sp_team_stats_meta( $post ) {
|
||||
// Get labels from outcome variables
|
||||
$outcome_labels = (array)sp_get_var_labels( 'sp_outcome' );
|
||||
|
||||
// Generate array of all division ids
|
||||
// Generate array of all league ids
|
||||
$div_ids = array();
|
||||
foreach ( $divisions as $key => $value ):
|
||||
foreach ( $leagues as $key => $value ):
|
||||
if ( is_object( $value ) && property_exists( $value, 'term_id' ) )
|
||||
$div_ids[] = $value->term_id;
|
||||
endforeach;
|
||||
|
||||
// Get all divisions populated with stats where available
|
||||
// Get all leagues populated with stats where available
|
||||
$data = sp_array_combine( $div_ids, $stats );
|
||||
|
||||
// Get equations from statistics variables
|
||||
@@ -96,7 +96,7 @@ function sp_team_stats_meta( $post ) {
|
||||
),
|
||||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => 'sp_div',
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'id',
|
||||
'terms' => $div_id
|
||||
)
|
||||
@@ -130,7 +130,7 @@ function sp_team_stats_meta( $post ) {
|
||||
endforeach;
|
||||
endforeach;
|
||||
|
||||
// Generate array of placeholder values for each division
|
||||
// Generate array of placeholder values for each league
|
||||
$placeholders[ $div_id ] = array();
|
||||
foreach ( $equations as $key => $value ):
|
||||
$placeholders[ $div_id ][ $key ] = $eos->solveIF( str_replace( ' ', '', $value ), $totals );
|
||||
|
||||
@@ -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
18
admin/terms/league.php
Normal 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' );
|
||||
?>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function sp_pos_term_init() {
|
||||
function sp_position_term_init() {
|
||||
$name = __( 'Positions', 'sportspress' );
|
||||
$singular_name = __( 'Position', 'sportspress' );
|
||||
$lowercase_name = __( 'position', 'sportspress' );
|
||||
@@ -12,9 +12,9 @@ function sp_pos_term_init() {
|
||||
'hierarchical' => true,
|
||||
'rewrite' => array( 'slug' => 'position' )
|
||||
);
|
||||
register_taxonomy( 'sp_pos', $object_type, $args );
|
||||
register_taxonomy_for_object_type( 'sp_pos', 'sp_player' );
|
||||
register_taxonomy_for_object_type( 'sp_pos', 'sp_staff' );
|
||||
register_taxonomy( 'sp_position', $object_type, $args );
|
||||
register_taxonomy_for_object_type( 'sp_position', 'sp_player' );
|
||||
register_taxonomy_for_object_type( 'sp_position', 'sp_staff' );
|
||||
}
|
||||
add_action( 'init', 'sp_pos_term_init' );
|
||||
add_action( 'init', 'sp_position_term_init' );
|
||||
?>
|
||||
Reference in New Issue
Block a user