Remove old post type functions

This commit is contained in:
Brian Miyaji
2014-03-26 10:53:01 +11:00
parent 7b80f687f2
commit 1a00fdb2da
15 changed files with 0 additions and 1571 deletions

View File

@@ -1,167 +0,0 @@
<?php
function sportspress_calendar_post_init() {
$labels = array(
'name' => __( 'Calendars', 'sportspress' ),
'singular_name' => __( 'Calendar', 'sportspress' ),
'add_new_item' => __( 'Add New Calendar', 'sportspress' ),
'edit_item' => __( 'Edit Calendar', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Calendars', 'sportspress' ),
'labels' => $labels,
'public' => true,
'has_archive' => false,
'hierarchical' => false,
'supports' => array( 'title', 'author', 'thumbnail' ),
'register_meta_box_cb' => 'sportspress_calendar_meta_init',
'rewrite' => array( 'slug' => get_option( 'sportspress_calendar_slug', 'calendar' ) ),
'show_in_menu' => 'edit.php?post_type=sp_event',
'show_in_admin_bar' => true,
'capability_type' => 'sp_calendar',
);
register_post_type( 'sp_calendar', $args );
}
add_action( 'init', 'sportspress_calendar_post_init' );
function sportspress_calendar_edit_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Title', 'sportspress' ),
'sp_league' => __( 'League', 'sportspress' ),
'sp_season' => __( 'Season', 'sportspress' ),
'sp_venue' => __( 'Venue', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ),
'sp_events' => __( 'Events', 'sportspress' ),
'sp_views' => __( 'Views', 'sportspress' ),
);
return $columns;
}
add_filter( 'manage_edit-sp_calendar_columns', 'sportspress_calendar_edit_columns' );
function sportspress_calendar_meta_init( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false );
remove_meta_box( 'sp_seasondiv', 'sp_calendar', 'side' );
remove_meta_box( 'sp_leaguediv', 'sp_calendar', 'side' );
remove_meta_box( 'sp_venuediv', 'sp_calendar', 'side' );
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'sportspress_calendar_shortcode_meta', 'sp_calendar', 'side', 'default' );
add_meta_box( 'sp_formatdiv', __( 'Format', 'sportspress' ), 'sportspress_calendar_format_meta', 'sp_calendar', 'side', 'default' );
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'sportspress_calendar_details_meta', 'sp_calendar', 'side', 'default' );
add_meta_box( 'sp_columnsdiv', __( 'Events', 'sportspress' ), 'sportspress_calendar_events_meta', 'sp_calendar', 'normal', 'high' );
add_meta_box( 'sp_descriptiondiv', __( 'Description', 'sportspress' ), 'sportspress_calendar_description_meta', 'sp_calendar', 'normal', 'high' );
}
function sportspress_calendar_shortcode_meta( $post ) {
$the_format = get_post_meta( $post->ID, 'sp_format', true );
?>
<p class="howto">
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
</p>
<p><input type="text" value="[event_<?php echo $the_format; ?> <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<?php
}
function sportspress_calendar_format_meta( $post ) {
global $sportspress_formats;
$the_format = get_post_meta( $post->ID, 'sp_format', true );
?>
<div id="post-formats-select">
<?php foreach ( $sportspress_formats['calendar'] as $key => $format ): ?>
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( true, ( $key == 'calendar' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo $key; ?>" class="post-format-icon post-format-<?php echo $key; ?>"><?php echo $format; ?></label><br>
<?php endforeach; ?>
</div>
<?php
}
function sportspress_calendar_details_meta( $post, $test ) {
global $sportspress_formats;
$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 );
$team_id = get_post_meta( $post->ID, 'sp_team', true );
$formats = get_post_meta( $post->ID, 'sp_format' );
?>
<div>
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'show_option_all' => __( '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;
?>
</p>
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
<p class="sp-tab-select">
<?php
$args = array(
'show_option_all' => __( '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;
?>
</p>
<p><strong><?php _e( 'Venue', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'show_option_all' => __( '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;
?>
</p>
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'show_option_all' => __( '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;
?>
</p>
</div>
<?php
sportspress_nonce();
}
function sportspress_calendar_events_meta( $post ) {
list( $data, $usecolumns ) = sportspress_get_calendar_data( $post->ID, true );
sportspress_edit_calendar_table( $data, $usecolumns );
sportspress_nonce();
}
function sportspress_calendar_description_meta( $post ) {
wp_editor( $post->post_content, 'content' );
}

View File

@@ -1,98 +0,0 @@
<?php
function sportspress_column_post_init() {
$labels = array(
'name' => __( 'Columns', 'sportspress' ),
'singular_name' => __( 'Column', 'sportspress' ),
'add_new_item' => __( 'Add New Column', 'sportspress' ),
'edit_item' => __( 'Edit Column', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Columns', 'sportspress' ),
'labels' => $labels,
'public' => false,
'show_ui' => true,
'show_in_menu' => false,
'has_archive' => false,
'hierarchical' => false,
'can_export' => false,
'supports' => array( 'title', 'page-attributes' ),
'register_meta_box_cb' => 'sportspress_column_meta_init',
'capability_type' => 'sp_config',
);
register_post_type( 'sp_column', $args );
}
add_action( 'init', 'sportspress_column_post_init' );
function sportspress_column_edit_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_key' => __( 'Key', 'sportspress' ),
'sp_equation' => __( 'Equation', 'sportspress' ),
'sp_precision' => __( 'Rounding', 'sportspress' ),
'sp_order' => __( 'Sort Order', 'sportspress' ),
);
return $columns;
}
add_filter( 'manage_edit-sp_column_columns', 'sportspress_column_edit_columns' );
function sportspress_column_meta_init() {
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'sportspress_column_details_meta', 'sp_column', 'normal', 'high' );
}
function sportspress_column_details_meta( $post ) {
$equation = explode( ' ', get_post_meta( $post->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;
?>
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
</p>
<p><strong><?php _e( 'Equation', 'sportspress' ); ?></strong></p>
<p class="sp-equation-selector">
<?php
foreach ( $equation as $piece ):
sportspress_equation_selector( $post->ID, $piece, array( 'team_event', 'result', 'outcome' ) );
endforeach;
?>
</p>
<p><strong><?php _e( 'Rounding', 'sportspress' ); ?></strong></p>
<p class="sp-precision-selector">
<input name="sp_precision" type="text" size="4" id="sp_precision" value="<?php echo $precision; ?>" placeholder="0">
</p>
<p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p>
<p class="sp-order-selector">
<select name="sp_priority">
<?php
$options = array( '0' => __( 'Disable', 'sportspress' ) );
$count = wp_count_posts( 'sp_column' );
for( $i = 1; $i <= $count->publish; $i++ ):
$options[ $i ] = $i;
endfor;
foreach ( $options as $key => $value ):
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
endforeach;
?>
</select>
<select name="sp_order">
<?php
$options = array( 'DESC' => __( 'Descending', 'sportspress' ), 'ASC' => __( 'Ascending', 'sportspress' ) );
foreach ( $options as $key => $value ):
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $order, false ), $value );
endforeach;
?>
</select>
</p>
<?php
sportspress_nonce();
}

View File

@@ -1,165 +0,0 @@
<?php
function sportspress_directory_post_init() {
$labels = array(
'name' => __( 'Directories', 'sportspress' ),
'singular_name' => __( 'Directory', 'sportspress' ),
'add_new_item' => __( 'Add New Directory', 'sportspress' ),
'edit_item' => __( 'Edit Directory', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Directories', 'sportspress' ),
'labels' => $labels,
'public' => true,
'has_archive' => false,
'hierarchical' => false,
'supports' => array( 'title', 'author', 'thumbnail' ),
'register_meta_box_cb' => 'sportspress_directory_meta_init',
'rewrite' => array( 'slug' => get_option( 'sportspress_directory_slug', 'directory' ) ),
'show_in_menu' => 'edit.php?post_type=sp_player',
'show_in_admin_bar' => true,
'capability_type' => 'sp_directory',
);
register_post_type( 'sp_directory', $args );
}
add_action( 'init', 'sportspress_directory_post_init' );
function sportspress_directory_edit_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Title', 'sportspress' ),
'sp_staff' => __( 'Staff', 'sportspress' ),
'sp_league' => __( 'League', 'sportspress' ),
'sp_season' => __( 'Season', 'sportspress' ),
'sp_team' => __( 'Team', 'sportspress' ),
'sp_views' => __( 'Views', 'sportspress' ),
);
return $columns;
}
add_filter( 'manage_edit-sp_directory_columns', 'sportspress_directory_edit_columns' );
function sportspress_directory_meta_init( $post ) {
$players = (array)get_post_meta( $post->ID, 'sp_staff', false );
remove_meta_box( 'sp_seasondiv', 'sp_directory', 'side' );
remove_meta_box( 'sp_leaguediv', 'sp_directory', 'side' );
add_meta_box( 'sp_formatdiv', __( 'Format', 'sportspress' ), 'sportspress_directory_format_meta', 'sp_directory', 'side', 'high' );
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'sportspress_directory_details_meta', 'sp_directory', 'side', 'high' );
//add_meta_box( 'sp_columnsdiv', __( 'Staff List', 'sportspress' ), 'sportspress_directory_columns_meta', 'sp_directory', 'normal', 'high' );
add_meta_box( 'sp_descriptiondiv', __( 'Description', 'sportspress' ), 'sportspress_directory_description_meta', 'sp_directory', 'normal', 'high' );
}
function sportspress_directory_format_meta( $post ) {
global $sportspress_formats;
$the_format = get_post_meta( $post->ID, 'sp_format', true );
?>
<div id="post-formats-select">
<?php foreach ( $sportspress_formats['list'] as $key => $format ): ?>
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( true, ( $key == 'list' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo $key; ?>" class="post-format-icon post-format-<?php echo $key; ?>"><?php echo $format; ?></label><br>
<?php endforeach; ?>
</div>
<?php
}
function sportspress_directory_details_meta( $post ) {
$league_id = sportspress_get_the_term_id( $post->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 );
?>
<div>
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'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;
?>
</p>
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
<p class="sp-tab-select">
<?php
$args = array(
'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;
?>
</p>
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
<p class="sp-tab-select">
<?php
$args = array(
'post_type' => '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;
?>
</p>
<p><strong><?php _e( 'Sort by:', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'prepend_options' => 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_directory', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><strong><?php _e( 'Sort Order:', 'sportspress' ); ?></strong></p>
<p>
<select name="sp_order">
<option value="ASC" <?php selected( 'ASC', $order ); ?>><?php _e( 'Ascending', 'sportspress' ); ?></option>
<option value="DESC" <?php selected( 'DESC', $order ); ?>><?php _e( 'Descending', 'sportspress' ); ?></option>
</select>
</p>
<p><strong><?php _e( 'Staff', 'sportspress' ); ?></strong></p>
<?php
sportspress_post_checklist( $post->ID, 'sp_staff', 'block', 'sp_team' );
sportspress_post_adder( 'sp_staff', __( 'Add New', 'sportspress' ) );
?>
</div>
<?php
sportspress_nonce();
}
function sportspress_directory_columns_meta( $post ) {
list( $columns, $usecolumns, $data, $placeholders, $merged ) = sportspress_get_player_list_data( $post->ID, true );
sportspress_edit_player_list_table( $columns, $usecolumns, $data, $placeholders );
sportspress_nonce();
}
function sportspress_directory_description_meta( $post ) {
wp_editor( $post->post_content, 'content' );
}

View File

@@ -1,235 +0,0 @@
<?php
function sportspress_event_post_init() {
$labels = array(
'name' => __( 'Schedule', 'sportspress' ),
'singular_name' => __( 'Event', 'sportspress' ),
'all_items' => __( 'Events', 'sportspress' ),
'add_new_item' => __( 'Add New Event', 'sportspress' ),
'edit_item' => __( 'Edit Event', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Events', 'sportspress' ),
'labels' => $labels,
'public' => true,
'has_archive' => true,
'hierarchical' => false,
'supports' => array( 'title', 'author', 'thumbnail', 'comments' ),
'register_meta_box_cb' => 'sportspress_event_meta_init',
'rewrite' => array( 'slug' => get_option( 'sportspress_events_slug', 'events' ) ),
'menu_icon' => 'dashicons-calendar',
'capability_type' => 'sp_event',
);
register_post_type( 'sp_event', $args );
}
add_action( 'init', 'sportspress_event_post_init' );
function sportspress_event_meta_init( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false );
$players = (array)get_post_meta( $post->ID, 'sp_player', false );
remove_meta_box( 'submitdiv', 'sp_event', 'side' );
remove_meta_box( 'sp_venuediv', 'sp_event', 'side' );
remove_meta_box( 'sp_leaguediv', 'sp_event', 'side' );
remove_meta_box( 'sp_seasondiv', 'sp_event', 'side' );
add_meta_box( 'submitdiv', __( 'Event', 'sportspress' ), 'post_submit_meta_box', 'sp_event', 'side', 'default' );
add_meta_box( 'sp_formatdiv', __( 'Format', 'sportspress' ), 'sportspress_event_format_meta', 'sp_event', 'side', 'default' );
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'sportspress_event_details_meta', 'sp_event', 'side', 'default' );
add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sportspress_event_team_meta', 'sp_event', 'side', 'default' );
add_meta_box( 'sp_videodiv', __( 'Video', 'sportspress' ), 'sportspress_event_video_meta', 'sp_event', 'side', 'low' );
if ( sizeof( $teams ) > 0 )
add_meta_box( 'sp_resultsdiv', __( 'Results', 'sportspress' ), 'sportspress_event_results_meta', 'sp_event', 'normal', 'high' );
do_action( 'sportspress_event_meta_init' );
if ( sizeof( $players ) > 0 )
add_meta_box( 'sp_performancediv', __( 'Performance', 'sportspress' ), 'sportspress_event_performance_meta', 'sp_event', 'normal', 'high' );
add_meta_box( 'sp_articlediv', __( 'Article', 'sportspress' ), 'sportspress_event_article_meta', 'sp_event', 'normal', 'high' );
}
function sportspress_event_format_meta( $post ) {
global $sportspress_formats;
$the_format = get_post_meta( $post->ID, 'sp_format', true );
?>
<div id="post-formats-select">
<?php foreach ( $sportspress_formats['event'] as $key => $format ): ?>
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( true, ( $key == 'league' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo $key; ?>" class="post-format-icon post-format-<?php echo $key; ?>"><?php echo $format; ?></label><br>
<?php endforeach; ?>
</div>
<?php
}
function sportspress_event_details_meta( $post ) {
$type = sportspress_get_the_term_id( $post->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 );
?>
<div>
<fieldset class="sp-event-format-field sp-league-event-field sp-friendly-event-field">
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'taxonomy' => 'sp_league',
'name' => 'sp_league',
'selected' => $league_id,
'values' => 'term_id',
'show_option_none' => __( '-- Not set --', 'sportspress' ),
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'taxonomy' => 'sp_season',
'name' => 'sp_season',
'selected' => $season_id,
'values' => 'term_id',
'show_option_none' => __( '-- Not set --', 'sportspress' ),
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
</fieldset>
<p><strong><?php _e( 'Venue', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'taxonomy' => '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;
?>
</p>
</div>
<?php
}
function sportspress_event_team_meta( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false );
foreach ( $teams as $key => $value ):
?>
<div class="sp-clone">
<p class="sp-tab-select sp-title-generator">
<?php
$args = array(
'post_type' => '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 );
?>
</p>
<ul id="sp_team-tabs" class="wp-tab-bar sp-tab-bar">
<li class="wp-tab-active"><a href="#sp_player-all"><?php _e( 'Players', 'sportspress' ); ?></a></li>
<li class="wp-tab"><a href="#sp_staff-all"><?php _e( 'Staff', 'sportspress' ); ?></a></li>
</ul>
<?php
sportspress_post_checklist( $post->ID, 'sp_player', 'block', 'sp_current_team', $key );
sportspress_post_checklist( $post->ID, 'sp_staff', 'none', 'sp_current_team', $key );
?>
</div>
<?php endforeach; ?>
<div class="sp-clone" data-clone-name="sp_team">
<p class="sp-tab-select sp-title-generator">
<?php
$args = array(
'post_type' => 'sp_team',
'name' => 'sp_team_selector',
'class' => 'sportspress-pages',
'show_option_none' => __( '&mdash; Add &mdash;', 'sportspress' ),
'option_none_value' => '0'
);
wp_dropdown_pages( $args );
?>
</p>
</div>
<?php
sportspress_nonce();
}
function sportspress_event_video_meta( $post ) {
$video = get_post_meta( $post->ID, 'sp_video', true );
if ( $video ):
?>
<fieldset class="sp-video-embed">
<?php echo apply_filters( 'the_content', '[embed width="254"]' . $video . '[/embed]' ); ?>
<p><a href="#" class="sp-remove-video"><?php _e( 'Remove video', 'sportspress' ); ?></a></p>
</fieldset>
<?php endif; ?>
<fieldset class="sp-video-field hidden">
<p><strong><?php _e( 'URL', 'sportspress' ); ?></strong></p>
<p><input class="widefat" type="text" name="sp_video" id="sp_video" value="<?php echo $video; ?>"></p>
<p><a href="#" class="sp-remove-video"><?php _e( 'Cancel', 'sportspress' ); ?></a></p>
</fieldset>
<fieldset class="sp-video-adder<?php if ( $video ): ?> hidden<?php endif; ?>">
<p><a href="#" class="sp-add-video"><?php _e( 'Add video', 'sportspress' ); ?></a></p>
</fieldset>
<?php
}
function sportspress_event_performance_meta( $post ) {
$teams = (array)get_post_meta( $post->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() ) );
?>
<div>
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
<?php sportspress_edit_event_players_table( $columns, $data, $team_id ); ?>
</div>
<?php
endforeach;
}
function sportspress_event_results_meta( $post ) {
$teams = (array)get_post_meta( $post->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 );
?>
<div>
<?php sportspress_edit_event_results_table( $columns, $data ); ?>
</div>
<?php
}
function sportspress_event_article_meta( $post ) {
wp_editor( $post->post_content, 'content' );
}

View File

@@ -1,176 +0,0 @@
<?php
function sportspress_list_post_init() {
$labels = array(
'name' => __( 'Player Lists', 'sportspress' ),
'singular_name' => __( 'Player List', 'sportspress' ),
'add_new_item' => __( 'Add New Player List', 'sportspress' ),
'edit_item' => __( 'Edit Player List', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Player Lists', 'sportspress' ),
'labels' => $labels,
'public' => true,
'has_archive' => false,
'hierarchical' => false,
'supports' => array( 'title', 'author', 'thumbnail' ),
'register_meta_box_cb' => 'sportspress_list_meta_init',
'rewrite' => array( 'slug' => get_option( 'sportspress_list_slug', 'list' ) ),
'show_in_menu' => 'edit.php?post_type=sp_player',
'show_in_admin_bar' => true,
'capability_type' => 'sp_list',
);
register_post_type( 'sp_list', $args );
}
add_action( 'init', 'sportspress_list_post_init' );
function sportspress_list_edit_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Title', 'sportspress' ),
'sp_player' => __( 'Players', 'sportspress' ),
'sp_league' => __( 'League', 'sportspress' ),
'sp_season' => __( 'Season', 'sportspress' ),
'sp_team' => __( 'Team', 'sportspress' ),
'sp_views' => __( 'Views', 'sportspress' ),
);
return $columns;
}
add_filter( 'manage_edit-sp_list_columns', 'sportspress_list_edit_columns' );
function sportspress_list_meta_init( $post ) {
$players = (array)get_post_meta( $post->ID, 'sp_player', false );
remove_meta_box( 'sp_seasondiv', 'sp_list', 'side' );
remove_meta_box( 'sp_leaguediv', 'sp_list', 'side' );
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'sportspress_list_shortcode_meta', 'sp_list', 'side', 'default' );
add_meta_box( 'sp_formatdiv', __( 'Format', 'sportspress' ), 'sportspress_list_format_meta', 'sp_list', 'side', 'default' );
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'sportspress_list_details_meta', 'sp_list', 'side', 'default' );
add_meta_box( 'sp_statsdiv', __( 'Player List', 'sportspress' ), 'sportspress_list_stats_meta', 'sp_list', 'normal', 'default' );
add_meta_box( 'sp_descriptiondiv', __( 'Description', 'sportspress' ), 'sportspress_list_description_meta', 'sp_list', 'normal', 'high' );
}
function sportspress_list_shortcode_meta( $post ) {
$the_format = get_post_meta( $post->ID, 'sp_format', true );
?>
<p class="howto">
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
</p>
<p><input type="text" value="[player_<?php echo $the_format; ?> <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<?php
}
function sportspress_list_format_meta( $post ) {
global $sportspress_formats;
$the_format = get_post_meta( $post->ID, 'sp_format', true );
?>
<div id="post-formats-select">
<?php foreach ( $sportspress_formats['list'] as $key => $format ): ?>
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( true, ( $key == 'list' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo $key; ?>" class="post-format-icon post-format-<?php echo $key; ?>"><?php echo $format; ?></label><br>
<?php endforeach; ?>
</div>
<?php
}
function sportspress_list_details_meta( $post ) {
$league_id = sportspress_get_the_term_id( $post->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 );
?>
<div>
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'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;
?>
</p>
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
<p class="sp-tab-select">
<?php
$args = array(
'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;
?>
</p>
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
<p class="sp-tab-select">
<?php
$args = array(
'post_type' => '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;
?>
</p>
<p><strong><?php _e( 'Sort by:', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'prepend_options' => 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;
?>
</p>
<p><strong><?php _e( 'Sort Order:', 'sportspress' ); ?></strong></p>
<p>
<select name="sp_order">
<option value="ASC" <?php selected( 'ASC', $order ); ?>><?php _e( 'Ascending', 'sportspress' ); ?></option>
<option value="DESC" <?php selected( 'DESC', $order ); ?>><?php _e( 'Descending', 'sportspress' ); ?></option>
</select>
</p>
<p><strong><?php _e( 'Players', 'sportspress' ); ?></strong></p>
<?php
sportspress_post_checklist( $post->ID, 'sp_player', 'block', 'sp_team' );
sportspress_post_adder( 'sp_player', __( 'Add New', 'sportspress' ) );
?>
</div>
<?php
sportspress_nonce();
}
function sportspress_list_stats_meta( $post ) {
list( $columns, $usecolumns, $data, $placeholders, $merged ) = sportspress_get_player_list_data( $post->ID, true );
sportspress_edit_player_list_table( $columns, $usecolumns, $data, $placeholders );
sportspress_nonce();
}
function sportspress_list_description_meta( $post ) {
wp_editor( $post->post_content, 'content' );
}

View File

@@ -1,38 +0,0 @@
<?php
function sportspress_metric_post_init() {
$labels = array(
'name' => __( 'Metrics', 'sportspress' ),
'singular_name' => __( 'Metric', 'sportspress' ),
'add_new_item' => __( 'Add New Metric', 'sportspress' ),
'edit_item' => __( 'Edit Metric', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Metrics', 'sportspress' ),
'labels' => $labels,
'public' => false,
'show_ui' => true,
'show_in_menu' => false,
'has_archive' => false,
'hierarchical' => false,
'can_export' => false,
'supports' => array( 'title', 'page-attributes' ),
'capability_type' => 'sp_config',
);
register_post_type( 'sp_metric', $args );
}
add_action( 'init', 'sportspress_metric_post_init' );
function sportspress_metric_edit_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_positions' => __( 'Positions', 'sportspress' ),
);
return $columns;
}
add_filter( 'manage_edit-sp_metric_columns', 'sportspress_metric_edit_columns' );

View File

@@ -1,53 +0,0 @@
<?php
function sportspress_outcome_post_init() {
$labels = array(
'name' => __( 'Outcomes', 'sportspress' ),
'singular_name' => __( 'Outcome', 'sportspress' ),
'add_new_item' => __( 'Add New Outcome', 'sportspress' ),
'edit_item' => __( 'Edit Outcome', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Outcomes', 'sportspress' ),
'labels' => $labels,
'public' => false,
'show_ui' => true,
'show_in_menu' => false,
'has_archive' => false,
'hierarchical' => false,
'can_export' => false,
'supports' => array( 'title', 'page-attributes' ),
'register_meta_box_cb' => 'sportspress_outcome_meta_init',
'capability_type' => 'sp_config',
);
register_post_type( 'sp_outcome', $args );
}
add_action( 'init', 'sportspress_outcome_post_init' );
function sportspress_outcome_edit_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_key' => __( 'Key', 'sportspress' ),
);
return $columns;
}
add_filter( 'manage_edit-sp_outcome_columns', 'sportspress_outcome_edit_columns' );
function sportspress_outcome_meta_init() {
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'sportspress_outcome_details_meta', 'sp_outcome', 'normal', 'high' );
}
function sportspress_outcome_details_meta( $post ) {
?>
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
</p>
<?php
sportspress_nonce();
}

View File

@@ -1,55 +0,0 @@
<?php
function sportspress_performance_post_init() {
$labels = array(
'name' => __( 'Performance', 'sportspress' ),
'singular_name' => __( 'Performance', 'sportspress' ),
'add_new_item' => __( 'Add New Performance', 'sportspress' ),
'edit_item' => __( 'Edit Performance', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Performance', 'sportspress' ),
'labels' => $labels,
'public' => false,
'show_ui' => true,
'show_in_menu' => false,
'has_archive' => false,
'hierarchical' => false,
'can_export' => false,
'supports' => array( 'title', 'page-attributes' ),
'register_meta_box_cb' => 'sportspress_performance_meta_init',
'capability_type' => 'sp_config',
);
register_post_type( 'sp_performance', $args );
}
add_action( 'init', 'sportspress_performance_post_init' );
function sportspress_performance_edit_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_positions' => __( 'Positions', 'sportspress' ),
'sp_calculate' => __( 'Calculate', 'sportspress' ),
);
return $columns;
}
add_filter( 'manage_edit-sp_performance_columns', 'sportspress_performance_edit_columns' );
function sportspress_performance_meta_init() {
add_meta_box( 'sp_equationdiv', __( 'Details', 'sportspress' ), 'sportspress_performance_equation_meta', 'sp_performance', 'normal', 'high' );
}
function sportspress_performance_equation_meta( $post ) {
$calculate = get_post_meta( $post->ID, 'sp_calculate', true );
?>
<p><strong><?php _e( 'Calculate', 'sportspress' ); ?></strong></p>
<p class="sp-calculate-selector">
<?php sportspress_calculate_selector( $post->ID, $calculate ); ?>
</p>
<?php
sportspress_nonce();
}

View File

@@ -1,250 +0,0 @@
<?php
function sportspress_player_post_init() {
$labels = array(
'name' => __( 'Players', 'sportspress' ),
'singular_name' => __( 'Player', 'sportspress' ),
'menu_name' => __( 'Roster', 'sportspress' ),
'all_items' => __( 'Players', 'sportspress' ),
'add_new_item' => __( 'Add New Player', 'sportspress' ),
'edit_item' => __( 'Edit Player', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Players', 'sportspress' ),
'labels' => $labels,
'public' => true,
'has_archive' => false,
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'page-attributes' ),
'register_meta_box_cb' => 'sportspress_player_meta_init',
'rewrite' => array( 'slug' => get_option( 'sportspress_players_slug', 'players' ) ),
'menu_icon' => 'dashicons-groups',
'capability_type' => 'sp_player',
);
register_post_type( 'sp_player', $args );
}
add_action( 'init', 'sportspress_player_post_init' );
function sportspress_player_edit_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'sp_number' => '<span class="dashicons sp-icon-tshirt tips" title="' . __( 'Number', 'sportspress' ) . '"></span>',
'title' => __( 'Player', 'sportspress' ),
'sp_position' => __( 'Positions', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' ),
'sp_season' => __( 'Seasons', 'sportspress' ),
'sp_views' => __( 'Views', 'sportspress' ),
);
return $columns;
}
add_filter( 'manage_edit-sp_player_columns', 'sportspress_player_edit_columns' );
function sportspress_player_meta_init( $post ) {
$leagues = get_the_terms( $post->ID, 'sp_league' );
$seasons = (array)get_the_terms( $post->ID, 'sp_season' );
remove_meta_box( 'sp_seasondiv', 'sp_player', 'side' );
remove_meta_box( 'sp_leaguediv', 'sp_player', 'side' );
remove_meta_box( 'sp_positiondiv', 'sp_player', 'side' );
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'sportspress_player_details_meta', 'sp_player', 'side', 'default' );
add_meta_box( 'sp_metricsdiv', __( 'Metrics', 'sportspress' ), 'sportspress_player_metrics_meta', 'sp_player', 'side', 'default' );
if ( $leagues && ! empty( $leagues ) && $seasons && ! empty( $seasons ) ):
add_meta_box( 'sp_performancediv', __( 'Performance', 'sportspress' ), 'sportspress_player_performance_meta', 'sp_player', 'normal', 'high' );
endif;
}
function sportspress_player_details_meta( $post ) {
$continents = SP()->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 );
?>
<p><strong><?php _e( 'Number', 'sportspress' ); ?></strong></p>
<p><input type="text" size="4" id="sp_number" name="sp_number" value="<?php echo $number; ?>"></p>
<p><strong><?php _e( 'Nationality', 'sportspress' ); ?></strong></p>
<p><select id="sp_nationality" name="sp_nationality" data-placeholder="<?php printf( __( 'Select %s', 'sportspress' ), __( 'Nationality', 'sportspress' ) ); ?>" class="widefat chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?>">
<option value=""></option>
<?php foreach ( $continents as $continent => $countries ): ?>
<optgroup label="<?php echo $continent; ?>">
<?php foreach ( $countries as $code => $country ): ?>
<option value="<?php echo $code; ?>" <?php selected ( $nationality, $code ); ?>><?php echo $country; ?></option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select></p>
<p><strong><?php _e( 'Positions', 'sportspress' ); ?></strong></p>
<p><?php
$args = array(
'taxonomy' => '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 );
?></p>
<p><strong><?php _e( 'Current Team', 'sportspress' ); ?></strong></p>
<p><?php
$args = array(
'post_type' => '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 );
?></p>
<p><strong><?php _e( 'Past Teams', 'sportspress' ); ?></strong></p>
<p><?php
$args = array(
'post_type' => '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 );
?></p>
<p><strong><?php _e( 'Leagues', 'sportspress' ); ?></strong></p>
<p><?php
$args = array(
'taxonomy' => '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 );
?></p>
<p><strong><?php _e( 'Seasons', 'sportspress' ); ?></strong></p>
<p><?php
$args = array(
'taxonomy' => '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 );
?></p>
<?php
}
function sportspress_player_metrics_meta( $post ) {
$metrics = get_post_meta( $post->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 ):
?>
<p><strong><?php echo $var->post_title; ?></strong></p>
<p><input type="text" name="sp_metrics[<?php echo $var->post_name; ?>]" value="<?php echo sportspress_array_value( $metrics, $var->post_name, '' ); ?>" /></p>
<?php
endforeach;
else:
sportspress_post_adder( 'sp_metric', __( 'Add New', 'sportspress' ) );
endif;
sportspress_nonce();
}
function sportspress_player_performance_meta( $post ) {
$leagues = get_the_terms( $post->ID, 'sp_league' );
$league_num = sizeof( $leagues );
// Loop through performance for each league
foreach ( $leagues as $league ):
if ( $league_num > 1 ):
?>
<p><strong><?php echo $league->name; ?></strong></p>
<?php
endif;
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = sportspress_get_player_performance_data( $post->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;
}

View File

@@ -1,54 +0,0 @@
<?php
function sportspress_result_post_init() {
$labels = array(
'name' => __( 'Results', 'sportspress' ),
'singular_name' => __( 'Result', 'sportspress' ),
'add_new_item' => __( 'Add New Result', 'sportspress' ),
'edit_item' => __( 'Edit Result', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Results', 'sportspress' ),
'labels' => $labels,
'public' => false,
'show_ui' => true,
'show_in_menu' => false,
'has_archive' => false,
'hierarchical' => false,
'can_export' => false,
'supports' => array( 'title', 'page-attributes' ),
'register_meta_box_cb' => 'sportspress_result_meta_init',
'capability_type' => 'sp_config',
);
register_post_type( 'sp_result', $args );
}
add_action( 'init', 'sportspress_result_post_init' );
function sportspress_result_edit_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_key' => __( 'Key', 'sportspress' ),
);
return $columns;
}
add_filter( 'manage_edit-sp_result_columns', 'sportspress_result_edit_columns' );
function sportspress_result_meta_init() {
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'sportspress_result_details_meta', 'sp_result', 'normal', 'high' );
}
function sportspress_result_details_meta( $post ) {
$formats = sportspress_get_config_formats();
?>
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
</p>
<?php
sportspress_nonce();
}

View File

@@ -1,13 +0,0 @@
<?php
function sportspress_separator_post_init() {
$args = array(
'label' => '',
'public' => false,
'show_ui' => true,
'show_in_nav_menus' => false,
'show_in_admin_bar' => false,
'can_export' => false,
);
register_post_type( 'sp_separator', $args );
}
add_action( 'init', 'sportspress_separator_post_init' );

View File

@@ -1,56 +0,0 @@
<?php
function sportspress_staff_post_init() {
$labels = array(
'name' => __( 'Staff', 'sportspress' ),
'singular_name' => __( 'Staff', 'sportspress' ),
'add_new_item' => __( 'Add New Staff', 'sportspress' ),
'edit_item' => __( 'Edit Staff', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Staff', 'sportspress' ),
'labels' => $labels,
'public' => true,
'has_archive' => false,
'hierarchical' => false,
'supports' => array( 'title', 'author', 'thumbnail' ),
'register_meta_box_cb' => 'sportspress_staff_meta_init',
'rewrite' => array( 'slug' => get_option( 'sportspress_staff_slug', 'staff' ) ),
'show_in_menu' => 'edit.php?post_type=sp_player',
'capability_type' => 'sp_staff',
);
register_post_type( 'sp_staff', $args );
}
add_action( 'init', 'sportspress_staff_post_init' );
function sportspress_staff_meta_init() {
add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sportspress_staff_team_meta', 'sp_staff', 'side', 'default' );
add_meta_box( 'sp_profilediv', __( 'Profile', 'sportspress' ), 'sportspress_staff_profile_meta', 'sp_staff', 'normal', 'high' );
}
function sportspress_staff_team_meta( $post ) {
sportspress_post_checklist( $post->ID, 'sp_team' );
sportspress_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
sportspress_nonce();
}
function sportspress_staff_profile_meta( $post ) {
wp_editor( $post->post_content, 'content' );
}
function sportspress_staff_edit_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Name', 'sportspress' ),
'sp_position' => __( 'Positions', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' ),
'sp_season' => __( 'Seasons', 'sportspress' ),
'sp_views' => __( 'Views', 'sportspress' ),
);
return $columns;
}
add_filter( 'manage_edit-sp_staff_columns', 'sportspress_staff_edit_columns' );

View File

@@ -1,118 +0,0 @@
<?php
function sportspress_table_post_init() {
$labels = array(
'name' => __( 'League Tables', 'sportspress' ),
'singular_name' => __( 'League Table', 'sportspress' ),
'add_new_item' => __( 'Add New League Table', 'sportspress' ),
'edit_item' => __( 'Edit League Table', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'League Tables', 'sportspress' ),
'labels' => $labels,
'public' => true,
'has_archive' => false,
'hierarchical' => false,
'supports' => array( 'title', 'author', 'thumbnail' ),
'register_meta_box_cb' => 'sportspress_table_meta_init',
'rewrite' => array( 'slug' => get_option( 'sportspress_table_slug', 'table' ) ),
'show_in_menu' => 'edit.php?post_type=sp_team',
'show_in_admin_bar' => true,
'capability_type' => 'sp_table',
);
register_post_type( 'sp_table', $args );
}
add_action( 'init', 'sportspress_table_post_init' );
function sportspress_table_edit_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Title', 'sportspress' ),
'sp_league' => __( 'League', 'sportspress' ),
'sp_season' => __( 'Season', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ),
'sp_views' => __( 'Views', 'sportspress' ),
);
return $columns;
}
add_filter( 'manage_edit-sp_table_columns', 'sportspress_table_edit_columns' );
function sportspress_table_meta_init( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false );
remove_meta_box( 'sp_seasondiv', 'sp_table', 'side' );
remove_meta_box( 'sp_leaguediv', 'sp_table', 'side' );
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'sportspress_table_shortcode_meta', 'sp_table', 'side', 'default' );
add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sportspress_table_team_meta', 'sp_table', 'side', 'default' );
add_meta_box( 'sp_columnsdiv', __( 'League Table', 'sportspress' ), 'sportspress_table_columns_meta', 'sp_table', 'normal', 'high' );
add_meta_box( 'sp_descriptiondiv', __( 'Description', 'sportspress' ), 'sportspress_table_description_meta', 'sp_table', 'normal', 'high' );
}
function sportspress_table_shortcode_meta( $post ) {
?>
<p class="howto">
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
</p>
<p><input type="text" value="[league_table <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<?php
}
function sportspress_table_team_meta( $post, $test ) {
$league_id = sportspress_get_the_term_id( $post->ID, 'sp_league', 0 );
$season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
?>
<div>
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'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;
?>
</p>
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
<p class="sp-tab-select">
<?php
$args = array(
'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;
?>
</p>
<p><strong><?php _e( 'Teams', 'sportspress' ); ?></strong></p>
<?php
sportspress_post_checklist( $post->ID, 'sp_team', 'block', 'sp_season' );
sportspress_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
?>
</div>
<?php
sportspress_nonce();
}
function sportspress_table_columns_meta( $post ) {
list( $columns, $usecolumns, $data, $placeholders, $merged ) = sportspress_get_league_table_data( $post->ID, true );
sportspress_edit_league_table( $columns, $usecolumns, $data, $placeholders );
sportspress_nonce();
}
function sportspress_table_description_meta( $post ) {
wp_editor( $post->post_content, 'content' );
}

View File

@@ -1,76 +0,0 @@
<?php
function sportspress_team_post_init() {
$labels = array(
'name' => __( 'Teams', 'sportspress' ),
'singular_name' => __( 'Team', 'sportspress' ),
'add_new_item' => __( 'Add New Team', 'sportspress' ),
'edit_item' => __( 'Edit Team', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
'parent_item_colon' => __( 'Parent:', 'sportspress' ),
);
$args = array(
'label' => __( 'Teams', 'sportspress' ),
'labels' => $labels,
'public' => true,
'has_archive' => false,
'hierarchical' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ),
'register_meta_box_cb' => 'sportspress_team_meta_init',
'rewrite' => array( 'slug' => get_option( 'sportspress_teams_slug', 'teams' ) ),
'menu_icon' => 'dashicons-shield-alt',
'capability_type' => 'sp_team',
);
register_post_type( 'sp_team', $args );
}
add_action( 'init', 'sportspress_team_post_init' );
function sportspress_team_meta_init( $post ) {
$leagues = get_the_terms( $post->ID, 'sp_league' );
$seasons = get_the_terms( $post->ID, 'sp_season' );
if ( $leagues && $seasons ):
add_meta_box( 'sp_columnssdiv', __( 'Columns', 'sportspress' ), 'sportspress_team_columns_meta', 'sp_team', 'normal', 'high' );
endif;
}
function sportspress_team_edit_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'sp_icon' => '<span class="dashicons sp-icon-shield tips" title="' . __( 'Logo', 'sportspress' ) . '"></span>',
'title' => __( 'Team', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' ),
'sp_season' => __( 'Seasons', 'sportspress' ),
'sp_views' => __( 'Views', 'sportspress' ),
);
return $columns;
}
add_filter( 'manage_edit-sp_team_columns', 'sportspress_team_edit_columns' );
function sportspress_team_columns_meta( $post ) {
$leagues = (array)get_the_terms( $post->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 ):
?>
<p><strong><?php echo $league->name; ?></strong></p>
<?php
endif;
list( $columns, $data, $placeholders, $merged, $leagues_seasons ) = sportspress_get_team_columns_data( $post->ID, $league_id, true );
sportspress_edit_team_columns_table( $league_id, $columns, $data, $placeholders, $merged, $leagues_seasons, ! current_user_can( 'edit_sp_tables' ) );
endforeach;
sportspress_nonce();
}

View File

@@ -207,23 +207,6 @@ final class SportsPress {
include_once( 'includes/admin/settings/options-text.php' );
include_once( 'includes/admin/settings/options-permalink.php' );
// Custom post types (deprecating)
//include_once( 'admin/post-types/separator.php' );
//include_once( 'admin/post-types/column.php' );
//include_once( 'admin/post-types/performance.php' );
//include_once( 'admin/post-types/statistic.php' );
//include_once( 'admin/post-types/metric.php' );
//include_once( 'admin/post-types/result.php' );
//include_once( 'admin/post-types/outcome.php' );
//include_once( 'admin/post-types/event.php' );
//include_once( 'admin/post-types/calendar.php' );
//include_once( 'admin/post-types/team.php' );
//include_once( 'admin/post-types/table.php' );
//include_once( 'admin/post-types/player.php' );
//include_once( 'admin/post-types/list.php' );
//include_once( 'admin/post-types/staff.php' );
//include_once( 'admin/post-types/directory.php' );
if ( is_admin() ) {
include_once( 'includes/admin/class-sp-admin.php' );
}