'widget_player_list widget_sp_player_list', 'description' => __( 'Display a list of players.', 'sportspress' ) ); parent::__construct('sp_player_list', __( 'Player List', 'sportspress' ) . ' (' . __( 'SportsPress', 'sportspress' ) . ')', $widget_ops); } function widget( $args, $instance ) { extract($args); $id = empty($instance['id']) ? 0 : $instance['id']; if ( $id <= 0 ) return; $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $number = empty($instance['number']) ? null : $instance['number']; $columns = $instance['columns']; $orderby = empty($instance['orderby']) ? 'default' : $instance['orderby']; $order = empty($instance['order']) ? 'ASC' : $instance['order']; $show_all_players_link = empty($instance['show_all_players_link']) ? false : $instance['show_all_players_link']; echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; // Action to hook into do_action( 'sportspress_before_widget_template', $args, $instance, 'player-list' ); sp_get_template( 'player-list.php', array( 'id' => $id, 'number' => $number, 'columns' => $columns, 'orderby' => $orderby, 'order' => $order, 'grouping' => 0, 'show_all_players_link' => $show_all_players_link ) ); // Action to hook into do_action( 'sportspress_after_widget_template', $args, $instance, 'player-list' ); 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['number'] = intval($new_instance['number']); $instance['columns'] = (array)$new_instance['columns']; $instance['orderby'] = strip_tags($new_instance['orderby']); $instance['order'] = strip_tags($new_instance['order']); $instance['show_all_players_link'] = $new_instance['show_all_players_link']; // Filter to hook into $instance = apply_filters( 'sportspress_widget_update', $instance, $new_instance, $old_instance, 'player-list' ); return $instance; } function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'number' => 5, 'columns' => null, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => true ) ); $title = strip_tags($instance['title']); $id = intval($instance['id']); $number = intval($instance['number']); $columns = $instance['columns']; $orderby = strip_tags($instance['orderby']); $order = strip_tags($instance['order']); $show_all_players_link = $instance['show_all_players_link']; // Action to hook into do_action( 'sportspress_before_widget_template_form', $this, $instance, 'player-list' ); ?>
'sp_list', 'name' => $this->get_field_name('id'), 'id' => $this->get_field_id('id'), 'selected' => $id, 'values' => 'ID', 'class' => 'widefat', ); if ( ! sp_dropdown_pages( $args ) ): sp_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) ); endif; ?>
array( 'sp_metric', 'sp_performance', 'sp_statistic' ),
'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');
?>
array( 'default' => __( 'Default', 'sportspress' ), 'number' => __( 'Number', 'sportspress' ), 'name' => __( 'Name', 'sportspress' ), 'eventsplayed' => __( 'Played', 'sportspress' ) ), 'post_type' => array( 'sp_metric', 'sp_performance', 'sp_statistic' ), 'name' => $this->get_field_name('orderby'), 'id' => $this->get_field_id('orderby'), 'selected' => $orderby, 'values' => 'slug', 'class' => 'sp-select-orderby widefat', ); if ( ! sp_dropdown_pages( $args ) ): sp_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) ); endif; ?>
>