Add positions to statistics and metrics
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
function sportspress_admin_head() {
|
||||
global $typenow;
|
||||
|
||||
if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic' ) ) ):
|
||||
if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic', 'sp_metric' ) ) ):
|
||||
sportspress_highlight_admin_menu();
|
||||
endif;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ function sportspress_gettext( $translated_text, $untranslated_text, $domain ) {
|
||||
case 'sp_event':
|
||||
switch ( $untranslated_text ):
|
||||
case 'Enter title here':
|
||||
$translated_text = __( '(no title)', 'sportspress' );
|
||||
$translated_text = __( '(auto)', 'sportspress' );
|
||||
break;
|
||||
case 'Scheduled for: <b>%1$s</b>':
|
||||
$translated_text = __( 'Date/Time: <b>%1$s</b>', 'sportspress' );
|
||||
|
||||
@@ -6,7 +6,10 @@ function sportspress_manage_posts_custom_column( $column, $post_id ) {
|
||||
edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-icon' ), '', '', $post_id );
|
||||
break;
|
||||
case 'sp_position':
|
||||
echo get_the_terms ( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
|
||||
echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
|
||||
break;
|
||||
case 'sp_positions':
|
||||
echo get_the_terms ( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : sprintf( __( 'All %s', 'sportspress' ), __( 'positions', 'sportspress' ) );
|
||||
break;
|
||||
case 'sp_team':
|
||||
$post_type = get_post_type( $post );
|
||||
@@ -60,8 +63,8 @@ function sportspress_manage_posts_custom_column( $column, $post_id ) {
|
||||
case 'sp_key':
|
||||
echo $post->post_name;
|
||||
break;
|
||||
case 'sp_format':
|
||||
echo sportspress_get_post_format( $post_id );
|
||||
case 'sp_precision':
|
||||
echo sportspress_get_post_precision( $post_id );
|
||||
break;
|
||||
case 'sp_player':
|
||||
echo sportspress_the_posts( $post_id, 'sp_player' );
|
||||
|
||||
45
admin/hooks/post-updated-messages.php
Normal file
45
admin/hooks/post-updated-messages.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
function sportspress_post_updated_messages( $messages ) {
|
||||
global $typenow, $post;
|
||||
|
||||
if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_metric', 'sp_statistic' ) ) ):
|
||||
$obj = get_post_type_object( $typenow );
|
||||
|
||||
$messages['post'][1] = sprintf( __( '%s updated.', 'sportspress' ), $obj->labels->singular_name ) .
|
||||
' <a href="' . esc_url( admin_url( 'edit.php?post_type=' . $typenow ) ) . '">' .
|
||||
sprintf( __( 'Edit %s', 'sportspress' ), $obj->labels->name ) . '</a>';
|
||||
|
||||
elseif ( in_array( $typenow, array( 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ):
|
||||
$obj = get_post_type_object( $typenow );
|
||||
|
||||
$messages['post'][1] = sprintf( __( '%s updated.', 'sportspress' ), $obj->labels->singular_name ) .
|
||||
' <a href="' . esc_url( get_permalink($post->ID) ) . '">' . $obj->labels->view_item . '</a>';
|
||||
|
||||
$messages['post'][4] = sprintf( __( '%s updated.', 'sportspress' ), $obj->labels->singular_name );
|
||||
|
||||
$messages['post'][6] = sprintf( __( '%s published.', 'sportspress' ), $obj->labels->singular_name ) .
|
||||
' <a href="' . esc_url( get_permalink($post->ID) ) . '">' . $obj->labels->view_item . '</a>';
|
||||
|
||||
$messages['post'][7] = sprintf( __( '%s saved.'), $obj->labels->singular_name );
|
||||
|
||||
$messages['post'][8] = sprintf( __( '%s submitted.', 'sportspress' ), $obj->labels->singular_name ) .
|
||||
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '">' .
|
||||
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
||||
|
||||
$messages['post'][9] = sprintf(
|
||||
__( '%s scheduled for: <strong>%s</strong>.', 'sportspress' ),
|
||||
date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post->ID) ) ) .
|
||||
' <a target="_blank" href="' . esc_url( get_permalink($post->ID) ) . '">' .
|
||||
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
||||
|
||||
$messages['post'][8] = sprintf( __( '%s draft updated.', 'sportspress' ), $obj->labels->singular_name ) .
|
||||
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '">' .
|
||||
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
||||
|
||||
endif;
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
add_filter('post_updated_messages', 'sportspress_post_updated_messages');
|
||||
?>
|
||||
@@ -48,15 +48,12 @@ function sportspress_save_post( $post_id ) {
|
||||
break;
|
||||
|
||||
case ( 'sp_column' ):
|
||||
|
||||
// Update format as string
|
||||
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'integer' ) );
|
||||
|
||||
// Update precision as integer
|
||||
update_post_meta( $post_id, 'sp_precision', (int) sportspress_array_value( $_POST, 'sp_precision', 1 ) );
|
||||
|
||||
|
||||
// Update equation as string
|
||||
update_post_meta( $post_id, 'sp_equation', implode( ' ', sportspress_array_value( $_POST, 'sp_equation', array() ) ) );
|
||||
|
||||
// Update precision as integer
|
||||
update_post_meta( $post_id, 'sp_precision', (int) sportspress_array_value( $_POST, 'sp_precision', 1 ) );
|
||||
|
||||
// Update sort order as string
|
||||
update_post_meta( $post_id, 'sp_priority', sportspress_array_value( $_POST, 'sp_priority', '0' ) );
|
||||
@@ -68,43 +65,8 @@ function sportspress_save_post( $post_id ) {
|
||||
|
||||
case ( 'sp_statistic' ):
|
||||
|
||||
// Update format as string
|
||||
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'integer' ) );
|
||||
|
||||
// Update precision as integer
|
||||
update_post_meta( $post_id, 'sp_precision', (int) sportspress_array_value( $_POST, 'sp_precision', 1 ) );
|
||||
|
||||
// Update sort order as string
|
||||
update_post_meta( $post_id, 'sp_priority', sportspress_array_value( $_POST, 'sp_priority', '0' ) );
|
||||
|
||||
// Update sort order as string
|
||||
update_post_meta( $post_id, 'sp_order', sportspress_array_value( $_POST, 'sp_order', 'DESC' ) );
|
||||
|
||||
break;
|
||||
|
||||
case ( 'sp_metric' ):
|
||||
|
||||
// Update format as string
|
||||
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'integer' ) );
|
||||
|
||||
// Update precision as integer
|
||||
update_post_meta( $post_id, 'sp_precision', (int) sportspress_array_value( $_POST, 'sp_precision', 1 ) );
|
||||
|
||||
// Update equation as string
|
||||
update_post_meta( $post_id, 'sp_equation', implode( ' ', sportspress_array_value( $_POST, 'sp_equation', array() ) ) );
|
||||
|
||||
// Update sort order as string
|
||||
update_post_meta( $post_id, 'sp_priority', sportspress_array_value( $_POST, 'sp_priority', '0' ) );
|
||||
|
||||
// Update sort order as string
|
||||
update_post_meta( $post_id, 'sp_order', sportspress_array_value( $_POST, 'sp_order', 'DESC' ) );
|
||||
|
||||
break;
|
||||
|
||||
case ( 'sp_result' ):
|
||||
|
||||
// Update format as string
|
||||
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'integer' ) );
|
||||
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user