Create unserialized posts function
This commit is contained in:
26
helpers.php
26
helpers.php
@@ -65,6 +65,32 @@ if ( ! function_exists( 'sp_dropdown_taxonomies' ) ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'sp_unserialized_posts' ) ) {
|
||||
function sp_unserialized_posts( $post_id = null, $meta = 'posts', $before = '', $sep = ',', $after = '' ) {
|
||||
echo $before;
|
||||
if ( ! isset( $post_id ) )
|
||||
global $post_id;
|
||||
$posts = get_post_meta( $post_id, $meta, true );
|
||||
if ( isset( $posts ) && $posts ):
|
||||
$posts = (array)unserialize( $posts );
|
||||
foreach ( $posts as $post ):
|
||||
$parents = get_post_ancestors( $post );
|
||||
$parents = array_combine( array_keys( $parents ), array_reverse( array_values( $parents ) ) );
|
||||
foreach ( $parents as $parent ):
|
||||
if ( !in_array( $parent, $posts ) )
|
||||
edit_post_link( get_the_title( $parent ), '', ' ', $parent );
|
||||
echo '— ';
|
||||
endforeach;
|
||||
edit_post_link( get_the_title( $post ), '', '', $post );
|
||||
if ( $post != end( $posts ) )
|
||||
echo $sep;
|
||||
endforeach;
|
||||
else:
|
||||
echo '—';
|
||||
endif;
|
||||
echo $after;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'sp_team_logo' ) ) {
|
||||
function sp_team_logo( $post_id = null ) {
|
||||
|
||||
12
player.php
12
player.php
@@ -59,17 +59,7 @@ function sp_player_custom_columns( $column, $post_id ) {
|
||||
echo '—';
|
||||
break;
|
||||
case 'sp_team':
|
||||
$teams = sp_get_teams( $post_id );
|
||||
foreach ( $teams as $team ):
|
||||
$parents = get_post_ancestors( $team );
|
||||
$parents = array_combine( array_keys( $parents ), array_reverse( array_values( $parents ) ) );
|
||||
foreach ( $parents as $parent ):
|
||||
if ( !in_array( $parent, $teams ) )
|
||||
edit_post_link( get_the_title( $parent ), '', ' ', $parent );
|
||||
echo '— ';
|
||||
endforeach;
|
||||
edit_post_link( get_the_title( $team ), '', '<br />', $team );
|
||||
endforeach;
|
||||
sp_unserialized_posts( $post_id, 'sp_teams', '', '<br />' );
|
||||
break;
|
||||
case 'sp_league':
|
||||
if ( get_the_terms ( $post_id, 'sp_league' ) )
|
||||
|
||||
@@ -38,8 +38,8 @@ function sp_staff_edit_columns( $columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Name', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_position' => __( 'Positions', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' )
|
||||
);
|
||||
@@ -57,6 +57,9 @@ function sp_staff_custom_columns( $column ) {
|
||||
else
|
||||
echo '—';
|
||||
break;
|
||||
case 'sp_team':
|
||||
sp_unserialized_posts( $post_id, 'sp_teams', '', '<br />' );
|
||||
break;
|
||||
case 'sp_league':
|
||||
if ( get_the_terms ( $post_id, 'sp_league' ) )
|
||||
the_terms( $post_id, 'sp_league' );
|
||||
|
||||
Reference in New Issue
Block a user