diff --git a/includes/admin/class-sp-admin-post-types.php b/includes/admin/class-sp-admin-post-types.php index d533c403..41ea4d3d 100644 --- a/includes/admin/class-sp-admin-post-types.php +++ b/includes/admin/class-sp-admin-post-types.php @@ -24,6 +24,7 @@ class SP_Admin_Post_Types { add_action( 'admin_init', array( $this, 'include_post_type_handlers' ) ); add_action( 'save_post', array( $this, 'unflag_post' ) ); add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) ); + add_filter( 'sportspress_meta_boxes', array( $this, 'meta_boxes' ) ); } /** @@ -105,6 +106,16 @@ class SP_Admin_Post_Types { return $messages; } + + /** + * Remove meta boxes as needed + */ + public static function meta_boxes( $meta_boxes ) { + if ( 'manual' != get_option( 'sportspress_player_columns', 'auto' ) ) { + unset( $meta_boxes['sp_player']['columns'] ); + } + return $meta_boxes; + } } endif; diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-statistics.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-statistics.php index ed4bc68b..a4b4988c 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-statistics.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-statistics.php @@ -43,17 +43,6 @@ class SP_Meta_Box_Player_Statistics { } else { $section_order = array( __( 'Offense', 'sportspress' ), __( 'Defense', 'sportspress' ) ); } - - // Get labels by section - $args = array( - 'post_type' => 'sp_performance', - 'numberposts' => 100, - 'posts_per_page' => 100, - 'orderby' => 'menu_order', - 'order' => 'ASC', - ); - - $columns = get_posts( $args ); $s = 0; foreach ( $section_order as $section_id => $section_label ) { diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-details.php index b3542c1c..21963045 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-details.php @@ -25,10 +25,15 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config { wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' ); $precision = get_post_meta( $post->ID, 'sp_precision', true ); $section = get_post_meta( $post->ID, 'sp_section', true ); + $visibility = get_post_meta( $post->ID, 'sp_visibility', true ); + + // Options + $visibility_options = apply_filters( 'sportspress_statistic_visibility_options', array( 'sp_event', 'sp_player', 'sp_list' ) ); // Defaults if ( '' === $precision ) $precision = 0; if ( '' === $section ) $section = -1; + if ( ! is_array( $visibility ) ) $visibility = $visibility_options; ?>
@@ -50,6 +55,17 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config { ?>
++