diff --git a/includes/admin/post-types/class-sp-admin-cpt-metric.php b/includes/admin/post-types/class-sp-admin-cpt-metric.php
index 319af6db..5ea0ced8 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-metric.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-metric.php
@@ -42,6 +42,8 @@ class SP_Admin_CPT_Metric extends SP_Admin_CPT {
'cb' => '',
'title' => __( 'Label', 'sportspress' ),
'sp_key' => __( 'Variable', 'sportspress' ),
+ 'sp_prepend' => __( 'Prepend', 'sportspress' ),
+ 'sp_append' => __( 'Append', 'sportspress' ),
'sp_description' => __( 'Description', 'sportspress' ),
);
return apply_filters( 'sportspress_metric_admin_columns', $columns );
@@ -57,6 +59,12 @@ class SP_Admin_CPT_Metric extends SP_Admin_CPT {
global $post;
echo $post->post_name;
break;
+ case 'sp_prepend':
+ echo sp_get_post_prepend( $post_id );
+ break;
+ case 'sp_append':
+ echo sp_get_post_append( $post_id );
+ break;
case 'sp_description':
global $post;
echo '' . $post->post_excerpt . '';
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-metric-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-metric-details.php
index 6d1f4ee3..b3991885 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-metric-details.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-metric-details.php
@@ -23,12 +23,30 @@ class SP_Meta_Box_Metric_Details extends SP_Meta_Box_Config {
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
+ $prepend = get_post_meta( $post->ID, 'sp_prepend', true );
+ $append = get_post_meta( $post->ID, 'sp_append', true );
?>
+
+
+
+
+
+
+
+
ID, 'sp_prepend', true );
+ $append = get_post_meta( $var->ID, 'sp_append', true );
?>
post_title; ?>
-
+
+ ' . $prepend . '' : '' ); ?>
+
+ ' . $append . '' : '' ); ?>
+
|
|
+ |
+ |
|
|
@@ -303,12 +305,14 @@
>
| post_title; ?> |
post_name; ?> |
+ ID ); ?> |
+ ID ); ?> |
post_excerpt; ?> |
|
- |
+ |
diff --git a/includes/class-sp-player-list.php b/includes/class-sp-player-list.php
index e1ae632d..5f448a8f 100644
--- a/includes/class-sp-player-list.php
+++ b/includes/class-sp-player-list.php
@@ -53,6 +53,24 @@ class SP_Player_List extends SP_Custom_Post {
// Get labels from result variables
$result_labels = (array)sp_get_var_labels( 'sp_result' );
+
+ // Get prepend and append from metric variables
+ $args = array(
+ 'post_type' => 'sp_metric',
+ 'numberposts' => -1,
+ 'posts_per_page' => -1,
+ 'orderby' => 'menu_order',
+ 'order' => 'ASC',
+ );
+
+ $vars = get_posts( $args );
+
+ $pa = array();
+ foreach ( $vars as $var ) {
+ $prepend = get_post_meta( $var->ID, 'sp_prepend', true );
+ $append = get_post_meta( $var->ID, 'sp_append', true );
+ $pa[ $var->post_name ] = array( $prepend, $append );
+ }
// Get players automatically if set to auto
if ( 'auto' == $select ) {
@@ -169,6 +187,13 @@ class SP_Player_List extends SP_Custom_Post {
$adjustment = sp_array_value( sp_array_value( $adjustments, $player_id, array() ), $key, null );
if ( $adjustment != null )
$metrics[ $key ] += $adjustment;
+
+ if ( '' !== $metrics[ $key ] ) {
+ $prepend = sp_array_value( sp_array_value( $pa, $key, array() ), 0, null );
+ $append = sp_array_value( sp_array_value( $pa, $key, array() ), 1, null );
+
+ $metrics[ $key ] = ( $prepend ? '' . $prepend . ' ' : '' ) . $metrics[ $key ] . ( $append ? ' ' . $append . '' : '' );
+ }
endforeach;
// Get static stats
diff --git a/includes/class-sp-player.php b/includes/class-sp-player.php
index 5d8dcc6e..48878254 100644
--- a/includes/class-sp-player.php
+++ b/includes/class-sp-player.php
@@ -88,14 +88,39 @@ class SP_Player extends SP_Custom_Post {
* @return array
*/
public function metrics( $neg = null ) {
+ $args = array(
+ 'post_type' => 'sp_metric',
+ 'numberposts' => -1,
+ 'posts_per_page' => -1,
+ 'orderby' => 'menu_order',
+ 'order' => 'ASC',
+ );
+
+ $vars = get_posts( $args );
+
+ $data = array();
+
+ if ( ! $vars ) return $data;
+
+ $pa = array();
+ foreach ( $vars as $var ) {
+ $prepend = get_post_meta( $var->ID, 'sp_prepend', true );
+ $append = get_post_meta( $var->ID, 'sp_append', true );
+ $pa[ $var->post_name ] = array( $prepend, $append );
+ }
+
$metrics = (array)get_post_meta( $this->ID, 'sp_metrics', true );
$metric_labels = (array)sp_get_var_labels( 'sp_metric', $neg );
- $data = array();
+
foreach( $metric_labels as $key => $value ):
$metric = sp_array_value( $metrics, $key, null );
if ( $metric == null )
continue;
- $data[ $value ] = sp_array_value( $metrics, $key, ' ' );
+
+ $prepend = sp_array_value( sp_array_value( $pa, $key, array() ), 0, null );
+ $append = sp_array_value( sp_array_value( $pa, $key, array() ), 1, null );
+
+ $data[ $value ] = ( $prepend ? '' . $prepend . ' ' : '' ) . sp_array_value( $metrics, $key, ' ' ) . ( $append ? ' ' . $append . '' : '' );
endforeach;
return $data;
}
diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php
index 3d91d53e..8c5bcaa2 100644
--- a/includes/sp-core-functions.php
+++ b/includes/sp-core-functions.php
@@ -449,6 +449,28 @@ if ( !function_exists( 'sp_get_post_order' ) ) {
}
}
+if ( !function_exists( 'sp_get_post_prepend' ) ) {
+ function sp_get_post_prepend( $post_id ) {
+ $prepend = get_post_meta ( $post_id, 'sp_prepend', true );
+ if ( $prepend ):
+ return $prepend;
+ else:
+ return '—';
+ endif;
+ }
+}
+
+if ( !function_exists( 'sp_get_post_append' ) ) {
+ function sp_get_post_append( $post_id ) {
+ $append = get_post_meta ( $post_id, 'sp_append', true );
+ if ( $append ):
+ return $append;
+ else:
+ return '—';
+ endif;
+ }
+}
+
if ( !function_exists( 'sp_dropdown_statuses' ) ) {
function sp_dropdown_statuses( $args = array() ) {
$defaults = array(