Change Statistics (sp_stat) to Table Columns (sp_column)

This commit is contained in:
ThemeBoy
2013-12-27 15:37:04 +11:00
parent 3e99dc70a2
commit aae424aa4f
9 changed files with 45 additions and 46 deletions

View File

@@ -1,8 +1,8 @@
<?php
function sp_stat_cpt_init() {
$name = __( 'Statistics', 'sportspress' );
$singular_name = __( 'Statistic', 'sportspress' );
$lowercase_name = __( 'statistics', 'sportspress' );
function sp_column_cpt_init() {
$name = __( 'Table Columns', 'sportspress' );
$singular_name = __( 'Table Column', 'sportspress' );
$lowercase_name = __( 'table columns', 'sportspress' );
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name, true );
$args = array(
'label' => $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' => '<input type="checkbox" />',
'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 );

View File

@@ -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 );

View File

@@ -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();
}
?>