Add player list widget and add league table widget columns selector
This commit is contained in:
@@ -21,7 +21,7 @@ function sportspress_gettext( $translated_text, $untranslated_text, $domain ) {
|
|||||||
elseif ( in_array( $typenow, array( 'sp_event', 'sp_player', 'sp_staff' ) ) ):
|
elseif ( in_array( $typenow, array( 'sp_event', 'sp_player', 'sp_staff' ) ) ):
|
||||||
switch ( $untranslated_text ):
|
switch ( $untranslated_text ):
|
||||||
case 'Enter title here':
|
case 'Enter title here':
|
||||||
$translated_text = __( 'Name', 'sportspress' );
|
$translated_text = __( '(Auto)', 'sportspress' );
|
||||||
break;
|
break;
|
||||||
case 'Set featured image':
|
case 'Set featured image':
|
||||||
$translated_text = sprintf( __( 'Select %s', 'sportspress' ), __( 'Photo', 'sportspress' ) );
|
$translated_text = sprintf( __( 'Select %s', 'sportspress' ), __( 'Photo', 'sportspress' ) );
|
||||||
|
|||||||
@@ -33,9 +33,24 @@ add_filter( 'the_content', 'sportspress_default_team_content' );
|
|||||||
|
|
||||||
function sportspress_default_table_content( $content ) {
|
function sportspress_default_table_content( $content ) {
|
||||||
if ( is_singular( 'sp_table' ) && in_the_loop() ):
|
if ( is_singular( 'sp_table' ) && in_the_loop() ):
|
||||||
|
$id = get_the_ID();
|
||||||
|
$leagues = get_the_terms( $id, 'sp_league' );
|
||||||
|
$seasons = get_the_terms( $id, 'sp_season' );
|
||||||
|
$terms = array();
|
||||||
|
if ( $leagues ):
|
||||||
|
$league = reset( $leagues );
|
||||||
|
$terms[] = $league->name;
|
||||||
|
endif;
|
||||||
|
if ( $seasons ):
|
||||||
|
$season = reset( $seasons );
|
||||||
|
$terms[] = $season->name;
|
||||||
|
endif;
|
||||||
|
$title = '';
|
||||||
|
if ( sizeof( $terms ) )
|
||||||
|
$title = '<h4 class="sp-table-caption">' . implode( ' — ', $terms ) . '</h4>';
|
||||||
$table = sportspress_league_table();
|
$table = sportspress_league_table();
|
||||||
$excerpt = has_excerpt() ? wpautop( get_the_excerpt() ) : '';
|
$excerpt = has_excerpt() ? wpautop( get_the_excerpt() ) : '';
|
||||||
$content = $table . $content . $excerpt;
|
$content = $title . $table . $content . $excerpt;
|
||||||
endif;
|
endif;
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ function sportspress_player_details_meta( $post ) {
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<select id="sp_nationality" name="sp_nationality">
|
<select id="sp_nationality" name="sp_nationality">
|
||||||
|
<option value=""><?php _e( '-- Not set --', 'sportspress' ); ?></option>
|
||||||
<?php foreach ( $continents as $continent => $countries ): ?>
|
<?php foreach ( $continents as $continent => $countries ): ?>
|
||||||
<option value=""><?php _e( '-- Not set --', 'sportspress' ); ?></option>
|
|
||||||
<optgroup label="<?php echo $continent; ?>">
|
<optgroup label="<?php echo $continent; ?>">
|
||||||
<?php foreach ( $countries as $code => $country ): ?>
|
<?php foreach ( $countries as $code => $country ): ?>
|
||||||
<option value="<?php echo $code; ?>" <?php selected ( $nationality, $code ); ?>>
|
<option value="<?php echo $code; ?>" <?php selected ( $nationality, $code ); ?>>
|
||||||
|
|||||||
@@ -6,34 +6,12 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
|
|||||||
$id = get_the_ID();
|
$id = get_the_ID();
|
||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'number_label' => __( 'Pos', 'sportspress' ),
|
'columns' => null,
|
||||||
'thumbnails' => 0,
|
|
||||||
'thumbnail_size' => 'thumbnail'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$r = wp_parse_args( $args, $defaults );
|
$r = wp_parse_args( $args, $defaults );
|
||||||
|
|
||||||
$leagues = get_the_terms( $id, 'sp_league' );
|
$output = '<div class="sp-table-wrapper">' .
|
||||||
$seasons = get_the_terms( $id, 'sp_season' );
|
|
||||||
|
|
||||||
$terms = array();
|
|
||||||
if ( $leagues ):
|
|
||||||
$league = reset( $leagues );
|
|
||||||
$terms[] = $league->name;
|
|
||||||
endif;
|
|
||||||
if ( $seasons ):
|
|
||||||
$season = reset( $seasons );
|
|
||||||
$terms[] = $season->name;
|
|
||||||
endif;
|
|
||||||
|
|
||||||
$title = sizeof( $terms ) ? implode( ' — ', $terms ) : get_the_title( $id );
|
|
||||||
|
|
||||||
if ( ! is_singular( 'sp_table' ) )
|
|
||||||
$output = '<h4 class="sp-table-caption"><a href="' . get_permalink( $id ) . '">' . $title . '</a></h4>';
|
|
||||||
else
|
|
||||||
$output = '<h4 class="sp-table-caption">' . $title . '</h4>';
|
|
||||||
|
|
||||||
$output .= '<div class="sp-table-wrapper">' .
|
|
||||||
'<table class="sp-league-table sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
'<table class="sp-league-table sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||||
|
|
||||||
$data = sportspress_get_league_table_data( $id );
|
$data = sportspress_get_league_table_data( $id );
|
||||||
@@ -44,9 +22,13 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
|
|||||||
// Remove the first row to leave us with the actual data
|
// Remove the first row to leave us with the actual data
|
||||||
unset( $data[0] );
|
unset( $data[0] );
|
||||||
|
|
||||||
$output .= '<th class="data-number">' . $r['number_label'] . '</th>';
|
$columns = sportspress_array_value( $r, 'columns', null );
|
||||||
|
|
||||||
|
$output .= '<th class="data-number">' . __( 'Pos', 'sportspress' ) . '</th>';
|
||||||
|
|
||||||
foreach( $labels as $key => $label ):
|
foreach( $labels as $key => $label ):
|
||||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
if ( ! is_array( $columns ) || $key == 'name' || in_array( $key, $columns ) )
|
||||||
|
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||||
@@ -57,23 +39,17 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
|
|||||||
|
|
||||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||||
|
|
||||||
// Position as number
|
// Rank
|
||||||
$output .= '<td class="data-number">' . ( $i + 1 ) . '</td>';
|
$output .= '<td class="data-rank">' . ( $i + 1 ) . '</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', ' ' ) );
|
$name = sportspress_array_value( $row, 'name', sportspress_array_value( $row, 'name', ' ' ) );
|
||||||
$output .= '<td class="data-name">' . ( $thumbnail ? $thumbnail . ' ' : '' ) . '<a href="' . $permalink . '">' . $name . '</a></td>';
|
$output .= '<td class="data-name"><a href="' . get_post_permalink( $team_id ) . '">' . $name . '</a></td>';
|
||||||
|
|
||||||
foreach( $labels as $key => $value ):
|
foreach( $labels as $key => $value ):
|
||||||
if ( $key == 'name' )
|
if ( $key == 'name' )
|
||||||
continue;
|
continue;
|
||||||
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
if ( ! is_array( $columns ) || in_array( $key, $columns ) )
|
||||||
|
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
$output .= '</tr>';
|
$output .= '</tr>';
|
||||||
@@ -84,7 +60,7 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
|
|||||||
|
|
||||||
$output .= '</tbody>' . '</table>' . '</div>';
|
$output .= '</tbody>' . '</table>' . '</div>';
|
||||||
|
|
||||||
return apply_filters( 'sportspress_league_table', $output );
|
return apply_filters( 'sportspress_league_table', $output, $id );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,51 @@
|
|||||||
<?php
|
<?php
|
||||||
if ( !function_exists( 'sportspress_player_list' ) ) {
|
if ( !function_exists( 'sportspress_player_list' ) ) {
|
||||||
function sportspress_player_list( $id = null ) {
|
function sportspress_player_list( $id = null, $args = '' ) {
|
||||||
|
|
||||||
if ( ! $id )
|
if ( ! $id )
|
||||||
$id = get_the_ID();
|
$id = get_the_ID();
|
||||||
|
|
||||||
$data = sportspress_get_player_list_data( $id );
|
$defaults = array(
|
||||||
|
'statistics' => null,
|
||||||
|
'orderby' => 'number',
|
||||||
|
'order' => 'ASC',
|
||||||
|
);
|
||||||
|
|
||||||
|
$r = wp_parse_args( $args, $defaults );
|
||||||
|
|
||||||
$output = '<div class="sp-table-wrapper">' .
|
$output = '<div class="sp-table-wrapper">' .
|
||||||
'<table class="sp-player-list sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
'<table class="sp-player-list sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||||
|
|
||||||
|
$data = sportspress_get_player_list_data( $id );
|
||||||
|
|
||||||
// The first row should be column labels
|
// The first row should be column labels
|
||||||
$labels = $data[0];
|
$labels = $data[0];
|
||||||
|
|
||||||
// Remove the first row to leave us with the actual data
|
// Remove the first row to leave us with the actual data
|
||||||
unset( $data[0] );
|
unset( $data[0] );
|
||||||
|
|
||||||
$output .= '<th class="data-number">#</th>';
|
$statistics = sportspress_array_value( $r, 'statistics', null );
|
||||||
|
|
||||||
|
if ( $r['orderby'] != 'number' || $r['order'] != 'ASC' ):
|
||||||
|
global $sportspress_statistic_priorities;
|
||||||
|
$sportspress_statistic_priorities = array(
|
||||||
|
array(
|
||||||
|
'statistic' => $r['orderby'],
|
||||||
|
'order' => $r['order'],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
uasort( $data, 'sportspress_sort_list_players' );
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if ( $r['orderby'] == 'number' ):
|
||||||
|
$output .= '<th class="data-number">#</th>';
|
||||||
|
else:
|
||||||
|
$output .= '<th class="data-rank">' . __( 'Rank', 'sportspress' ) . '</th>';
|
||||||
|
endif;
|
||||||
|
|
||||||
foreach( $labels as $key => $label ):
|
foreach( $labels as $key => $label ):
|
||||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
if ( ! is_array( $statistics ) || $key == 'name' || in_array( $key, $statistics ) )
|
||||||
|
$output .= '<th class="data-' . $key . '">'. $label . '</th>';
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||||
@@ -29,9 +56,13 @@ if ( !function_exists( 'sportspress_player_list' ) ) {
|
|||||||
|
|
||||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||||
|
|
||||||
// Player number
|
// Rank or number
|
||||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
if ( isset( $r['orderby'] ) && $r['orderby'] != 'number' ):
|
||||||
$output .= '<td class="data-number">' . ( $number ? $number : ' ' ) . '</td>';
|
$output .= '<td class="data-rank">' . ( $i + 1 ) . '</td>';
|
||||||
|
else:
|
||||||
|
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||||
|
$output .= '<td class="data-number">' . ( $number ? $number : ' ' ) . '</td>';
|
||||||
|
endif;
|
||||||
|
|
||||||
// Name as link
|
// Name as link
|
||||||
$permalink = get_post_permalink( $player_id );
|
$permalink = get_post_permalink( $player_id );
|
||||||
@@ -41,6 +72,7 @@ if ( !function_exists( 'sportspress_player_list' ) ) {
|
|||||||
foreach( $labels as $key => $value ):
|
foreach( $labels as $key => $value ):
|
||||||
if ( $key == 'name' )
|
if ( $key == 'name' )
|
||||||
continue;
|
continue;
|
||||||
|
if ( ! is_array( $statistics ) || in_array( $key, $statistics ) )
|
||||||
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
|
|||||||
@@ -10,11 +10,12 @@ class SportsPress_Widget_League_Table extends WP_Widget {
|
|||||||
extract($args);
|
extract($args);
|
||||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||||
$id = empty($instance['id']) ? null : $instance['id'];
|
$id = empty($instance['id']) ? null : $instance['id'];
|
||||||
|
$columns = $instance['columns'];
|
||||||
echo $before_widget;
|
echo $before_widget;
|
||||||
if ( $title )
|
if ( $title )
|
||||||
echo $before_title . $title . $after_title;
|
echo $before_title . $title . $after_title;
|
||||||
echo '<div id="sp_league_table_wrap">';
|
echo '<div id="sp_league_table_wrap">';
|
||||||
echo sportspress_league_table( $id );
|
echo sportspress_league_table( $id, array( 'columns' => $columns ) );
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
echo $after_widget;
|
echo $after_widget;
|
||||||
}
|
}
|
||||||
@@ -23,14 +24,16 @@ class SportsPress_Widget_League_Table extends WP_Widget {
|
|||||||
$instance = $old_instance;
|
$instance = $old_instance;
|
||||||
$instance['title'] = strip_tags($new_instance['title']);
|
$instance['title'] = strip_tags($new_instance['title']);
|
||||||
$instance['id'] = intval($new_instance['id']);
|
$instance['id'] = intval($new_instance['id']);
|
||||||
|
$instance['columns'] = (array)$new_instance['columns'];
|
||||||
|
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
function form( $instance ) {
|
function form( $instance ) {
|
||||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '' ) );
|
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'columns' => null ) );
|
||||||
$title = strip_tags($instance['title']);
|
$title = strip_tags($instance['title']);
|
||||||
$id = intval($instance['id']);
|
$id = intval($instance['id']);
|
||||||
|
$columns = $instance['columns'];
|
||||||
?>
|
?>
|
||||||
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:', 'sportspress' ); ?></label>
|
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:', 'sportspress' ); ?></label>
|
||||||
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
|
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
|
||||||
@@ -50,6 +53,26 @@ class SportsPress_Widget_League_Table extends WP_Widget {
|
|||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p class="sp-prefs">
|
||||||
|
<?php _e( 'Columns:', 'sportspress' ); ?><br>
|
||||||
|
<?php
|
||||||
|
$args = array(
|
||||||
|
'post_type' => 'sp_column',
|
||||||
|
'numberposts' => -1,
|
||||||
|
'posts_per_page' => -1,
|
||||||
|
'orderby' => 'menu_order',
|
||||||
|
'order' => 'ASC'
|
||||||
|
);
|
||||||
|
$the_columns = get_posts( $args );
|
||||||
|
|
||||||
|
$field_name = $this->get_field_name('columns') . '[]';
|
||||||
|
$field_id = $this->get_field_id('columns');
|
||||||
|
?>
|
||||||
|
<?php foreach ( $the_columns as $column ): ?>
|
||||||
|
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . $column->post_name; ?>" value="<?php echo $column->post_name; ?>" <?php if ( $columns === null || in_array( $column->post_name, $columns ) ): ?>checked="checked"<?php endif; ?>><?php echo $column->post_title; ?></label>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</p>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
112
admin/widgets/player-list.php
Normal file
112
admin/widgets/player-list.php
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
class SportsPress_Widget_Player_list extends WP_Widget {
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
$widget_ops = array('classname' => 'widget_player_list widget_sp_player_list', 'description' => __( 'SportsPress widget.', 'sportspress' ) );
|
||||||
|
parent::__construct('sp_player_list', __( 'Player List', 'sportspress' ), $widget_ops);
|
||||||
|
}
|
||||||
|
|
||||||
|
function widget( $args, $instance ) {
|
||||||
|
extract($args);
|
||||||
|
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||||
|
$id = empty($instance['id']) ? null : $instance['id'];
|
||||||
|
$statistics = $instance['statistics'];
|
||||||
|
$orderby = empty($instance['orderby']) ? 'number' : $instance['orderby'];
|
||||||
|
$order = empty($instance['order']) ? 'ASC' : $instance['order'];
|
||||||
|
echo $before_widget;
|
||||||
|
if ( $title )
|
||||||
|
echo $before_title . $title . $after_title;
|
||||||
|
echo '<div id="sp_player_list_wrap">';
|
||||||
|
echo sportspress_player_list( $id, array( 'statistics' => $statistics, 'orderby' => $orderby , 'order' => $order ) );
|
||||||
|
echo '</div>';
|
||||||
|
echo $after_widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
function update( $new_instance, $old_instance ) {
|
||||||
|
$instance = $old_instance;
|
||||||
|
$instance['title'] = strip_tags($new_instance['title']);
|
||||||
|
$instance['id'] = intval($new_instance['id']);
|
||||||
|
$instance['statistics'] = (array)$new_instance['statistics'];
|
||||||
|
$instance['orderby'] = strip_tags($new_instance['orderby']);
|
||||||
|
$instance['order'] = strip_tags($new_instance['order']);
|
||||||
|
|
||||||
|
return $instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
function form( $instance ) {
|
||||||
|
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'statistics' => null, 'orderby' => 'number', 'order' => 'ASC' ) );
|
||||||
|
$title = strip_tags($instance['title']);
|
||||||
|
$id = intval($instance['id']);
|
||||||
|
$statistics = $instance['statistics'];
|
||||||
|
$orderby = strip_tags($instance['orderby']);
|
||||||
|
$order = strip_tags($instance['order']);
|
||||||
|
?>
|
||||||
|
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:', 'sportspress' ); ?></label>
|
||||||
|
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
|
||||||
|
|
||||||
|
<p><label for="<?php echo $this->get_field_id('id'); ?>"><?php _e( 'Player List:', 'sportspress' ); ?></label>
|
||||||
|
<?php
|
||||||
|
$args = array(
|
||||||
|
'post_type' => 'sp_list',
|
||||||
|
'name' => $this->get_field_name('id'),
|
||||||
|
'id' => $this->get_field_id('id'),
|
||||||
|
'selected' => $id,
|
||||||
|
'values' => 'ID',
|
||||||
|
'class' => 'widefat',
|
||||||
|
);
|
||||||
|
if ( ! sportspress_dropdown_pages( $args ) ):
|
||||||
|
sportspress_post_adder( 'sp_list' );
|
||||||
|
endif;
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p class="sp-prefs">
|
||||||
|
<?php _e( 'Statistics:', 'sportspress' ); ?><br>
|
||||||
|
<?php
|
||||||
|
$args = array(
|
||||||
|
'post_type' => 'sp_statistic',
|
||||||
|
'numberposts' => -1,
|
||||||
|
'posts_per_page' => -1,
|
||||||
|
'orderby' => 'menu_order',
|
||||||
|
'order' => 'ASC'
|
||||||
|
);
|
||||||
|
$the_statistics = get_posts( $args );
|
||||||
|
|
||||||
|
$field_name = $this->get_field_name('statistics') . '[]';
|
||||||
|
$field_id = $this->get_field_id('statistics');
|
||||||
|
?>
|
||||||
|
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . 'eventsplayed'; ?>" value="<?php echo 'eventsplayed'; ?>" <?php if ( is_array( $statistics) && in_array( 'eventsplayed', $statistics ) ): ?>checked="checked"<?php endif; ?>><?php _e( 'Played', 'sportspress' ); ?></label>
|
||||||
|
<?php foreach ( $the_statistics as $column ): ?>
|
||||||
|
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . $column->post_name; ?>" value="<?php echo $column->post_name; ?>" <?php if ( $statistics === null || in_array( $column->post_name, $statistics ) ): ?>checked="checked"<?php endif; ?>><?php echo $column->post_title; ?></label>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p><label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e( 'Sort by:', 'sportspress' ); ?></label>
|
||||||
|
<?php
|
||||||
|
$args = array(
|
||||||
|
'post_type' => 'sp_statistic',
|
||||||
|
'show_option_all' => __( 'Number', 'sportspress' ),
|
||||||
|
'option_all_value' => 'number',
|
||||||
|
'show_option_none' => __( 'Played', 'sportspress' ),
|
||||||
|
'option_none_value' => 'eventsplayed',
|
||||||
|
'name' => $this->get_field_name('orderby'),
|
||||||
|
'id' => $this->get_field_id('orderby'),
|
||||||
|
'selected' => $orderby,
|
||||||
|
'values' => 'slug',
|
||||||
|
'class' => 'widefat',
|
||||||
|
);
|
||||||
|
if ( ! sportspress_dropdown_pages( $args ) ):
|
||||||
|
sportspress_post_adder( 'sp_list' );
|
||||||
|
endif;
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p><label for="<?php echo $this->get_field_id('order'); ?>"><?php _e( 'Sort Order:', 'sportspress' ); ?></label>
|
||||||
|
<select name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order'); ?>" class="widefat">
|
||||||
|
<option value="ASC" <?php selected( 'ASC', $order ); ?>><?php _e( 'Ascending', 'sportspress' ); ?></option>
|
||||||
|
<option value="DESC" <?php selected( 'DESC', $order ); ?>><?php _e( 'Descending', 'sportspress' ); ?></option>
|
||||||
|
</select></p>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add_action( 'widgets_init', create_function( '', 'return register_widget( "SportsPress_Widget_Player_list" );' ) );
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
.widget[id*="sp_future_events-"] .widget-title h4:before,
|
.widget[id*="sp_future_events-"] .widget-title h4:before,
|
||||||
.widget[id*="sp_countdown-"] .widget-title h4:before,
|
.widget[id*="sp_countdown-"] .widget-title h4:before,
|
||||||
.widget[id*="sp_events_calendar-"] .widget-title h4:before,
|
.widget[id*="sp_events_calendar-"] .widget-title h4:before,
|
||||||
|
.widget[id*="sp_player_list-"] .widget-title h4:before,
|
||||||
.widget[id*="sp_league_table-"] .widget-title h4:before {
|
.widget[id*="sp_league_table-"] .widget-title h4:before {
|
||||||
font-family: 'themeboy';
|
font-family: 'themeboy';
|
||||||
speak: none;
|
speak: none;
|
||||||
@@ -94,6 +95,31 @@ table.widefat td.column-sp_icon {
|
|||||||
height: 320px;
|
height: 320px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sp-prefs .button {
|
||||||
|
margin: 0 3px 4px 0;
|
||||||
|
padding: 0 7px 1px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sp-prefs .button input[type=checkbox] {
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
-webkit-box-shadow: none;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sp-prefs .button input[type=checkbox]:not(:checked):before {
|
||||||
|
float: left;
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
|
width: 16px;
|
||||||
|
font: 400 21px/1 dashicons;
|
||||||
|
speak: none;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
content: '\f335';
|
||||||
|
margin: -3px 0 0 -4px;
|
||||||
|
color: #a00;
|
||||||
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 768px) {
|
@media only screen and (max-width: 768px) {
|
||||||
|
|
||||||
|
|||||||
@@ -265,6 +265,7 @@ if ( !function_exists( 'sportspress_dropdown_pages' ) ) {
|
|||||||
'option_all_value' => 0,
|
'option_all_value' => 0,
|
||||||
'option_none_value' => -1,
|
'option_none_value' => -1,
|
||||||
'name' => 'page_id',
|
'name' => 'page_id',
|
||||||
|
'id' => 'page_id',
|
||||||
'selected' => null,
|
'selected' => null,
|
||||||
'numberposts' => -1,
|
'numberposts' => -1,
|
||||||
'posts_per_page' => -1,
|
'posts_per_page' => -1,
|
||||||
@@ -286,25 +287,27 @@ if ( !function_exists( 'sportspress_dropdown_pages' ) ) {
|
|||||||
$args = array_merge( $defaults, $args );
|
$args = array_merge( $defaults, $args );
|
||||||
$name = $args['name'];
|
$name = $args['name'];
|
||||||
unset( $args['name'] );
|
unset( $args['name'] );
|
||||||
|
$id = $args['id'];
|
||||||
|
unset( $args['id'] );
|
||||||
$values = $args['values'];
|
$values = $args['values'];
|
||||||
unset( $args['values'] );
|
unset( $args['values'] );
|
||||||
$class = $args['class'];
|
$class = $args['class'];
|
||||||
unset( $args['class'] );
|
unset( $args['class'] );
|
||||||
$posts = get_posts( $args );
|
$posts = get_posts( $args );
|
||||||
if ( $posts ):
|
if ( $posts ):
|
||||||
printf( '<select name="%1$s" class="postform %2$s">', $name, $class );
|
printf( '<select name="%s" id="%s" class="postform %s">', $name, $id, $class );
|
||||||
if ( $args['show_option_all'] ):
|
if ( $args['show_option_all'] ):
|
||||||
printf( '<option value="%1$s">%2$s</option>', $args['option_all_value'], $args['show_option_all'] );
|
printf( '<option value="%s" %s>%s</option>', $args['option_all_value'], selected( $args['selected'], $args['option_all_value'], false ), $args['show_option_all'] );
|
||||||
endif;
|
endif;
|
||||||
if ( $args['show_option_none'] ):
|
if ( $args['show_option_none'] ):
|
||||||
printf( '<option value="%1$s">%2$s</option>', $args['option_none_value'], $args['show_option_none'] );
|
printf( '<option value="%s" %s>%s</option>', $args['option_none_value'], selected( $args['selected'], $args['option_none_value'], false ), $args['show_option_none'] );
|
||||||
endif;
|
endif;
|
||||||
foreach ( $posts as $post ):
|
foreach ( $posts as $post ):
|
||||||
setup_postdata( $post );
|
setup_postdata( $post );
|
||||||
if ( $values == 'ID' ):
|
if ( $values == 'ID' ):
|
||||||
printf( '<option value="%s" %s>%s</option>', $post->ID, selected( true, $args['selected'] == $post->ID, false ), $post->post_title . ( $args['show_dates'] ? ' (' . $post->post_date . ')' : '' ) );
|
printf( '<option value="%s" %s>%s</option>', $post->ID, selected( $args['selected'], $post->ID, false ), $post->post_title . ( $args['show_dates'] ? ' (' . $post->post_date . ')' : '' ) );
|
||||||
else:
|
else:
|
||||||
printf( '<option value="%s" %s>%s</option>', $post->post_name, selected( true, $args['selected'] == $post->post_name, false ), $post->post_title );
|
printf( '<option value="%s" %s>%s</option>', $post->post_name, selected( $args['selected'], $post->post_name, false ), $post->post_title );
|
||||||
endif;
|
endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
wp_reset_postdata();
|
wp_reset_postdata();
|
||||||
@@ -1988,6 +1991,34 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !function_exists( 'sportspress_sort_list_players' ) ) {
|
||||||
|
function sportspress_sort_list_players ( $a, $b ) {
|
||||||
|
|
||||||
|
global $sportspress_statistic_priorities;
|
||||||
|
|
||||||
|
// Loop through priorities
|
||||||
|
foreach( $sportspress_statistic_priorities as $priority ):
|
||||||
|
|
||||||
|
// Proceed if columns are not equal
|
||||||
|
if ( sportspress_array_value( $a, $priority['statistic'], 0 ) != sportspress_array_value( $b, $priority['statistic'], 0 ) ):
|
||||||
|
|
||||||
|
// Compare statistic values
|
||||||
|
$output = sportspress_array_value( $a, $priority['statistic'], 0 ) - sportspress_array_value( $b, $priority['statistic'], 0 );
|
||||||
|
|
||||||
|
// Flip value if descending order
|
||||||
|
if ( $priority['order'] == 'DESC' ) $output = 0 - $output;
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
// Default sort by number
|
||||||
|
return strcmp( sportspress_array_value( $a, 'number', '' ), sportspress_array_value( $b, 'number', '' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( !function_exists( 'sportspress_get_player_metrics_data' ) ) {
|
if ( !function_exists( 'sportspress_get_player_metrics_data' ) ) {
|
||||||
function sportspress_get_player_metrics_data( $post_id ) {
|
function sportspress_get_player_metrics_data( $post_id ) {
|
||||||
|
|
||||||
|
|||||||
33
readme.txt
33
readme.txt
@@ -1,14 +1,30 @@
|
|||||||
=== SportsPress ===
|
=== SportsPress - Automated League Statistics ===
|
||||||
Contributors: themeboy
|
Contributors: themeboy
|
||||||
Tags: sports, sports journalism, teams, team management, fixtures, results, standings, league tables, leagues, reporting, themeboy, wordpress sports, configurable
|
Tags: sports, sports journalism, teams, team management, fixtures, results, standings, league tables, leagues, reporting, themeboy, wordpress sports, configurable
|
||||||
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=support@themeboy.com&item_name=Donation+for+SportsPress
|
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=support@themeboy.com&item_name=Donation+for+SportsPress
|
||||||
Requires at least: 3.5
|
Requires at least: 3.8
|
||||||
Tested up to: 3.8
|
Tested up to: 3.8.1
|
||||||
Stable tag: 0.2.6
|
Stable tag: 0.2.8
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
SportsPress is a flexible sports management plugin that adds team management functionality to WordPress. Currently in beta for internal testing.
|
SportsPress is a fully configurable sports plugin that seemlessly automates league, team, and player statistics. Currently in beta.
|
||||||
|
|
||||||
|
== Description ==
|
||||||
|
|
||||||
|
Add schedules, results, league tables, player profiles and statistics to your team or league site with SportsPress. It is designed to work with virtually every WordPress theme, and includes several language translations.
|
||||||
|
|
||||||
|
= Customizable =
|
||||||
|
|
||||||
|
League table columns, player statistics, and match results can be customized to fit any sport. Presets are available for some of the most popular sports including soccer, rugby, American football, Australian Rules football, baseball, basketball, cricket, and hockey.
|
||||||
|
|
||||||
|
= Available Languages =
|
||||||
|
* English
|
||||||
|
* Spanish
|
||||||
|
* French
|
||||||
|
* Japanese
|
||||||
|
|
||||||
|
[Let us know](http://wordpress.org/support/plugin/sportspress) if you come across any missing or inaccurate translations in your language.
|
||||||
|
|
||||||
== Installation ==
|
== Installation ==
|
||||||
|
|
||||||
@@ -69,9 +85,14 @@ SportsPress is currently in beta and is undergoing testing. We are still activel
|
|||||||
2. Teams admin.
|
2. Teams admin.
|
||||||
3. Players admin.
|
3. Players admin.
|
||||||
4. SportsPress Settings panel.
|
4. SportsPress Settings panel.
|
||||||
|
5. League Table widget.
|
||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
|
= 0.2.7 =
|
||||||
|
* Feature - Select columns to display in league table widget.
|
||||||
|
* Tweak - Start league table positions at 1 instead of 0.
|
||||||
|
|
||||||
= 0.2.6 =
|
= 0.2.6 =
|
||||||
* Localization - Add French translations.
|
* Localization - Add French translations.
|
||||||
* Preset - Update soccer preset.
|
* Preset - Update soccer preset.
|
||||||
@@ -81,9 +102,9 @@ SportsPress is currently in beta and is undergoing testing. We are still activel
|
|||||||
|
|
||||||
= 0.2.4 =
|
= 0.2.4 =
|
||||||
* Feature - Display venue map on event page and venue archive.
|
* Feature - Display venue map on event page and venue archive.
|
||||||
* Tweak - Sort sports presets alphabetically by localized name.
|
|
||||||
* Fix - Add checks to prevent league table dividing by zero when no events have been played.
|
* Fix - Add checks to prevent league table dividing by zero when no events have been played.
|
||||||
* Fix - Flush rewrite rules for taxonomies on activation.
|
* Fix - Flush rewrite rules for taxonomies on activation.
|
||||||
|
* Tweak - Sort sports presets alphabetically by localized name.
|
||||||
|
|
||||||
= 0.2.3 =
|
= 0.2.3 =
|
||||||
* Feature - Enable selecting main event result.
|
* Feature - Enable selecting main event result.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
Plugin Name: SportsPress
|
Plugin Name: SportsPress
|
||||||
Plugin URI: http://themeboy.com/sportspress
|
Plugin URI: http://themeboy.com/sportspress
|
||||||
Description: Manage your club and its players, staff, events, league tables, and player lists.
|
Description: Manage your club and its players, staff, events, league tables, and player lists.
|
||||||
Version: 0.2.6
|
Version: 0.2.8
|
||||||
Author: ThemeBoy
|
Author: ThemeBoy
|
||||||
Author URI: http://themeboy.com/
|
Author URI: http://themeboy.com/
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
@@ -18,7 +18,7 @@ if ( !function_exists( 'add_action' ) ) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
define( 'SPORTSPRESS_VERSION', '0.2.4' );
|
define( 'SPORTSPRESS_VERSION', '0.2.8' );
|
||||||
define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||||
define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
||||||
define( 'SPORTSPRESS_PLUGIN_FILE', __FILE__ );
|
define( 'SPORTSPRESS_PLUGIN_FILE', __FILE__ );
|
||||||
@@ -78,6 +78,7 @@ require_once dirname( __FILE__ ) . '/admin/widgets/recent-events.php';
|
|||||||
require_once dirname( __FILE__ ) . '/admin/widgets/future-events.php';
|
require_once dirname( __FILE__ ) . '/admin/widgets/future-events.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/widgets/countdown.php';
|
require_once dirname( __FILE__ ) . '/admin/widgets/countdown.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/widgets/events-calendar.php';
|
require_once dirname( __FILE__ ) . '/admin/widgets/events-calendar.php';
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/widgets/player-list.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/widgets/league-table.php';
|
require_once dirname( __FILE__ ) . '/admin/widgets/league-table.php';
|
||||||
|
|
||||||
// Typical request actions
|
// Typical request actions
|
||||||
|
|||||||
Reference in New Issue
Block a user