Add positions to statistics and metrics

This commit is contained in:
Brian Miyaji
2014-01-21 20:35:13 +11:00
parent 08ce1eea27
commit 9cde21de71
33 changed files with 2922 additions and 2685 deletions

View File

@@ -1,8 +1,8 @@
<?php
function sportspress_column_post_init() {
$name = __( 'Table Columns', 'sportspress' );
$singular_name = __( 'Table Column', 'sportspress' );
$lowercase_name = __( 'table columns', 'sportspress' );
$name = __( 'Columns', 'sportspress' );
$singular_name = __( 'Column', 'sportspress' );
$lowercase_name = __( 'columns', 'sportspress' );
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name, true );
$args = array(
'label' => $name,
@@ -24,8 +24,8 @@ function sportspress_column_edit_columns() {
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_key' => __( 'Key', 'sportspress' ),
'sp_format' => __( 'Format', 'sportspress' ),
'sp_equation' => __( 'Equation', 'sportspress' ),
'sp_precision' => __( 'Precision', 'sportspress' ),
'sp_order' => __( 'Sort Order', 'sportspress' ),
);
return $columns;
@@ -37,8 +37,6 @@ function sportspress_column_meta_init() {
}
function sportspress_column_details_meta( $post ) {
$formats = sportspress_get_config_formats();
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
$order = get_post_meta( $post->ID, 'sp_order', true );
$priority = get_post_meta( $post->ID, 'sp_priority', true );
@@ -51,20 +49,6 @@ function sportspress_column_details_meta( $post ) {
<p>
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
</p>
<p><strong><?php _e( 'Format', 'sportspress' ); ?></strong></p>
<p class="sp-format-selector">
<select name="sp_format">
<?php
foreach ( $formats as $key => $value ):
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
endforeach;
?>
</select>
</p>
<p><strong><?php _e( 'Precision', 'sportspress' ); ?></strong></p>
<p class="sp-precision-selector">
<input name="sp_precision" type="text" size="4" id="sp_precision" value="<?php echo $precision; ?>" placeholder="1">
</p>
<p><strong><?php _e( 'Equation', 'sportspress' ); ?></strong></p>
<p class="sp-equation-selector">
<?php
@@ -73,6 +57,10 @@ function sportspress_column_details_meta( $post ) {
endforeach;
?>
</p>
<p><strong><?php _e( 'Precision', 'sportspress' ); ?></strong></p>
<p class="sp-precision-selector">
<input name="sp_precision" type="text" size="4" id="sp_precision" value="<?php echo $precision; ?>" placeholder="1">
</p>
<p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p>
<p class="sp-order-selector">
<select name="sp_priority">

View File

@@ -8,6 +8,7 @@ function sportspress_event_post_init() {
'label' => $name,
'labels' => $labels,
'public' => true,
'has_archive' => true,
'hierarchical' => false,
'supports' => array( 'title', 'author', 'thumbnail', 'comments' ),
'register_meta_box_cb' => 'sportspress_event_meta_init',

View File

@@ -1,8 +1,8 @@
<?php
function sportspress_metric_post_init() {
$name = __( 'Player Metrics', 'sportspress' );
$singular_name = __( 'Player Metric', 'sportspress' );
$lowercase_name = __( 'player metrics', 'sportspress' );
$name = __( 'Metrics', 'sportspress' );
$singular_name = __( 'Metric', 'sportspress' );
$lowercase_name = __( 'metrics', 'sportspress' );
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name, true );
$args = array(
'label' => $name,
@@ -12,7 +12,6 @@ function sportspress_metric_post_init() {
'show_in_menu' => false,
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes' ),
'register_meta_box_cb' => 'sportspress_metric_meta_init',
'capability_type' => 'sp_config'
);
register_post_type( 'sp_metric', $args );
@@ -23,75 +22,8 @@ function sportspress_metric_edit_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_key' => __( 'Key', 'sportspress' ),
'sp_format' => __( 'Format', 'sportspress' ),
'sp_equation' => __( 'Equation', 'sportspress' ),
'sp_order' => __( 'Sort Order', 'sportspress' ),
'sp_positions' => __( 'Positions', 'sportspress' ),
);
return $columns;
}
add_filter( 'manage_edit-sp_metric_columns', 'sportspress_metric_edit_columns' );
function sportspress_metric_meta_init() {
add_meta_box( 'sp_equationdiv', __( 'Details', 'sportspress' ), 'sportspress_metric_equation_meta', 'sp_metric', 'normal', 'high' );
}
function sportspress_metric_equation_meta( $post ) {
$formats = sportspress_get_config_formats();
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
$order = get_post_meta( $post->ID, 'sp_order', true );
$priority = get_post_meta( $post->ID, 'sp_priority', true );
$precision = get_post_meta( $post->ID, 'sp_precision', true );
// Defaults
if ( $precision == '' ) $precision = 1;
?>
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
</p>
<p><strong><?php _e( 'Format', 'sportspress' ); ?></strong></p>
<p class="sp-format-selector">
<select name="sp_format">
<?php
foreach ( $formats as $key => $value ):
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
endforeach;
?>
</select>
</p>
<p><strong><?php _e( 'Precision', 'sportspress' ); ?></strong></p>
<p class="sp-precision-selector">
<input name="sp_precision" type="text" size="4" id="sp_precision" value="<?php echo $precision; ?>" placeholder="1">
</p>
<p><strong><?php _e( 'Equation', 'sportspress' ); ?></strong></p>
<p class="sp-equation-selector">
<?php
foreach ( $equation as $piece ):
sportspress_get_equation_selector( $post->ID, $piece, array( 'player_event' ) );
endforeach;
?>
</p>
<p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p>
<p class="sp-order-selector">
<select name="sp_priority">
<?php
$options = array( '0' => __( 'Disable', 'sportspress' ), '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', );
foreach ( $options as $key => $value ):
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
endforeach;
?>
</select>
<select name="sp_order"<?php if ( ! $priority ): ?> disabled="disabled;"<?php endif; ?>>
<?php
$options = array( 'DESC' => __( 'Descending', 'sportspress' ), 'ASC' => __( 'Ascending', 'sportspress' ) );
foreach ( $options as $key => $value ):
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $order, false ), $value );
endforeach;
?>
</select>
</p>
<?php
sportspress_nonce();
}

View File

@@ -45,10 +45,10 @@ function sportspress_player_meta_init( $post ) {
add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sportspress_player_team_meta', 'sp_player', 'side', 'high' );
if ( $leagues && ! empty( $leagues ) && $seasons && is_array( $seasons ) && is_object( $seasons[0] ) ):
add_meta_box( 'sp_statsdiv', __( 'Player Statistics', 'sportspress' ), 'sportspress_player_stats_meta', 'sp_player', 'normal', 'high' );
add_meta_box( 'sp_statsdiv', __( 'Statistics', 'sportspress' ), 'sportspress_player_stats_meta', 'sp_player', 'normal', 'high' );
endif;
add_meta_box( 'sp_metricsdiv', __( 'Player Metrics', 'sportspress' ), 'sportspress_player_metrics_meta', 'sp_player', 'normal', 'high' );
add_meta_box( 'sp_metricsdiv', __( 'Metrics', 'sportspress' ), 'sportspress_player_metrics_meta', 'sp_player', 'normal', 'high' );
add_meta_box( 'sp_profilediv', __( 'Profile' ), 'sportspress_player_profile_meta', 'sp_player', 'normal', 'high' );
}

View File

@@ -24,7 +24,6 @@ function sportspress_result_edit_columns() {
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_key' => __( 'Key', 'sportspress' ),
'sp_format' => __( 'Format', 'sportspress' ),
);
return $columns;
}
@@ -41,16 +40,6 @@ function sportspress_result_details_meta( $post ) {
<p>
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
</p>
<p><strong><?php _e( 'Format', 'sportspress' ); ?></strong></p>
<p class="sp-format-selector">
<select name="sp_format">
<?php
foreach ( $formats as $key => $value ):
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
endforeach;
?>
</select>
</p>
<?php
sportspress_nonce();
}

View File

@@ -1,8 +1,8 @@
<?php
function sportspress_statistic_post_init() {
$name = __( 'Player Statistics', 'sportspress' );
$singular_name = __( 'Player Statistic', 'sportspress' );
$lowercase_name = __( 'player statistics', 'sportspress' );
$name = __( 'Statistics', 'sportspress' );
$singular_name = __( 'Statistic', 'sportspress' );
$lowercase_name = __( 'statistics', 'sportspress' );
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name, true );
$args = array(
'label' => $name,
@@ -23,10 +23,8 @@ function sportspress_statistic_edit_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_key' => __( 'Key', 'sportspress' ),
'sp_format' => __( 'Format', 'sportspress' ),
'sp_positions' => __( 'Positions', 'sportspress' ),
'sp_equation' => __( 'Equation', 'sportspress' ),
'sp_order' => __( 'Sort Order', 'sportspress' ),
);
return $columns;
}
@@ -37,34 +35,8 @@ function sportspress_statistic_meta_init() {
}
function sportspress_statistic_equation_meta( $post ) {
$formats = sportspress_get_config_formats();
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
$order = get_post_meta( $post->ID, 'sp_order', true );
$priority = get_post_meta( $post->ID, 'sp_priority', true );
$precision = get_post_meta( $post->ID, 'sp_precision', true );
// Defaults
if ( $precision == '' ) $precision = 1;
?>
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
</p>
<p><strong><?php _e( 'Format', 'sportspress' ); ?></strong></p>
<p class="sp-format-selector">
<select name="sp_format">
<?php
foreach ( $formats as $key => $value ):
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
endforeach;
?>
</select>
</p>
<p><strong><?php _e( 'Precision', 'sportspress' ); ?></strong></p>
<p class="sp-precision-selector">
<input name="sp_precision" type="text" size="4" id="sp_precision" value="<?php echo $precision; ?>" placeholder="1">
</p>
<p><strong><?php _e( 'Equation', 'sportspress' ); ?></strong></p>
<p class="sp-equation-selector">
<?php
@@ -73,25 +45,6 @@ function sportspress_statistic_equation_meta( $post ) {
endforeach;
?>
</p>
<p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p>
<p class="sp-order-selector">
<select name="sp_priority">
<?php
$options = array( '0' => __( 'Disable', 'sportspress' ), '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', );
foreach ( $options as $key => $value ):
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
endforeach;
?>
</select>
<select name="sp_order"<?php if ( ! $priority ): ?> disabled="disabled;"<?php endif; ?>>
<?php
$options = array( 'DESC' => __( 'Descending', 'sportspress' ), 'ASC' => __( 'Ascending', 'sportspress' ) );
foreach ( $options as $key => $value ):
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $order, false ), $value );
endforeach;
?>
</select>
</p>
<?php
sportspress_nonce();
}

View File

@@ -29,7 +29,7 @@ function sportspress_team_meta_init( $post ) {
add_meta_box( 'postimagediv', __( 'Logo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_team', 'side', 'low' );
if ( $leagues && $seasons ):
add_meta_box( 'sp_columnssdiv', __( 'Table Columns', 'sportspress' ), 'sportspress_team_columns_meta', 'sp_team', 'normal', 'high' );
add_meta_box( 'sp_columnssdiv', __( 'Columns', 'sportspress' ), 'sportspress_team_columns_meta', 'sp_team', 'normal', 'high' );
endif;
}