Change Statistic to Performance

This commit is contained in:
Brian Miyaji
2014-03-24 19:24:54 +11:00
parent 967e0729a1
commit 514e3d4da4
48 changed files with 284 additions and 277 deletions

View File

@@ -22,7 +22,7 @@ function sportspress_calendar_post_init() {
'rewrite' => array( 'slug' => get_option( 'sportspress_calendar_slug', 'calendar' ) ),
'show_in_menu' => 'edit.php?post_type=sp_event',
'show_in_admin_bar' => true,
'capability_type' => 'sp_calendar'
'capability_type' => 'sp_calendar',
);
register_post_type( 'sp_calendar', $args );
}

View File

@@ -19,9 +19,10 @@ function sportspress_column_post_init() {
'show_in_menu' => false,
'has_archive' => false,
'hierarchical' => false,
'can_export' => false,
'supports' => array( 'title', 'page-attributes' ),
'register_meta_box_cb' => 'sportspress_column_meta_init',
'capability_type' => 'sp_config'
'capability_type' => 'sp_config',
);
register_post_type( 'sp_column', $args );
}

View File

@@ -22,7 +22,7 @@ function sportspress_directory_post_init() {
'rewrite' => array( 'slug' => get_option( 'sportspress_directory_slug', 'directory' ) ),
'show_in_menu' => 'edit.php?post_type=sp_player',
'show_in_admin_bar' => true,
'capability_type' => 'sp_directory'
'capability_type' => 'sp_directory',
);
register_post_type( 'sp_directory', $args );
}
@@ -125,7 +125,7 @@ function sportspress_directory_details_meta( $post ) {
'name' => __( 'Name', 'sportspress' ),
'eventsplayed' => __( 'Played', 'sportspress' )
),
'post_type' => 'sp_statistic',
'post_type' => 'sp_performance',
'name' => 'sp_orderby',
'selected' => $orderby,
'values' => 'slug',

View File

@@ -22,7 +22,7 @@ function sportspress_event_post_init() {
'register_meta_box_cb' => 'sportspress_event_meta_init',
'rewrite' => array( 'slug' => get_option( 'sportspress_events_slug', 'events' ) ),
'menu_icon' => 'dashicons-calendar',
'capability_type' => 'sp_event'
'capability_type' => 'sp_event',
);
register_post_type( 'sp_event', $args );
}
@@ -74,7 +74,7 @@ function sportspress_event_meta_init( $post ) {
do_action( 'sportspress_event_meta_init' );
if ( sizeof( $players ) > 0 )
add_meta_box( 'sp_statisticsdiv', __( 'Statistics', 'sportspress' ), 'sportspress_event_statistics_meta', 'sp_event', 'normal', 'high' );
add_meta_box( 'sp_performancediv', __( 'Performance', 'sportspress' ), 'sportspress_event_performance_meta', 'sp_event', 'normal', 'high' );
add_meta_box( 'sp_articlediv', __( 'Article', 'sportspress' ), 'sportspress_event_article_meta', 'sp_event', 'normal', 'high' );
}
@@ -214,12 +214,12 @@ function sportspress_event_video_meta( $post ) {
<?php
}
function sportspress_event_statistics_meta( $post ) {
function sportspress_event_performance_meta( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false );
$stats = (array)get_post_meta( $post->ID, 'sp_players', true );
// Get columns from statistic variables
$columns = sportspress_get_var_labels( 'sp_statistic' );
// Get columns from performance variables
$columns = sportspress_get_var_labels( 'sp_performance' );
foreach ( $teams as $key => $team_id ):
if ( ! $team_id ) continue;

View File

@@ -22,7 +22,7 @@ function sportspress_list_post_init() {
'rewrite' => array( 'slug' => get_option( 'sportspress_list_slug', 'list' ) ),
'show_in_menu' => 'edit.php?post_type=sp_player',
'show_in_admin_bar' => true,
'capability_type' => 'sp_list'
'capability_type' => 'sp_list',
);
register_post_type( 'sp_list', $args );
}
@@ -136,7 +136,7 @@ function sportspress_list_details_meta( $post ) {
'name' => __( 'Name', 'sportspress' ),
'eventsplayed' => __( 'Played', 'sportspress' )
),
'post_type' => 'sp_statistic',
'post_type' => 'sp_performance',
'name' => 'sp_orderby',
'selected' => $orderby,
'values' => 'slug',

