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 ) {
|
function sp_event_team_meta( $post, $metabox ) {
|
||||||
global $post_id;
|
global $post_id;
|
||||||
$limit = get_option( 'sp_event_team_count' );
|
$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(
|
$args = array(
|
||||||
'post_type' => 'sp_team',
|
'post_type' => 'sp_team',
|
||||||
'name' => 'sportspress[sp_team_' . $i . ']',
|
'name' => 'sportspress[sp_team][]',
|
||||||
'selected' => get_post_meta( $post_id, 'sp_team_' . $i, true ),
|
'selected' => $selected[ $i ]
|
||||||
);
|
);
|
||||||
wp_dropdown_pages( $args );
|
wp_dropdown_pages( $args );
|
||||||
echo '<div class="clear"></div>' . PHP_EOL;
|
echo '<div class="clear"></div>' . PHP_EOL;
|
||||||
@@ -186,15 +187,7 @@ function sp_event_custom_columns( $column, $post_id ) {
|
|||||||
if ( $typenow == 'sp_event' ):
|
if ( $typenow == 'sp_event' ):
|
||||||
switch ( $column ):
|
switch ( $column ):
|
||||||
case 'sp_team':
|
case 'sp_team':
|
||||||
$limit = get_option( 'sp_event_team_count' );
|
sp_the_posts( $post_id, 'sp_team', '', '<br />' );
|
||||||
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;
|
|
||||||
break;
|
break;
|
||||||
case 'sp_league':
|
case 'sp_league':
|
||||||
if ( get_the_terms ( $post_id, '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 ) {
|
function sp_team_checklist( $post_id = null ) {
|
||||||
if ( ! isset( $post_id ) )
|
if ( ! isset( $post_id ) )
|
||||||
global $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') );
|
$teams = get_pages( array( 'post_type' => 'sp_team') );
|
||||||
foreach ( $teams as $team ):
|
foreach ( $teams as $team ):
|
||||||
$parents = get_post_ancestors( $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' );
|
add_filter( 'manage_edit-sp_staff_columns', 'sp_staff_edit_columns' );
|
||||||
|
|
||||||
function sp_staff_custom_columns( $column ) {
|
function sp_staff_custom_columns( $column, $post_id ) {
|
||||||
global $post, $post_id, $typenow;
|
global $post, $typenow;
|
||||||
if ( $typenow == 'sp_staff' ):
|
if ( $typenow == 'sp_staff' ):
|
||||||
switch ($column):
|
switch ($column):
|
||||||
case 'sp_position':
|
case 'sp_position':
|
||||||
@@ -58,7 +58,7 @@ function sp_staff_custom_columns( $column ) {
|
|||||||
echo '—';
|
echo '—';
|
||||||
break;
|
break;
|
||||||
case 'sp_team':
|
case 'sp_team':
|
||||||
sp_unserialized_posts( $post_id, 'sp_teams', '', '<br />' );
|
sp_the_posts( $post_id, 'sp_team', '', '<br />' );
|
||||||
break;
|
break;
|
||||||
case 'sp_league':
|
case 'sp_league':
|
||||||
if ( get_the_terms ( $post_id, 'sp_league' ) )
|
if ( get_the_terms ( $post_id, 'sp_league' ) )
|
||||||
@@ -75,7 +75,7 @@ function sp_staff_custom_columns( $column ) {
|
|||||||
endswitch;
|
endswitch;
|
||||||
endif;
|
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() {
|
function sp_staff_request_filter_dropdowns() {
|
||||||
global $typenow, $wp_query;
|
global $typenow, $wp_query;
|
||||||
|
|||||||
Reference in New Issue
Block a user