Highlight admin menu when editing configs and add abbreviation to outcome
This commit is contained in:
@@ -12,6 +12,7 @@ function sp_outcome_cpt_init() {
|
|||||||
'show_in_menu' => false,
|
'show_in_menu' => false,
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'page-attributes' ),
|
'supports' => array( 'title', 'page-attributes' ),
|
||||||
|
'register_meta_box_cb' => 'sp_outcome_meta_init',
|
||||||
'capability_type' => 'sp_config'
|
'capability_type' => 'sp_config'
|
||||||
);
|
);
|
||||||
register_post_type( 'sp_outcome', $args );
|
register_post_type( 'sp_outcome', $args );
|
||||||
@@ -21,9 +22,25 @@ add_action( 'init', 'sp_outcome_cpt_init' );
|
|||||||
function sp_outcome_edit_columns() {
|
function sp_outcome_edit_columns() {
|
||||||
$columns = array(
|
$columns = array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'title' => __( 'Label', 'sportspress' )
|
'title' => __( 'Label', 'sportspress' ),
|
||||||
|
'sp_abbreviation' => __( 'Abbreviation', 'sportspress' )
|
||||||
);
|
);
|
||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
add_filter( 'manage_edit-sp_outcome_columns', 'sp_outcome_edit_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 );
|
||||||
|
?>
|
||||||
|
<p><strong><?php _e( 'Abbreviation', 'sportspress' ); ?></strong></p>
|
||||||
|
<p>
|
||||||
|
<input name="sp_abbreviation" type="text" size="4" id="sp_abbreviation" value="<?php echo $abbreviation; ?>" placeholder="<?php echo get_the_title( $post->ID ); ?>">
|
||||||
|
</p>
|
||||||
|
<?php
|
||||||
|
sp_nonce();
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
26
install.php
26
install.php
@@ -176,4 +176,30 @@ if ( !function_exists( 'sportspress_install' ) ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action( 'admin_init', 'sportspress_install', 1 );
|
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 );
|
||||||
?>
|
?>
|
||||||
@@ -78,6 +78,14 @@ function sp_manage_posts_custom_column( $column, $post_id ) {
|
|||||||
echo '—';
|
echo '—';
|
||||||
endif;
|
endif;
|
||||||
break;
|
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':
|
case 'sp_player':
|
||||||
echo sp_the_posts( $post_id, 'sp_player' );
|
echo sp_the_posts( $post_id, 'sp_player' );
|
||||||
break;
|
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_posts_custom_column', 'sp_manage_posts_custom_column', 10, 2 );
|
||||||
add_action( 'manage_pages_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() {
|
function sp_restrict_manage_posts() {
|
||||||
|
sp_highlight_admin_menu();
|
||||||
global $typenow, $wp_query;
|
global $typenow, $wp_query;
|
||||||
if ( in_array( $typenow, array( 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_list', 'sp_tournament' ) ) ):
|
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;
|
$selected = isset( $_REQUEST['sp_team'] ) ? $_REQUEST['sp_team'] : null;
|
||||||
@@ -184,8 +198,8 @@ function sp_save_post( $post_id ) {
|
|||||||
|
|
||||||
case ( 'sp_outcome' ):
|
case ( 'sp_outcome' ):
|
||||||
|
|
||||||
// Update equation as string
|
// Update abbreviation as string
|
||||||
update_post_meta( $post_id, 'sp_equation', implode( ' ', sp_array_value( $_POST, 'sp_equation', array() ) ) );
|
update_post_meta( $post_id, 'sp_abbreviation', sp_array_value( $_POST, 'sp_abbreviation', '' ) );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -463,7 +463,7 @@ if ( !function_exists( 'sp_league_table' ) ) {
|
|||||||
if ( !$team_id ) continue;
|
if ( !$team_id ) continue;
|
||||||
$div = get_term( $team_id, 'sp_league' );
|
$div = get_term( $team_id, 'sp_league' );
|
||||||
?>
|
?>
|
||||||
<tr class="sp-row sp-post<?php if ( $i % 2 ) echo ' alternate'; ?>">
|
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||||
<td>
|
<td>
|
||||||
<?php echo get_the_title( $team_id ); ?>
|
<?php echo get_the_title( $team_id ); ?>
|
||||||
</td>
|
</td>
|
||||||
@@ -503,7 +503,7 @@ if ( !function_exists( 'sp_player_table' ) ) {
|
|||||||
if ( !$player_id ) continue;
|
if ( !$player_id ) continue;
|
||||||
$div = get_term( $player_id, 'sp_league' );
|
$div = get_term( $player_id, 'sp_league' );
|
||||||
?>
|
?>
|
||||||
<tr class="sp-row sp-post<?php if ( $i % 2 ) echo ' alternate'; ?>">
|
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||||
<td>
|
<td>
|
||||||
<?php echo get_the_title( $player_id ); ?>
|
<?php echo get_the_title( $player_id ); ?>
|
||||||
</td>
|
</td>
|
||||||
@@ -541,7 +541,7 @@ if ( !function_exists( 'sp_team_columns_table' ) ) {
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
if ( empty( $data ) ):
|
if ( empty( $data ) ):
|
||||||
?>
|
?>
|
||||||
<tr class="sp-row sp-post<?php if ( $i % 2 ) echo ' alternate'; ?>">
|
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||||
<td><strong><?php printf( __( 'Select %s', 'sportspress' ), __( 'League', 'sportspress' ) ); ?></strong></td>
|
<td><strong><?php printf( __( 'Select %s', 'sportspress' ), __( 'League', 'sportspress' ) ); ?></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
@@ -550,7 +550,7 @@ if ( !function_exists( 'sp_team_columns_table' ) ) {
|
|||||||
if ( !$div_id ) continue;
|
if ( !$div_id ) continue;
|
||||||
$div = get_term( $div_id, 'sp_league' );
|
$div = get_term( $div_id, 'sp_league' );
|
||||||
?>
|
?>
|
||||||
<tr class="sp-row sp-post<?php if ( $i % 2 ) echo ' alternate'; ?>">
|
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||||
<td>
|
<td>
|
||||||
<?php echo $div->name; ?>
|
<?php echo $div->name; ?>
|
||||||
</td>
|
</td>
|
||||||
@@ -598,7 +598,7 @@ if ( !function_exists( 'sp_player_statistics_table' ) ) {
|
|||||||
if ( !$div_id ) continue;
|
if ( !$div_id ) continue;
|
||||||
$div = get_term( $div_id, 'sp_league' );
|
$div = get_term( $div_id, 'sp_league' );
|
||||||
?>
|
?>
|
||||||
<tr class="sp-row sp-post<?php if ( $i % 2 ) echo ' alternate'; ?>">
|
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||||
<td>
|
<td>
|
||||||
<?php echo $div->name; ?>
|
<?php echo $div->name; ?>
|
||||||
</td>
|
</td>
|
||||||
@@ -639,7 +639,7 @@ if ( !function_exists( 'sp_event_results_table' ) ) {
|
|||||||
foreach ( $data as $team_id => $team_results ):
|
foreach ( $data as $team_id => $team_results ):
|
||||||
if ( !$team_id ) continue;
|
if ( !$team_id ) continue;
|
||||||
?>
|
?>
|
||||||
<tr class="sp-row sp-post<?php if ( $i % 2 ) echo ' alternate'; ?>">
|
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||||
<td>
|
<td>
|
||||||
<?php echo get_the_title( $team_id ); ?>
|
<?php echo get_the_title( $team_id ); ?>
|
||||||
</td>
|
</td>
|
||||||
@@ -692,7 +692,7 @@ if ( !function_exists( 'sp_event_players_table' ) ) {
|
|||||||
foreach ( $data as $player_id => $player_statistics ):
|
foreach ( $data as $player_id => $player_statistics ):
|
||||||
if ( !$player_id ) continue;
|
if ( !$player_id ) continue;
|
||||||
?>
|
?>
|
||||||
<tr class="sp-row sp-post<?php if ( $i % 2 ) echo ' alternate'; ?>">
|
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||||
<td>
|
<td>
|
||||||
<?php echo get_the_title( $player_id ); ?>
|
<?php echo get_the_title( $player_id ); ?>
|
||||||
</td>
|
</td>
|
||||||
@@ -706,7 +706,7 @@ if ( !function_exists( 'sp_event_players_table' ) ) {
|
|||||||
$i++;
|
$i++;
|
||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
<tr class="sp-row sp-total<?php if ( $i % 2 ) echo ' alternate'; ?>">
|
<tr class="sp-row sp-total<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||||
<td><strong><?php _e( 'Total', 'sportspress' ); ?></strong></td>
|
<td><strong><?php _e( 'Total', 'sportspress' ); ?></strong></td>
|
||||||
<?php foreach( $columns as $column => $label ):
|
<?php foreach( $columns as $column => $label ):
|
||||||
$player_id = 0;
|
$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';
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
// Flush rewrite rules on activation to make sure permalinks work properly
|
|
||||||
function sp_rewrite_flush() {
|
|
||||||
sp_config_cpt_init();
|
|
||||||
sp_event_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' );
|
|
||||||
?>
|
|
||||||
@@ -53,9 +53,10 @@ require_once dirname( __FILE__ ) . '/admin/terms/position.php';
|
|||||||
// Install
|
// Install
|
||||||
include dirname( __FILE__ ) . '/install.php';
|
include dirname( __FILE__ ) . '/install.php';
|
||||||
|
|
||||||
// Hooks, Actions, and Filters
|
// Actions
|
||||||
require_once dirname( __FILE__ ) . '/sportspress-hooks.php';
|
|
||||||
require_once dirname( __FILE__ ) . '/sportspress-actions.php';
|
require_once dirname( __FILE__ ) . '/sportspress-actions.php';
|
||||||
|
|
||||||
|
// Filters
|
||||||
require_once dirname( __FILE__ ) . '/sportspress-filters.php';
|
require_once dirname( __FILE__ ) . '/sportspress-filters.php';
|
||||||
|
|
||||||
// Admin Styles
|
// Admin Styles
|
||||||
|
|||||||
Reference in New Issue
Block a user