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' ); ?> - + @@ -503,7 +503,7 @@ if ( !function_exists( 'sp_player_table' ) ) { if ( !$player_id ) continue; $div = get_term( $player_id, 'sp_league' ); ?> - + @@ -541,7 +541,7 @@ if ( !function_exists( 'sp_team_columns_table' ) ) { $i = 0; if ( empty( $data ) ): ?> - + - + name; ?> @@ -598,7 +598,7 @@ if ( !function_exists( 'sp_player_statistics_table' ) ) { if ( !$div_id ) continue; $div = get_term( $div_id, 'sp_league' ); ?> - + name; ?> @@ -639,7 +639,7 @@ if ( !function_exists( 'sp_event_results_table' ) ) { foreach ( $data as $team_id => $team_results ): if ( !$team_id ) continue; ?> - + @@ -692,7 +692,7 @@ if ( !function_exists( 'sp_event_players_table' ) ) { foreach ( $data as $player_id => $player_statistics ): if ( !$player_id ) continue; ?> - + @@ -706,7 +706,7 @@ if ( !function_exists( 'sp_event_players_table' ) ) { $i++; endforeach; ?> - + $label ): $player_id = 0; @@ -1328,4 +1328,13 @@ if ( !function_exists( 'sp_get_list_html' ) ) { } } + + +if ( !function_exists( 'sp_highlight_admin_menu' ) ) { + function sp_highlight_admin_menu() { + global $parent_file, $submenu_file; + $parent_file = 'options-general.php'; + $submenu_file = 'sportspress'; + } +} ?> \ No newline at end of file diff --git a/sportspress-hooks.php b/sportspress-hooks.php deleted file mode 100644 index 1837f2d4..00000000 --- a/sportspress-hooks.php +++ /dev/null @@ -1,14 +0,0 @@ - \ No newline at end of file diff --git a/sportspress.php b/sportspress.php index 30a73a13..c8dedd84 100644 --- a/sportspress.php +++ b/sportspress.php @@ -53,9 +53,10 @@ require_once dirname( __FILE__ ) . '/admin/terms/position.php'; // Install include dirname( __FILE__ ) . '/install.php'; -// Hooks, Actions, and Filters -require_once dirname( __FILE__ ) . '/sportspress-hooks.php'; +// Actions require_once dirname( __FILE__ ) . '/sportspress-actions.php'; + +// Filters require_once dirname( __FILE__ ) . '/sportspress-filters.php'; // Admin Styles