Add positions to statistics and metrics
This commit is contained in:
2005
admin-functions.php
2005
admin-functions.php
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
|||||||
function sportspress_admin_head() {
|
function sportspress_admin_head() {
|
||||||
global $typenow;
|
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();
|
sportspress_highlight_admin_menu();
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ function sportspress_gettext( $translated_text, $untranslated_text, $domain ) {
|
|||||||
case 'sp_event':
|
case 'sp_event':
|
||||||
switch ( $untranslated_text ):
|
switch ( $untranslated_text ):
|
||||||
case 'Enter title here':
|
case 'Enter title here':
|
||||||
$translated_text = __( '(no title)', 'sportspress' );
|
$translated_text = __( '(auto)', 'sportspress' );
|
||||||
break;
|
break;
|
||||||
case 'Scheduled for: <b>%1$s</b>':
|
case 'Scheduled for: <b>%1$s</b>':
|
||||||
$translated_text = __( 'Date/Time: <b>%1$s</b>', 'sportspress' );
|
$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 );
|
edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-icon' ), '', '', $post_id );
|
||||||
break;
|
break;
|
||||||
case 'sp_position':
|
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;
|
break;
|
||||||
case 'sp_team':
|
case 'sp_team':
|
||||||
$post_type = get_post_type( $post );
|
$post_type = get_post_type( $post );
|
||||||
@@ -60,8 +63,8 @@ function sportspress_manage_posts_custom_column( $column, $post_id ) {
|
|||||||
case 'sp_key':
|
case 'sp_key':
|
||||||
echo $post->post_name;
|
echo $post->post_name;
|
||||||
break;
|
break;
|
||||||
case 'sp_format':
|
case 'sp_precision':
|
||||||
echo sportspress_get_post_format( $post_id );
|
echo sportspress_get_post_precision( $post_id );
|
||||||
break;
|
break;
|
||||||
case 'sp_player':
|
case 'sp_player':
|
||||||
echo sportspress_the_posts( $post_id, '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');
|
||||||
|
?>
|
||||||
@@ -49,15 +49,12 @@ function sportspress_save_post( $post_id ) {
|
|||||||
|
|
||||||
case ( 'sp_column' ):
|
case ( 'sp_column' ):
|
||||||
|
|
||||||
// Update format as string
|
// Update equation as string
|
||||||
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'integer' ) );
|
update_post_meta( $post_id, 'sp_equation', implode( ' ', sportspress_array_value( $_POST, 'sp_equation', array() ) ) );
|
||||||
|
|
||||||
// Update precision as integer
|
// Update precision as integer
|
||||||
update_post_meta( $post_id, 'sp_precision', (int) sportspress_array_value( $_POST, 'sp_precision', 1 ) );
|
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 sort order as string
|
||||||
update_post_meta( $post_id, 'sp_priority', sportspress_array_value( $_POST, 'sp_priority', '0' ) );
|
update_post_meta( $post_id, 'sp_priority', sportspress_array_value( $_POST, 'sp_priority', '0' ) );
|
||||||
|
|
||||||
@@ -68,44 +65,9 @@ function sportspress_save_post( $post_id ) {
|
|||||||
|
|
||||||
case ( 'sp_statistic' ):
|
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 equation as string
|
||||||
update_post_meta( $post_id, 'sp_equation', implode( ' ', sportspress_array_value( $_POST, 'sp_equation', array() ) ) );
|
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;
|
break;
|
||||||
|
|
||||||
case ( 'sp_player' ):
|
case ( 'sp_player' ):
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
function sportspress_column_post_init() {
|
function sportspress_column_post_init() {
|
||||||
$name = __( 'Table Columns', 'sportspress' );
|
$name = __( 'Columns', 'sportspress' );
|
||||||
$singular_name = __( 'Table Column', 'sportspress' );
|
$singular_name = __( 'Column', 'sportspress' );
|
||||||
$lowercase_name = __( 'table columns', 'sportspress' );
|
$lowercase_name = __( 'columns', 'sportspress' );
|
||||||
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name, true );
|
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name, true );
|
||||||
$args = array(
|
$args = array(
|
||||||
'label' => $name,
|
'label' => $name,
|
||||||
@@ -24,8 +24,8 @@ function sportspress_column_edit_columns() {
|
|||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'title' => __( 'Label', 'sportspress' ),
|
'title' => __( 'Label', 'sportspress' ),
|
||||||
'sp_key' => __( 'Key', 'sportspress' ),
|
'sp_key' => __( 'Key', 'sportspress' ),
|
||||||
'sp_format' => __( 'Format', 'sportspress' ),
|
|
||||||
'sp_equation' => __( 'Equation', 'sportspress' ),
|
'sp_equation' => __( 'Equation', 'sportspress' ),
|
||||||
|
'sp_precision' => __( 'Precision', 'sportspress' ),
|
||||||
'sp_order' => __( 'Sort Order', 'sportspress' ),
|
'sp_order' => __( 'Sort Order', 'sportspress' ),
|
||||||
);
|
);
|
||||||
return $columns;
|
return $columns;
|
||||||
@@ -37,8 +37,6 @@ function sportspress_column_meta_init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sportspress_column_details_meta( $post ) {
|
function sportspress_column_details_meta( $post ) {
|
||||||
$formats = sportspress_get_config_formats();
|
|
||||||
|
|
||||||
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
|
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
|
||||||
$order = get_post_meta( $post->ID, 'sp_order', true );
|
$order = get_post_meta( $post->ID, 'sp_order', true );
|
||||||
$priority = get_post_meta( $post->ID, 'sp_priority', true );
|
$priority = get_post_meta( $post->ID, 'sp_priority', true );
|
||||||
@@ -51,20 +49,6 @@ function sportspress_column_details_meta( $post ) {
|
|||||||
<p>
|
<p>
|
||||||
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
|
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
|
||||||
</p>
|
</p>
|
||||||
<p><strong><?php _e( 'Format', 'sportspress' ); ?></strong></p>
|
|
||||||
<p class="sp-format-selector">
|
|
||||||
<select name="sp_format">
|
|
||||||
<?php
|
|
||||||
foreach ( $formats as $key => $value ):
|
|
||||||
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
|
|
||||||
endforeach;
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</p>
|
|
||||||
<p><strong><?php _e( 'Precision', 'sportspress' ); ?></strong></p>
|
|
||||||
<p class="sp-precision-selector">
|
|
||||||
<input name="sp_precision" type="text" size="4" id="sp_precision" value="<?php echo $precision; ?>" placeholder="1">
|
|
||||||
</p>
|
|
||||||
<p><strong><?php _e( 'Equation', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Equation', 'sportspress' ); ?></strong></p>
|
||||||
<p class="sp-equation-selector">
|
<p class="sp-equation-selector">
|
||||||
<?php
|
<?php
|
||||||
@@ -73,6 +57,10 @@ function sportspress_column_details_meta( $post ) {
|
|||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
<p><strong><?php _e( 'Precision', 'sportspress' ); ?></strong></p>
|
||||||
|
<p class="sp-precision-selector">
|
||||||
|
<input name="sp_precision" type="text" size="4" id="sp_precision" value="<?php echo $precision; ?>" placeholder="1">
|
||||||
|
</p>
|
||||||
<p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p>
|
||||||
<p class="sp-order-selector">
|
<p class="sp-order-selector">
|
||||||
<select name="sp_priority">
|
<select name="sp_priority">
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ function sportspress_event_post_init() {
|
|||||||
'label' => $name,
|
'label' => $name,
|
||||||
'labels' => $labels,
|
'labels' => $labels,
|
||||||
'public' => true,
|
'public' => true,
|
||||||
|
'has_archive' => true,
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'author', 'thumbnail', 'comments' ),
|
'supports' => array( 'title', 'author', 'thumbnail', 'comments' ),
|
||||||
'register_meta_box_cb' => 'sportspress_event_meta_init',
|
'register_meta_box_cb' => 'sportspress_event_meta_init',
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
function sportspress_metric_post_init() {
|
function sportspress_metric_post_init() {
|
||||||
$name = __( 'Player Metrics', 'sportspress' );
|
$name = __( 'Metrics', 'sportspress' );
|
||||||
$singular_name = __( 'Player Metric', 'sportspress' );
|
$singular_name = __( 'Metric', 'sportspress' );
|
||||||
$lowercase_name = __( 'player metrics', 'sportspress' );
|
$lowercase_name = __( 'metrics', 'sportspress' );
|
||||||
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name, true );
|
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name, true );
|
||||||
$args = array(
|
$args = array(
|
||||||
'label' => $name,
|
'label' => $name,
|
||||||
@@ -12,7 +12,6 @@ function sportspress_metric_post_init() {
|
|||||||
'show_in_menu' => false,
|
'show_in_menu' => false,
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'page-attributes' ),
|
'supports' => array( 'title', 'page-attributes' ),
|
||||||
'register_meta_box_cb' => 'sportspress_metric_meta_init',
|
|
||||||
'capability_type' => 'sp_config'
|
'capability_type' => 'sp_config'
|
||||||
);
|
);
|
||||||
register_post_type( 'sp_metric', $args );
|
register_post_type( 'sp_metric', $args );
|
||||||
@@ -23,75 +22,8 @@ function sportspress_metric_edit_columns() {
|
|||||||
$columns = array(
|
$columns = array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'title' => __( 'Label', 'sportspress' ),
|
'title' => __( 'Label', 'sportspress' ),
|
||||||
'sp_key' => __( 'Key', 'sportspress' ),
|
'sp_positions' => __( 'Positions', 'sportspress' ),
|
||||||
'sp_format' => __( 'Format', 'sportspress' ),
|
|
||||||
'sp_equation' => __( 'Equation', 'sportspress' ),
|
|
||||||
'sp_order' => __( 'Sort Order', 'sportspress' ),
|
|
||||||
);
|
);
|
||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
add_filter( 'manage_edit-sp_metric_columns', 'sportspress_metric_edit_columns' );
|
add_filter( 'manage_edit-sp_metric_columns', 'sportspress_metric_edit_columns' );
|
||||||
|
|
||||||
function sportspress_metric_meta_init() {
|
|
||||||
add_meta_box( 'sp_equationdiv', __( 'Details', 'sportspress' ), 'sportspress_metric_equation_meta', 'sp_metric', 'normal', 'high' );
|
|
||||||
}
|
|
||||||
|
|
||||||
function sportspress_metric_equation_meta( $post ) {
|
|
||||||
$formats = sportspress_get_config_formats();
|
|
||||||
|
|
||||||
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
|
|
||||||
$order = get_post_meta( $post->ID, 'sp_order', true );
|
|
||||||
$priority = get_post_meta( $post->ID, 'sp_priority', true );
|
|
||||||
$precision = get_post_meta( $post->ID, 'sp_precision', true );
|
|
||||||
|
|
||||||
// Defaults
|
|
||||||
if ( $precision == '' ) $precision = 1;
|
|
||||||
?>
|
|
||||||
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
|
|
||||||
<p>
|
|
||||||
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
|
|
||||||
</p>
|
|
||||||
<p><strong><?php _e( 'Format', 'sportspress' ); ?></strong></p>
|
|
||||||
<p class="sp-format-selector">
|
|
||||||
<select name="sp_format">
|
|
||||||
<?php
|
|
||||||
foreach ( $formats as $key => $value ):
|
|
||||||
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
|
|
||||||
endforeach;
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</p>
|
|
||||||
<p><strong><?php _e( 'Precision', 'sportspress' ); ?></strong></p>
|
|
||||||
<p class="sp-precision-selector">
|
|
||||||
<input name="sp_precision" type="text" size="4" id="sp_precision" value="<?php echo $precision; ?>" placeholder="1">
|
|
||||||
</p>
|
|
||||||
<p><strong><?php _e( 'Equation', 'sportspress' ); ?></strong></p>
|
|
||||||
<p class="sp-equation-selector">
|
|
||||||
<?php
|
|
||||||
foreach ( $equation as $piece ):
|
|
||||||
sportspress_get_equation_selector( $post->ID, $piece, array( 'player_event' ) );
|
|
||||||
endforeach;
|
|
||||||
?>
|
|
||||||
</p>
|
|
||||||
<p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p>
|
|
||||||
<p class="sp-order-selector">
|
|
||||||
<select name="sp_priority">
|
|
||||||
<?php
|
|
||||||
$options = array( '0' => __( 'Disable', 'sportspress' ), '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', );
|
|
||||||
foreach ( $options as $key => $value ):
|
|
||||||
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
|
|
||||||
endforeach;
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
<select name="sp_order"<?php if ( ! $priority ): ?> disabled="disabled;"<?php endif; ?>>
|
|
||||||
<?php
|
|
||||||
$options = array( 'DESC' => __( 'Descending', 'sportspress' ), 'ASC' => __( 'Ascending', 'sportspress' ) );
|
|
||||||
foreach ( $options as $key => $value ):
|
|
||||||
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $order, false ), $value );
|
|
||||||
endforeach;
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</p>
|
|
||||||
<?php
|
|
||||||
sportspress_nonce();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ function sportspress_player_meta_init( $post ) {
|
|||||||
add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sportspress_player_team_meta', 'sp_player', 'side', 'high' );
|
add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sportspress_player_team_meta', 'sp_player', 'side', 'high' );
|
||||||
|
|
||||||
if ( $leagues && ! empty( $leagues ) && $seasons && is_array( $seasons ) && is_object( $seasons[0] ) ):
|
if ( $leagues && ! empty( $leagues ) && $seasons && is_array( $seasons ) && is_object( $seasons[0] ) ):
|
||||||
add_meta_box( 'sp_statsdiv', __( 'Player Statistics', 'sportspress' ), 'sportspress_player_stats_meta', 'sp_player', 'normal', 'high' );
|
add_meta_box( 'sp_statsdiv', __( 'Statistics', 'sportspress' ), 'sportspress_player_stats_meta', 'sp_player', 'normal', 'high' );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
add_meta_box( 'sp_metricsdiv', __( 'Player Metrics', 'sportspress' ), 'sportspress_player_metrics_meta', 'sp_player', 'normal', 'high' );
|
add_meta_box( 'sp_metricsdiv', __( 'Metrics', 'sportspress' ), 'sportspress_player_metrics_meta', 'sp_player', 'normal', 'high' );
|
||||||
add_meta_box( 'sp_profilediv', __( 'Profile' ), 'sportspress_player_profile_meta', 'sp_player', 'normal', 'high' );
|
add_meta_box( 'sp_profilediv', __( 'Profile' ), 'sportspress_player_profile_meta', 'sp_player', 'normal', 'high' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ function sportspress_result_edit_columns() {
|
|||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'title' => __( 'Label', 'sportspress' ),
|
'title' => __( 'Label', 'sportspress' ),
|
||||||
'sp_key' => __( 'Key', 'sportspress' ),
|
'sp_key' => __( 'Key', 'sportspress' ),
|
||||||
'sp_format' => __( 'Format', 'sportspress' ),
|
|
||||||
);
|
);
|
||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
@@ -41,16 +40,6 @@ function sportspress_result_details_meta( $post ) {
|
|||||||
<p>
|
<p>
|
||||||
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
|
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
|
||||||
</p>
|
</p>
|
||||||
<p><strong><?php _e( 'Format', 'sportspress' ); ?></strong></p>
|
|
||||||
<p class="sp-format-selector">
|
|
||||||
<select name="sp_format">
|
|
||||||
<?php
|
|
||||||
foreach ( $formats as $key => $value ):
|
|
||||||
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
|
|
||||||
endforeach;
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</p>
|
|
||||||
<?php
|
<?php
|
||||||
sportspress_nonce();
|
sportspress_nonce();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
function sportspress_statistic_post_init() {
|
function sportspress_statistic_post_init() {
|
||||||
$name = __( 'Player Statistics', 'sportspress' );
|
$name = __( 'Statistics', 'sportspress' );
|
||||||
$singular_name = __( 'Player Statistic', 'sportspress' );
|
$singular_name = __( 'Statistic', 'sportspress' );
|
||||||
$lowercase_name = __( 'player statistics', 'sportspress' );
|
$lowercase_name = __( 'statistics', 'sportspress' );
|
||||||
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name, true );
|
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name, true );
|
||||||
$args = array(
|
$args = array(
|
||||||
'label' => $name,
|
'label' => $name,
|
||||||
@@ -23,10 +23,8 @@ function sportspress_statistic_edit_columns() {
|
|||||||
$columns = array(
|
$columns = array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'title' => __( 'Label', 'sportspress' ),
|
'title' => __( 'Label', 'sportspress' ),
|
||||||
'sp_key' => __( 'Key', 'sportspress' ),
|
'sp_positions' => __( 'Positions', 'sportspress' ),
|
||||||
'sp_format' => __( 'Format', 'sportspress' ),
|
|
||||||
'sp_equation' => __( 'Equation', 'sportspress' ),
|
'sp_equation' => __( 'Equation', 'sportspress' ),
|
||||||
'sp_order' => __( 'Sort Order', 'sportspress' ),
|
|
||||||
);
|
);
|
||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
@@ -37,34 +35,8 @@ function sportspress_statistic_meta_init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sportspress_statistic_equation_meta( $post ) {
|
function sportspress_statistic_equation_meta( $post ) {
|
||||||
$formats = sportspress_get_config_formats();
|
|
||||||
|
|
||||||
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
|
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
|
||||||
$order = get_post_meta( $post->ID, 'sp_order', true );
|
|
||||||
$priority = get_post_meta( $post->ID, 'sp_priority', true );
|
|
||||||
$precision = get_post_meta( $post->ID, 'sp_precision', true );
|
|
||||||
|
|
||||||
// Defaults
|
|
||||||
if ( $precision == '' ) $precision = 1;
|
|
||||||
?>
|
?>
|
||||||
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
|
|
||||||
<p>
|
|
||||||
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
|
|
||||||
</p>
|
|
||||||
<p><strong><?php _e( 'Format', 'sportspress' ); ?></strong></p>
|
|
||||||
<p class="sp-format-selector">
|
|
||||||
<select name="sp_format">
|
|
||||||
<?php
|
|
||||||
foreach ( $formats as $key => $value ):
|
|
||||||
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
|
|
||||||
endforeach;
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</p>
|
|
||||||
<p><strong><?php _e( 'Precision', 'sportspress' ); ?></strong></p>
|
|
||||||
<p class="sp-precision-selector">
|
|
||||||
<input name="sp_precision" type="text" size="4" id="sp_precision" value="<?php echo $precision; ?>" placeholder="1">
|
|
||||||
</p>
|
|
||||||
<p><strong><?php _e( 'Equation', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Equation', 'sportspress' ); ?></strong></p>
|
||||||
<p class="sp-equation-selector">
|
<p class="sp-equation-selector">
|
||||||
<?php
|
<?php
|
||||||
@@ -73,25 +45,6 @@ function sportspress_statistic_equation_meta( $post ) {
|
|||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
<p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p>
|
|
||||||
<p class="sp-order-selector">
|
|
||||||
<select name="sp_priority">
|
|
||||||
<?php
|
|
||||||
$options = array( '0' => __( 'Disable', 'sportspress' ), '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', );
|
|
||||||
foreach ( $options as $key => $value ):
|
|
||||||
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
|
|
||||||
endforeach;
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
<select name="sp_order"<?php if ( ! $priority ): ?> disabled="disabled;"<?php endif; ?>>
|
|
||||||
<?php
|
|
||||||
$options = array( 'DESC' => __( 'Descending', 'sportspress' ), 'ASC' => __( 'Ascending', 'sportspress' ) );
|
|
||||||
foreach ( $options as $key => $value ):
|
|
||||||
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $order, false ), $value );
|
|
||||||
endforeach;
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</p>
|
|
||||||
<?php
|
<?php
|
||||||
sportspress_nonce();
|
sportspress_nonce();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ function sportspress_team_meta_init( $post ) {
|
|||||||
add_meta_box( 'postimagediv', __( 'Logo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_team', 'side', 'low' );
|
add_meta_box( 'postimagediv', __( 'Logo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_team', 'side', 'low' );
|
||||||
|
|
||||||
if ( $leagues && $seasons ):
|
if ( $leagues && $seasons ):
|
||||||
add_meta_box( 'sp_columnssdiv', __( 'Table Columns', 'sportspress' ), 'sportspress_team_columns_meta', 'sp_team', 'normal', 'high' );
|
add_meta_box( 'sp_columnssdiv', __( 'Columns', 'sportspress' ), 'sportspress_team_columns_meta', 'sp_team', 'normal', 'high' );
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
61
admin/settings/events.php
Normal file
61
admin/settings/events.php
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
$args = array(
|
||||||
|
'post_type' => 'sp_result',
|
||||||
|
'numberposts' => -1,
|
||||||
|
'posts_per_page' => -1,
|
||||||
|
'orderby' => 'menu_order',
|
||||||
|
'order' => 'ASC'
|
||||||
|
);
|
||||||
|
$data = get_posts( $args );
|
||||||
|
?>
|
||||||
|
<h3 class="title"><?php _e( 'Results', 'sportspress' ); ?></h3>
|
||||||
|
<table class="widefat sp-admin-config-table">
|
||||||
|
<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 == 0 ) echo ' class="alternate"'; ?>>
|
||||||
|
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||||
|
<td><?php echo $row->post_name; ?>for / <?php echo $row->post_name; ?>against</td>
|
||||||
|
</tr>
|
||||||
|
<?php $i++; endforeach; ?>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$args = array(
|
||||||
|
'post_type' => 'sp_outcome',
|
||||||
|
'numberposts' => -1,
|
||||||
|
'posts_per_page' => -1,
|
||||||
|
'orderby' => 'menu_order',
|
||||||
|
'order' => 'ASC'
|
||||||
|
);
|
||||||
|
$data = get_posts( $args );
|
||||||
|
?>
|
||||||
|
<h3 class="title"><?php _e( 'Outcomes', 'sportspress' ); ?></h3>
|
||||||
|
<table class="widefat sp-admin-config-table">
|
||||||
|
<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 == 0 ) 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 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>
|
||||||
64
admin/settings/players.php
Normal file
64
admin/settings/players.php
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
$args = array(
|
||||||
|
'post_type' => 'sp_metric',
|
||||||
|
'numberposts' => -1,
|
||||||
|
'posts_per_page' => -1,
|
||||||
|
'orderby' => 'menu_order',
|
||||||
|
'order' => 'ASC'
|
||||||
|
);
|
||||||
|
$data = get_posts( $args );
|
||||||
|
?>
|
||||||
|
<h3 class="title"><?php _e( 'Metrics', 'sportspress' ); ?></h3>
|
||||||
|
<table class="widefat sp-admin-config-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><?php _e( 'Label', 'sportspress' ); ?></th>
|
||||||
|
<th><?php _e( 'Positions', 'sportspress' ); ?></th>
|
||||||
|
<td> </td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<?php $i = 0; foreach ( $data as $row ): ?>
|
||||||
|
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
||||||
|
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||||
|
<td><?php echo get_the_terms ( $row->ID, 'sp_position' ) ? the_terms( $row->ID, 'sp_position' ) : sprintf( __( 'All %s', 'sportspress' ), __( 'positions', 'sportspress' ) ); ?></td>
|
||||||
|
<td> </td>
|
||||||
|
</tr>
|
||||||
|
<?php $i++; endforeach; ?>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<th colspan="4"><a href="<?php echo admin_url( 'edit.php?post_type=sp_metric' ); ?>"><?php printf( __( 'Edit %s', 'sportspress' ), __( 'Metrics', 'sportspress' ) ); ?></a></th>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
<?php
|
||||||
|
$args = array(
|
||||||
|
'post_type' => 'sp_statistic',
|
||||||
|
'numberposts' => -1,
|
||||||
|
'posts_per_page' => -1,
|
||||||
|
'orderby' => 'menu_order',
|
||||||
|
'order' => 'ASC'
|
||||||
|
);
|
||||||
|
$data = get_posts( $args );
|
||||||
|
?>
|
||||||
|
<h3 class="title"><?php _e( 'Statistics', 'sportspress' ); ?></h3>
|
||||||
|
<table class="widefat sp-admin-config-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><?php _e( 'Label', 'sportspress' ); ?></th>
|
||||||
|
<th><?php _e( 'Positions', 'sportspress' ); ?></th>
|
||||||
|
<th><?php _e( 'Equation', 'sportspress' ); ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<?php $i = 0; foreach ( $data as $row ): ?>
|
||||||
|
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
||||||
|
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||||
|
<td><?php echo get_the_terms ( $row->ID, 'sp_position' ) ? the_terms( $row->ID, 'sp_position' ) : sprintf( __( 'All %s', 'sportspress' ), __( 'positions', 'sportspress' ) ); ?></td>
|
||||||
|
<td><?php echo sportspress_get_post_equation( $row->ID ); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php $i++; endforeach; ?>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<th colspan="4"><a href="<?php echo admin_url( 'edit.php?post_type=sp_statistic' ); ?>"><?php printf( __( 'Edit %s', 'sportspress' ), __( 'Statistics', 'sportspress' ) ); ?></a></th>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
@@ -9,18 +9,21 @@ function sportspress_settings() {
|
|||||||
<h2 class="nav-tab-wrapper">
|
<h2 class="nav-tab-wrapper">
|
||||||
<a href="?page=sportspress" class="nav-tab<?php echo $active_tab == 'general' ? ' nav-tab-active' : ''; ?>"><?php _e( 'SportsPress', 'sportspress' ); ?></a>
|
<a href="?page=sportspress" class="nav-tab<?php echo $active_tab == 'general' ? ' nav-tab-active' : ''; ?>"><?php _e( 'SportsPress', 'sportspress' ); ?></a>
|
||||||
<a href="?page=sportspress&tab=events" class="nav-tab<?php echo $active_tab == 'events' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Events', 'sportspress' ); ?></a>
|
<a href="?page=sportspress&tab=events" class="nav-tab<?php echo $active_tab == 'events' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Events', 'sportspress' ); ?></a>
|
||||||
<a href="?page=sportspress&tab=teams" class="nav-tab<?php echo $active_tab == 'teams' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Teams', 'sportspress' ); ?></a>
|
<a href="?page=sportspress&tab=tables" class="nav-tab<?php echo $active_tab == 'tables' ? ' nav-tab-active' : ''; ?>"><?php _e( 'League Tables', 'sportspress' ); ?></a>
|
||||||
<a href="?page=sportspress&tab=players" class="nav-tab<?php echo $active_tab == 'players' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Players', 'sportspress' ); ?></a>
|
<a href="?page=sportspress&tab=players" class="nav-tab<?php echo $active_tab == 'players' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Players', 'sportspress' ); ?></a>
|
||||||
<a href="?page=sportspress&tab=staff" class="nav-tab<?php echo $active_tab == 'staff' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Staff', 'sportspress' ); ?></a>
|
|
||||||
<a href="?page=sportspress&tab=config" class="nav-tab<?php echo $active_tab == 'config' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Configure', 'sportspress' ); ?></a>
|
|
||||||
<a href="?page=sportspress&tab=advanced" class="nav-tab<?php echo $active_tab == 'advanced' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Advanced', 'sportspress' ); ?></a>
|
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<form method="post" action="options.php">
|
<form method="post" action="options.php">
|
||||||
<?php
|
<?php
|
||||||
switch ( $active_tab ):
|
switch ( $active_tab ):
|
||||||
case 'config':
|
case 'events':
|
||||||
include 'config.php';
|
include 'events.php';
|
||||||
|
break;
|
||||||
|
case 'tables':
|
||||||
|
include 'tables.php';
|
||||||
|
break;
|
||||||
|
case 'players':
|
||||||
|
include 'players.php';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
include 'general.php';
|
include 'general.php';
|
||||||
|
|||||||
36
admin/settings/tables.php
Normal file
36
admin/settings/tables.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
$args = array(
|
||||||
|
'post_type' => 'sp_column',
|
||||||
|
'numberposts' => -1,
|
||||||
|
'posts_per_page' => -1,
|
||||||
|
'orderby' => 'menu_order',
|
||||||
|
'order' => 'ASC'
|
||||||
|
);
|
||||||
|
$data = get_posts( $args );
|
||||||
|
?>
|
||||||
|
<h3 class="title"><?php _e( 'Columns', 'sportspress' ); ?></h3>
|
||||||
|
<table class="widefat sp-admin-config-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><?php _e( 'Label', 'sportspress' ); ?></th>
|
||||||
|
<th><?php _e( 'Key', 'sportspress' ); ?></th>
|
||||||
|
<th><?php _e( 'Equation', 'sportspress' ); ?></th>
|
||||||
|
<th><?php _e( 'Precision', 'sportspress' ); ?></th>
|
||||||
|
<th><?php _e( 'Sort Order', 'sportspress' ); ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<?php $i = 0; foreach ( $data as $row ): ?>
|
||||||
|
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
||||||
|
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||||
|
<td><?php echo $row->post_name; ?></td>
|
||||||
|
<td><?php echo sportspress_get_post_equation( $row->ID, $row->post_name ); ?></td>
|
||||||
|
<td><?php echo sportspress_get_post_precision( $row->ID ); ?></td>
|
||||||
|
<td><?php echo sportspress_get_post_order( $row->ID ); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php $i++; endforeach; ?>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<th colspan="5"><a href="<?php echo admin_url( 'edit.php?post_type=sp_column' ); ?>"><?php printf( __( 'Edit %s', 'sportspress' ), __( 'Columns', 'sportspress' ) ); ?></a></th>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
46
admin/templates/event-details.php
Normal file
46
admin/templates/event-details.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
if ( !function_exists( 'sportspress_event_details' ) ) {
|
||||||
|
function sportspress_event_details( $id = null ) {
|
||||||
|
|
||||||
|
if ( ! $id ):
|
||||||
|
global $post;
|
||||||
|
$id = $post->ID;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
$date = get_the_time( get_option('date_format'), $id );
|
||||||
|
$time = get_the_time( get_option('time_format'), $id );
|
||||||
|
$leagues = get_the_terms( $id, 'sp_league' );
|
||||||
|
$seasons = get_the_terms( $id, 'sp_season' );
|
||||||
|
|
||||||
|
$data = array( __( 'Date', 'sportspress' ) => $date, __( 'Time', 'sportspress' ) => $time );
|
||||||
|
|
||||||
|
if ( $leagues )
|
||||||
|
$data[ __( 'League', 'sportspress' ) ] = sportspress_array_value( $leagues, 0, '—' )->name;
|
||||||
|
|
||||||
|
if ( $seasons )
|
||||||
|
$data[ __( 'Season', 'sportspress' ) ] = sportspress_array_value( $seasons, 0, '—' )->name;
|
||||||
|
|
||||||
|
|
||||||
|
$output = '<h3>' . __( 'Details', 'sportspress' ) . '</h3>';
|
||||||
|
|
||||||
|
$output .= '<table class="sp-event-details sp-data-table"><tbody>';
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
foreach( $data as $label => $value ):
|
||||||
|
|
||||||
|
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||||
|
$output .= '<th>' . $label . '</th>';
|
||||||
|
$output .= '<td>' . $value . '</td>';
|
||||||
|
$output .= '</tr>';
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tbody></table>';
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_event_details', $output );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
105
admin/templates/event-players.php
Normal file
105
admin/templates/event-players.php
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<?php
|
||||||
|
if ( !function_exists( 'sportspress_event_players' ) ) {
|
||||||
|
function sportspress_event_players( $id = null ) {
|
||||||
|
|
||||||
|
if ( ! $id ):
|
||||||
|
global $post;
|
||||||
|
$id = $post->ID;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
$teams = (array)get_post_meta( $id, 'sp_team', false );
|
||||||
|
$staff = (array)get_post_meta( $id, 'sp_staff', false );
|
||||||
|
$stats = (array)get_post_meta( $id, 'sp_players', true );
|
||||||
|
$statistic_labels = sportspress_get_var_labels( 'sp_statistic' );
|
||||||
|
|
||||||
|
$output = '';
|
||||||
|
|
||||||
|
foreach( $teams as $key => $team_id ):
|
||||||
|
if ( ! $team_id ) continue;
|
||||||
|
|
||||||
|
// Get results for players in the team
|
||||||
|
$players = sportspress_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $key );
|
||||||
|
$data = sportspress_array_combine( $players, sportspress_array_value( $stats, $team_id, array() ) );
|
||||||
|
|
||||||
|
$output .= '<h3>' . get_the_title( $team_id ) . '</h3>';
|
||||||
|
|
||||||
|
$output .= '<table class="sp-event-statistics sp-data-table">' . '<thead>' . '<tr>';
|
||||||
|
|
||||||
|
$output .= '<th class="data-number">#</th>';
|
||||||
|
$output .= '<th class="data-number">' . __( 'Player', 'sportspress' ) . '</th>';
|
||||||
|
|
||||||
|
foreach( $statistic_labels as $key => $label ):
|
||||||
|
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
foreach( $data as $player_id => $row ):
|
||||||
|
|
||||||
|
if ( ! $player_id )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||||
|
|
||||||
|
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||||
|
|
||||||
|
// Player number
|
||||||
|
$output .= '<td class="data-number">' . $number . '</td>';
|
||||||
|
|
||||||
|
// Name as link
|
||||||
|
$permalink = get_post_permalink( $player_id );
|
||||||
|
$name = get_the_title( $player_id );
|
||||||
|
$output .= '<td class="data-name">' . '<a href="' . $permalink . '">' . $name . '</a></td>';
|
||||||
|
|
||||||
|
foreach( $statistic_labels as $key => $label ):
|
||||||
|
if ( $key == 'name' )
|
||||||
|
continue;
|
||||||
|
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
|
||||||
|
$value = $row[ $key ];
|
||||||
|
else:
|
||||||
|
$value = 0;
|
||||||
|
endif;
|
||||||
|
$output .= '<td class="data-' . $key . '">' . $value . '</td>';
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tr>';
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tbody>';
|
||||||
|
|
||||||
|
if ( array_key_exists( 0, $data ) ):
|
||||||
|
|
||||||
|
$output .= '<tfoot><tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||||
|
|
||||||
|
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||||
|
|
||||||
|
// Player number
|
||||||
|
$output .= '<td class="data-number"> </td>';
|
||||||
|
$output .= '<td class="data-name">' . __( 'Total', 'sportspress' ) . '</td>';
|
||||||
|
|
||||||
|
$row = $data[0];
|
||||||
|
|
||||||
|
foreach( $statistic_labels as $key => $label ):
|
||||||
|
if ( $key == 'name' ):
|
||||||
|
continue;
|
||||||
|
endif;
|
||||||
|
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tr></tfoot>';
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
$output .= '</table>';
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_event_players', $output );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
66
admin/templates/event-results.php
Normal file
66
admin/templates/event-results.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
if ( !function_exists( 'sportspress_event_results' ) ) {
|
||||||
|
function sportspress_event_results( $id = null ) {
|
||||||
|
|
||||||
|
if ( ! $id ):
|
||||||
|
global $post;
|
||||||
|
$id = $post->ID;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
$teams = (array)get_post_meta( $id, 'sp_team', false );
|
||||||
|
$results = sportspress_array_combine( $teams, (array)get_post_meta( $id, 'sp_results', true ) );
|
||||||
|
$result_labels = sportspress_get_var_labels( 'sp_result' );
|
||||||
|
|
||||||
|
$output = '';
|
||||||
|
|
||||||
|
// Initialize and check
|
||||||
|
$table_rows = '';
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
foreach( $results as $team_id => $result ):
|
||||||
|
if ( sportspress_array_value( $result, 'outcome', '-1' ) != '-1' ):
|
||||||
|
|
||||||
|
unset( $result['outcome'] );
|
||||||
|
|
||||||
|
$table_rows .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||||
|
|
||||||
|
$table_rows .= '<td class="column_name">' . get_the_title( $team_id ) . '</td>';
|
||||||
|
|
||||||
|
foreach( $result_labels as $key => $label ):
|
||||||
|
if ( $key == 'name' )
|
||||||
|
continue;
|
||||||
|
if ( array_key_exists( $key, $result ) && $result[ $key ] != '' ):
|
||||||
|
$value = $result[ $key ];
|
||||||
|
else:
|
||||||
|
$value = '—';
|
||||||
|
endif;
|
||||||
|
$table_rows .= '<td class="data-' . $key . '">' . $value . '</td>';
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$table_rows .= '</tr>';
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
if ( ! empty( $table_rows ) ):
|
||||||
|
|
||||||
|
$output .= '<h3>' . __( 'Results', 'sportspress' ) . '</h3>';
|
||||||
|
|
||||||
|
$output .= '<table class="sp-event-results sp-data-table"><thead>';
|
||||||
|
$output .= '<th class="data-name">' . __( 'Team', 'sportspress' ) . '</th>';
|
||||||
|
foreach( $result_labels as $key => $label ):
|
||||||
|
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||||
|
endforeach;
|
||||||
|
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||||
|
$output .= $table_rows;
|
||||||
|
$output .= '</tbody></table>';
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_event_results', $output );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
17
admin/templates/event-staff.php
Normal file
17
admin/templates/event-staff.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
if ( !function_exists( 'sportspress_event_staff' ) ) {
|
||||||
|
function sportspress_event_staff( $id = null ) {
|
||||||
|
|
||||||
|
if ( ! $id ):
|
||||||
|
global $post;
|
||||||
|
$id = $post->ID;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
$staff = (array)get_post_meta( $id, 'sp_staff', false );
|
||||||
|
|
||||||
|
$output = '';
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_event_staff', $output );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
29
admin/templates/event-venue.php
Normal file
29
admin/templates/event-venue.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
if ( !function_exists( 'sportspress_event_venue' ) ) {
|
||||||
|
function sportspress_event_venue( $id ) {
|
||||||
|
|
||||||
|
$venues = get_the_terms( $id, 'sp_venue' );
|
||||||
|
|
||||||
|
$output = '';
|
||||||
|
|
||||||
|
if ( ! $venues )
|
||||||
|
return $output;
|
||||||
|
|
||||||
|
foreach( $venues as $venue ):
|
||||||
|
|
||||||
|
$t_id = $venue->term_id;
|
||||||
|
$term_meta = get_option( "taxonomy_$t_id" );
|
||||||
|
|
||||||
|
$address = sportspress_array_value( $term_meta, 'sp_address', '' );
|
||||||
|
$latitude = sportspress_array_value( $term_meta, 'sp_latitude', 0 );
|
||||||
|
$longitude = sportspress_array_value( $term_meta, 'sp_longitude', 0 );
|
||||||
|
|
||||||
|
$output .= '<h3>' . $venue->name . '</h3>';
|
||||||
|
$output .= '<div class="sp-google-map" data-address="' . $address . '" data-latitude="' . $latitude . '" data-longitude="' . $longitude . '"></div>';
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_event_venue', $output );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
180
admin/templates/events-calendar.php
Normal file
180
admin/templates/events-calendar.php
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
<?php
|
||||||
|
if ( !function_exists( 'sportspress_events_calendar' ) ) {
|
||||||
|
function sportspress_events_calendar( $id = null ) {
|
||||||
|
|
||||||
|
if ( ! $id ):
|
||||||
|
global $post;
|
||||||
|
$id = $post->ID;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
|
||||||
|
$initial = false;
|
||||||
|
$echo = 1;
|
||||||
|
|
||||||
|
// Quick check. If we have no posts at all, abort!
|
||||||
|
if ( !$posts )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// week_begins = 0 stands for Sunday
|
||||||
|
$week_begins = intval(get_option('start_of_week'));
|
||||||
|
|
||||||
|
// Let's figure out when we are
|
||||||
|
if ( !empty($monthnum) && !empty($year) ) {
|
||||||
|
$thismonth = ''.zeroise(intval($monthnum), 2);
|
||||||
|
$thisyear = ''.intval($year);
|
||||||
|
} elseif ( !empty($w) ) {
|
||||||
|
// We need to get the month from MySQL
|
||||||
|
$thisyear = ''.intval(substr($m, 0, 4));
|
||||||
|
$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
|
||||||
|
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
|
||||||
|
} elseif ( !empty($m) ) {
|
||||||
|
$thisyear = ''.intval(substr($m, 0, 4));
|
||||||
|
if ( strlen($m) < 6 )
|
||||||
|
$thismonth = '01';
|
||||||
|
else
|
||||||
|
$thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
|
||||||
|
} else {
|
||||||
|
$thisyear = gmdate('Y', current_time('timestamp'));
|
||||||
|
$thismonth = gmdate('m', current_time('timestamp'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
|
||||||
|
$last_day = date('t', $unixmonth);
|
||||||
|
|
||||||
|
// Get the next and previous month and year with at least one post
|
||||||
|
$previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
||||||
|
FROM $wpdb->posts
|
||||||
|
WHERE post_date < '$thisyear-$thismonth-01'
|
||||||
|
AND post_type = 'sp_event' AND post_status = 'publish'
|
||||||
|
ORDER BY post_date DESC
|
||||||
|
LIMIT 1");
|
||||||
|
$next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
||||||
|
FROM $wpdb->posts
|
||||||
|
WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
|
||||||
|
AND post_type = 'sp_event' AND post_status = 'publish'
|
||||||
|
ORDER BY post_date ASC
|
||||||
|
LIMIT 1");
|
||||||
|
|
||||||
|
/* translators: Calendar caption: 1: month name, 2: 4-digit year */
|
||||||
|
$calendar_caption = _x('%1$s %2$s', 'calendar caption');
|
||||||
|
$calendar_output = '<table id="wp-calendar">
|
||||||
|
<caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
|
||||||
|
<thead>
|
||||||
|
<tr>';
|
||||||
|
|
||||||
|
$myweek = array();
|
||||||
|
|
||||||
|
for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
|
||||||
|
$myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ( $myweek as $wd ) {
|
||||||
|
$day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
|
||||||
|
$wd = esc_attr($wd);
|
||||||
|
$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$calendar_output .= '
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tfoot>
|
||||||
|
<tr>';
|
||||||
|
|
||||||
|
if ( $previous ) {
|
||||||
|
$calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
|
||||||
|
} else {
|
||||||
|
$calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$calendar_output .= "\n\t\t".'<td class="pad"> </td>';
|
||||||
|
|
||||||
|
if ( $next ) {
|
||||||
|
$calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>';
|
||||||
|
} else {
|
||||||
|
$calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$calendar_output .= '
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<tr>';
|
||||||
|
|
||||||
|
// Get days with posts
|
||||||
|
$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
|
||||||
|
FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
|
||||||
|
AND post_type = 'sp_event' AND post_status = 'publish'
|
||||||
|
AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
|
||||||
|
if ( $dayswithposts ) {
|
||||||
|
foreach ( (array) $dayswithposts as $daywith ) {
|
||||||
|
$daywithpost[] = $daywith[0];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$daywithpost = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
|
||||||
|
$ak_title_separator = "\n";
|
||||||
|
else
|
||||||
|
$ak_title_separator = ', ';
|
||||||
|
|
||||||
|
$ak_titles_for_day = array();
|
||||||
|
$ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
|
||||||
|
."FROM $wpdb->posts "
|
||||||
|
."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
|
||||||
|
."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
|
||||||
|
."AND post_type = 'sp_event' AND post_status = 'publish'"
|
||||||
|
);
|
||||||
|
if ( $ak_post_titles ) {
|
||||||
|
foreach ( (array) $ak_post_titles as $ak_post_title ) {
|
||||||
|
|
||||||
|
/** This filter is documented in wp-includes/post-template.php */
|
||||||
|
$post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
|
||||||
|
|
||||||
|
if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
|
||||||
|
$ak_titles_for_day['day_'.$ak_post_title->dom] = '';
|
||||||
|
if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
|
||||||
|
$ak_titles_for_day["$ak_post_title->dom"] = $post_title;
|
||||||
|
else
|
||||||
|
$ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// See how much we should pad in the beginning
|
||||||
|
$pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
|
||||||
|
if ( 0 != $pad )
|
||||||
|
$calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>';
|
||||||
|
|
||||||
|
$daysinmonth = intval(date('t', $unixmonth));
|
||||||
|
for ( $day = 1; $day <= $daysinmonth; ++$day ) {
|
||||||
|
if ( isset($newrow) && $newrow )
|
||||||
|
$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
|
||||||
|
$newrow = false;
|
||||||
|
|
||||||
|
if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
|
||||||
|
$calendar_output .= '<td id="today">';
|
||||||
|
else
|
||||||
|
$calendar_output .= '<td>';
|
||||||
|
|
||||||
|
if ( in_array($day, $daywithpost) ) // any posts today?
|
||||||
|
$calendar_output .= '<a href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>";
|
||||||
|
else
|
||||||
|
$calendar_output .= $day;
|
||||||
|
$calendar_output .= '</td>';
|
||||||
|
|
||||||
|
if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
|
||||||
|
$newrow = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
|
||||||
|
if ( $pad != 0 && $pad != 7 )
|
||||||
|
$calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>';
|
||||||
|
|
||||||
|
$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_events_calendar', $calendar_output );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
72
admin/templates/league-table.php
Normal file
72
admin/templates/league-table.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
if ( !function_exists( 'sportspress_league_table' ) ) {
|
||||||
|
function sportspress_league_table( $id = null, $args = '' ) {
|
||||||
|
|
||||||
|
if ( ! $id ):
|
||||||
|
global $post;
|
||||||
|
$id = $post->ID;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
$defaults = array(
|
||||||
|
'number_label' => __( 'Pos', 'sportspress' ),
|
||||||
|
'thumbnails' => 1,
|
||||||
|
'thumbnail_size' => 'thumbnail'
|
||||||
|
);
|
||||||
|
|
||||||
|
$r = wp_parse_args( $args, $defaults );
|
||||||
|
|
||||||
|
$data = sportspress_get_league_table_data( $id );
|
||||||
|
|
||||||
|
$output = '<table class="sp-league-table sp-data-table">' .
|
||||||
|
'<caption>' . get_the_title( $id ) . '</caption>' . '<thead>' . '<tr>';
|
||||||
|
|
||||||
|
// The first row should be column labels
|
||||||
|
$labels = $data[0];
|
||||||
|
|
||||||
|
// Remove the first row to leave us with the actual data
|
||||||
|
unset( $data[0] );
|
||||||
|
|
||||||
|
$output .= '<th class="data-number">' . $r['number_label'] . '</th>';
|
||||||
|
foreach( $labels as $key => $label ):
|
||||||
|
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
foreach( $data as $team_id => $row ):
|
||||||
|
|
||||||
|
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||||
|
|
||||||
|
// Position as number
|
||||||
|
$output .= '<td class="data-number">' . $i . '</td>';
|
||||||
|
|
||||||
|
// Thumbnail and name as link
|
||||||
|
$permalink = get_post_permalink( $team_id );
|
||||||
|
if ( $r['thumbnails'] ):
|
||||||
|
$thumbnail = get_the_post_thumbnail( $team_id, $r['thumbnail_size'], array( 'class' => 'logo' ) );
|
||||||
|
else:
|
||||||
|
$thumbnail = null;
|
||||||
|
endif;
|
||||||
|
$name = sportspress_array_value( $row, 'name', sportspress_array_value( $row, 'name', ' ' ) );
|
||||||
|
$output .= '<td class="data-name">' . ( $thumbnail ? $thumbnail . ' ' : '' ) . '<a href="' . $permalink . '">' . $name . '</a></td>';
|
||||||
|
|
||||||
|
foreach( $labels as $key => $value ):
|
||||||
|
if ( $key == 'name' )
|
||||||
|
continue;
|
||||||
|
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tr>';
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tbody>' . '</table>';
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_league_table', $output );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
48
admin/templates/player-league-statistics.php
Normal file
48
admin/templates/player-league-statistics.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
if ( !function_exists( 'sportspress_player_league_statistics' ) ) {
|
||||||
|
function sportspress_player_league_statistics( $league, $id = null ) {
|
||||||
|
|
||||||
|
if ( ! $id ):
|
||||||
|
global $post;
|
||||||
|
$id = $post->ID;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
$data = sportspress_get_player_statistics_data( $id, $league->term_id );
|
||||||
|
|
||||||
|
// The first row should be column labels
|
||||||
|
$labels = $data[0];
|
||||||
|
|
||||||
|
// Remove the first row to leave us with the actual data
|
||||||
|
unset( $data[0] );
|
||||||
|
|
||||||
|
$output = '<table class="sp-player-statistics sp-data-table">' .
|
||||||
|
'<caption>' . $league->name . '</caption>' . '<thead>' . '<tr>';
|
||||||
|
|
||||||
|
foreach( $labels as $key => $label ):
|
||||||
|
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
foreach( $data as $season_id => $row ):
|
||||||
|
|
||||||
|
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||||
|
|
||||||
|
foreach( $labels as $key => $value ):
|
||||||
|
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tr>';
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tbody>' . '</table>';
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_player_league_statistics', $output );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
59
admin/templates/player-list.php
Normal file
59
admin/templates/player-list.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
if ( !function_exists( 'sportspress_player_list' ) ) {
|
||||||
|
function sportspress_player_list( $id = null ) {
|
||||||
|
|
||||||
|
if ( ! $id ):
|
||||||
|
global $post;
|
||||||
|
$id = $post->ID;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
$data = sportspress_get_player_list_data( $id );
|
||||||
|
|
||||||
|
$output = '<table class="sp-player-list sp-data-table">' . '<thead>' . '<tr>';
|
||||||
|
|
||||||
|
// The first row should be column labels
|
||||||
|
$labels = $data[0];
|
||||||
|
|
||||||
|
// Remove the first row to leave us with the actual data
|
||||||
|
unset( $data[0] );
|
||||||
|
|
||||||
|
$output .= '<th class="data-number">#</th>';
|
||||||
|
foreach( $labels as $key => $label ):
|
||||||
|
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
foreach( $data as $player_id => $row ):
|
||||||
|
|
||||||
|
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||||
|
|
||||||
|
// Player number
|
||||||
|
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||||
|
$output .= '<td class="data-number">' . ( $number ? $number : ' ' ) . '</td>';
|
||||||
|
|
||||||
|
// Name as link
|
||||||
|
$permalink = get_post_permalink( $player_id );
|
||||||
|
$name = sportspress_array_value( $row, 'name', sportspress_array_value( $row, 'name', ' ' ) );
|
||||||
|
$output .= '<td class="data-name">' . '<a href="' . $permalink . '">' . $name . '</a></td>';
|
||||||
|
|
||||||
|
foreach( $labels as $key => $value ):
|
||||||
|
if ( $key == 'name' )
|
||||||
|
continue;
|
||||||
|
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tr>';
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tbody>' . '</table>';
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_player_list', $output );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
42
admin/templates/player-metrics.php
Normal file
42
admin/templates/player-metrics.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
if ( !function_exists( 'sportspress_player_metrics' ) ) {
|
||||||
|
function sportspress_player_metrics( $id = null ) {
|
||||||
|
|
||||||
|
if ( ! $id ):
|
||||||
|
global $post;
|
||||||
|
$id = $post->ID;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
global $sportspress_countries;
|
||||||
|
|
||||||
|
$number = get_post_meta( $id, 'sp_number', true );
|
||||||
|
$nationality = get_post_meta( $id, 'sp_nationality', true );
|
||||||
|
$metrics = sportspress_get_player_metrics_data( $id );
|
||||||
|
|
||||||
|
$flag_image = '<img src="' . SPORTSPRESS_PLUGIN_URL . 'assets/images/flags/' . strtolower( $nationality ) . '.png" class="sp-flag">';
|
||||||
|
|
||||||
|
$common = array(
|
||||||
|
__( 'Number', 'sportspress' ) => $number,
|
||||||
|
__( 'Nationality', 'sportspress' ) => $flag_image . ' ' . sportspress_array_value( $sportspress_countries, $nationality, '—' ),
|
||||||
|
);
|
||||||
|
|
||||||
|
$data = array_merge( $common, $metrics );
|
||||||
|
|
||||||
|
$output = '<table class="sp-player-metrics sp-data-table">' . '<tbody>';
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
foreach( $data as $label => $value ):
|
||||||
|
|
||||||
|
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '"><th>' . $label . '</th><td>' . $value . '</td></tr>';
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tbody>' . '</table>';
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_player_metrics', $output );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
24
admin/templates/player-statistics.php
Normal file
24
admin/templates/player-statistics.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
if ( !function_exists( 'sportspress_player_statistics' ) ) {
|
||||||
|
function sportspress_player_statistics( $id = null ) {
|
||||||
|
|
||||||
|
if ( ! $id ):
|
||||||
|
global $post;
|
||||||
|
$id = $post->ID;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
$leagues = get_the_terms( $id, 'sp_league' );
|
||||||
|
|
||||||
|
$output = '';
|
||||||
|
|
||||||
|
// Loop through statistics for each league
|
||||||
|
foreach ( $leagues as $league ):
|
||||||
|
|
||||||
|
$output .= sportspress_player_league_statistics( $league, $id );
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_player_statistics', $output );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
63
admin/templates/team-columns.php
Normal file
63
admin/templates/team-columns.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
if ( !function_exists( 'sportspress_team_columns' ) ) {
|
||||||
|
function sportspress_team_columns( $id = null ) {
|
||||||
|
|
||||||
|
if ( ! $id ):
|
||||||
|
global $post;
|
||||||
|
$id = $post->ID;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
$leagues = get_the_terms( $id, 'sp_league' );
|
||||||
|
|
||||||
|
$output = '';
|
||||||
|
|
||||||
|
// Loop through data for each league
|
||||||
|
foreach ( $leagues as $league ):
|
||||||
|
|
||||||
|
$data = sportspress_get_team_columns_data( $id, $league->term_id );
|
||||||
|
|
||||||
|
if ( sizeof( $data ) <= 1 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ( sizeof( $leagues ) > 1 )
|
||||||
|
$output .= '<h4 class="sp-team-league-name">' . $league->name . '</h4>';
|
||||||
|
|
||||||
|
// The first row should be column labels
|
||||||
|
$labels = $data[0];
|
||||||
|
|
||||||
|
// Remove the first row to leave us with the actual data
|
||||||
|
unset( $data[0] );
|
||||||
|
|
||||||
|
$output .= '<table class="sp-team-columns sp-data-table">' . '<thead>' . '<tr>';
|
||||||
|
|
||||||
|
foreach( $labels as $key => $label ):
|
||||||
|
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
foreach( $data as $season_id => $row ):
|
||||||
|
|
||||||
|
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||||
|
|
||||||
|
foreach( $labels as $key => $value ):
|
||||||
|
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tr>';
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$output .= '</tbody>' . '</table>';
|
||||||
|
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_team_columns', $output );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ function sportspress_position_term_init() {
|
|||||||
$name = __( 'Positions', 'sportspress' );
|
$name = __( 'Positions', 'sportspress' );
|
||||||
$singular_name = __( 'Position', 'sportspress' );
|
$singular_name = __( 'Position', 'sportspress' );
|
||||||
$lowercase_name = __( 'position', 'sportspress' );
|
$lowercase_name = __( 'position', 'sportspress' );
|
||||||
$object_type = array( 'sp_player', 'attachment' );
|
$object_type = array( 'sp_player', 'sp_statistic', 'sp_metric', 'attachment' );
|
||||||
$labels = sportspress_get_term_labels( $name, $singular_name, $lowercase_name );
|
$labels = sportspress_get_term_labels( $name, $singular_name, $lowercase_name );
|
||||||
$args = array(
|
$args = array(
|
||||||
'label' => $name,
|
'label' => $name,
|
||||||
@@ -14,6 +14,8 @@ function sportspress_position_term_init() {
|
|||||||
);
|
);
|
||||||
register_taxonomy( 'sp_position', $object_type, $args );
|
register_taxonomy( 'sp_position', $object_type, $args );
|
||||||
register_taxonomy_for_object_type( 'sp_position', 'sp_player' );
|
register_taxonomy_for_object_type( 'sp_position', 'sp_player' );
|
||||||
|
register_taxonomy_for_object_type( 'sp_position', 'sp_statistic' );
|
||||||
|
register_taxonomy_for_object_type( 'sp_position', 'sp_metric' );
|
||||||
register_taxonomy_for_object_type( 'sp_position', 'attachment' );
|
register_taxonomy_for_object_type( 'sp_position', 'attachment' );
|
||||||
}
|
}
|
||||||
add_action( 'init', 'sportspress_position_term_init' );
|
add_action( 'init', 'sportspress_position_term_init' );
|
||||||
|
|||||||
2364
functions.php
2364
functions.php
File diff suppressed because it is too large
Load Diff
10
readme.txt
10
readme.txt
@@ -12,7 +12,15 @@ SportsPress is a flexible sports management plugin that adds team management fun
|
|||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
= 0.1.3 =
|
= 0.1.3 =
|
||||||
* Feature - Lots of features. To be updated.
|
* Fix - Style conflict with Foundation framework in table columns.
|
||||||
|
* Feature - HTML output added to custom post types with data table sorting.
|
||||||
|
* Feature - Enable metrics and statistics per player position.
|
||||||
|
* Feature - Save team played per season per league in player edit screen.
|
||||||
|
* Feature - Give teams the option to show and hide past seasons.
|
||||||
|
* Feature - Venues, Seasons, and Leagues added as taxonomies.
|
||||||
|
* Feature - Add L10 counter to report last 10 outcomes.
|
||||||
|
* Feature - Add STRK counter to report current outcome streak.
|
||||||
|
* Localization - Add country names in Czech, German, Spanish, French, Italian, Japanese, Polish, Russian, and Slovak.
|
||||||
|
|
||||||
= 0.1.2 =
|
= 0.1.2 =
|
||||||
* Tweak - Use custom post types for metrics and statistics configuration.
|
* Tweak - Use custom post types for metrics and statistics configuration.
|
||||||
|
|||||||
@@ -32,9 +32,22 @@ include_once dirname( __FILE__ ) . '/admin/globals/countries.php';
|
|||||||
include_once dirname( __FILE__ ) . '/admin/globals/sports.php';
|
include_once dirname( __FILE__ ) . '/admin/globals/sports.php';
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
require_once dirname( __FILE__ ) . '/admin-functions.php';
|
|
||||||
require_once dirname( __FILE__ ) . '/functions.php';
|
require_once dirname( __FILE__ ) . '/functions.php';
|
||||||
|
|
||||||
|
// Templates
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/templates/event-details.php';
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/templates/event-players.php';
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/templates/event-results.php';
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/templates/event-staff.php';
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/templates/event-venue.php';
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/templates/events-calendar.php';
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/templates/league-table.php';
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/templates/player-league-statistics.php';
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/templates/player-list.php';
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/templates/player-metrics.php';
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/templates/player-statistics.php';
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/templates/team-columns.php';
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
include dirname( __FILE__ ) . '/admin/settings/settings.php' ;
|
include dirname( __FILE__ ) . '/admin/settings/settings.php' ;
|
||||||
|
|
||||||
@@ -84,6 +97,7 @@ require_once dirname( __FILE__ ) . '/admin/hooks/sanitize-title.php';
|
|||||||
require_once dirname( __FILE__ ) . '/admin/hooks/the-content.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/the-content.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/hooks/wp-insert-post-data.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/wp-insert-post-data.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/hooks/plugin-action-links.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/plugin-action-links.php';
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/hooks/post-updated-messages.php';
|
||||||
|
|
||||||
// Register activation hook
|
// Register activation hook
|
||||||
require_once dirname( __FILE__ ) . '/admin/hooks/register-activation-hook.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/register-activation-hook.php';
|
||||||
|
|||||||
Reference in New Issue
Block a user