diff --git a/actions.php b/actions.php
index 44004a7b..a7a16dff 100644
--- a/actions.php
+++ b/actions.php
@@ -23,6 +23,9 @@ function sp_manage_posts_custom_column( $column, $post_id ) {
$result = get_post_meta( $post_id, 'sp_result', false );
echo get_post_meta ( $post_id, 'sp_team' ) ? sp_the_posts( $post_id, 'sp_team', '', '
', $result, ( empty( $result ) ? ' — ' : ' ' ) ) : '—';
break;
+ case 'sp_player':
+ echo sp_the_posts( $post_id, 'sp_player' );
+ break;
case 'sp_event':
echo get_post_meta ( $post_id, 'sp_event' ) ? sizeof( get_post_meta ( $post_id, 'sp_event' ) ) : '—';
break;
@@ -124,6 +127,12 @@ function sp_save_post( $post_id ) {
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
break;
+ case ( 'sp_list' ):
+ update_post_meta( $post_id, 'sp_stats', sp_array_value( $_POST, 'sp_stats', array() ) );
+ update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
+ wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
+ sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) );
+ break;
endswitch;
/*
diff --git a/event.php b/event.php
index 6effb381..51bf7c2e 100644
--- a/event.php
+++ b/event.php
@@ -2,7 +2,8 @@
function sp_event_cpt_init() {
$name = __( 'Events', 'sportspress' );
$singular_name = __( 'Event', 'sportspress' );
- $labels = sp_cpt_labels( $name, $singular_name );
+ $lowercase_name = __( 'events', 'sportspress' );
+ $labels = sp_cpt_labels( $name, $singular_name, $lowercase_name );
$args = array(
'label' => $name,
'labels' => $labels,
diff --git a/helpers.php b/helpers.php
index 50436bd0..67a2263a 100644
--- a/helpers.php
+++ b/helpers.php
@@ -65,7 +65,8 @@ if ( !function_exists( 'sp_num_to_letter' ) ) {
}
if ( !function_exists( 'sp_cpt_labels' ) ) {
- function sp_cpt_labels( $name, $singular_name ) {
+ function sp_cpt_labels( $name, $singular_name, $lowercase_name = null ) {
+ if ( !$lowercase_name ) $lowercase_name = $name;
$labels = array(
'name' => $name,
'singular_name' => $singular_name,
@@ -75,8 +76,8 @@ if ( !function_exists( 'sp_cpt_labels' ) ) {
'new_item' => sprintf( __( 'New %s', 'sportspress' ), $singular_name ),
'view_item' => sprintf( __( 'View %s', 'sportspress' ), $singular_name ),
'search_items' => sprintf( __( 'Search %s', 'sportspress' ), $name ),
- 'not_found' => sprintf( __( 'No %s found', 'sportspress' ), $name ),
- 'not_found_in_trash' => sprintf( __( 'No %s found in trash', 'sportspress' ), $name ),
+ 'not_found' => sprintf( __( 'No %s found', 'sportspress' ), $lowercase_name ),
+ 'not_found_in_trash' => sprintf( __( 'No %s found in trash', 'sportspress' ), $lowercase_name ),
'parent_item_colon' => sprintf( __( 'Parent %s', 'sportspress' ), $singular_name ) . ':'
);
return $labels;
@@ -84,7 +85,8 @@ if ( !function_exists( 'sp_cpt_labels' ) ) {
}
if ( !function_exists( 'sp_tax_labels' ) ) {
- function sp_tax_labels( $name, $singular_name ) {
+ function sp_tax_labels( $name, $singular_name, $lowercase_name = null ) {
+ if ( !$lowercase_name ) $lowercase_name = $name;
$labels = array(
'name' => $name,
'singular_name' => $singular_name,
@@ -97,7 +99,7 @@ if ( !function_exists( 'sp_tax_labels' ) ) {
'parent_item' => sprintf( __( 'Parent %s', 'sportspress' ), $singular_name ),
'parent_item_colon' => sprintf( __( 'Parent %s', 'sportspress' ), $singular_name ) . ':',
'search_items' => sprintf( __( 'Search %s', 'sportspress' ), $name ),
- 'not_found' => sprintf( __( 'No %s found', 'sportspress' ), $name )
+ 'not_found' => sprintf( __( 'No %s found', 'sportspress' ), $lowercase_name )
);
return $labels;
}
@@ -125,7 +127,7 @@ if ( !function_exists( 'sp_dropdown_taxonomies' ) ) {
'show_option_none' => false,
'taxonomy' => null,
'name' => null,
- 'selected' => null,
+ 'selected' => null
);
$args = array_merge( $defaults, $args );
$terms = get_terms( $args['taxonomy'] );
@@ -354,7 +356,7 @@ if ( !function_exists( 'sp_get_stats_row' ) ) {
else:
$output = $dynamic;
-
+
endif;
return $output;
diff --git a/league.php b/league.php
index 1cb203ff..4f3f6881 100644
--- a/league.php
+++ b/league.php
@@ -2,8 +2,9 @@
function sp_league_tax_init() {
$name = __( 'Leagues', 'sportspress' );
$singular_name = __( 'League', 'sportspress' );
- $object_type = array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff', 'sp_list' );
- $labels = sp_tax_labels( $name, $singular_name );
+ $lowercase_name = __( 'leagues', 'sportspress' );
+ $object_type = array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff' );
+ $labels = sp_tax_labels( $name, $singular_name, $lowercase_name );
$args = array(
'label' => $name,
'labels' => $labels,
diff --git a/list.php b/list.php
index 3612f619..df14e5c5 100644
--- a/list.php
+++ b/list.php
@@ -2,13 +2,15 @@
function sp_list_cpt_init() {
$name = __( 'Player Lists', 'sportspress' );
$singular_name = __( 'Player List', 'sportspress' );
- $labels = sp_cpt_labels( $name, $singular_name );
+ $lowercase_name = __( 'player lists', 'sportspress' );
+ $labels = sp_cpt_labels( $name, $singular_name, $lowercase_name );
$args = array(
'label' => $name,
'labels' => $labels,
'public' => true,
'hierarchical' => false,
- 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ),
+ 'supports' => array( 'title', 'author', 'thumbnail', 'page-attributes' ),
+ 'register_meta_box_cb' => 'sp_list_meta_init',
'rewrite' => array( 'slug' => 'list' )
);
register_post_type( 'sp_list', $args );
@@ -19,10 +21,85 @@ function sp_list_edit_columns() {
$columns = array(
'cb' => '',
'title' => __( 'Title' ),
+ 'sp_player' => __( 'Players', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' )
);
return $columns;
}
add_filter( 'manage_edit-sp_list_columns', 'sp_list_edit_columns' );
+
+function sp_list_meta_init() {
+ add_meta_box( 'sp_playerdiv', __( 'Players', 'sportspress' ), 'sp_list_player_meta', 'sp_list', 'side', 'high' );
+ add_meta_box( 'sp_statsdiv', __( 'Player List', 'sportspress' ), 'sp_list_stats_meta', 'sp_list', 'normal', 'high' );
+}
+
+function sp_list_player_meta( $post ) {
+ $league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
+ $team_id = get_post_meta( $post->ID, 'sp_team', true );
+ ?>
+
+ sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ), + 'taxonomy' => 'sp_league', + 'name' => 'sp_league', + 'selected' => $league_id + ); + sp_dropdown_taxonomies( $args ); + ?> +
++ sprintf( __( 'All %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ), + 'option_none_value' => '0', + 'post_type' => 'sp_team', + 'name' => 'sp_team', + 'selected' => $team_id + ); + wp_dropdown_pages( $args ); + ?> +
+ ID, 'sp_player', 'block', 'sp_team' ); + sp_post_adder( 'sp_player' ); + ?> +