View File

@@ -19,8 +19,9 @@ function sportspress_metric_post_init() {
'show_in_menu' => false,
'has_archive' => false,
'hierarchical' => false,
'can_export' => false,
'supports' => array( 'title', 'page-attributes' ),
'capability_type' => 'sp_config'
'capability_type' => 'sp_config',
);
register_post_type( 'sp_metric', $args );
}

View File

@@ -19,9 +19,10 @@ function sportspress_outcome_post_init() {
'show_in_menu' => false,
'has_archive' => false,
'hierarchical' => false,
'can_export' => false,
'supports' => array( 'title', 'page-attributes' ),
'register_meta_box_cb' => 'sportspress_outcome_meta_init',
'capability_type' => 'sp_config'
'capability_type' => 'sp_config',
);
register_post_type( 'sp_outcome', $args );
}

View File

@@ -1,10 +1,10 @@
<?php
function sportspress_statistic_post_init() {
function sportspress_performance_post_init() {
$labels = array(
'name' => __( 'Statistics', 'sportspress' ),
'singular_name' => __( 'Statistic', 'sportspress' ),
'add_new_item' => __( 'Add New Statistic', 'sportspress' ),
'edit_item' => __( 'Edit Statistic', 'sportspress' ),
'name' => __( 'Performance', 'sportspress' ),
'singular_name' => __( 'Performance', 'sportspress' ),
'add_new_item' => __( 'Add New Performance', 'sportspress' ),
'edit_item' => __( 'Edit Performance', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
@@ -12,22 +12,23 @@ function sportspress_statistic_post_init() {
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Statistics', 'sportspress' ),
'label' => __( 'Performance', 'sportspress' ),
'labels' => $labels,
'public' => false,
'show_ui' => true,
'show_in_menu' => false,
'has_archive' => false,
'hierarchical' => false,
'can_export' => false,
'supports' => array( 'title', 'page-attributes' ),
'register_meta_box_cb' => 'sportspress_statistic_meta_init',
'capability_type' => 'sp_config'
'register_meta_box_cb' => 'sportspress_performance_meta_init',
'capability_type' => 'sp_config',
);
register_post_type( 'sp_statistic', $args );
register_post_type( 'sp_performance', $args );
}
add_action( 'init', 'sportspress_statistic_post_init' );
add_action( 'init', 'sportspress_performance_post_init' );
function sportspress_statistic_edit_columns() {
function sportspress_performance_edit_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
@@ -36,13 +37,13 @@ function sportspress_statistic_edit_columns() {
);
return $columns;
}
add_filter( 'manage_edit-sp_statistic_columns', 'sportspress_statistic_edit_columns' );
add_filter( 'manage_edit-sp_performance_columns', 'sportspress_performance_edit_columns' );
function sportspress_statistic_meta_init() {
add_meta_box( 'sp_equationdiv', __( 'Details', 'sportspress' ), 'sportspress_statistic_equation_meta', 'sp_statistic', 'normal', 'high' );
function sportspress_performance_meta_init() {
add_meta_box( 'sp_equationdiv', __( 'Details', 'sportspress' ), 'sportspress_performance_equation_meta', 'sp_performance', 'normal', 'high' );
}
function sportspress_statistic_equation_meta( $post ) {
function sportspress_performance_equation_meta( $post ) {
$calculate = get_post_meta( $post->ID, 'sp_calculate', true );
?>
<p><strong><?php _e( 'Calculate', 'sportspress' ); ?></strong></p>

View File

@@ -56,7 +56,7 @@ function sportspress_player_meta_init( $post ) {
add_meta_box( 'sp_metricsdiv', __( 'Metrics', 'sportspress' ), 'sportspress_player_metrics_meta', 'sp_player', 'side', 'default' );
if ( $leagues && ! empty( $leagues ) && $seasons && ! empty( $seasons ) ):
add_meta_box( 'sp_statsdiv', __( 'Statistics', 'sportspress' ), 'sportspress_player_stats_meta', 'sp_player', 'normal', 'high' );
add_meta_box( 'sp_performancediv', __( 'Performance', 'sportspress' ), 'sportspress_player_performance_meta', 'sp_player', 'normal', 'high' );
endif;
}
@@ -236,12 +236,12 @@ function sportspress_player_metrics_meta( $post ) {
sportspress_nonce();
}
function sportspress_player_stats_meta( $post ) {
function sportspress_player_performance_meta( $post ) {
$leagues = get_the_terms( $post->ID, 'sp_league' );
$league_num = sizeof( $leagues );
// Loop through statistics for each league
// Loop through performance for each league
foreach ( $leagues as $league ):
if ( $league_num > 1 ):
@@ -250,9 +250,9 @@ function sportspress_player_stats_meta( $post ) {
<?php
endif;
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = sportspress_get_player_statistics_data( $post->ID, $league->term_id, true );
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = sportspress_get_player_performance_data( $post->ID, $league->term_id, true );
sportspress_edit_player_statistics_table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, ! current_user_can( 'edit_sp_teams' ) );
sportspress_edit_player_performance_table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, ! current_user_can( 'edit_sp_teams' ) );
endforeach;
}

View File

@@ -19,9 +19,10 @@ function sportspress_result_post_init() {
'show_in_menu' => false,
'has_archive' => false,
'hierarchical' => false,
'can_export' => false,
'supports' => array( 'title', 'page-attributes' ),
'register_meta_box_cb' => 'sportspress_result_meta_init',
'capability_type' => 'sp_config'
'capability_type' => 'sp_config',
);
register_post_type( 'sp_result', $args );
}

View File

@@ -5,7 +5,8 @@ function sportspress_separator_post_init() {
'public' => false,
'show_ui' => true,
'show_in_nav_menus' => false,
'show_in_admin_bar' => false
'show_in_admin_bar' => false,
'can_export' => false,
);
register_post_type( 'sp_separator', $args );
}

View File

@@ -21,7 +21,7 @@ function sportspress_staff_post_init() {
'register_meta_box_cb' => 'sportspress_staff_meta_init',
'rewrite' => array( 'slug' => get_option( 'sportspress_staff_slug', 'staff' ) ),
'show_in_menu' => 'edit.php?post_type=sp_player',
'capability_type' => 'sp_staff'
'capability_type' => 'sp_staff',
);
register_post_type( 'sp_staff', $args );
}

View File

@@ -22,7 +22,7 @@ function sportspress_table_post_init() {
'rewrite' => array( 'slug' => get_option( 'sportspress_table_slug', 'table' ) ),
'show_in_menu' => 'edit.php?post_type=sp_team',
'show_in_admin_bar' => true,
'capability_type' => 'sp_table'
'capability_type' => 'sp_table',
);
register_post_type( 'sp_table', $args );
}

View File

@@ -22,7 +22,7 @@ function sportspress_team_post_init() {
'register_meta_box_cb' => 'sportspress_team_meta_init',
'rewrite' => array( 'slug' => get_option( 'sportspress_teams_slug', 'teams' ) ),
'menu_icon' => 'dashicons-shield-alt',
'capability_type' => 'sp_team'
'capability_type' => 'sp_team',
);
register_post_type( 'sp_team', $args );
}
@@ -55,7 +55,7 @@ function sportspress_team_columns_meta( $post ) {
$league_num = sizeof( $leagues );
// Loop through statistics for each league
// Loop through columns for each league
foreach ( $leagues as $league ):
$league_id = $league->term_id;