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

@@ -1,7 +1,7 @@
<?php
function sportspress_admin_head() {
global $typenow;
if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic', 'sp_metric' ) ) )
if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance', 'sp_metric' ) ) )
sportspress_highlight_admin_menu();
elseif ( $typenow == 'sp_table' )
sportspress_highlight_admin_menu( 'edit.php?post_type=sp_team', 'edit.php?post_type=sp_table' );

View File

@@ -3,7 +3,7 @@ function sportspress_post_updated_messages( $messages ) {
global $typenow, $post;
if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_metric', 'sp_statistic' ) ) ):
if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_metric', 'sp_performance' ) ) ):
$obj = get_post_type_object( $typenow );
for ( $i = 0; $i <= 10; $i++ ):

View File

@@ -7,7 +7,7 @@ function sportspress_pre_get_posts( $query ) {
endif;
$post_type = $query->query['post_type'];
if ( in_array( $post_type, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic' ) ) ):
if ( in_array( $post_type, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance' ) ) ):
$query->set( 'orderby', 'menu_order' );
$query->set( 'order', 'ASC' );
elseif ( $post_type == 'sp_event' ):

View File

@@ -5,7 +5,7 @@ function sportspress_sanitize_title( $title ) {
return $title;
elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && in_array( $_POST['post_type'], array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic', 'sp_metric' ) ) ):
elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && in_array( $_POST['post_type'], array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance', 'sp_metric' ) ) ):
$key = isset( $_POST['sp_key'] ) ? $_POST['sp_key'] : null;

View File

@@ -11,7 +11,7 @@ function sportspress_save_post( $post_id ) {
// Update leagues seasons to show
update_post_meta( $post_id, 'sp_leagues_seasons', sportspress_array_value( $_POST, 'sp_leagues_seasons', array() ) );
// Update player statistics array
// Update team columns array
if ( current_user_can( 'edit_sp_tables' ) )
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
@@ -25,7 +25,7 @@ function sportspress_save_post( $post_id ) {
// Update results
update_post_meta( $post_id, 'sp_results', $results );
// Update player statistics
// Update player performance
update_post_meta( $post_id, 'sp_players', sportspress_array_value( $_POST, 'sp_players', array() ) );
// Update team array
@@ -109,7 +109,7 @@ function sportspress_save_post( $post_id ) {
break;
case ( 'sp_statistic' ):
case ( 'sp_performance' ):
// Delete posts with duplicate key
sportspress_delete_duplicate_post( $_POST );
@@ -142,9 +142,9 @@ function sportspress_save_post( $post_id ) {
// Update player metrics array
update_post_meta( $post_id, 'sp_metrics', sportspress_array_value( $_POST, 'sp_metrics', array() ) );
// Update player statistics array
// Update player performance array
if ( current_user_can( 'edit_sp_teams' ) )
update_post_meta( $post_id, 'sp_statistics', sportspress_array_value( $_POST, 'sp_statistics', array() ) );
update_post_meta( $post_id, 'sp_performance', sportspress_array_value( $_POST, 'sp_performance', array() ) );
break;
@@ -176,7 +176,7 @@ function sportspress_save_post( $post_id ) {
case ( 'sp_list' ):
// Update statistics array
// Update performance array
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
// Update players array

View File

@@ -11,7 +11,7 @@ function sportspress_default_event_content( $content ) {
if ( is_singular( 'sp_event' ) && in_the_loop() ):
$details = sportspress_event_details();
$results = sportspress_event_results();
$statistics = sportspress_event_statistics();
$performance = sportspress_event_performance();
$staff = sportspress_event_staff();
$id = get_the_ID();
$video_url = get_post_meta( $id, 'sp_video', true );
@@ -22,10 +22,10 @@ function sportspress_default_event_content( $content ) {
$video = '';
endif;
if ( $results ):
$content = $video . $results . $details . $statistics . $staff . $content;
$content = $video . $results . $details . $performance . $staff . $content;
else:
$venue = sportspress_event_venue();
$content = $video . $details . $venue . $statistics . $staff . $content;
$content = $video . $details . $venue . $performance . $staff . $content;
endif;
endif;
return $content;
@@ -87,8 +87,8 @@ add_filter( 'the_content', 'sportspress_default_table_content' );
function sportspress_default_player_content( $content ) {
if ( is_singular( 'sp_player' ) && in_the_loop() ):
$metrics = sportspress_player_metrics();
$statistics = sportspress_player_statistics();
$content .= $metrics . $statistics;
$performance = sportspress_player_performance();
$content .= $metrics . $performance;
endif;
return $content;
}

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;

View File

@@ -29,9 +29,9 @@ class SportsPressEventSettingsPage {
);
add_settings_field(
'statistics',
__( 'Statistics', 'sportspress' ),
array( $this, 'statistics_callback' ),
'performance',
__( 'Performance', 'sportspress' ),
array( $this, 'performance_callback' ),
'sportspress_events',
'event'
);
@@ -68,29 +68,29 @@ class SportsPressEventSettingsPage {
<?php
}
function statistics_callback() {
$responsive = sportspress_array_value( $this->options, 'event_statistics_responsive', true );
$sortable = sportspress_array_value( $this->options, 'event_statistics_sortable', true );
$link_posts = sportspress_array_value( $this->options, 'event_statistics_link_posts', true );
function performance_callback() {
$responsive = sportspress_array_value( $this->options, 'event_performance_responsive', true );
$sortable = sportspress_array_value( $this->options, 'event_performance_sortable', true );
$link_posts = sportspress_array_value( $this->options, 'event_performance_link_posts', true );
?>
<fieldset>
<label for="sportspress_event_statistics_responsive">
<input id="sportspress_event_statistics_responsive_default" name="sportspress[event_statistics_responsive]" type="hidden" value="0">
<input id="sportspress_event_statistics_responsive" name="sportspress[event_statistics_responsive]" type="checkbox" value="1" <?php checked( $responsive ); ?>>
<label for="sportspress_event_performance_responsive">
<input id="sportspress_event_performance_responsive_default" name="sportspress[event_performance_responsive]" type="hidden" value="0">
<input id="sportspress_event_performance_responsive" name="sportspress[event_performance_responsive]" type="checkbox" value="1" <?php checked( $responsive ); ?>>
<?php _e( 'Responsive', 'sportspress' ); ?>
</label>
</fieldset>
<fieldset>
<label for="sportspress_event_statistics_sortable">
<input id="sportspress_event_statistics_sortable_default" name="sportspress[event_statistics_sortable]" type="hidden" value="0">
<input id="sportspress_event_statistics_sortable" name="sportspress[event_statistics_sortable]" type="checkbox" value="1" <?php checked( $sortable ); ?>>
<label for="sportspress_event_performance_sortable">
<input id="sportspress_event_performance_sortable_default" name="sportspress[event_performance_sortable]" type="hidden" value="0">
<input id="sportspress_event_performance_sortable" name="sportspress[event_performance_sortable]" type="checkbox" value="1" <?php checked( $sortable ); ?>>
<?php _e( 'Sortable', 'sportspress' ); ?>
</label>
</fieldset>
<fieldset>
<label for="sportspress_event_statistics_link_posts">
<input id="sportspress_event_statistics_link_posts_default" name="sportspress[event_statistics_link_posts]" type="hidden" value="0">
<input id="sportspress_event_statistics_link_posts" name="sportspress[event_statistics_link_posts]" type="checkbox" value="1" <?php checked( $link_posts ); ?>>
<label for="sportspress_event_performance_link_posts">
<input id="sportspress_event_performance_link_posts_default" name="sportspress[event_performance_link_posts]" type="hidden" value="0">
<input id="sportspress_event_performance_link_posts" name="sportspress[event_performance_link_posts]" type="checkbox" value="1" <?php checked( $link_posts ); ?>>
<?php _e( 'Link players', 'sportspress' ); ?>
</label>
</fieldset>

View File

@@ -60,9 +60,9 @@ class SportsPressPlayerSettingsPage {
);
add_settings_field(
'statistics',
__( 'Statistics', 'sportspress' ),
array( $this, 'statistics_callback' ),
'performance',
__( 'Performance', 'sportspress' ),
array( $this, 'performance_callback' ),
'sportspress_players',
'list'
);
@@ -161,9 +161,9 @@ class SportsPressPlayerSettingsPage {
<?
}
function statistics_callback() {
function performance_callback() {
$args = array(
'post_type' => 'sp_statistic',
'post_type' => 'sp_performance',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
@@ -190,8 +190,8 @@ class SportsPressPlayerSettingsPage {
</table>
<div class="tablenav bottom">
<div class="alignleft actions">
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_statistic' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_statistic' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_performance' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_performance' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
</div>
<br class="clear">
</div>

View File

@@ -1,6 +1,6 @@
<?php
if ( !function_exists( 'sportspress_event_statistics' ) ) {
function sportspress_event_statistics( $id = null ) {
if ( !function_exists( 'sportspress_event_performance' ) ) {
function sportspress_event_performance( $id = null ) {
global $sportspress_options;
if ( ! $id )
@@ -9,10 +9,10 @@ if ( !function_exists( 'sportspress_event_statistics' ) ) {
$teams = (array)get_post_meta( $id, 'sp_team', false );
$staff = (array)get_post_meta( $id, 'sp_staff', false );
$stats = (array)get_post_meta( $id, 'sp_players', true );
$statistic_labels = sportspress_get_var_labels( 'sp_statistic' );
$link_posts = sportspress_array_value( $sportspress_options, 'event_statistics_link_posts', true );
$sortable = sportspress_array_value( $sportspress_options, 'event_statistics_sortable', true );
$responsive = sportspress_array_value( $sportspress_options, 'event_statistics_responsive', true );
$performance_labels = sportspress_get_var_labels( 'sp_performance' );
$link_posts = sportspress_array_value( $sportspress_options, 'event_performance_link_posts', true );
$sortable = sportspress_array_value( $sportspress_options, 'event_performance_sortable', true );
$responsive = sportspress_array_value( $sportspress_options, 'event_performance_responsive', true );
$output = '';
@@ -28,12 +28,12 @@ if ( !function_exists( 'sportspress_event_statistics' ) ) {
$output .= '<h3>' . get_the_title( $team_id ) . '</h3>';
$output .= '<div class="sp-table-wrapper">' .
'<table class="sp-event-statistics sp-data-table' . ( $responsive ? ' sp-responsive-table' : '' ) . ( $sortable ? ' sp-sortable-table' : '' ) . '">' . '<thead>' . '<tr>';
'<table class="sp-event-performance sp-data-table' . ( $responsive ? ' sp-responsive-table' : '' ) . ( $sortable ? ' sp-sortable-table' : '' ) . '">' . '<thead>' . '<tr>';
$output .= '<th class="data-number">#</th>';
$output .= '<th class="data-number">' . __( 'Player', 'sportspress' ) . '</th>';
foreach( $statistic_labels as $key => $label ):
foreach( $performance_labels as $key => $label ):
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
endforeach;
@@ -65,7 +65,7 @@ if ( !function_exists( 'sportspress_event_statistics' ) ) {
$output .= '<td class="data-name">' . $name . '</td>';
foreach( $statistic_labels as $key => $label ):
foreach( $performance_labels as $key => $label ):
if ( $key == 'name' )
continue;
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
@@ -100,7 +100,7 @@ if ( !function_exists( 'sportspress_event_statistics' ) ) {
$row = $data[0];
foreach( $statistic_labels as $key => $label ):
foreach( $performance_labels as $key => $label ):
if ( $key == 'name' ):
continue;
endif;
@@ -120,7 +120,7 @@ if ( !function_exists( 'sportspress_event_statistics' ) ) {
endforeach;
return apply_filters( 'sportspress_event_statistics', $output );
return apply_filters( 'sportspress_event_performance', $output );
}
}

View File

@@ -48,16 +48,16 @@ if ( !function_exists( 'sportspress_player_gallery' ) ) {
// Remove the first row to leave us with the actual data
unset( $data[0] );
$statistics = sportspress_array_value( $r, 'statistics', null );
$performance = sportspress_array_value( $r, 'performance', null );
if ( $r['orderby'] == 'default' ):
$r['orderby'] = get_post_meta( $id, 'sp_orderby', true );
$r['order'] = get_post_meta( $id, 'sp_order', true );
else:
global $sportspress_statistic_priorities;
$sportspress_statistic_priorities = array(
global $sportspress_performance_priorities;
$sportspress_performance_priorities = array(
array(
'statistic' => $r['orderby'],
'key' => $r['orderby'],
'order' => $r['order'],
),
);
@@ -94,7 +94,7 @@ if ( !function_exists( 'sportspress_player_gallery' ) ) {
if ( is_int( $r['number'] ) && $r['number'] > 0 )
$limit = $r['number'];
foreach( $data as $player_id => $statistics ):
foreach( $data as $player_id => $performance ):
if ( $r['show_names_on_hover'] ):
$caption = get_the_title( $player_id );

View File

@@ -1,6 +1,6 @@
<?php
if ( !function_exists( 'sportspress_player_league_statistics' ) ) {
function sportspress_player_league_statistics( $league, $id = null ) {
if ( !function_exists( 'sportspress_player_league_performance' ) ) {
function sportspress_player_league_performance( $league, $id = null ) {
if ( ! $league )
return false;
@@ -8,7 +8,7 @@ if ( !function_exists( 'sportspress_player_league_statistics' ) ) {
if ( ! $id )
$id = get_the_ID();
$data = sportspress_get_player_statistics_data( $id, $league->term_id );
$data = sportspress_get_player_performance_data( $id, $league->term_id );
// The first row should be column labels
$labels = $data[0];
@@ -22,7 +22,7 @@ if ( !function_exists( 'sportspress_player_league_statistics' ) ) {
$output = '<h4 class="sp-table-caption">' . $league->name . '</h4>' .
'<div class="sp-table-wrapper">' .
'<table class="sp-player-statistics sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
'<table class="sp-player-performance sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
foreach( $labels as $key => $label ):
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
@@ -48,7 +48,7 @@ if ( !function_exists( 'sportspress_player_league_statistics' ) ) {
$output .= '</tbody>' . '</table>' . '</div>';
return apply_filters( 'sportspress_player_league_statistics', $output );
return apply_filters( 'sportspress_player_league_performance', $output );
}
}

View File

@@ -9,7 +9,7 @@ if ( !function_exists( 'sportspress_player_list' ) ) {
$defaults = array(
'number' => -1,
'statistics' => null,
'performance' => null,
'orderby' => 'default',
'order' => 'ASC',
'show_all_players_link' => false,
@@ -31,16 +31,16 @@ if ( !function_exists( 'sportspress_player_list' ) ) {
// Remove the first row to leave us with the actual data
unset( $data[0] );
$statistics = sportspress_array_value( $r, 'statistics', null );
$performance = sportspress_array_value( $r, 'performance', null );
if ( $r['orderby'] == 'default' ):
$r['orderby'] = get_post_meta( $id, 'sp_orderby', true );
$r['order'] = get_post_meta( $id, 'sp_order', true );
else:
global $sportspress_statistic_priorities;
$sportspress_statistic_priorities = array(
global $sportspress_performance_priorities;
$sportspress_performance_priorities = array(
array(
'statistic' => $r['orderby'],
'key' => $r['orderby'],
'order' => $r['order'],
),
);
@@ -54,7 +54,7 @@ if ( !function_exists( 'sportspress_player_list' ) ) {
endif;
foreach( $labels as $key => $label ):
if ( ! is_array( $statistics ) || $key == 'name' || in_array( $key, $statistics ) )
if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) )
$output .= '<th class="data-' . $key . '">'. $label . '</th>';
endforeach;
@@ -91,7 +91,7 @@ if ( !function_exists( 'sportspress_player_list' ) ) {
foreach( $labels as $key => $value ):
if ( $key == 'name' )
continue;
if ( ! is_array( $statistics ) || in_array( $key, $statistics ) )
if ( ! is_array( $performance ) || in_array( $key, $performance ) )
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '&mdash;' ) . '</td>';
endforeach;

View File

@@ -0,0 +1,22 @@
<?php
if ( !function_exists( 'sportspress_player_performance' ) ) {
function sportspress_player_performance( $id = null ) {
if ( ! $id )
$id = get_the_ID();
$leagues = get_the_terms( $id, 'sp_league' );
$output = '';
// Loop through performance for each league
if ( is_array( $leagues ) ):
foreach ( $leagues as $league ):
$output .= sportspress_player_league_performance( $league, $id );
endforeach;
endif;
return apply_filters( 'sportspress_player_performance', $output );
}
}

View File

@@ -6,7 +6,7 @@ if ( !function_exists( 'sportspress_player_roster' ) ) {
$id = get_the_ID();
$defaults = array(
'statistics' => null,
'performance' => null,
'orderby' => 'default',
'order' => 'ASC',
);
@@ -23,16 +23,16 @@ if ( !function_exists( 'sportspress_player_roster' ) ) {
// Remove the first row to leave us with the actual data
unset( $data[0] );
$statistics = sportspress_array_value( $r, 'statistics', null );
$performance = sportspress_array_value( $r, 'performance', null );
if ( $r['orderby'] == 'default' ):
$r['orderby'] = get_post_meta( $id, 'sp_orderby', true );
$r['order'] = get_post_meta( $id, 'sp_order', true );
else:
global $sportspress_statistic_priorities;
$sportspress_statistic_priorities = array(
global $sportspress_performance_priorities;
$sportspress_performance_priorities = array(
array(
'statistic' => $r['orderby'],
'key' => $r['orderby'],
'order' => $r['order'],
),
);
@@ -68,7 +68,7 @@ if ( !function_exists( 'sportspress_player_roster' ) ) {
foreach( $labels as $key => $value ):
if ( $key == 'name' )
continue;
if ( ! is_array( $statistics ) || in_array( $key, $statistics ) )
if ( ! is_array( $performance ) || in_array( $key, $performance ) )
$rows .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '&mdash;' ) . '</td>';
endforeach;
@@ -89,7 +89,7 @@ if ( !function_exists( 'sportspress_player_roster' ) ) {
endif;
foreach( $labels as $key => $label ):
if ( ! is_array( $statistics ) || $key == 'name' || in_array( $key, $statistics ) )
if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) )
$output .= '<th class="data-' . $key . '">'. $label . '</th>';
endforeach;
$output .= '</tr>' . '</thead>' . '<tbody>' . $rows . '</tbody>' . '</table>' . '</div>';

View File

@@ -1,22 +0,0 @@
<?php
if ( !function_exists( 'sportspress_player_statistics' ) ) {
function sportspress_player_statistics( $id = null ) {
if ( ! $id )
$id = get_the_ID();
$leagues = get_the_terms( $id, 'sp_league' );
$output = '';
// Loop through statistics for each league
if ( is_array( $leagues ) ):
foreach ( $leagues as $league ):
$output .= sportspress_player_league_statistics( $league, $id );
endforeach;
endif;
return apply_filters( 'sportspress_player_statistics', $output );
}
}

View File

@@ -23,7 +23,7 @@ function sportspress_position_term_init() {
'hierarchical' => true,
'rewrite' => array( 'slug' => get_option( 'sportspress_position_slug', 'position' ) ),
);
$object_types = array( 'sp_player', 'sp_statistic', 'sp_metric', 'attachment' );
$object_types = array( 'sp_player', 'sp_performance', 'sp_metric', 'attachment' );
register_taxonomy( 'sp_position', $object_types, $args );
foreach ( $object_types as $object_type ):
register_taxonomy_for_object_type( 'sp_league', $object_type );

View File

@@ -119,9 +119,9 @@ if ( class_exists( 'WP_Importer' ) ) {
$league = ( empty( $_POST['sp_league'] ) ? false : $_POST['sp_league'] );
$season = ( empty( $_POST['sp_season'] ) ? false : $_POST['sp_season'] );
// Get labels from result and statistic post types
// Get labels from result and performance post types
$result_labels = sportspress_get_var_labels( 'sp_result' );
$statistic_labels = sportspress_get_var_labels( 'sp_statistic' );
$performance_labels = sportspress_get_var_labels( 'sp_performance' );
while ( ( $row = fgetcsv( $handle, 0, $this->delimiter ) ) !== FALSE ):
@@ -133,7 +133,7 @@ if ( class_exists( 'WP_Importer' ) ) {
// Add new event if date is given
if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ):
// Add player statistics to last event if available
// Add player performance to last event if available
if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ):
update_post_meta( $id, 'sp_players', $players );
endif;
@@ -155,7 +155,7 @@ if ( class_exists( 'WP_Importer' ) ) {
// Insert event
$id = wp_insert_post( $args );
// Initialize statistics array
// Initialize performance array
$players = array();
// Flag as import
@@ -331,7 +331,7 @@ if ( class_exists( 'WP_Importer' ) ) {
// Add new player if player name is given
if ( sizeof( $player ) > 0 && ! empty( $player[0] ) ):
// Get and unset player name leaving us with the statistics
// Get and unset player name leaving us with the performance
$player_name = $player[0];
unset( $player[0] );
@@ -378,17 +378,17 @@ if ( class_exists( 'WP_Importer' ) ) {
// Add player to event
add_post_meta( $id, 'sp_player', $player_id );
// Add player statistics to array if team is available
// Add player performance to array if team is available
if ( isset( $team_id ) ):
// Initialize statistics array
$statistics = array();
// Initialize performance array
$performance = array();
// Map keys to player statistics
foreach ( $statistic_labels as $key => $label ):
$statistics[ $key ] = array_shift( $player );
// Map keys to player performance
foreach ( $performance_labels as $key => $label ):
$performance[ $key ] = array_shift( $player );
endforeach;
$players[ $team_id ][ $player_id ] = $statistics;
$players[ $team_id ][ $player_id ] = $performance;
// Get player teams
$player_teams = get_post_meta( $player_id, 'sp_team', false );
@@ -415,7 +415,7 @@ if ( class_exists( 'WP_Importer' ) ) {
endwhile;
// Add player statistics to last event if available
// Add player performance to last event if available
if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ):
update_post_meta( $id, 'sp_players', $players );
endif;

View File

@@ -78,7 +78,7 @@ class SP_Widget_Player_Gallery extends WP_Widget {
'name' => __( 'Name', 'sportspress' ),
'eventsplayed' => __( 'Played', 'sportspress' )
),
'post_type' => 'sp_statistic',
'post_type' => 'sp_performance',
'name' => $this->get_field_name('orderby'),
'id' => $this->get_field_id('orderby'),
'selected' => $orderby,

View File

@@ -11,7 +11,7 @@ class SP_Widget_Player_list extends WP_Widget {
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
$id = empty($instance['id']) ? null : $instance['id'];
$number = empty($instance['number']) ? null : $instance['number'];
$statistics = $instance['statistics'];
$performance = $instance['performance'];
$orderby = empty($instance['orderby']) ? 'default' : $instance['orderby'];
$order = empty($instance['order']) ? 'ASC' : $instance['order'];
$show_all_players_link = empty($instance['show_all_players_link']) ? false : $instance['show_all_players_link'];
@@ -19,7 +19,7 @@ class SP_Widget_Player_list extends WP_Widget {
if ( $title )
echo $before_title . $title . $after_title;
echo '<div id="sp_player_list_wrap">';
echo sportspress_player_list( $id, array( 'number' => $number, 'statistics' => $statistics, 'orderby' => $orderby , 'order' => $order, 'show_all_players_link' => $show_all_players_link ) );
echo sportspress_player_list( $id, array( 'number' => $number, 'performance' => $performance, 'orderby' => $orderby , 'order' => $order, 'show_all_players_link' => $show_all_players_link ) );
echo '</div>';
echo $after_widget;
}
@@ -29,7 +29,7 @@ class SP_Widget_Player_list extends WP_Widget {
$instance['title'] = strip_tags($new_instance['title']);
$instance['id'] = intval($new_instance['id']);
$instance['number'] = intval($new_instance['number']);
$instance['statistics'] = (array)$new_instance['statistics'];
$instance['performance'] = (array)$new_instance['performance'];
$instance['orderby'] = strip_tags($new_instance['orderby']);
$instance['order'] = strip_tags($new_instance['order']);
$instance['show_all_players_link'] = $new_instance['show_all_players_link'];
@@ -38,11 +38,11 @@ class SP_Widget_Player_list extends WP_Widget {
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'number' => 5, 'statistics' => null, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => true ) );
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'number' => 5, 'performance' => null, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => true ) );
$title = strip_tags($instance['title']);
$id = intval($instance['id']);
$number = intval($instance['number']);
$statistics = $instance['statistics'];
$performance = $instance['performance'];
$orderby = strip_tags($instance['orderby']);
$order = strip_tags($instance['order']);
$show_all_players_link = $instance['show_all_players_link'];
@@ -70,23 +70,23 @@ class SP_Widget_Player_list extends WP_Widget {
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
<p class="sp-prefs">
<?php _e( 'Statistics:', 'sportspress' ); ?><br>
<?php _e( 'Performance:', 'sportspress' ); ?><br>
<?php
$args = array(
'post_type' => 'sp_statistic',
'post_type' => 'sp_performance',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$the_statistics = get_posts( $args );
$the_performance = get_posts( $args );
$field_name = $this->get_field_name('statistics') . '[]';
$field_id = $this->get_field_id('statistics');
$field_name = $this->get_field_name('performance') . '[]';
$field_id = $this->get_field_id('performance');
?>
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . 'eventsplayed'; ?>" value="<?php echo 'eventsplayed'; ?>" <?php if ( is_array( $statistics) && in_array( 'eventsplayed', $statistics ) ): ?>checked="checked"<?php endif; ?>><?php _e( 'Played', 'sportspress' ); ?></label>
<?php foreach ( $the_statistics as $column ): ?>
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . $column->post_name; ?>" value="<?php echo $column->post_name; ?>" <?php if ( $statistics === null || in_array( $column->post_name, $statistics ) ): ?>checked="checked"<?php endif; ?>><?php echo $column->post_title; ?></label>
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . 'eventsplayed'; ?>" value="<?php echo 'eventsplayed'; ?>" <?php if ( is_array( $performance) && in_array( 'eventsplayed', $performance ) ): ?>checked="checked"<?php endif; ?>><?php _e( 'Played', 'sportspress' ); ?></label>
<?php foreach ( $the_performance as $column ): ?>
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . $column->post_name; ?>" value="<?php echo $column->post_name; ?>" <?php if ( $performance === null || in_array( $column->post_name, $performance ) ): ?>checked="checked"<?php endif; ?>><?php echo $column->post_title; ?></label>
<?php endforeach; ?>
</p>
@@ -99,7 +99,7 @@ class SP_Widget_Player_list extends WP_Widget {
'name' => __( 'Name', 'sportspress' ),
'eventsplayed' => __( 'Played', 'sportspress' )
),
'post_type' => 'sp_statistic',
'post_type' => 'sp_performance',
'name' => $this->get_field_name('orderby'),
'id' => $this->get_field_id('orderby'),
'selected' => $orderby,