Display config keys and event outcomes in edit list
This commit is contained in:
@@ -131,16 +131,18 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _e( 'Label', 'sportspress' ); ?></th>
|
||||
<th><?php _e( 'Key', 'sportspress' ); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php $i = 0; foreach ( $data as $row ): ?>
|
||||
<tr<?php if ( $i % 2 ) echo ' class="alternate"'; ?>>
|
||||
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||
<td><?php echo $row->post_name; ?></td>
|
||||
</tr>
|
||||
<?php $i++; endforeach; ?>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th><a href="<?php echo admin_url( 'edit.php?post_type=sp_result' ); ?>"><?php printf( __( 'Edit %s', 'sportspress' ), __( 'Results', 'sportspress' ) ); ?></a></th>
|
||||
<th colspan="2"><a href="<?php echo admin_url( 'edit.php?post_type=sp_result' ); ?>"><?php printf( __( 'Edit %s', 'sportspress' ), __( 'Results', 'sportspress' ) ); ?></a></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@@ -160,16 +162,18 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _e( 'Label', 'sportspress' ); ?></th>
|
||||
<th><?php _e( 'Key', 'sportspress' ); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php $i = 0; foreach ( $data as $row ): ?>
|
||||
<tr<?php if ( $i % 2 ) echo ' class="alternate"'; ?>>
|
||||
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||
<td><?php echo $row->post_name; ?></td>
|
||||
</tr>
|
||||
<?php $i++; endforeach; ?>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th><a href="<?php echo admin_url( 'edit.php?post_type=sp_outcome' ); ?>"><?php printf( __( 'Edit %s', 'sportspress' ), __( 'Outcomes', 'sportspress' ) ); ?></a></th>
|
||||
<th colspan="2"><a href="<?php echo admin_url( 'edit.php?post_type=sp_outcome' ); ?>"><?php printf( __( 'Edit %s', 'sportspress' ), __( 'Outcomes', 'sportspress' ) ); ?></a></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@@ -24,7 +24,8 @@ function sp_column_edit_columns() {
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_equation' => __( 'Equation', 'sportspress' ),
|
||||
'sp_order' => __( 'Sort Order', 'sportspress' )
|
||||
'sp_order' => __( 'Sort Order', 'sportspress' ),
|
||||
'sp_key' => __( 'Key', 'sportspress' )
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ function sp_outcome_edit_columns() {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_abbreviation' => __( 'Abbreviation', 'sportspress' )
|
||||
'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
|
||||
'sp_key' => __( 'Key', 'sportspress' )
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ add_action( 'init', 'sp_result_cpt_init' );
|
||||
function sp_result_edit_columns() {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Label', 'sportspress' )
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_key' => __( 'Key', 'sportspress' )
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ function sp_statistic_edit_columns() {
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_equation' => __( 'Equation', 'sportspress' ),
|
||||
'sp_key' => __( 'Key', 'sportspress' )
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
||||
@@ -106,13 +106,13 @@ function sp_team_columns_meta( $post ) {
|
||||
$events = get_posts( $args );
|
||||
|
||||
foreach( $events as $event ):
|
||||
$totals['eventsplayed']++;
|
||||
$results = (array)get_post_meta( $event->ID, 'sp_results', true );
|
||||
foreach ( $results as $team_id => $team_result ):
|
||||
foreach ( $team_result as $key => $value ):
|
||||
if ( $team_id == $post->ID ):
|
||||
if ( $key == 'outcome' ):
|
||||
if ( array_key_exists( $value, $totals ) ):
|
||||
$totals['eventsplayed']++;
|
||||
$totals[ $value ]++;
|
||||
endif;
|
||||
else:
|
||||
|
||||
@@ -51,8 +51,21 @@ function sp_manage_posts_custom_column( $column, $post_id ) {
|
||||
echo get_the_terms ( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
|
||||
break;
|
||||
case 'sp_team':
|
||||
$result = get_post_meta( $post_id, 'sp_result', false );
|
||||
echo get_post_meta ( $post_id, 'sp_team' ) ? sp_the_posts( $post_id, 'sp_team', '', '<br />', $result, ( empty( $result ) ? ' — ' : ' ' ) ) : '—';
|
||||
$results = get_post_meta( $post_id, 'sp_results', true );
|
||||
$teams = get_post_meta ( $post_id, 'sp_team', false );
|
||||
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;
|
||||
break;
|
||||
case 'sp_equation':
|
||||
$equation = get_post_meta ( $post_id, 'sp_equation', true );
|
||||
@@ -86,6 +99,9 @@ function sp_manage_posts_custom_column( $column, $post_id ) {
|
||||
echo get_the_title( $post_id );
|
||||
endif;
|
||||
break;
|
||||
case 'sp_key':
|
||||
echo $post->post_name;
|
||||
break;
|
||||
case 'sp_player':
|
||||
echo sp_the_posts( $post_id, 'sp_player' );
|
||||
break;
|
||||
|
||||
@@ -175,7 +175,7 @@ if ( !function_exists( 'sp_dropdown_pages' ) ) {
|
||||
}
|
||||
|
||||
if ( !function_exists( 'sp_the_posts' ) ) {
|
||||
function sp_the_posts( $post_id = null, $meta = 'post', $before = '', $sep = ', ', $after = '', $delimiter = ' - ' ) {
|
||||
function sp_the_posts( $post_id = null, $meta = 'post' ) {
|
||||
if ( ! isset( $post_id ) )
|
||||
global $post_id;
|
||||
$ids = get_post_meta( $post_id, $meta, false );
|
||||
@@ -186,34 +186,19 @@ if ( !function_exists( 'sp_the_posts' ) ) {
|
||||
if ( isset( $ids ) && $ids && is_array( $ids ) && !empty( $ids ) ):
|
||||
foreach ( $ids as $id ):
|
||||
if ( !$id ) continue;
|
||||
if ( !empty( $before ) ):
|
||||
if ( is_array( $before ) && array_key_exists( $i, $before ) )
|
||||
echo $before[ $i ] . ' - ';
|
||||
else
|
||||
echo $before;
|
||||
endif;
|
||||
$parents = get_post_ancestors( $id );
|
||||
$parents = array_combine( array_keys( $parents ), array_reverse( array_values( $parents ) ) );
|
||||
foreach ( $parents as $parent ):
|
||||
if ( !in_array( $parent, $ids ) )
|
||||
edit_post_link( get_the_title( $parent ), '', '', $parent );
|
||||
echo $delimiter;
|
||||
echo ' - ';
|
||||
endforeach;
|
||||
$title = get_the_title( $id );
|
||||
if ( empty( $title ) )
|
||||
$title = __( '(no title)', 'sportspress' );
|
||||
edit_post_link( $title, '', '', $id );
|
||||
if ( !empty( $after ) ):
|
||||
if ( is_array( $after ) ):
|
||||
if ( array_key_exists( $i, $after ) && $after[ $i ] != '' ):
|
||||
echo ' - ' . $after[ $i ];
|
||||
endif;
|
||||
else:
|
||||
echo $after;
|
||||
endif;
|
||||
endif;
|
||||
if ( ++$i !== $count )
|
||||
echo $sep;
|
||||
echo ', ';
|
||||
endforeach;
|
||||
endif;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user