diff --git a/assets/css/admin.css b/assets/css/admin.css
index 0ceb08e3..90f60dc2 100644
--- a/assets/css/admin.css
+++ b/assets/css/admin.css
@@ -157,6 +157,10 @@
color: #888;
}
+.form-table td input.sp-number-input {
+ width: auto;
+}
+
/* Settings */
.sportspress table.form-table, .sportspress table.form-table .forminp-radio ul {
margin: 0;
diff --git a/includes/admin/class-sp-admin-taxonomies.php b/includes/admin/class-sp-admin-taxonomies.php
index de6a4206..45311141 100644
--- a/includes/admin/class-sp-admin-taxonomies.php
+++ b/includes/admin/class-sp-admin-taxonomies.php
@@ -19,6 +19,14 @@ class SP_Admin_Taxonomies {
*/
public function __construct() {
+ // Add league field
+ add_action( 'sp_league_edit_form_fields', array( $this, 'edit_taxonomy_fields' ), 10, 1 );
+ add_action( 'edited_sp_league', array( $this, 'save_fields' ), 10, 1 );
+
+ // Add season field
+ add_action( 'sp_season_edit_form_fields', array( $this, 'edit_taxonomy_fields' ), 10, 1 );
+ add_action( 'edited_sp_season', array( $this, 'save_fields' ), 10, 1 );
+
// Add venue field
add_action( 'sp_venue_add_form_fields', array( $this, 'add_venue_fields' ) );
add_action( 'sp_venue_edit_form_fields', array( $this, 'edit_venue_fields' ), 10, 1 );
@@ -31,9 +39,13 @@ class SP_Admin_Taxonomies {
add_action( 'edited_sp_position', array( $this, 'save_fields' ), 10, 1 );
add_action( 'create_sp_position', array( $this, 'save_fields' ), 10, 1 );
- // Change league and season columns
+ // Change league columns
add_filter( 'manage_edit-sp_league_columns', array( $this, 'taxonomy_columns' ) );
+ add_filter( 'manage_sp_league_custom_column', array( $this, 'column_value' ), 10, 3 );
+
+ // Change league columns
add_filter( 'manage_edit-sp_season_columns', array( $this, 'taxonomy_columns' ) );
+ add_filter( 'manage_sp_season_custom_column', array( $this, 'column_value' ), 10, 3 );
// Change venue columns
add_filter( 'manage_edit-sp_venue_columns', array( $this, 'venue_columns' ) );
@@ -42,9 +54,25 @@ class SP_Admin_Taxonomies {
// Change position columns
add_filter( 'manage_edit-sp_position_columns', array( $this, 'position_columns' ) );
add_filter( 'manage_sp_position_custom_column', array( $this, 'column_value' ), 10, 3 );
+ }
- // Change role columns
- add_filter( 'manage_edit-sp_role_columns', array( $this, 'role_columns' ) );
+ /**
+ * Edit league/season fields.
+ *
+ * @access public
+ * @param mixed $term Term (category) being edited
+ */
+ public function edit_taxonomy_fields( $term ) {
+ $t_id = $term->term_id;
+ ?>
+
+
+
+ |
+ |
+
+
+
-
-
+
+
+
+ |
+ |
+
+
'sp_duty',
'hide_empty' => false,
- 'orderby' => 'slug',
+ 'orderby' => 'meta_value_num',
+ 'meta_query' => array(
+ 'relation' => 'OR',
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'NOT EXISTS'
+ ),
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'EXISTS'
+ ),
+ ),
) );
$officials = (array) get_post_meta( $post->ID, 'sp_officials', true );
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php
index be80b134..95c0558e 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php
@@ -414,7 +414,18 @@ class SP_Meta_Box_Event_Performance {
'taxonomy' => 'sp_position',
'name' => 'sp_players[' . $team_id . '][' . $player_id . '][position][]',
'values' => 'term_id',
- 'orderby' => 'slug',
+ 'orderby' => 'meta_value_num',
+ 'meta_query' => array(
+ 'relation' => 'OR',
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'NOT EXISTS'
+ ),
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'EXISTS'
+ ),
+ ),
'selected' => $selected,
'class' => 'sp-position',
'property' => 'multiple',
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php
index 55037e7c..bbf4304f 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php
@@ -129,7 +129,18 @@ class SP_Meta_Box_List_Data {
'name' => 'sp_players[' . $player_id . '][position]',
'show_option_blank' => __( '(Auto)', 'sportspress' ),
'values' => 'term_id',
- 'orderby' => 'slug',
+ 'orderby' => 'meta_value_num',
+ 'meta_query' => array(
+ 'relation' => 'OR',
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'NOT EXISTS'
+ ),
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'EXISTS'
+ ),
+ ),
'selected' => $selected,
'include_children' => ( 'no' == get_option( 'sportspress_event_hide_child_positions', 'no' ) ),
);
diff --git a/includes/class-sp-event.php b/includes/class-sp-event.php
index aeb76ca9..5ff1c9e1 100644
--- a/includes/class-sp-event.php
+++ b/includes/class-sp-event.php
@@ -551,7 +551,18 @@ class SP_Event extends SP_Custom_Post{
$duties = get_terms( array(
'taxonomy' => 'sp_duty',
'hide_empty' => false,
- 'orderby' => 'slug',
+ 'orderby' => 'meta_value_num',
+ 'meta_query' => array(
+ 'relation' => 'OR',
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'NOT EXISTS'
+ ),
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'EXISTS'
+ ),
+ ),
) );
if ( ! $include_empty && empty( $duties ) ) return null;
diff --git a/modules/sportspress-officials.php b/modules/sportspress-officials.php
index 3eb86562..2a093479 100644
--- a/modules/sportspress-officials.php
+++ b/modules/sportspress-officials.php
@@ -39,6 +39,8 @@ class SportsPress_Officials {
add_action( 'sportspress_event_list_row', array( $this, 'event_list_row' ), 10, 2 );
add_action( 'sportspress_calendar_data_meta_box_table_head_row', array( $this, 'calendar_meta_head_row' ) );
add_action( 'sportspress_calendar_data_meta_box_table_row', array( $this, 'calendar_meta_row' ), 10, 2 );
+ add_action( 'sp_duty_edit_form_fields', array( $this, 'edit_taxonomy_fields' ), 10, 1 );
+ add_action( 'edited_sp_duty', array( $this, 'save_taxonomy_fields' ), 10, 1 );
// Filters
add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_boxes' ) );
@@ -49,6 +51,8 @@ class SportsPress_Officials {
add_filter( 'sportspress_post_types', array( $this, 'add_post_type' ) );
add_filter( 'sportspress_primary_post_types', array( $this, 'add_post_type' ) );
add_filter( 'sportspress_post_type_hierarchy', array( $this, 'add_to_hierarchy' ) );
+ add_filter( 'manage_edit-sp_duty_columns', array( $this, 'taxonomy_columns' ) );
+ add_filter( 'manage_sp_duty_custom_column', array( $this, 'taxonomy_column_value' ), 10, 3 );
}
/**
@@ -197,7 +201,18 @@ class SportsPress_Officials {
$duties = get_terms( array(
'taxonomy' => 'sp_duty',
'hide_empty' => false,
- 'orderby' => 'slug',
+ 'orderby' => 'meta_value_num',
+ 'meta_query' => array(
+ 'relation' => 'OR',
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'NOT EXISTS'
+ ),
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'EXISTS'
+ ),
+ ),
) );
if ( empty( $duties ) ) return;
@@ -239,7 +254,18 @@ class SportsPress_Officials {
$duties = get_terms( array(
'taxonomy' => 'sp_duty',
'hide_empty' => false,
- 'orderby' => 'slug',
+ 'orderby' => 'meta_value_num',
+ 'meta_query' => array(
+ 'relation' => 'OR',
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'NOT EXISTS'
+ ),
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'EXISTS'
+ ),
+ ),
) );
if ( empty( $duties ) ) return;
@@ -442,6 +468,8 @@ class SportsPress_Officials {
return array_merge( $ids, array(
'sp_official',
'edit-sp_official',
+ 'sp_duty',
+ 'edit-sp_duty',
) );
}
@@ -454,6 +482,103 @@ class SportsPress_Officials {
$hierarchy['sp_official'] = array();
return $hierarchy;
}
+
+ /**
+ * Taxonomy columns.
+ *
+ * @access public
+ * @param mixed $columns
+ * @return array
+ */
+ public function taxonomy_columns( $columns ) {
+ $new_columns = array();
+
+ if ( function_exists( 'get_term_meta' ) ) $new_columns['sp_order'] = __( 'Order', 'sportspress' );
+
+ $new_columns['posts'] = $columns['posts'];
+
+ unset( $columns['posts'] );
+
+ return array_merge( $columns, $new_columns );
+ }
+
+ /**
+ * Edit taxonomy fields.
+ *
+ * @access public
+ * @param mixed $term Term (category) being edited
+ */
+ public function edit_taxonomy_fields( $term ) {
+ $t_id = $term->term_id;
+ ?>
+
+
+
+ |
+ |
+
+
+ __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
+
+ $sections = sp_get_term_sections( $id );
+
+ $section_names = array();
+
+ if ( is_array( $sections ) ) {
+ foreach ( $sections as $section ) {
+ if ( array_key_exists( $section, $options ) ) {
+ $section_names[] = $options[ $section ];
+ }
+ }
+ }
+
+ $columns .= implode( ', ', $section_names );
+
+ } elseif ( $column == 'sp_order' ) {
+
+ $columns = (int) get_term_meta( $id, 'sp_order', true );
+
+ }
+
+ return $columns;
+ }
}
endif;
diff --git a/modules/sportspress-overview.php b/modules/sportspress-overview.php
index e4e8780e..fcadbba3 100644
--- a/modules/sportspress-overview.php
+++ b/modules/sportspress-overview.php
@@ -78,7 +78,7 @@ class SportsPress_Overview {
object_type, $taxonomy ); ?>
labels->name; ?>
- false, 'parent' => 0, 'orderby' => 'slug' ) ); ?>
+ false, 'parent' => 0, 'orderby' => 'slug', ) ); ?>
0 ): ?>
diff --git a/templates/player-gallery.php b/templates/player-gallery.php
index 453585b4..6d803c6d 100644
--- a/templates/player-gallery.php
+++ b/templates/player-gallery.php
@@ -112,7 +112,20 @@ echo apply_filters( 'gallery_style', $gallery_style . "\n\t\t" );
$limit = $number;
if ( $grouping === 'position' ):
- $groups = get_terms( 'sp_position', array( 'orderby' => 'slug' ) );
+ $groups = get_terms( 'sp_position', array(
+ 'orderby' => 'meta_value_num',
+ 'meta_query' => array(
+ 'relation' => 'OR',
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'NOT EXISTS'
+ ),
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'EXISTS'
+ ),
+ ),
+ ) );
else:
$group = new stdClass();
$group->term_id = null;
diff --git a/templates/player-list.php b/templates/player-list.php
index 5c46c995..7a7157b2 100644
--- a/templates/player-list.php
+++ b/templates/player-list.php
@@ -79,7 +79,20 @@ endif;
$output = '';
if ( $grouping === 'position' ):
- $groups = get_terms( 'sp_position', array( 'orderby' => 'slug' ) );
+ $groups = get_terms( 'sp_position', array(
+ 'orderby' => 'meta_value_num',
+ 'meta_query' => array(
+ 'relation' => 'OR',
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'NOT EXISTS'
+ ),
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'EXISTS'
+ ),
+ ),
+ ) );
else:
if ( $show_title && false === $title && $id ):
$caption = $list->caption;