Save team as multiple meta values in event and staff
This commit is contained in:
17
event.php
17
event.php
@@ -35,11 +35,12 @@ function sp_event_meta_init() {
|
||||
function sp_event_team_meta( $post, $metabox ) {
|
||||
global $post_id;
|
||||
$limit = get_option( 'sp_event_team_count' );
|
||||
for ( $i = 1; $i <= $limit; $i++ ):
|
||||
for ( $i = 0; $i < $limit; $i++ ):
|
||||
$selected = array_pad( array_slice( (array)get_post_meta( $post_id, 'sp_team', false ), 0, $limit ), $limit, 0);
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sportspress[sp_team_' . $i . ']',
|
||||
'selected' => get_post_meta( $post_id, 'sp_team_' . $i, true ),
|
||||
'name' => 'sportspress[sp_team][]',
|
||||
'selected' => $selected[ $i ]
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
echo '<div class="clear"></div>' . PHP_EOL;
|
||||
@@ -186,15 +187,7 @@ function sp_event_custom_columns( $column, $post_id ) {
|
||||
if ( $typenow == 'sp_event' ):
|
||||
switch ( $column ):
|
||||
case 'sp_team':
|
||||
$limit = get_option( 'sp_event_team_count' );
|
||||
for ( $i = 1; $i <= $limit; $i++ ):
|
||||
$team = get_post_meta( $post_id, 'sp_team_' . $i, true );
|
||||
$parents = get_post_ancestors( $team );
|
||||
foreach ( $parents as $parent ):
|
||||
edit_post_link( get_the_title( $parent ), '', ' — ', $parent );
|
||||
endforeach;
|
||||
edit_post_link( get_the_title( $team ), '', '<br />', $team );
|
||||
endfor;
|
||||
sp_the_posts( $post_id, 'sp_team', '', '<br />' );
|
||||
break;
|
||||
case 'sp_league':
|
||||
if ( get_the_terms ( $post_id, 'sp_league' ) )
|
||||
|
||||
@@ -113,7 +113,7 @@ if ( ! function_exists( 'sp_team_checklist' ) ) {
|
||||
function sp_team_checklist( $post_id = null ) {
|
||||
if ( ! isset( $post_id ) )
|
||||
global $post_id;
|
||||
$selected = get_post_meta( $post_id, 'sp_team', false );
|
||||
$selected = (array)get_post_meta( $post_id, 'sp_team', false );
|
||||
$teams = get_pages( array( 'post_type' => 'sp_team') );
|
||||
foreach ( $teams as $team ):
|
||||
$parents = get_post_ancestors( $team );
|
||||
|
||||
@@ -47,8 +47,8 @@ function sp_staff_edit_columns( $columns ) {
|
||||
}
|
||||
add_filter( 'manage_edit-sp_staff_columns', 'sp_staff_edit_columns' );
|
||||
|
||||
function sp_staff_custom_columns( $column ) {
|
||||
global $post, $post_id, $typenow;
|
||||
function sp_staff_custom_columns( $column, $post_id ) {
|
||||
global $post, $typenow;
|
||||
if ( $typenow == 'sp_staff' ):
|
||||
switch ($column):
|
||||
case 'sp_position':
|
||||
@@ -58,7 +58,7 @@ function sp_staff_custom_columns( $column ) {
|
||||
echo '—';
|
||||
break;
|
||||
case 'sp_team':
|
||||
sp_unserialized_posts( $post_id, 'sp_teams', '', '<br />' );
|
||||
sp_the_posts( $post_id, 'sp_team', '', '<br />' );
|
||||
break;
|
||||
case 'sp_league':
|
||||
if ( get_the_terms ( $post_id, 'sp_league' ) )
|
||||
@@ -75,7 +75,7 @@ function sp_staff_custom_columns( $column ) {
|
||||
endswitch;
|
||||
endif;
|
||||
}
|
||||
add_action( 'manage_posts_custom_column', 'sp_staff_custom_columns' );
|
||||
add_action( 'manage_posts_custom_column', 'sp_staff_custom_columns', 10, 2 );
|
||||
|
||||
function sp_staff_request_filter_dropdowns() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
Reference in New Issue
Block a user