diff --git a/admin/hooks/admin-enqueue-scripts.php b/admin/hooks/admin-enqueue-scripts.php
deleted file mode 100644
index e2f7268d..00000000
--- a/admin/hooks/admin-enqueue-scripts.php
+++ /dev/null
@@ -1,28 +0,0 @@
- __( 'None', 'sportspress' ), 'remove_text' => __( '— Remove —', 'sportspress' ), 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ) ) );
-}
-add_action( 'admin_enqueue_scripts', 'sportspress_admin_enqueue_scripts' );
diff --git a/admin/hooks/wp-insert-post-data.php b/admin/hooks/wp-insert-post-data.php
deleted file mode 100644
index 6811afcf..00000000
--- a/admin/hooks/wp-insert-post-data.php
+++ /dev/null
@@ -1,20 +0,0 @@
-id, sp_get_screen_ids() ) ) {
// Admin styles for SP pages only
- wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . 'assets/css/admin.css', array(), SP_VERSION );
- wp_enqueue_style( 'jquery-chosen', SP()->plugin_url() . 'assets/css/chosen.css', array(), '1.1.0' );
+ wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
+ wp_enqueue_style( 'jquery-chosen', SP()->plugin_url() . '/assets/css/chosen.css', array(), '1.1.0' );
wp_enqueue_style( 'wp-color-picker' );
}
@@ -60,21 +60,21 @@ class SP_Admin_Assets {
$screen = get_current_screen();
// Register scripts
- wp_register_script( 'jquery-chosen', SP()->plugin_url() .'assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
+ wp_register_script( 'jquery-chosen', SP()->plugin_url() . '/assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
- wp_register_script( 'jquery-tiptip', SP()->plugin_url() .'assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true );
+ wp_register_script( 'jquery-tiptip', SP()->plugin_url() . '/assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true );
- wp_register_script( 'jquery-caret', SP()->plugin_url() .'assets/js/jquery.caret.min.js', array( 'jquery' ), '1.02', true );
+ wp_register_script( 'jquery-caret', SP()->plugin_url() . '/assets/js/jquery.caret.min.js', array( 'jquery' ), '1.02', true );
- wp_register_script( 'jquery-countdown', SP()->plugin_url() .'assets/js/jquery.countdown.min.js', array( 'jquery' ), '2.0.2', true );
+ wp_register_script( 'jquery-countdown', SP()->plugin_url() . '/assets/js/jquery.countdown.min.js', array( 'jquery' ), '2.0.2', true );
wp_register_script( 'google-maps', 'http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places' );
- wp_register_script( 'jquery-locationpicker', SP()->plugin_url() .'assets/js/locationpicker.jquery.js', array( 'jquery', 'google-maps' ), '0.1.6', true );
+ wp_register_script( 'jquery-locationpicker', SP()->plugin_url() . '/assets/js/locationpicker.jquery.js', array( 'jquery', 'google-maps' ), '0.1.6', true );
- wp_register_script( 'sportspress-admin-locationpicker', SP()->plugin_url() .'assets/js/admin-locationpicker.js', array( 'jquery', 'google-maps', 'jquery-locationpicker' ), SP_VERSION, true );
+ wp_register_script( 'sportspress-admin-locationpicker', SP()->plugin_url() . '/assets/js/admin-locationpicker.js', array( 'jquery', 'google-maps', 'jquery-locationpicker' ), SP_VERSION, true );
- wp_register_script( 'sportspress-admin', SP()->plugin_url() .'assets/js/admin.js', array( 'jquery', 'jquery-chosen', 'jquery-tiptip', 'jquery-caret', 'jquery-countdown' ), SP_VERSION, true );
+ wp_register_script( 'sportspress-admin', SP()->plugin_url() . '/assets/js/admin.js', array( 'jquery', 'jquery-chosen', 'jquery-tiptip', 'jquery-caret', 'jquery-countdown' ), SP_VERSION, true );
// SportsPress admin pages
if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
diff --git a/includes/admin/class-sp-admin-post-types.php b/includes/admin/class-sp-admin-post-types.php
index 4819afcf..1b5d47eb 100644
--- a/includes/admin/class-sp-admin-post-types.php
+++ b/includes/admin/class-sp-admin-post-types.php
@@ -29,7 +29,7 @@ class SP_Admin_Post_Types {
* Conditonally load classes and functions only needed when viewing a post type.
*/
public function include_post_type_handlers() {
- //include( 'post-types/class-sp-admin-meta-boxes.php' );
+ include( 'post-types/class-sp-admin-meta-boxes.php' );
include( 'post-types/class-sp-admin-cpt-result.php' );
include( 'post-types/class-sp-admin-cpt-outcome.php' );
include( 'post-types/class-sp-admin-cpt-performance.php' );
@@ -52,52 +52,43 @@ class SP_Admin_Post_Types {
* @return array
*/
public function post_updated_messages( $messages ) {
- global $post, $post_ID;
+ global $typenow, $post;
- $messages['product'] = array(
- 0 => '', // Unused. Messages start at index 1.
- 1 => sprintf( __( 'Product updated. View Product', 'sportspress' ), esc_url( get_permalink($post_ID) ) ),
- 2 => __( 'Custom field updated.', 'sportspress' ),
- 3 => __( 'Custom field deleted.', 'sportspress' ),
- 4 => __( 'Product updated.', 'sportspress' ),
- 5 => isset($_GET['revision']) ? sprintf( __( 'Product restored to revision from %s', 'sportspress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
- 6 => sprintf( __( 'Product published. View Product', 'sportspress' ), esc_url( get_permalink($post_ID) ) ),
- 7 => __( 'Product saved.', 'sportspress' ),
- 8 => sprintf( __( 'Product submitted. Preview Product', 'sportspress' ), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
- 9 => sprintf( __( 'Product scheduled for: %1$s. Preview Product', 'sportspress' ),
- date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
- 10 => sprintf( __( 'Product draft updated. Preview Product', 'sportspress' ), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
- );
+ if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_metric', 'sp_performance' ) ) ):
+ $obj = get_post_type_object( $typenow );
- $messages['shop_order'] = array(
- 0 => '', // Unused. Messages start at index 1.
- 1 => __( 'Order updated.', 'sportspress' ),
- 2 => __( 'Custom field updated.', 'sportspress' ),
- 3 => __( 'Custom field deleted.', 'sportspress' ),
- 4 => __( 'Order updated.', 'sportspress' ),
- 5 => isset($_GET['revision']) ? sprintf( __( 'Order restored to revision from %s', 'sportspress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
- 6 => __( 'Order updated.', 'sportspress' ),
- 7 => __( 'Order saved.', 'sportspress' ),
- 8 => __( 'Order submitted.', 'sportspress' ),
- 9 => sprintf( __( 'Order scheduled for: %1$s.', 'sportspress' ),
- date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ) ),
- 10 => __( 'Order draft updated.', 'sportspress' )
- );
+ for ( $i = 0; $i <= 10; $i++ ):
+ $messages['post'][ $i ] = __( 'Settings saved.', 'sportspress' ) .
+ ' ' .
+ __( 'View All', 'sportspress' ) . '';
+ endfor;
+ elseif ( in_array( $typenow, array( 'sp_event', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ):
+ $obj = get_post_type_object( $typenow );
- $messages['shop_coupon'] = array(
- 0 => '', // Unused. Messages start at index 1.
- 1 => __( 'Coupon updated.', 'sportspress' ),
- 2 => __( 'Custom field updated.', 'sportspress' ),
- 3 => __( 'Custom field deleted.', 'sportspress' ),
- 4 => __( 'Coupon updated.', 'sportspress' ),
- 5 => isset($_GET['revision']) ? sprintf( __( 'Coupon restored to revision from %s', 'sportspress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
- 6 => __( 'Coupon updated.', 'sportspress' ),
- 7 => __( 'Coupon saved.', 'sportspress' ),
- 8 => __( 'Coupon submitted.', 'sportspress' ),
- 9 => sprintf( __( 'Coupon scheduled for: %1$s.', 'sportspress' ),
- date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ) ),
- 10 => __( 'Coupon draft updated.', 'sportspress' )
- );
+ $messages['post'][1] = __( 'Changes saved.', 'sportspress' ) .
+ ' ' . $obj->labels->view_item . '';
+
+ $messages['post'][4] = __( 'Changes saved.', 'sportspress' );
+
+ $messages['post'][6] = __( 'Success!', 'sportspress' ) .
+ ' ' . $obj->labels->view_item . '';
+
+ $messages['post'][7] = __( 'Changes saved.', 'sportspress' );
+
+ $messages['post'][8] = __( 'Success!', 'sportspress' ) .
+ ' ' .
+ sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '';
+
+ $messages['post'][9] = sprintf(
+ __( 'Scheduled for: %1$s.', 'sportspress' ),
+ date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post->ID) ) ) .
+ ' ' .
+ sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '';
+
+ $messages['post'][10] = __( 'Success!', 'sportspress' ) .
+ ' ' .
+ sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '';
+ endif;
return $messages;
}
diff --git a/includes/admin/class-sp-admin.php b/includes/admin/class-sp-admin.php
index 54db69b9..0701ac5f 100644
--- a/includes/admin/class-sp-admin.php
+++ b/includes/admin/class-sp-admin.php
@@ -21,8 +21,6 @@ class SP_Admin {
add_action( 'init', array( $this, 'includes' ) );
add_action( 'current_screen', array( $this, 'conditonal_includes' ) );
add_action( 'admin_init', array( $this, 'prevent_admin_access' ) );
-// add_action( 'admin_init', array( $this, 'preview_emails' ) );
-// add_action( 'admin_footer', 'sp_print_js', 25 );
}
/**
diff --git a/includes/admin/post-types/class-sp-admin-meta-boxes.php b/includes/admin/post-types/class-sp-admin-meta-boxes.php
new file mode 100644
index 00000000..bf0dd711
--- /dev/null
+++ b/includes/admin/post-types/class-sp-admin-meta-boxes.php
@@ -0,0 +1,192 @@
+post_status || 'private' == $post->post_status ) ) {
+ remove_meta_box( 'commentsdiv', 'product', 'normal' );
+
+ add_meta_box( 'commentsdiv', __( 'Reviews', 'sportspress' ), 'post_comment_meta_box', 'product', 'normal' );
+ }
+ }
+
+ /**
+ * Check if we're saving, then trigger an action based on the post type
+ *
+ * @param int $post_id
+ * @param object $post
+ */
+ public function save_meta_boxes( $post_id, $post ) {
+ if ( empty( $post_id ) || empty( $post ) ) return;
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
+ if ( is_int( wp_is_post_revision( $post ) ) ) return;
+ if ( is_int( wp_is_post_autosave( $post ) ) ) return;
+ if ( empty( $_POST['sportspress_meta_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_meta_nonce'], 'sportspress_save_data' ) ) return;
+ if ( ! current_user_can( 'edit_post', $post_id )) return;
+ if ( ! in_array( $post->post_type, array( 'sp_result', 'sp_outcome', 'sp_performance', 'sp_column', 'sp_metric', 'sp_statistic', 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ) return;
+
+ do_action( 'sportspress_process_' . $post->post_type . '_meta', $post_id, $post );
+ }
+
+}
+
+new SP_Admin_Meta_Boxes();
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php
new file mode 100644
index 00000000..ff242dfc
--- /dev/null
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php
@@ -0,0 +1,35 @@
+ID, true );
+
+ sportspress_edit_calendar_table( $data, $usecolumns );
+
+ sportspress_nonce();
+ }
+
+ /**
+ * Save meta box data
+ */
+ public static function save( $post_id, $post ) {
+ update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
+ }
+}
\ No newline at end of file
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-description.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-description.php
new file mode 100644
index 00000000..95ff79f1
--- /dev/null
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-description.php
@@ -0,0 +1,24 @@
+post_content, 'content' );
+ }
+}
\ No newline at end of file
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php
new file mode 100644
index 00000000..2cc4cfb6
--- /dev/null
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php
@@ -0,0 +1,103 @@
+ID, 'sp_league', 0 );
+ $season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
+ $venue_id = sportspress_get_the_term_id( $post->ID, 'sp_venue', 0 );
+ $team_id = get_post_meta( $post->ID, 'sp_team', true );
+ $formats = get_post_meta( $post->ID, 'sp_format' );
+ ?>
+
+
+
+ __( 'All', 'sportspress' ),
+ 'taxonomy' => 'sp_league',
+ 'name' => 'sp_league',
+ 'selected' => $league_id,
+ 'values' => 'term_id'
+ );
+ if ( ! sportspress_dropdown_taxonomies( $args ) ):
+ sportspress_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
+ endif;
+ ?>
+
+
+
+ __( 'All', 'sportspress' ),
+ 'taxonomy' => 'sp_season',
+ 'name' => 'sp_season',
+ 'selected' => $season_id,
+ 'values' => 'term_id'
+ );
+ if ( ! sportspress_dropdown_taxonomies( $args ) ):
+ sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
+ endif;
+ ?>
+
+
+
+ __( 'All', 'sportspress' ),
+ 'taxonomy' => 'sp_venue',
+ 'name' => 'sp_venue',
+ 'selected' => $venue_id,
+ 'values' => 'term_id'
+ );
+ if ( ! sportspress_dropdown_taxonomies( $args ) ):
+ sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
+ endif;
+ ?>
+
+
+
+ __( 'All', 'sportspress' ),
+ 'post_type' => 'sp_team',
+ 'name' => 'sp_team',
+ 'selected' => $team_id,
+ 'values' => 'ID'
+ );
+ if ( ! sportspress_dropdown_pages( $args ) ):
+ sportspress_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
+ endif;
+ ?>
+
+
+ ID, 'sp_format', true );
+ ?>
+
+ formats->calendar as $key => $format ): ?>
+ >
+
+
+ ID, 'sp_format', true );
+ ?>
+
+
+
+
+ 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 = 0;
+ ?>
+
+
+
+
+
+
+ ID, $piece, array( 'team_event', 'result', 'outcome' ) );
+ endforeach;
+ ?>
+
+
+
+
+
+
+
+
+
+
+ post_content, 'content' );
+ }
+}
\ No newline at end of file
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-details.php
new file mode 100644
index 00000000..069a1d22
--- /dev/null
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-details.php
@@ -0,0 +1,87 @@
+ID, 'sp_type', null );
+ $league_id = sportspress_get_the_term_id( $post->ID, 'sp_league', 0 );
+ $season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
+ $venue_id = sportspress_get_the_term_id( $post->ID, 'sp_venue', 0 );
+ ?>
+
+
+
+
+ 'sp_venue',
+ 'name' => 'sp_venue',
+ 'selected' => $venue_id,
+ 'values' => 'term_id',
+ 'show_option_none' => __( '-- Not set --', 'sportspress' ),
+ );
+ if ( ! sportspress_dropdown_taxonomies( $args ) ):
+ sportspress_taxonomy_adder( 'sp_venue', 'sp_event', __( 'Add New', 'sportspress' ) );
+ endif;
+ ?>
+
+
+ ID, 'sp_format', true );
+ ?>
+
+ formats->event as $key => $format ): ?>
+ >
+
+
+ ID, 'sp_team', false );
+ $stats = (array)get_post_meta( $post->ID, 'sp_players', true );
+
+ // Get columns from performance variables
+ $columns = sportspress_get_var_labels( 'sp_performance' );
+
+ 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( $post->ID, 'sp_player', false ), 0, $key );
+ $data = sportspress_array_combine( $players, sportspress_array_value( $stats, $team_id, array() ) );
+
+ ?>
+
+ ID, 'sp_team', false );
+
+ $results = (array)get_post_meta( $post->ID, 'sp_results', true );
+
+ // Get columns from result variables
+ $columns = sportspress_get_var_labels( 'sp_result' );
+
+ // Get results for all teams
+ $data = sportspress_array_combine( $teams, $results );
+
+ ?>
+
+
+
+ ID, 'sp_team', false );
+ foreach ( $teams as $key => $value ):
+ ?>
+
+
+ 'sp_team',
+ 'name' => 'sp_team[]',
+ 'class' => 'sportspress-pages',
+ 'show_option_none' => sprintf( __( 'Remove', 'sportspress' ), 'Team' ),
+ 'option_none_value' => '0',
+ 'selected' => $value
+ );
+ wp_dropdown_pages( $args );
+ ?>
+
+
+ ID, 'sp_player', 'block', 'sp_current_team', $key );
+ sportspress_post_checklist( $post->ID, 'sp_staff', 'none', 'sp_current_team', $key );
+ ?>
+
+
+
+
+ 'sp_team',
+ 'name' => 'sp_team_selector',
+ 'class' => 'sportspress-pages',
+ 'show_option_none' => __( '— Add —', 'sportspress' ),
+ 'option_none_value' => '0'
+ );
+ wp_dropdown_pages( $args );
+ ?>
+
+
+ ID, 'sp_video', true );
+ if ( $video ):
+ ?>
+
+
+
+
+ ID, true );
+
+ sportspress_edit_player_list_table( $columns, $usecolumns, $data, $placeholders );
+ }
+
+ /**
+ * Save meta box data
+ */
+ public static function save( $post_id, $post ) {
+ update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
+ update_post_meta( $post_id, 'sp_players', sportspress_array_value( $_POST, 'sp_players', array() ) );
+ }
+}
\ No newline at end of file
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-details.php
new file mode 100644
index 00000000..2401b7b9
--- /dev/null
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-details.php
@@ -0,0 +1,118 @@
+ID, 'sp_league', 0 );
+ $season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
+ $team_id = get_post_meta( $post->ID, 'sp_team', true );
+ $orderby = get_post_meta( $post->ID, 'sp_orderby', true );
+ $order = get_post_meta( $post->ID, 'sp_order', true );
+ ?>
+
+
+
+ 'sp_league',
+ 'name' => 'sp_league',
+ 'selected' => $league_id,
+ 'values' => 'term_id',
+ );
+ if ( ! sportspress_dropdown_taxonomies( $args ) ):
+ sportspress_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
+ endif;
+ ?>
+
+
+
+ 'sp_season',
+ 'name' => 'sp_season',
+ 'selected' => $season_id,
+ 'values' => 'term_id',
+ );
+ if ( ! sportspress_dropdown_taxonomies( $args ) ):
+ sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
+ endif;
+ ?>
+
+
+
+ 'sp_team',
+ 'name' => 'sp_team',
+ 'show_option_all' => __( 'All', 'sportspress' ),
+ 'selected' => $team_id,
+ 'values' => 'ID',
+ );
+ if ( ! sportspress_dropdown_pages( $args ) ):
+ sportspress_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
+ endif;
+ ?>
+
+
+
+ array(
+ 'number' => __( 'Number', 'sportspress' ),
+ 'name' => __( 'Name', 'sportspress' ),
+ 'eventsplayed' => __( 'Played', 'sportspress' )
+ ),
+ 'post_type' => 'sp_performance',
+ 'name' => 'sp_orderby',
+ 'selected' => $orderby,
+ 'values' => 'slug',
+ );
+ if ( ! sportspress_dropdown_pages( $args ) ):
+ sportspress_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
+ endif;
+ ?>
+
+
+
+
+
+
+ ID, 'sp_player', 'block', 'sp_team' );
+ sportspress_post_adder( 'sp_player', __( 'Add New', 'sportspress' ) );
+ ?>
+
+ ID, 'sp_format', true );
+ ?>
+
+ formats->list as $key => $format ): ?>
+ >
+
+
+
+
+
+
+
+ ID, 'sp_calculate', true );
+ ?>
+
+
+ ID, $calculate ); ?>
+
+ countries->continents;
+
+ $number = get_post_meta( $post->ID, 'sp_number', true );
+ $nationality = get_post_meta( $post->ID, 'sp_nationality', true );
+
+ $leagues = get_the_terms( $post->ID, 'sp_league' );
+ $league_ids = array();
+ if ( $leagues ):
+ foreach ( $leagues as $league ):
+ $league_ids[] = $league->term_id;
+ endforeach;
+ endif;
+
+ $seasons = get_the_terms( $post->ID, 'sp_season' );
+ $season_ids = array();
+ if ( $seasons ):
+ foreach ( $seasons as $season ):
+ $season_ids[] = $season->term_id;
+ endforeach;
+ endif;
+
+ $positions = get_the_terms( $post->ID, 'sp_position' );
+ $position_ids = array();
+ if ( $positions ):
+ foreach ( $positions as $position ):
+ $position_ids[] = $position->term_id;
+ endforeach;
+ endif;
+
+ $teams = get_posts( array( 'post_type' => 'sp_team', 'posts_per_page' => -1 ) );
+ $past_teams = array_filter( get_post_meta( $post->ID, 'sp_past_team', false ) );
+ $current_team = get_post_meta( $post->ID, 'sp_current_team', true );
+ ?>
+
+
+
+
+
+
+
+ 'sp_position',
+ 'name' => 'tax_input[sp_position][]',
+ 'selected' => $position_ids,
+ 'values' => 'term_id',
+ 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Positions', 'sportspress' ) ),
+ 'class' => 'widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
+ );
+ sportspress_dropdown_taxonomies( $args );
+ ?>
+
+
+ 'sp_team',
+ 'name' => 'sp_current_team',
+ 'show_option_blank' => true,
+ 'selected' => $current_team,
+ 'values' => 'ID',
+ 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Team', 'sportspress' ) ),
+ 'class' => 'sp-current-team widefat',
+ 'chosen' => true,
+ );
+ sportspress_dropdown_pages( $args );
+ ?>
+
+
+ 'sp_team',
+ 'name' => 'sp_past_team[]',
+ 'selected' => $past_teams,
+ 'values' => 'ID',
+ 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
+ 'class' => 'sp-past-teams widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
+ );
+ sportspress_dropdown_pages( $args );
+ ?>
+
+
+ 'sp_league',
+ 'name' => 'tax_input[sp_league][]',
+ 'selected' => $league_ids,
+ 'values' => 'term_id',
+ 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ),
+ 'class' => 'widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
+ );
+ sportspress_dropdown_taxonomies( $args );
+ ?>
+
+
+ 'sp_season',
+ 'name' => 'tax_input[sp_season][]',
+ 'selected' => $season_ids,
+ 'values' => 'term_id',
+ 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ),
+ 'class' => 'widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
+ );
+ sportspress_dropdown_taxonomies( $args );
+ ?>
+ ID, 'sp_metrics', true );
+ $positions = get_the_terms( $post->ID, 'sp_position' );
+
+ $args = array(
+ 'post_type' => 'sp_metric',
+ 'numberposts' => -1,
+ 'posts_per_page' => -1,
+ 'orderby' => 'menu_order',
+ 'order' => 'ASC',
+ );
+
+ if ( $positions ):
+ $position_ids = array();
+ foreach( $positions as $position ):
+ $position_ids[] = $position->term_id;
+ endforeach;
+ $args['tax_query'] = array(
+ array(
+ 'taxonomy' => 'sp_position',
+ 'field' => 'id',
+ 'terms' => $position_ids,
+ ),
+ );
+ endif;
+
+ $vars = get_posts( $args );
+
+ if ( $vars ):
+ foreach ( $vars as $var ):
+ ?>
+ post_title; ?>
+
+ ID, 'sp_league' );
+
+ $league_num = sizeof( $leagues );
+
+ // Loop through performance for each league
+ foreach ( $leagues as $league ):
+
+ if ( $league_num > 1 ):
+ ?>
+ name; ?>
+ ID, $league->term_id, true );
+
+ sportspress_edit_player_performance_table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, ! current_user_can( 'edit_sp_teams' ) );
+
+ endforeach;
+ }
+
+ /**
+ * Save meta box data
+ */
+ public static function save( $post_id, $post ) {
+ update_post_meta( $post_id, 'sp_leagues', sportspress_array_value( $_POST, 'sp_leagues', array() ) );
+ if ( current_user_can( 'edit_sp_teams' ) )
+ update_post_meta( $post_id, 'sp_performance', sportspress_array_value( $_POST, 'sp_performance', array() ) );
+ }
+}
\ No newline at end of file
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-result-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-result-details.php
new file mode 100644
index 00000000..aca464dc
--- /dev/null
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-result-details.php
@@ -0,0 +1,37 @@
+
+
+
+
+
+ ID, true );
+
+ sportspress_edit_league_table( $columns, $usecolumns, $data, $placeholders );
+
+ sportspress_nonce();
+ }
+
+ /**
+ * Save meta box data
+ */
+ public static function save( $post_id, $post ) {
+ update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
+ update_post_meta( $post_id, 'sp_teams', sportspress_array_value( $_POST, 'sp_teams', array() ) );
+ }
+}
\ No newline at end of file
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-description.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-description.php
new file mode 100644
index 00000000..de869e15
--- /dev/null
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-description.php
@@ -0,0 +1,24 @@
+post_content, 'content' );
+ }
+}
\ No newline at end of file
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-details.php
new file mode 100644
index 00000000..5ac9a46c
--- /dev/null
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-details.php
@@ -0,0 +1,72 @@
+ID, 'sp_league', 0 );
+ $season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
+ ?>
+
+
+
+ 'sp_league',
+ 'name' => 'sp_league',
+ 'selected' => $league_id,
+ 'values' => 'term_id'
+ );
+ if ( ! sportspress_dropdown_taxonomies( $args ) ):
+ sportspress_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
+ endif;
+ ?>
+
+
+
+ 'sp_season',
+ 'name' => 'sp_season',
+ 'selected' => $season_id,
+ 'values' => 'term_id'
+ );
+ if ( ! sportspress_dropdown_taxonomies( $args ) ):
+ sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
+ endif;
+ ?>
+
+
+ ID, 'sp_team', 'block', 'sp_season' );
+ sportspress_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
+ ?>
+
+
+
+
+
+
+ ID, 'sp_league' );
+ $league_num = sizeof( $leagues );
+
+ // Loop through columns for each league
+ foreach ( $leagues as $league ):
+
+ $league_id = $league->term_id;
+
+ if ( $league_num > 1 ):
+ ?>
+ name; ?>
+ ID, $league_id, true );
+
+ sportspress_edit_team_columns_table( $league_id, $columns, $data, $placeholders, $merged, $leagues_seasons, ! current_user_can( 'edit_sp_tables' ) );
+
+ endforeach;
+ }
+
+ /**
+ * Save meta box data
+ */
+ public static function save( $post_id, $post ) {
+ update_post_meta( $post_id, 'sp_leagues_seasons', sportspress_array_value( $_POST, 'sp_leagues_seasons', array() ) );
+ if ( current_user_can( 'edit_sp_tables' ) )
+ update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
+ }
+}
\ No newline at end of file
diff --git a/includes/admin/settings/options-general.php b/includes/admin/settings/options-general.php
index 38511688..392a0888 100644
--- a/includes/admin/settings/options-general.php
+++ b/includes/admin/settings/options-general.php
@@ -30,7 +30,7 @@ class SportsPressGeneralSettingsPage {
}
function sport_callback() {
- global $sportspress_options, $sportspress_sports;
+ global $sportspress_options;
$selected = sportspress_array_value( $sportspress_options, 'sport', null );
$custom_sport_name = sportspress_array_value( $sportspress_options, 'custom_sport_name', null );
@@ -38,7 +38,7 @@ class SportsPressGeneralSettingsPage {