From c8cec6de68a23f3481e28ae776e85fc308b15e22 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Tue, 29 Dec 2015 15:18:02 +1100 Subject: [PATCH] Remove append and prepend --- .../post-types/class-sp-admin-cpt-metric.php | 8 ----- .../class-sp-meta-box-metric-details.php | 18 ----------- .../class-sp-meta-box-player-metrics.php | 8 +---- includes/admin/views/html-admin-config.php | 6 +--- includes/class-sp-player-list.php | 25 ---------------- includes/class-sp-player.php | 30 ++----------------- includes/sp-core-functions.php | 23 -------------- 7 files changed, 5 insertions(+), 113 deletions(-) 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 5ea0ced8..319af6db 100644 --- a/includes/admin/post-types/class-sp-admin-cpt-metric.php +++ b/includes/admin/post-types/class-sp-admin-cpt-metric.php @@ -42,8 +42,6 @@ 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 ); @@ -59,12 +57,6 @@ 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 b3991885..6d1f4ee3 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,30 +23,12 @@ 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 . '' : '' ); ?> -

+

- - @@ -305,14 +303,12 @@ > 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 5f448a8f..e1ae632d 100644 --- a/includes/class-sp-player-list.php +++ b/includes/class-sp-player-list.php @@ -53,24 +53,6 @@ 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 ) { @@ -187,13 +169,6 @@ 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 48878254..21da8ae7 100644 --- a/includes/class-sp-player.php +++ b/includes/class-sp-player.php @@ -88,39 +88,15 @@ 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 ): + foreach ( $metric_labels as $key => $value ): $metric = sp_array_value( $metrics, $key, null ); if ( $metric == null ) continue; - - $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 . '' : '' ); + $data[ $value ] = sp_array_value( $metrics, $key, ' ' ); endforeach; return $data; } diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index 8c5bcaa2..54ee0e6e 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -449,28 +449,6 @@ 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( @@ -1306,7 +1284,6 @@ function sp_get_text_options() { __( 'Pos', 'sportspress' ), __( 'Position', 'sportspress' ), __( 'Preview', 'sportspress' ), - __( 'Profile', 'sportspress' ), __( 'Rank', 'sportspress' ), __( 'Recap', 'sportspress' ), __( 'Results', 'sportspress' ),