diff --git a/admin/post-types/stat.php b/admin/post-types/column.php similarity index 77% rename from admin/post-types/stat.php rename to admin/post-types/column.php index abaed77c..5242f122 100644 --- a/admin/post-types/stat.php +++ b/admin/post-types/column.php @@ -1,8 +1,8 @@ $name, @@ -12,15 +12,14 @@ function sp_stat_cpt_init() { 'show_in_nav_menus' => false, 'hierarchical' => false, 'supports' => array( 'title', 'page-attributes' ), - 'register_meta_box_cb' => 'sp_stat_meta_init', - 'rewrite' => array( 'slug' => 'stat' ), + 'register_meta_box_cb' => 'sp_column_meta_init', 'show_in_menu' => 'edit.php?post_type=sp_event' ); - register_post_type( 'sp_stat', $args ); + register_post_type( 'sp_column', $args ); } -add_action( 'init', 'sp_stat_cpt_init' ); +add_action( 'init', 'sp_column_cpt_init' ); -function sp_stat_edit_columns() { +function sp_column_edit_columns() { $columns = array( 'cb' => '', 'title' => __( 'Label', 'sportspress' ), @@ -29,13 +28,13 @@ function sp_stat_edit_columns() { ); return $columns; } -add_filter( 'manage_edit-sp_stat_columns', 'sp_stat_edit_columns' ); +add_filter( 'manage_edit-sp_column_columns', 'sp_column_edit_columns' ); -function sp_stat_meta_init() { - add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'sp_stat_details_meta', 'sp_stat', 'normal', 'high' ); +function sp_column_meta_init() { + add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'sp_column_details_meta', 'sp_column', 'normal', 'high' ); } -function sp_stat_details_meta( $post ) { +function sp_column_details_meta( $post ) { $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 ); diff --git a/admin/post-types/table.php b/admin/post-types/table.php index 1c471262..68b6339c 100644 --- a/admin/post-types/table.php +++ b/admin/post-types/table.php @@ -35,7 +35,7 @@ function sp_table_meta_init( $post ) { add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sp_table_team_meta', 'sp_table', 'side', 'high' ); if ( $teams && $teams != array(0) ): - add_meta_box( 'sp_statsdiv', __( 'League Table', 'sportspress' ), 'sp_table_stats_meta', 'sp_table', 'normal', 'high' ); + add_meta_box( 'sp_columnsdiv', __( 'League Table', 'sportspress' ), 'sp_table_columns_meta', 'sp_table', 'normal', 'high' ); endif; } @@ -63,7 +63,7 @@ function sp_table_team_meta( $post, $test ) { sp_nonce(); } -function sp_table_stats_meta( $post ) { +function sp_table_columns_meta( $post ) { list( $columns, $data, $placeholders, $merged ) = sp_get_table( $post->ID, true ); diff --git a/admin/post-types/team.php b/admin/post-types/team.php index 377fe68d..b1912e52 100644 --- a/admin/post-types/team.php +++ b/admin/post-types/team.php @@ -27,7 +27,7 @@ function sp_team_meta_init( $post ) { add_meta_box( 'postimagediv', __( 'Logo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_team', 'side', 'high' ); if ( $leagues && $leagues != array(0) ): - add_meta_box( 'sp_statsdiv', __( 'Statistics', 'sportspress' ), 'sp_team_stats_meta', 'sp_team', 'normal', 'high' ); + add_meta_box( 'sp_columnssdiv', __( 'Table Columns', 'sportspress' ), 'sp_team_columns_meta', 'sp_team', 'normal', 'high' ); endif; } @@ -42,9 +42,9 @@ function sp_team_edit_columns() { } add_filter( 'manage_edit-sp_team_columns', 'sp_team_edit_columns' ); -function sp_team_stats_meta( $post ) { +function sp_team_columns_meta( $post ) { $leagues = (array)get_the_terms( $post->ID, 'sp_league' ); - $stats = (array)get_post_meta( $post->ID, 'sp_stats', true ); + $columns = (array)get_post_meta( $post->ID, 'sp_columns', true ); // Equation Operating System $eos = new eqEOS(); @@ -62,11 +62,11 @@ function sp_team_stats_meta( $post ) { $div_ids[] = $value->term_id; endforeach; - // Get all leagues populated with stats where available - $data = sp_array_combine( $div_ids, $stats ); + // Get all leagues populated with columns where available + $data = sp_array_combine( $div_ids, $columns ); - // Get equations from statistics variables - $equations = sp_get_var_equations( 'sp_stat' ); + // Get equations from column variables + $equations = sp_get_var_equations( 'sp_column' ); // Initialize placeholders array $placeholders = array(); @@ -139,9 +139,9 @@ function sp_team_stats_meta( $post ) { endforeach; // Get columns from statistics variables - $columns = sp_get_var_labels( 'sp_stat' ); + $columns = sp_get_var_labels( 'sp_column' ); - sp_team_stats_table( $columns, $data, $placeholders ); + sp_team_columns_table( $columns, $data, $placeholders ); sp_nonce(); } ?> \ No newline at end of file diff --git a/assets/js/admin.js b/assets/js/admin.js index e3515d42..ee4aa766 100644 --- a/assets/js/admin.js +++ b/assets/js/admin.js @@ -86,6 +86,6 @@ jQuery(document).ready(function($){ $('.sp-equation-selector select:last').change().siblings().change(); // Remove slug editor in quick edit for slug-sensitive post types - $('.inline-edit-sp_result, .inline-edit-sp_outcome, .inline-edit-sp_stat, .inline-edit-sp_metric').find('input[name=post_name]').closest('label').remove(); + $('.inline-edit-sp_result, .inline-edit-sp_outcome, .inline-edit-sp_column, .inline-edit-sp_metric').find('input[name=post_name]').closest('label').remove(); }); \ No newline at end of file diff --git a/sportspress-actions.php b/sportspress-actions.php index b6ce6f12..f2cb3f77 100644 --- a/sportspress-actions.php +++ b/sportspress-actions.php @@ -136,7 +136,7 @@ function sp_save_post( $post_id ) { case ( 'sp_team' ): // Update stats - update_post_meta( $post_id, 'sp_stats', sp_array_value( $_POST, 'sp_stats', array() ) ); + update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) ); break; @@ -173,7 +173,7 @@ function sp_save_post( $post_id ) { break; - case ( 'sp_stat' ): + case ( 'sp_column' ): // Update equation as string update_post_meta( $post_id, 'sp_equation', implode( ' ', sp_array_value( $_POST, 'sp_equation', array() ) ) ); diff --git a/sportspress-defaults.php b/sportspress-defaults.php index 9849d43e..6a910eac 100644 --- a/sportspress-defaults.php +++ b/sportspress-defaults.php @@ -17,14 +17,14 @@ if ( !function_exists( 'sp_install_defaults' ) ) { array( 'post_title' => 'Loss', 'post_name' => 'loss', 'post_status' => 'publish', 'post_type' => 'sp_outcome' ), // Statistics - array( 'post_title' => 'P', 'post_name' => 'p', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$eventsplayed' ) ), - array( 'post_title' => 'W', 'post_name' => 'w', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$win' ) ), - array( 'post_title' => 'D', 'post_name' => 'd', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$draw' ) ), - array( 'post_title' => 'L', 'post_name' => 'l', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$loss' ) ), - array( 'post_title' => 'F', 'post_name' => 'f', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$goalsfor', 'sp_priority' => '3', 'sp_order' => 'DESC' ) ), - array( 'post_title' => 'A', 'post_name' => 'a', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$goalsagainst' ) ), - array( 'post_title' => 'GD', 'post_name' => 'gd', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$goalsfor - $goalsagainst', 'sp_priority' => '2', 'sp_order' => 'DESC' ) ), - array( 'post_title' => 'PTS', 'post_name' => 'pts', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$win x 3 + $draw', 'sp_priority' => '1', 'sp_order' => 'DESC' ) ), + array( 'post_title' => 'P', 'post_name' => 'p', 'post_status' => 'publish', 'post_type' => 'sp_column', 'meta' => array( 'sp_equation' => '$eventsplayed' ) ), + array( 'post_title' => 'W', 'post_name' => 'w', 'post_status' => 'publish', 'post_type' => 'sp_column', 'meta' => array( 'sp_equation' => '$win' ) ), + array( 'post_title' => 'D', 'post_name' => 'd', 'post_status' => 'publish', 'post_type' => 'sp_column', 'meta' => array( 'sp_equation' => '$draw' ) ), + array( 'post_title' => 'L', 'post_name' => 'l', 'post_status' => 'publish', 'post_type' => 'sp_column', 'meta' => array( 'sp_equation' => '$loss' ) ), + array( 'post_title' => 'F', 'post_name' => 'f', 'post_status' => 'publish', 'post_type' => 'sp_column', 'meta' => array( 'sp_equation' => '$goalsfor', 'sp_priority' => '3', 'sp_order' => 'DESC' ) ), + array( 'post_title' => 'A', 'post_name' => 'a', 'post_status' => 'publish', 'post_type' => 'sp_column', 'meta' => array( 'sp_equation' => '$goalsagainst' ) ), + array( 'post_title' => 'GD', 'post_name' => 'gd', 'post_status' => 'publish', 'post_type' => 'sp_column', 'meta' => array( 'sp_equation' => '$goalsfor - $goalsagainst', 'sp_priority' => '2', 'sp_order' => 'DESC' ) ), + array( 'post_title' => 'PTS', 'post_name' => 'pts', 'post_status' => 'publish', 'post_type' => 'sp_column', 'meta' => array( 'sp_equation' => '$win x 3 + $draw', 'sp_priority' => '1', 'sp_order' => 'DESC' ) ), // Metrics array( 'post_title' => 'Appearances', 'post_name' => 'appearances', 'post_status' => 'publish', 'post_type' => 'sp_metric', 'meta' => array( 'sp_equation' => '$eventsplayed' ) ), diff --git a/sportspress-filters.php b/sportspress-filters.php index ff58836c..81f0aa10 100644 --- a/sportspress-filters.php +++ b/sportspress-filters.php @@ -59,7 +59,7 @@ add_filter('the_content', 'sportspress_the_content'); function sp_sanitize_title( $title ) { - if ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && in_array( $_POST['post_type'], array( 'sp_result', 'sp_outcome', 'sp_stat', 'sp_metric' ) ) ): + if ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && in_array( $_POST['post_type'], array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_metric' ) ) ): // Get post title $title = $_POST['post_title']; @@ -86,7 +86,7 @@ function sp_pre_get_posts( $wp_query ) { if ( is_admin() ): $post_type = $wp_query->query['post_type']; - if ( in_array( $post_type, array( 'sp_result', 'sp_outcome', 'sp_stat', 'sp_metric' ) ) ): + if ( in_array( $post_type, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_metric' ) ) ): $wp_query->set( 'orderby', 'menu_order' ); $wp_query->set( 'order', 'ASC' ); endif; diff --git a/sportspress-functions.php b/sportspress-functions.php index 2c60a408..cd71d0a3 100644 --- a/sportspress-functions.php +++ b/sportspress-functions.php @@ -283,7 +283,7 @@ if ( !function_exists( 'sp_get_equation_optgroup_array' ) ) { function sp_get_equation_optgroup_array( $postid, $type = null, $variations = null, $defaults = null, $totals = true ) { $arr = array(); - // Get stats within the sports that the current stat is in ### TODO: should be for sport selected + // Get posts $args = array( 'post_type' => $type, 'numberposts' => -1, @@ -343,8 +343,8 @@ if ( !function_exists( 'sp_get_equation_selector' ) ) { case 'outcome': $options[ __( 'Outcomes', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_outcome', array( 'max' => '↑', 'min' => '↓' ) ); break; - case 'stat': - $options[ __( 'Statistics', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_stat' ); + case 'column': + $options[ __( 'Statistics', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_column' ); break; case 'metric': $options[ __( 'Metrics', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_metric' ); @@ -520,8 +520,8 @@ if ( !function_exists( 'sp_player_table' ) ) { } } -if ( !function_exists( 'sp_team_stats_table' ) ) { - function sp_team_stats_table( $columns = array(), $data = array(), $placeholders = array() ) { +if ( !function_exists( 'sp_team_columns_table' ) ) { + function sp_team_columns_table( $columns = array(), $data = array(), $placeholders = array() ) { ?> @@ -554,7 +554,7 @@ if ( !function_exists( 'sp_team_stats_table' ) ) { $value = sp_array_value( $div_stats, $column, '' ); $placeholder = sp_array_value( sp_array_value( $placeholders, $div_id, array() ), $column, 0 ); ?> - + 'sp_stat', + 'post_type' => 'sp_column', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', diff --git a/sportspress.php b/sportspress.php index d7f3c956..10751d26 100644 --- a/sportspress.php +++ b/sportspress.php @@ -37,7 +37,7 @@ include dirname( __FILE__ ) . '/sportspress-settings.php' ; require_once dirname( __FILE__ ) . '/admin/post-types/event.php'; require_once dirname( __FILE__ ) . '/admin/post-types/result.php'; require_once dirname( __FILE__ ) . '/admin/post-types/outcome.php'; -require_once dirname( __FILE__ ) . '/admin/post-types/stat.php'; +require_once dirname( __FILE__ ) . '/admin/post-types/column.php'; require_once dirname( __FILE__ ) . '/admin/post-types/metric.php'; require_once dirname( __FILE__ ) . '/admin/post-types/team.php'; require_once dirname( __FILE__ ) . '/admin/post-types/table.php';