Put things in folders and stuff
This commit is contained in:
86
admin/actions/manage-posts-custom-column.php
Normal file
86
admin/actions/manage-posts-custom-column.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
function sp_manage_posts_custom_column( $column, $post_id ) {
|
||||
global $post;
|
||||
switch ( $column ):
|
||||
case 'sp_logo':
|
||||
edit_post_link( get_the_post_thumbnail( $post_id, 'sp_icon' ), '', '', $post_id );
|
||||
break;
|
||||
case 'sp_position':
|
||||
echo get_the_terms ( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
|
||||
break;
|
||||
case 'sp_team':
|
||||
$post_type = get_post_type( $post );
|
||||
$teams = get_post_meta ( $post_id, 'sp_team', false );
|
||||
unset( $teams[0] );
|
||||
if ( $post_type == 'sp_event' ):
|
||||
$results = get_post_meta( $post_id, 'sp_results', true );
|
||||
foreach( $teams as $team_id ):
|
||||
$team = get_post( $team_id );
|
||||
$outcome_slug = sp_array_value( sp_array_value( $results, $team_id, null ), 'outcome', null );
|
||||
|
||||
$args=array(
|
||||
'name' => $outcome_slug,
|
||||
'post_type' => 'sp_outcome',
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => 1
|
||||
);
|
||||
$outcomes = get_posts( $args );
|
||||
echo $team->post_title . ( $outcomes ? ' — ' . $outcomes[0]->post_title : '' ) . '<br>';
|
||||
endforeach;
|
||||
elseif ( $post_type == 'sp_player' ):
|
||||
$results = get_post_meta( $post_id, 'sp_results', true );
|
||||
foreach( $teams as $team_id ):
|
||||
$team = get_post( $team_id );
|
||||
$outcome_slug = sp_array_value( sp_array_value( $results, $team_id, null ), 'outcome', null );
|
||||
|
||||
$args=array(
|
||||
'name' => $outcome_slug,
|
||||
'post_type' => 'sp_outcome',
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => 1
|
||||
);
|
||||
$outcomes = get_posts( $args );
|
||||
echo $team->post_title . ( $outcomes ? ' — ' . $outcomes[0]->post_title : '' ) . '<br>';
|
||||
endforeach;
|
||||
else:
|
||||
foreach( $teams as $team_id ):
|
||||
$team = get_post( $team_id );
|
||||
echo $team->post_title . '<br>';
|
||||
endforeach;
|
||||
endif;
|
||||
break;
|
||||
case 'sp_equation':
|
||||
echo sp_get_post_equation( $post_id );
|
||||
break;
|
||||
case 'sp_order':
|
||||
echo sp_get_post_order( $post_id );
|
||||
break;
|
||||
case 'sp_key':
|
||||
echo $post->post_name;
|
||||
break;
|
||||
case 'sp_format':
|
||||
echo sp_get_post_format( $post_id );
|
||||
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;
|
||||
case 'sp_season':
|
||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||
break;
|
||||
case 'sp_sponsor':
|
||||
echo get_the_terms ( $post_id, 'sp_sponsor' ) ? the_terms( $post_id, 'sp_sponsor' ) : '—';
|
||||
break;
|
||||
case 'sp_kickoff':
|
||||
echo ( $post->post_status == 'future' ? __( 'Scheduled' ) : __( 'Played', 'sportspress' ) ) . '<br />' . date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) );
|
||||
break;
|
||||
case 'sp_address':
|
||||
echo get_post_meta( $post_id, 'sp_address', true ) ? get_post_meta( $post_id, 'sp_address', true ) : '—';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
add_action( 'manage_posts_custom_column', 'sp_manage_posts_custom_column', 10, 2 );
|
||||
add_action( 'manage_pages_custom_column', 'sp_manage_posts_custom_column', 10, 2 );
|
||||
?>
|
||||
Reference in New Issue
Block a user