diff --git a/admin/post-types/outcome.php b/admin/post-types/outcome.php index a4d7a136..86fa9025 100644 --- a/admin/post-types/outcome.php +++ b/admin/post-types/outcome.php @@ -12,6 +12,7 @@ function sp_outcome_cpt_init() { 'show_in_menu' => false, 'hierarchical' => false, 'supports' => array( 'title', 'page-attributes' ), + 'register_meta_box_cb' => 'sp_outcome_meta_init', 'capability_type' => 'sp_config' ); register_post_type( 'sp_outcome', $args ); @@ -21,9 +22,25 @@ add_action( 'init', 'sp_outcome_cpt_init' ); function sp_outcome_edit_columns() { $columns = array( 'cb' => '', - 'title' => __( 'Label', 'sportspress' ) + 'title' => __( 'Label', 'sportspress' ), + 'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ) ); return $columns; } add_filter( 'manage_edit-sp_outcome_columns', 'sp_outcome_edit_columns' ); + +function sp_outcome_meta_init() { + add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'sp_outcome_details_meta', 'sp_outcome', 'normal', 'high' ); +} + +function sp_outcome_details_meta( $post ) { + $abbreviation = get_post_meta( $post->ID, 'sp_abbreviation', true ); + ?> +
+
+ +
+ \ No newline at end of file diff --git a/install.php b/install.php index d6b0359e..0941d9f4 100644 --- a/install.php +++ b/install.php @@ -176,4 +176,30 @@ if ( !function_exists( 'sportspress_install' ) ) { } } add_action( 'admin_init', 'sportspress_install', 1 ); + +// Flush rewrite rules on activation +function sp_rewrite_flush() { + sp_event_cpt_init(); + sp_result_cpt_init(); + sp_outcome_cpt_init(); + sp_column_cpt_init(); + sp_statistic_cpt_init(); + sp_team_cpt_init(); + sp_table_cpt_init(); + sp_player_cpt_init(); + sp_list_cpt_init(); + sp_staff_cpt_init(); + flush_rewrite_rules(); +} +register_activation_hook( __FILE__, 'sp_rewrite_flush' ); + +function sp_admin_head_edit() { + global $typenow; + + if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic' ) ) ): + sp_highlight_admin_menu(); + endif; +} +add_action( 'admin_head-edit.php', 'sp_admin_head_edit', 10, 2 ); +add_action( 'admin_head-post.php', 'sp_admin_head_edit', 10, 2 ); ?> \ No newline at end of file diff --git a/sportspress-actions.php b/sportspress-actions.php index 704f205d..85fa5501 100644 --- a/sportspress-actions.php +++ b/sportspress-actions.php @@ -78,6 +78,14 @@ function sp_manage_posts_custom_column( $column, $post_id ) { echo '—'; endif; break; + case 'sp_abbreviation': + $abbreviation = get_post_meta ( $post_id, 'sp_abbreviation', true ); + if ( $abbreviation ): + echo $abbreviation; + else: + echo get_the_title( $post_id ); + endif; + break; case 'sp_player': echo sp_the_posts( $post_id, 'sp_player' ); break; @@ -101,7 +109,13 @@ function sp_manage_posts_custom_column( $column, $post_id ) { add_action( 'manage_posts_custom_column', 'sp_manage_posts_custom_column', 10, 2 ); add_action( 'manage_pages_custom_column', 'sp_manage_posts_custom_column', 10, 2 ); +function sp_manage_posts_columns() { + sp_highlight_admin_menu(); +} +add_action( 'manage_posts_columns', 'sp_manage_posts_columns' ); + function sp_restrict_manage_posts() { + sp_highlight_admin_menu(); global $typenow, $wp_query; if ( in_array( $typenow, array( 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_list', 'sp_tournament' ) ) ): $selected = isset( $_REQUEST['sp_team'] ) ? $_REQUEST['sp_team'] : null; @@ -184,8 +198,8 @@ function sp_save_post( $post_id ) { case ( 'sp_outcome' ): - // Update equation as string - update_post_meta( $post_id, 'sp_equation', implode( ' ', sp_array_value( $_POST, 'sp_equation', array() ) ) ); + // Update abbreviation as string + update_post_meta( $post_id, 'sp_abbreviation', sp_array_value( $_POST, 'sp_abbreviation', '' ) ); break; diff --git a/sportspress-functions.php b/sportspress-functions.php index ccb6e43b..df5745a5 100644 --- a/sportspress-functions.php +++ b/sportspress-functions.php @@ -463,7 +463,7 @@ if ( !function_exists( 'sp_league_table' ) ) { if ( !$team_id ) continue; $div = get_term( $team_id, 'sp_league' ); ?> -