diff --git a/includes/admin/class-sp-admin-menus.php b/includes/admin/class-sp-admin-menus.php index c3509fc3..41e5b93d 100644 --- a/includes/admin/class-sp-admin-menus.php +++ b/includes/admin/class-sp-admin-menus.php @@ -68,7 +68,7 @@ class SP_Admin_Menus { */ public function menu_highlight() { global $typenow, $submenu; - if ( sp_is_config_type( $typenow ) ) + if ( is_sp_config_type( $typenow ) ) $this->highlight_admin_menu(); elseif ( $typenow == 'sp_calendar' ) $this->highlight_admin_menu( 'edit.php?post_type=sp_event', 'edit.php?post_type=sp_calendar' ); diff --git a/includes/admin/class-sp-admin-post-types.php b/includes/admin/class-sp-admin-post-types.php index d977e1f4..0ea92baa 100644 --- a/includes/admin/class-sp-admin-post-types.php +++ b/includes/admin/class-sp-admin-post-types.php @@ -54,7 +54,7 @@ class SP_Admin_Post_Types { public function post_updated_messages( $messages ) { global $typenow, $post; - if ( sp_is_config_type( $typenow ) ): + if ( is_sp_config_type( $typenow ) ): $obj = get_post_type_object( $typenow ); for ( $i = 0; $i <= 10; $i++ ): 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 index 300bfa01..0f807470 100644 --- 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 @@ -19,8 +19,10 @@ class SP_Meta_Box_Calendar_Data { * Output the metabox */ public static function output( $post ) { - list( $data, $usecolumns ) = sp_get_calendar_data( $post->ID, true ); - sp_edit_calendar_table( $data, $usecolumns ); + $calendar = new SP_Calendar( $post ); + $data = $calendar->data(); + $usecolumns = $calendar->columns; + self::table( $data, $usecolumns ); } /** @@ -29,4 +31,132 @@ class SP_Meta_Box_Calendar_Data { public static function save( $post_id, $post ) { update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) ); } + + /** + * Admin edit table + */ + public static function table( $data = array(), $usecolumns = null ) { + if ( is_array( $usecolumns ) ) + $usecolumns = array_filter( $usecolumns ); + ?> +
| + + | ++ + | ++ + | ++ + | ++ + | ++ + | +
|---|---|---|---|---|---|
| + | post_title; ?> | +
+ ID ) . '">' . $team_result . ' ';
+ endif;
+
+ echo $name . ' '; + endif; + endforeach; + ?> + |
+ + | ID, 'sp_venue' ); ?> | ++ + + + ID ) ): ?> + + + post_content == null ): + _e( 'None', 'sportspress' ); + elseif ( $event->post_status == 'publish' ): + _e( 'Recap', 'sportspress' ); + else: + _e( 'Preview', 'sportspress' ); + endif; + ?> + + | +
| + + | +|||||
- +
| # | ++ + | + + | + |
|---|---|---|---|
| + | + $label ): + $value = sp_array_value( $player_performance, $column, '' ); + ?> + | + + | + ++ + + | +
| + | + $label ): + $player_id = 0; + $player_performance = sp_array_value( $data, 0, array() ); + $value = sp_array_value( $player_performance, $column, '' ); + ?> + | + + | + |
| + $label ): ?> + | + + | + |
|---|---|---|
| + + | + $label ): + $value = sp_array_value( $team_results, $column, '' ); + ?> ++ + | + 'sp_outcome', + 'name' => 'sp_results[' . $team_id . '][outcome][]', + 'option_none_value' => '', + 'sort_order' => 'ASC', + 'sort_column' => 'menu_order', + 'selected' => $values, + 'class' => 'sp-outcome', + 'property' => 'multiple', + 'chosen' => true, + ); + sp_dropdown_pages( $args ); + ?> + | +
@@ -29,11 +31,4 @@ class SP_Meta_Box_Performance_Details {
ID, $league->term_id, true ); + $player = new SP_Player( $post ); - sp_edit_player_performance_table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, ! current_user_can( 'edit_sp_teams' ) ); + list( $columns, $data, $placeholders, $merged, $seasons_teams ) = $player->data( $league->term_id, true ); + + self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, ! current_user_can( 'edit_sp_teams' ) ); endforeach; else: @@ -51,4 +53,85 @@ class SP_Meta_Box_Player_Performance { if ( current_user_can( 'edit_sp_teams' ) ) update_post_meta( $post_id, 'sp_performance', sp_array_value( $_POST, 'sp_performance', array() ) ); } + + /** + * Admin edit table + */ + public static function table( $id = null, $league_id, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $leagues = array(), $readonly = true ) { + if ( ! $id ) + $id = get_the_ID(); + + $teams = array_filter( get_post_meta( $id, 'sp_team', false ) ); + ?> +| + | + + | + + |
|---|---|---|
| + name; ?> + | ++ 'sp_team', + 'name' => 'sp_leagues[' . $league_id . '][' . $div_id . ']', + 'show_option_none' => __( '— None —', 'sportspress' ), + 'sort_order' => 'ASC', + 'sort_column' => 'menu_order', + 'selected' => $value, + 'values' => 'ID', + 'include' => $teams, + 'tax_query' => array( + 'relation' => 'AND', + array( + 'taxonomy' => 'sp_league', + 'terms' => $league_id, + 'field' => 'id', + ), + array( + 'taxonomy' => 'sp_season', + 'terms' => $div_id, + 'field' => 'id', + ), + ), + ); + if ( ! sp_dropdown_pages( $args ) ): + _e( 'No results found.', 'sportspress' ); + endif; + ?> + | + $label ): + ?> +'; + ?> | + +
| + | + + | + + |
|---|---|---|
| + name; ?> + | ++ 'sp_team', + 'name' => 'sp_leagues[' . $league_id . '][' . $div_id . ']', + 'show_option_none' => __( '— None —', 'sportspress' ), + 'sort_order' => 'ASC', + 'sort_column' => 'menu_order', + 'selected' => $value, + 'values' => 'ID', + 'include' => $teams, + 'tax_query' => array( + 'relation' => 'AND', + array( + 'taxonomy' => 'sp_league', + 'terms' => $league_id, + 'field' => 'id', + ), + array( + 'taxonomy' => 'sp_season', + 'terms' => $div_id, + 'field' => 'id', + ), + ), + ); + if ( ! sp_dropdown_pages( $args ) ): + _e( 'No results found.', 'sportspress' ); + endif; + ?> + | + $label ): + ?> +'; + ?> | + +
| + | + + | + + |
|---|---|---|
| + > + | ++ + | + $label ): + $value = sp_array_value( sp_array_value( $data, $div_id, array() ), $column, 0 ); + ?> +'; + ?> | + +
| - - | -- - | -- - | -- - | -- - | -- - | -
|---|---|---|---|---|---|
| - | post_title; ?> | -
- ID ) . '">' . $team_result . ' ';
- endif;
-
- echo $name . ' '; - endif; - endforeach; - ?> - |
- - | ID, 'sp_venue' ); ?> | -- - - - ID ) ): ?> - - - post_content == null ): - _e( 'None', 'sportspress' ); - elseif ( $event->post_status == 'publish' ): - _e( 'Recap', 'sportspress' ); - else: - _e( 'Preview', 'sportspress' ); - endif; - ?> - - | -
| - - | -|||||
| - | - - | - - |
|---|---|---|
| - > - | -- - | - $label ): - $value = sp_array_value( sp_array_value( $data, $div_id, array() ), $column, 0 ); - ?> -'; - ?> | - -
| - | - - | - - |
|---|---|---|
| - name; ?> - | -- 'sp_team', - 'name' => 'sp_leagues[' . $league_id . '][' . $div_id . ']', - 'show_option_none' => __( '— None —', 'sportspress' ), - 'sort_order' => 'ASC', - 'sort_column' => 'menu_order', - 'selected' => $value, - 'values' => 'ID', - 'include' => $teams, - 'tax_query' => array( - 'relation' => 'AND', - array( - 'taxonomy' => 'sp_league', - 'terms' => $league_id, - 'field' => 'id', - ), - array( - 'taxonomy' => 'sp_season', - 'terms' => $div_id, - 'field' => 'id', - ), - ), - ); - if ( ! sp_dropdown_pages( $args ) ): - _e( 'No results found.', 'sportspress' ); - endif; - ?> - | - $label ): - ?> -'; - ?> | - -
| - | - - | - - |
|---|---|---|
| - name; ?> - | -- 'sp_team', - 'name' => 'sp_leagues[' . $league_id . '][' . $div_id . ']', - 'show_option_none' => __( '— None —', 'sportspress' ), - 'sort_order' => 'ASC', - 'sort_column' => 'menu_order', - 'selected' => $value, - 'values' => 'ID', - 'include' => $teams, - 'tax_query' => array( - 'relation' => 'AND', - array( - 'taxonomy' => 'sp_league', - 'terms' => $league_id, - 'field' => 'id', - ), - array( - 'taxonomy' => 'sp_season', - 'terms' => $div_id, - 'field' => 'id', - ), - ), - ); - if ( ! sp_dropdown_pages( $args ) ): - _e( 'No results found.', 'sportspress' ); - endif; - ?> - | - $label ): - ?> -'; - ?> | - -
| - $label ): ?> - | - - | - |
|---|---|---|
| - - | - $label ): - $value = sp_array_value( $team_results, $column, '' ); - ?> -- - | - 'sp_outcome', - 'name' => 'sp_results[' . $team_id . '][outcome][]', - 'option_none_value' => '', - 'sort_order' => 'ASC', - 'sort_column' => 'menu_order', - 'selected' => $values, - 'class' => 'sp-outcome', - 'property' => 'multiple', - 'chosen' => true, - ); - sp_dropdown_pages( $args ); - ?> - | -
| # | -- - | - - | - |
|---|---|---|---|
| - | - $label ): - $value = sp_array_value( $player_performance, $column, '' ); - ?> - | - - | - -- - - | -
| - | - $label ): - $player_id = 0; - $player_performance = sp_array_value( $data, 0, array() ); - $value = sp_array_value( $player_performance, $column, '' ); - ?> - | - - | - |
| ' . ( $i + 1 ) . ' | '; - else: - $number = get_post_meta( $player_id, 'sp_number', true ); - $rows .= '' . ( $number ? $number : ' ' ) . ' | '; - endif; - - // Name as link - $permalink = get_post_permalink( $player_id ); - $name = sp_array_value( $row, 'name', sp_array_value( $row, 'name', ' ' ) ); - $rows .= '' . '' . $name . ' | '; - - foreach( $labels as $key => $value ): - if ( $key == 'name' ) - continue; - if ( ! is_array( $performance ) || in_array( $key, $performance ) ) - $rows .= '' . sp_array_value( $row, $key, '—' ) . ' | '; - endforeach; - - $rows .= '
| # | '; - else: - $output .= '' . SP()->text->string('Rank') . ' | '; - endif; - - foreach( $labels as $key => $label ): - if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) ) - $output .= ''. $label . ' | '; - endforeach; - $output .= '
|---|