From 233d39eb8fbf1d4df669c1cf3f52e2422a1bc9d6 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Mon, 6 Jan 2014 12:21:05 +1100 Subject: [PATCH] Organize config table --- admin/post-types/column.php | 1 - admin/post-types/statistic.php | 1 - admin/presets/baseball.php | 14 ++++++++++++++ admin/settings/config.php | 30 ++++++++++++++++++------------ assets/css/admin.css | 4 ++++ sportspress-actions.php | 3 --- sportspress-functions.php | 7 ++++++- 7 files changed, 42 insertions(+), 18 deletions(-) diff --git a/admin/post-types/column.php b/admin/post-types/column.php index f2fcef18..4a4d715f 100644 --- a/admin/post-types/column.php +++ b/admin/post-types/column.php @@ -25,7 +25,6 @@ function sp_column_edit_columns() { 'title' => __( 'Label', 'sportspress' ), 'sp_key' => __( 'Key', 'sportspress' ), 'sp_format' => __( 'Format', 'sportspress' ), - 'sp_precision' => __( 'Precision', 'sportspress' ), 'sp_equation' => __( 'Equation', 'sportspress' ), 'sp_order' => __( 'Sort Order', 'sportspress' ), ); diff --git a/admin/post-types/statistic.php b/admin/post-types/statistic.php index 4b510b28..588e7458 100644 --- a/admin/post-types/statistic.php +++ b/admin/post-types/statistic.php @@ -25,7 +25,6 @@ function sp_statistic_edit_columns() { 'title' => __( 'Label', 'sportspress' ), 'sp_key' => __( 'Key', 'sportspress' ), 'sp_format' => __( 'Format', 'sportspress' ), - 'sp_precision' => __( 'Precision', 'sportspress' ), 'sp_equation' => __( 'Equation', 'sportspress' ), 'sp_order' => __( 'Sort Order', 'sportspress' ), ); diff --git a/admin/presets/baseball.php b/admin/presets/baseball.php index f16db198..cf22f13d 100644 --- a/admin/presets/baseball.php +++ b/admin/presets/baseball.php @@ -11,6 +11,8 @@ $sportspress_sports['baseball'] = array( 'post_name' => 'w', 'meta' => array( 'sp_equation' => '$w', + 'sp_format' => 'integer', + 'sp_precision' => 1, 'sp_priority' => 1, 'sp_order' => 'DESC', ), @@ -20,6 +22,8 @@ $sportspress_sports['baseball'] = array( 'post_name' => 'l', 'meta' => array( 'sp_equation' => '$l', + 'sp_format' => 'integer', + 'sp_precision' => 1, 'sp_priority' => 2, 'sp_order' => 'ASC', ), @@ -29,6 +33,8 @@ $sportspress_sports['baseball'] = array( 'post_name' => 'pct', 'meta' => array( 'sp_equation' => '$w / $eventsplayed', + 'sp_format' => 'decimal', + 'sp_precision' => 3, ), ), array( @@ -36,6 +42,8 @@ $sportspress_sports['baseball'] = array( 'post_name' => 'gb', 'meta' => array( 'sp_equation' => '( $wmax + $l - $w - $lmax ) / 2', + 'sp_format' => 'decimal', + 'sp_precision' => 2, ), ), array( @@ -43,6 +51,8 @@ $sportspress_sports['baseball'] = array( 'post_name' => 'rs', 'meta' => array( 'sp_equation' => '$rfor', + 'sp_format' => 'integer', + 'sp_precision' => 1, 'sp_priority' => 3, 'sp_order' => 'DESC', ), @@ -52,6 +62,8 @@ $sportspress_sports['baseball'] = array( 'post_name' => 'ra', 'meta' => array( 'sp_equation' => '$ragainst', + 'sp_format' => 'integer', + 'sp_precision' => 1, ), ), array( @@ -59,6 +71,8 @@ $sportspress_sports['baseball'] = array( 'post_name' => 'strk', 'meta' => array( 'sp_equation' => '$streak', + 'sp_format' => 'integer', + 'sp_precision' => 1, ), ), ), diff --git a/admin/settings/config.php b/admin/settings/config.php index 7d39a98d..230e4da0 100644 --- a/admin/settings/config.php +++ b/admin/settings/config.php @@ -9,13 +9,12 @@ $data = get_posts( $args ); ?>

- +
- @@ -25,14 +24,13 @@ - - +
post_title; ?> post_name; ?> ID ); ?>ID ); ?> ID ); ?> ID ); ?>
@@ -48,13 +46,12 @@ $data = get_posts( $args ); ?>

- +
- @@ -64,14 +61,13 @@ - - +
post_title; ?> post_name; ?> ID ); ?>ID ); ?> ID ); ?> ID ); ?>
@@ -87,12 +83,14 @@ $data = get_posts( $args ); ?>

- +
+ + @@ -100,11 +98,13 @@ + + - +
post_title; ?> post_name; ?> ID ); ?>
@@ -120,22 +120,28 @@ $data = get_posts( $args ); ?>

- +
+ + + > + + + - +
post_title; ?> post_name; ?>
\ No newline at end of file diff --git a/assets/css/admin.css b/assets/css/admin.css index d884b840..cbc1ab1e 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -103,6 +103,10 @@ min-width: 14px; width: 100%; } +.sp-config-table th, +.sp-config-table td { + width: 20%; +} .widefat th.column-sp_logo, .widefat td.column-sp_logo { width: 32px; diff --git a/sportspress-actions.php b/sportspress-actions.php index 2694b55e..3c524129 100644 --- a/sportspress-actions.php +++ b/sportspress-actions.php @@ -79,9 +79,6 @@ function sp_manage_posts_custom_column( $column, $post_id ) { case 'sp_format': echo sp_get_post_format( $post_id ); break; - case 'sp_precision': - echo sp_get_post_precision( $post_id ); - break; case 'sp_player': echo sp_the_posts( $post_id, 'sp_player' ); break; diff --git a/sportspress-functions.php b/sportspress-functions.php index 289a7d47..b231de23 100644 --- a/sportspress-functions.php +++ b/sportspress-functions.php @@ -106,7 +106,12 @@ if ( !function_exists( 'sp_get_post_format' ) ) { $format = get_post_meta ( $post_id, 'sp_format', true ); if ( $format ): global $sportspress_config_formats; - return sp_array_value( $sportspress_config_formats, $format, '—' ); + $format_str = sp_array_value( $sportspress_config_formats, $format, '—' ); + if ( in_array( $format, array( 'decimal', 'time' ) ) ): + return $format_str . ' (' . sp_get_post_precision( $post_id ) . ')'; + else: + return $format_str; + endif; else: return '—'; endif;