Finalize term names and add divider

This commit is contained in:
ThemeBoy
2013-11-25 11:32:39 +11:00
parent 102d6d20e1
commit 3d492f4d80
15 changed files with 84 additions and 358 deletions

View File

@@ -10,14 +10,22 @@ function sp_after_theme_setup() {
} }
add_action( 'after_theme_setup', 'sp_after_theme_setup' ); add_action( 'after_theme_setup', 'sp_after_theme_setup' );
function sp_admin_menu_separator() {
if ( ! current_user_can( 'manage_options' ) )
return;
global $menu;
$menu[41] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
}
add_action( 'admin_menu', 'sp_admin_menu_separator' );
function sp_manage_posts_custom_column( $column, $post_id ) { function sp_manage_posts_custom_column( $column, $post_id ) {
global $post; global $post;
switch ( $column ): switch ( $column ):
case 'sp_icon': case 'sp_logo':
edit_post_link( get_the_post_thumbnail( $post_id, 'sp_icon' ), '', '', $post_id ); edit_post_link( get_the_post_thumbnail( $post_id, 'sp_icon' ), '', '', $post_id );
break; break;
case 'sp_position': case 'sp_pos':
echo get_the_terms ( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—'; echo get_the_terms ( $post_id, 'sp_pos' ) ? the_terms( $post_id, 'sp_pos' ) : '—';
break; break;
case 'sp_team': case 'sp_team':
$result = get_post_meta( $post_id, 'sp_result', false ); $result = get_post_meta( $post_id, 'sp_result', false );
@@ -29,8 +37,8 @@ function sp_manage_posts_custom_column( $column, $post_id ) {
case 'sp_event': case 'sp_event':
echo get_post_meta ( $post_id, 'sp_event' ) ? sizeof( get_post_meta ( $post_id, 'sp_event' ) ) : '—'; echo get_post_meta ( $post_id, 'sp_event' ) ? sizeof( get_post_meta ( $post_id, 'sp_event' ) ) : '—';
break; break;
case 'sp_division': case 'sp_div':
echo get_the_terms ( $post_id, 'sp_division' ) ? the_terms( $post_id, 'sp_division' ) : '—'; echo get_the_terms ( $post_id, 'sp_div' ) ? the_terms( $post_id, 'sp_div' ) : '—';
break; break;
case 'sp_sponsor': case 'sp_sponsor':
echo get_the_terms ( $post_id, 'sp_sponsor' ) ? the_terms( $post_id, 'sp_sponsor' ) : '—'; echo get_the_terms ( $post_id, 'sp_sponsor' ) ? the_terms( $post_id, 'sp_sponsor' ) : '—';
@@ -59,21 +67,21 @@ function sp_restrict_manage_posts() {
wp_dropdown_pages( $args ); wp_dropdown_pages( $args );
endif; endif;
if ( in_array( $typenow, array( 'sp_player', 'sp_staff' ) ) ): if ( in_array( $typenow, array( 'sp_player', 'sp_staff' ) ) ):
$selected = isset( $_REQUEST['sp_position'] ) ? $_REQUEST['sp_position'] : null; $selected = isset( $_REQUEST['sp_pos'] ) ? $_REQUEST['sp_pos'] : null;
$args = array( $args = array(
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Positions', 'sportspress' ) ), 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Positions', 'sportspress' ) ),
'taxonomy' => 'sp_position', 'taxonomy' => 'sp_pos',
'name' => 'sp_position', 'name' => 'sp_pos',
'selected' => $selected 'selected' => $selected
); );
sp_dropdown_taxonomies( $args ); sp_dropdown_taxonomies( $args );
endif; endif;
if ( in_array( $typenow, array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_list' ) ) ): if ( in_array( $typenow, array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_list' ) ) ):
$selected = isset( $_REQUEST['sp_division'] ) ? $_REQUEST['sp_division'] : null; $selected = isset( $_REQUEST['sp_div'] ) ? $_REQUEST['sp_div'] : null;
$args = array( $args = array(
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Divisions', 'sportspress' ) ), 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Divisions', 'sportspress' ) ),
'taxonomy' => 'sp_division', 'taxonomy' => 'sp_div',
'name' => 'sp_division', 'name' => 'sp_div',
'selected' => $selected 'selected' => $selected
); );
sp_dropdown_taxonomies( $args ); sp_dropdown_taxonomies( $args );
@@ -131,13 +139,13 @@ function sp_save_post( $post_id ) {
break; break;
case ( 'sp_table' ): case ( 'sp_table' ):
update_post_meta( $post_id, 'sp_stats', sp_array_value( $_POST, 'sp_stats', array() ) ); update_post_meta( $post_id, 'sp_stats', sp_array_value( $_POST, 'sp_stats', array() ) );
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_division', 0 ), 'sp_division' ); wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_div', 0 ), 'sp_div' );
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
break; break;
case ( 'sp_list' ): case ( 'sp_list' ):
update_post_meta( $post_id, 'sp_stats', sp_array_value( $_POST, 'sp_stats', array() ) ); update_post_meta( $post_id, 'sp_stats', sp_array_value( $_POST, 'sp_stats', array() ) );
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_division', 0 ), 'sp_division' ); wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_div', 0 ), 'sp_div' );
sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) ); sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) );
break; break;
endswitch; endswitch;

View File

@@ -1,5 +1,5 @@
<?php <?php
function sp_division_tax_init() { function sp_div_tax_init() {
$name = __( 'Divisions', 'sportspress' ); $name = __( 'Divisions', 'sportspress' );
$singular_name = __( 'Division', 'sportspress' ); $singular_name = __( 'Division', 'sportspress' );
$lowercase_name = __( 'divisions', 'sportspress' ); $lowercase_name = __( 'divisions', 'sportspress' );
@@ -12,7 +12,7 @@ function sp_division_tax_init() {
'hierarchical' => true, 'hierarchical' => true,
'rewrite' => array( 'slug' => 'division' ), 'rewrite' => array( 'slug' => 'division' ),
); );
register_taxonomy( 'sp_division', $object_type, $args ); register_taxonomy( 'sp_div', $object_type, $args );
} }
add_action( 'init', 'sp_division_tax_init' ); add_action( 'init', 'sp_div_tax_init' );
?> ?>

View File

@@ -11,7 +11,8 @@ function sp_event_cpt_init() {
'hierarchical' => false, 'hierarchical' => false,
'supports' => array( 'title', 'author', 'comments' ), 'supports' => array( 'title', 'author', 'comments' ),
'register_meta_box_cb' => 'sp_event_meta_init', 'register_meta_box_cb' => 'sp_event_meta_init',
'rewrite' => array( 'slug' => 'event' ) 'rewrite' => array( 'slug' => 'event' ),
'menu_position' => 44
); );
register_post_type( 'sp_event', $args ); register_post_type( 'sp_event', $args );
} }
@@ -131,7 +132,7 @@ function sp_event_edit_columns() {
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'title' => __( 'Event', 'sportspress' ), 'title' => __( 'Event', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ),
'sp_division' => __( 'Divisions', 'sportspress' ), 'sp_div' => __( 'Divisions', 'sportspress' ),
'sp_kickoff' => __( 'Kick-off', 'sportspress' ) 'sp_kickoff' => __( 'Kick-off', 'sportspress' )
); );
return $columns; return $columns;

View File

@@ -2,8 +2,8 @@
$sportspress_texts = array( $sportspress_texts = array(
'sp_team' => array( 'sp_team' => array(
'Enter title here' => __( 'Team', 'sportspress' ), 'Enter title here' => __( 'Team', 'sportspress' ),
'Set featured image' => sprintf( __( 'Add %s', 'sportspress' ), __( 'Logo', 'sportspress' ) ), 'Set featured image' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Logo', 'sportspress' ) ),
'Set Featured Image' => sprintf( __( 'Add %s', 'sportspress' ), __( 'Logo', 'sportspress' ) ), 'Set Featured Image' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Logo', 'sportspress' ) ),
'Parent' => sprintf( __( 'Parent %s', 'sportspress' ), __( 'Team', 'sportspress' ) ), 'Parent' => sprintf( __( 'Parent %s', 'sportspress' ), __( 'Team', 'sportspress' ) ),
'Remove featured image' => sprintf( __( 'Remove %s', 'sportspress' ), __( 'Logo', 'sportspress' ) ) 'Remove featured image' => sprintf( __( 'Remove %s', 'sportspress' ), __( 'Logo', 'sportspress' ) )
), ),
@@ -15,8 +15,8 @@ $sportspress_texts = array(
), ),
'sp_player' => array( 'sp_player' => array(
'Enter title here' => __( 'Name', 'sportspress' ), 'Enter title here' => __( 'Name', 'sportspress' ),
'Set featured image' => sprintf( __( 'Add %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ), 'Set featured image' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ),
'Set Featured Image' => sprintf( __( 'Add %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ), 'Set Featured Image' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ),
'Remove featured image' => sprintf( __( 'Remove %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ), 'Remove featured image' => sprintf( __( 'Remove %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ),
'Scheduled for: <b>%1$s</b>' => __( 'Joined', 'sportspress' ) . ': <b>%1$s</b>', 'Scheduled for: <b>%1$s</b>' => __( 'Joined', 'sportspress' ) . ': <b>%1$s</b>',
'Published on: <b>%1$s</b>' => __( 'Joined', 'sportspress' ) . ': <b>%1$s</b>', 'Published on: <b>%1$s</b>' => __( 'Joined', 'sportspress' ) . ': <b>%1$s</b>',
@@ -24,8 +24,8 @@ $sportspress_texts = array(
), ),
'sp_staff' => array( 'sp_staff' => array(
'Enter title here' => __( 'Name', 'sportspress' ), 'Enter title here' => __( 'Name', 'sportspress' ),
'Set featured image' => sprintf( __( 'Add %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ), 'Set featured image' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ),
'Set Featured Image' => sprintf( __( 'Add %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ), 'Set Featured Image' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ),
'Remove featured image' => sprintf( __( 'Remove %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ), 'Remove featured image' => sprintf( __( 'Remove %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ),
'Scheduled for: <b>%1$s</b>' => __( 'Joined', 'sportspress' ) . ': <b>%1$s</b>', 'Scheduled for: <b>%1$s</b>' => __( 'Joined', 'sportspress' ) . ': <b>%1$s</b>',
'Published on: <b>%1$s</b>' => __( 'Joined', 'sportspress' ) . ': <b>%1$s</b>', 'Published on: <b>%1$s</b>' => __( 'Joined', 'sportspress' ) . ': <b>%1$s</b>',
@@ -38,15 +38,15 @@ $sportspress_texts = array(
$sportspress_thumbnail_texts = array( $sportspress_thumbnail_texts = array(
'sp_team' => array( 'sp_team' => array(
'Set featured image' => sprintf( __( 'Add %s', 'sportspress' ), __( 'Logo', 'sportspress' ) ), 'Set featured image' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Logo', 'sportspress' ) ),
'Remove featured image' => sprintf( __( 'Remove %s', 'sportspress' ), __( 'Logo', 'sportspress' ) ) 'Remove featured image' => sprintf( __( 'Remove %s', 'sportspress' ), __( 'Logo', 'sportspress' ) )
), ),
'sp_player' => array( 'sp_player' => array(
'Set featured image' => sprintf( __( 'Add %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ), 'Set featured image' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ),
'Remove featured image' => sprintf( __( 'Remove %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ) 'Remove featured image' => sprintf( __( 'Remove %s', 'sportspress' ), __( 'Photo', 'sportspress' ) )
), ),
'sp_staff' => array( 'sp_staff' => array(
'Set featured image' => sprintf( __( 'Add %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ), 'Set featured image' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ),
'Remove featured image' => sprintf( __( 'Remove %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ) 'Remove featured image' => sprintf( __( 'Remove %s', 'sportspress' ), __( 'Photo', 'sportspress' ) )
) )
); );

View File

@@ -210,7 +210,7 @@ if ( !function_exists( 'sp_post_checklist' ) ) {
$parents = get_post_ancestors( $post ); $parents = get_post_ancestors( $post );
if ( $filter ): if ( $filter ):
$filter_values = (array)get_post_meta( $post->ID, $filter, false ); $filter_values = (array)get_post_meta( $post->ID, $filter, false );
$terms = (array)get_the_terms( $post->ID, 'sp_division' ); $terms = (array)get_the_terms( $post->ID, 'sp_div' );
foreach ( $terms as $term ): foreach ( $terms as $term ):
if ( is_object( $term ) && property_exists( $term, 'term_id' ) ) if ( is_object( $term ) && property_exists( $term, 'term_id' ) )
$filter_values[] = $term->term_id; $filter_values[] = $term->term_id;
@@ -249,7 +249,7 @@ if ( !function_exists( 'sp_post_checklist' ) ) {
if ( !function_exists( 'sp_get_eos_rows' ) ) { if ( !function_exists( 'sp_get_eos_rows' ) ) {
function sp_get_eos_rows( $raw ) { function sp_get_eos_rows( $raw ) {
$raw = str_replace( array( "\r\n", ' ' ), array( "\n", '' ), $raw ); $raw = str_replace( array( "\r\n", ' ' ), array( "\n", '' ), $raw );
$output = explode( "\n", $raw ); $output = explode( "\r\n", $raw );
return $output; return $output;
} }
} }
@@ -257,7 +257,7 @@ if ( !function_exists( 'sp_get_eos_rows' ) ) {
if ( !function_exists( 'sp_get_eos_keys' ) ) { if ( !function_exists( 'sp_get_eos_keys' ) ) {
function sp_get_eos_keys( $raw ) { function sp_get_eos_keys( $raw ) {
$raw = str_replace( array( "\r\n", ' :' ), array( "\n", ':' ), $raw ); $raw = str_replace( array( "\r\n", ' :' ), array( "\n", ':' ), $raw );
$arr = explode( "\n", $raw ); $arr = explode( "\r\n", $raw );
$output = array(); $output = array();
foreach ( $arr as $value ): foreach ( $arr as $value ):
$output[] = substr( $value, 0, strpos( $value, ':') ); $output[] = substr( $value, 0, strpos( $value, ':') );

View File

@@ -24,7 +24,7 @@ function sp_list_edit_columns() {
'title' => __( 'Title' ), 'title' => __( 'Title' ),
'sp_player' => __( 'Players', 'sportspress' ), 'sp_player' => __( 'Players', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ),
'sp_division' => __( 'Divisions', 'sportspress' ) 'sp_div' => __( 'Divisions', 'sportspress' )
); );
return $columns; return $columns;
} }
@@ -36,7 +36,7 @@ function sp_list_meta_init() {
} }
function sp_list_player_meta( $post ) { function sp_list_player_meta( $post ) {
$division_id = sp_get_the_term_id( $post->ID, 'sp_division', 0 ); $division_id = sp_get_the_term_id( $post->ID, 'sp_div', 0 );
$team_id = get_post_meta( $post->ID, 'sp_team', true ); $team_id = get_post_meta( $post->ID, 'sp_team', true );
?> ?>
<div> <div>
@@ -44,8 +44,8 @@ function sp_list_player_meta( $post ) {
<?php <?php
$args = array( $args = array(
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Divisions', 'sportspress' ) ), 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Divisions', 'sportspress' ) ),
'taxonomy' => 'sp_division', 'taxonomy' => 'sp_div',
'name' => 'sp_division', 'name' => 'sp_div',
'selected' => $division_id 'selected' => $division_id
); );
sp_dropdown_taxonomies( $args ); sp_dropdown_taxonomies( $args );
@@ -75,7 +75,7 @@ function sp_list_player_meta( $post ) {
function sp_list_stats_meta( $post ) { function sp_list_stats_meta( $post ) {
$players = (array)get_post_meta( $post->ID, 'sp_player', false ); $players = (array)get_post_meta( $post->ID, 'sp_player', false );
$stats = (array)get_post_meta( $post->ID, 'sp_stats', true ); $stats = (array)get_post_meta( $post->ID, 'sp_stats', true );
$division_id = sp_get_the_term_id( $post->ID, 'sp_division', 0 ); $division_id = sp_get_the_term_id( $post->ID, 'sp_div', 0 );
$team_id = get_post_meta( $post->ID, 'sp_team', true ); $team_id = get_post_meta( $post->ID, 'sp_team', true );
$data = sp_array_combine( $players, sp_array_value( $stats, $division_id, array() ) ); $data = sp_array_combine( $players, sp_array_value( $stats, $division_id, array() ) );
@@ -92,7 +92,7 @@ function sp_list_stats_meta( $post ) {
), ),
'tax_query' => array( 'tax_query' => array(
array( array(
'taxonomy' => 'sp_division', 'taxonomy' => 'sp_div',
'field' => 'id', 'field' => 'id',
'terms' => $division_id 'terms' => $division_id
) )

View File

@@ -11,7 +11,8 @@ function sp_player_cpt_init() {
'hierarchical' => false, 'hierarchical' => false,
'supports' => array( 'title', 'author', 'thumbnail' ), 'supports' => array( 'title', 'author', 'thumbnail' ),
'register_meta_box_cb' => 'sp_player_meta_init', 'register_meta_box_cb' => 'sp_player_meta_init',
'rewrite' => array( 'slug' => 'player' ) 'rewrite' => array( 'slug' => 'player' ),
'menu_position' => 45
); );
register_post_type( 'sp_player', $args ); register_post_type( 'sp_player', $args );
} }
@@ -35,7 +36,7 @@ function sp_player_team_meta( $post ) {
function sp_player_stats_meta( $post ) { function sp_player_stats_meta( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false ); $teams = (array)get_post_meta( $post->ID, 'sp_team', false );
$divisions = (array)get_the_terms( $post->ID, 'sp_division' ); $divisions = (array)get_the_terms( $post->ID, 'sp_div' );
$stats = (array)get_post_meta( $post->ID, 'sp_stats', true ); $stats = (array)get_post_meta( $post->ID, 'sp_stats', true );
// Get column names from settings // Get column names from settings
@@ -70,7 +71,7 @@ function sp_player_stats_meta( $post ) {
if ( $division_id ): if ( $division_id ):
$args['tax_query'] = array( $args['tax_query'] = array(
array( array(
'taxonomy' => 'sp_division', 'taxonomy' => 'sp_div',
'field' => 'id', 'field' => 'id',
'terms' => $division_id 'terms' => $division_id
) )
@@ -82,7 +83,7 @@ function sp_player_stats_meta( $post ) {
<p><strong><?php _e( 'Overall', 'sportspress' ); ?></strong></p> <p><strong><?php _e( 'Overall', 'sportspress' ); ?></strong></p>
<?php <?php
sp_stats_table( $data, $placeholders, 0, $columns, true, 'sp_division' ); sp_stats_table( $data, $placeholders, 0, $columns, true, 'sp_div' );
// Divisions // Divisions
foreach ( $teams as $team ): foreach ( $teams as $team ):
@@ -108,7 +109,7 @@ function sp_player_stats_meta( $post ) {
), ),
'tax_query' => array( 'tax_query' => array(
array( array(
'taxonomy' => 'sp_division', 'taxonomy' => 'sp_div',
'field' => 'id', 'field' => 'id',
'terms' => $division_id 'terms' => $division_id
) )
@@ -120,7 +121,7 @@ function sp_player_stats_meta( $post ) {
<p><strong><?php echo get_the_title( $team ); ?></strong></p> <p><strong><?php echo get_the_title( $team ); ?></strong></p>
<?php <?php
sp_stats_table( $data, $placeholders, $team, $columns, true, 'sp_division' ); sp_stats_table( $data, $placeholders, $team, $columns, true, 'sp_div' );
?> ?>
<?php <?php
@@ -136,9 +137,9 @@ function sp_player_edit_columns() {
$columns = array( $columns = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'title' => __( 'Name', 'sportspress' ), 'title' => __( 'Name', 'sportspress' ),
'sp_position' => __( 'Positions', 'sportspress' ), 'sp_pos' => __( 'Positions', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ),
'sp_division' => __( 'Divisions', 'sportspress' ) 'sp_div' => __( 'Divisions', 'sportspress' )
); );
return $columns; return $columns;
} }

View File

@@ -1,5 +1,5 @@
<?php <?php
function sp_position_tax_init() { function sp_pos_tax_init() {
$name = __( 'Positions', 'sportspress' ); $name = __( 'Positions', 'sportspress' );
$singular_name = __( 'Position', 'sportspress' ); $singular_name = __( 'Position', 'sportspress' );
$lowercase_name = __( 'position', 'sportspress' ); $lowercase_name = __( 'position', 'sportspress' );
@@ -12,7 +12,7 @@ function sp_position_tax_init() {
'hierarchical' => true, 'hierarchical' => true,
'rewrite' => array( 'slug' => 'position' ), 'rewrite' => array( 'slug' => 'position' ),
); );
register_taxonomy( 'sp_position', $object_type, $args ); register_taxonomy( 'sp_pos', $object_type, $args );
} }
add_action( 'init', 'sp_position_tax_init' ); add_action( 'init', 'sp_pos_tax_init' );
?> ?>

View File

@@ -1,286 +0,0 @@
<?php
$sportspress_presets = array(
'Baseball' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'1' . ': $first' . "\r\n" .
'2' . ': $second' . "\r\n" .
'3' . ': $third' . "\r\n" .
'4' . ': $fourth' . "\r\n" .
'5' . ': $fifth' . "\r\n" .
'6' . ': $sixth' . "\r\n" .
'7' . ': $seventh' . "\r\n" .
'8' . ': $eigth' . "\r\n" .
'9' . ': $ninth' . "\r\n" .
'&nbsp;' . ': $extra' . "\r\n" .
'R' . ': $runs' . "\r\n" .
'H' . ': $hits' . "\r\n" .
'E' . ': $errors:' . "\r\n" .
'LOB' . ': $lob',
'player' =>
array(
'G' . ': $played' . "\r\n" .
'AB' . ': $ab' . "\r\n" .
'R' . ': $runs' . "\r\n" .
'H' . ': $hits' . "\r\n" .
'2B' . ': $double' . "\r\n" .
'3B' . ': $triple' . "\r\n" .
'HR' . ': $hr' . "\r\n" .
'RBI' . ': $rbi' . "\r\n" .
'BB' . ': $bb' . "\r\n" .
'SO' . ': $so' . "\r\n" .
'SB' . ': $sb' . "\r\n" .
'CS' . ': $cs' . "\r\n" .
'AVG' . ': $hits / $ab' . "\r\n" .
'OBP' . ': ( $hits + $bb + $hbp ) / ( $ab + $bb + $hbp + $sf )' . "\r\n" .
'SLG' . ': $tb / $ab' . "\r\n" .
'OPS' . ': ( $hits + $bb + $hbp ) / ( $ab + $bb + $hbp + $sf ) + ( $tb / $ab )'
),
array(
'W' . ': $wins' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'ERA' . ': ( $er * 9 ) / $ip' . "\r\n" .
'G' . ': $played' . "\r\n" .
'GS' . ': $gs' . "\r\n" .
'SV' . ': $sv' . "\r\n" .
'SVO' . ': $svo' . "\r\n" .
'IP' . ': $ip' . "\r\n" .
'H' . ': $hits' . "\r\n" .
'R' . ': $runs' . "\r\n" .
'ER' . ': $er' . "\r\n" .
'HR' . ': $hr' . "\r\n" .
'BB' . ': $bb' . "\r\n" .
'SO' . ': $so' . "\r\n" .
'AVG' . ': $hits / $ab' . "\r\n" .
'WHIP' . ': ( $hits + $walks ) / $ip'
),
array(
'W' . ': $wins' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'ERA' . ': ( $er * 9 ) / $ip' . "\r\n" .
'G' . ': $played' . "\r\n" .
'AB' . ': $ab' . "\r\n" .
'R' . ': $runs' . "\r\n" .
'H' . ': $hits' . "\r\n" .
'2B' . ': $double' . "\r\n" .
'3B' . ': $triple' . "\r\n" .
'HR' . ': $hr' . "\r\n" .
'RBI' . ': $rbi' . "\r\n" .
'BB' . ': $bb' . "\r\n" .
'SO' . ': $so' . "\r\n" .
'SB' . ': $sb' . "\r\n" .
'CS' . ': $cs' . "\r\n" .
'AVG' . ': $hits / $ab' . "\r\n" .
'OBP' . ': ( $hits + $bb + $hbp ) / ( $ab + $bb + $hbp + $sf )' . "\r\n" .
'SLG' . ': $tb / $ab' . "\r\n" .
'OPS' . ': ( $hits + $bb + $hbp ) / ( $ab + $bb + $hbp + $sf ) + ( $tb / $ab )'
)
),
'Basketball' => array(
'team' =>
'W' . ': $wins' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'Pct' . ': $wins / $played' . "\r\n" .
'GB' . ': ( $leadwins - $leadlosses + $wins - $losses ) / 2' . "\r\n" .
'Home' . ': $homewins $homelosses' . "\r\n" .
'Road' . ': $awaywins $awaylosses' . "\r\n" .
'L10' . ': $lastten' . "\r\n" .
'Streak' . ': $streak',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards'
),
'Cricket' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards'
),
'Football (USA)' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards'
),
'Footy (Australia)' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards'
),
'Hockey' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards'
),
'Rugby' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow' . ' Cards: $yellowcards' . "\r\n" .
'Red' . ' Cards: $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow' . ' Cards: $yellowcards' . "\r\n" .
'Red' . ' Cards: $redcards'
),
'soccer' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards'
),
'Tennis' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow' . ' Cards: $yellowcards' . "\r\n" .
'Red' . ' Cards: $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow' . ' Cards: $yellowcards' . "\r\n" .
'Red' . ' Cards: $redcards'
),
'Volleyball' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow' . ' Cards: $yellowcards' . "\r\n" .
'Red' . ' Cards: $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow' . ' Cards: $yellowcards' . "\r\n" .
'Red' . ' Cards: $redcards'
)
);
?>

View File

@@ -1,15 +1,15 @@
=== SportsPress - flexible sports management === === SportsPress ===
Contributors: themeboy Contributors: themeboy
Tags: sports, sports journalism, teams, team management, fixtures, results, standings, league tables, divisions, reporting, themeboy, wordpress sports, configurable, variable, widgets Tags: sports, sports journalism, teams, team management, fixtures, results, standings, league tables, divisions, reporting, themeboy, wordpress sports, configurable, variable, widgets
Requires at least: 3.5 Requires at least: 3.5
Tested up to: 3.6 Tested up to: 3.6
Stable tag: 1.0 Stable tag: 0.1
License: GPLv3 License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html License URI: http://www.gnu.org/licenses/gpl-3.0.html
SportsPress is a powerful, flexible sports management plugin that helps you broadcast your team to the world. SportsPress is a flexible sports management plugin that adds team management functionality to WordPress. Currently in alpha for theme development and testing purposes.
== Changelog == == Changelog ==
= 1.0 - 23/09/2013 = = 0.1 - 23/11/2013 =
* Initial Release. Game on! * Alpha release for first look and testing.

View File

@@ -104,8 +104,8 @@
min-width: 14px; min-width: 14px;
width: 100%; width: 100%;
} }
.widefat th.column-sp_icon, .widefat th.column-sp_logo,
.widefat td.column-sp_icon { .widefat td.column-sp_logo {
width: 32px; width: 32px;
text-align: center; text-align: center;
} }

View File

@@ -6,7 +6,7 @@
Plugin Name: SportsPress Plugin Name: SportsPress
Plugin URI: http://themeboy.com/sportspress Plugin URI: http://themeboy.com/sportspress
Description: Manage your club and its players, staff, events, league tables, and player lists. Description: Manage your club and its players, staff, events, league tables, and player lists.
Version: 1.0 Version: 0.1
Author: ThemeBoy Author: ThemeBoy
Author URI: http://themeboy.com Author URI: http://themeboy.com
License: GPLv3 License: GPLv3
@@ -18,7 +18,7 @@ if ( !function_exists( 'add_action' ) ) {
exit; exit;
} }
define( 'SPORTSPRESS_VERSION', '1.0' ); define( 'SPORTSPRESS_VERSION', '0.1' );
define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
// Libraries // Libraries

View File

@@ -11,7 +11,8 @@ function sp_staff_cpt_init() {
'hierarchical' => false, 'hierarchical' => false,
'supports' => array( 'title', 'author', 'thumbnail' ), 'supports' => array( 'title', 'author', 'thumbnail' ),
'register_meta_box_cb' => 'sp_staff_meta_init', 'register_meta_box_cb' => 'sp_staff_meta_init',
'rewrite' => array( 'slug' => 'staff' ) 'rewrite' => array( 'slug' => 'staff' ),
'menu_position' => 46
); );
register_post_type( 'sp_staff', $args ); register_post_type( 'sp_staff', $args );
} }
@@ -39,9 +40,9 @@ function sp_staff_edit_columns() {
$columns = array( $columns = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'title' => __( 'Name', 'sportspress' ), 'title' => __( 'Name', 'sportspress' ),
'sp_position' => __( 'Positions', 'sportspress' ), 'sp_pos' => __( 'Positions', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ),
'sp_division' => __( 'Divisions', 'sportspress' ), 'sp_div' => __( 'Divisions', 'sportspress' ),
); );
return $columns; return $columns;
} }

View File

@@ -23,7 +23,7 @@ function sp_table_edit_columns() {
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'title' => __( 'Title' ), 'title' => __( 'Title' ),
'sp_team' => __( 'Teams', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ),
'sp_division' => __( 'Divisions', 'sportspress' ), 'sp_div' => __( 'Divisions', 'sportspress' ),
); );
return $columns; return $columns;
} }
@@ -35,22 +35,22 @@ function sp_table_meta_init() {
} }
function sp_table_team_meta( $post ) { function sp_table_team_meta( $post ) {
$division_id = sp_get_the_term_id( $post->ID, 'sp_division', 0 ); $division_id = sp_get_the_term_id( $post->ID, 'sp_div', 0 );
?> ?>
<div> <div>
<p class="sp-tab-select"> <p class="sp-tab-select">
<?php <?php
$args = array( $args = array(
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Divisions', 'sportspress' ) ), 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Divisions', 'sportspress' ) ),
'taxonomy' => 'sp_division', 'taxonomy' => 'sp_div',
'name' => 'sp_division', 'name' => 'sp_div',
'selected' => $division_id 'selected' => $division_id
); );
sp_dropdown_taxonomies( $args ); sp_dropdown_taxonomies( $args );
?> ?>
</p> </p>
<?php <?php
sp_post_checklist( $post->ID, 'sp_team', 'block', 'sp_division' ); sp_post_checklist( $post->ID, 'sp_team', 'block', 'sp_div' );
sp_post_adder( 'sp_team' ); sp_post_adder( 'sp_team' );
?> ?>
</div> </div>
@@ -61,7 +61,7 @@ function sp_table_team_meta( $post ) {
function sp_table_stats_meta( $post ) { function sp_table_stats_meta( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false ); $teams = (array)get_post_meta( $post->ID, 'sp_team', false );
$stats = (array)get_post_meta( $post->ID, 'sp_stats', true ); $stats = (array)get_post_meta( $post->ID, 'sp_stats', true );
$division_id = sp_get_the_term_id( $post->ID, 'sp_division', 0 ); $division_id = sp_get_the_term_id( $post->ID, 'sp_div', 0 );
$data = sp_array_combine( $teams, sp_array_value( $stats, $division_id, array() ) ); $data = sp_array_combine( $teams, sp_array_value( $stats, $division_id, array() ) );
// Generate array of placeholder values for each team // Generate array of placeholder values for each team
@@ -77,7 +77,7 @@ function sp_table_stats_meta( $post ) {
), ),
'tax_query' => array( 'tax_query' => array(
array( array(
'taxonomy' => 'sp_division', 'taxonomy' => 'sp_div',
'field' => 'id', 'field' => 'id',
'terms' => $division_id 'terms' => $division_id
) )

View File

@@ -11,7 +11,8 @@ function sp_team_cpt_init() {
'hierarchical' => true, 'hierarchical' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ), 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ),
'register_meta_box_cb' => 'sp_team_meta_init', 'register_meta_box_cb' => 'sp_team_meta_init',
'rewrite' => array( 'slug' => 'team' ) 'rewrite' => array( 'slug' => 'team' ),
'menu_position' => 43
); );
register_post_type( 'sp_team', $args ); register_post_type( 'sp_team', $args );
} }
@@ -28,16 +29,16 @@ function sp_team_meta_init() {
function sp_team_edit_columns() { function sp_team_edit_columns() {
$columns = array( $columns = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'sp_icon' => '&nbsp;', 'sp_logo' => '&nbsp;',
'title' => __( 'Team', 'sportspress' ), 'title' => __( 'Team', 'sportspress' ),
'sp_division' => __( 'Divisions', 'sportspress' ) 'sp_div' => __( 'Divisions', 'sportspress' )
); );
return $columns; return $columns;
} }
add_filter( 'manage_edit-sp_team_columns', 'sp_team_edit_columns' ); add_filter( 'manage_edit-sp_team_columns', 'sp_team_edit_columns' );
function sp_team_stats_meta( $post ) { function sp_team_stats_meta( $post ) {
$divisions = (array)get_the_terms( $post->ID, 'sp_division' ); $divisions = (array)get_the_terms( $post->ID, 'sp_div' );
$stats = (array)get_post_meta( $post->ID, 'sp_stats', true ); $stats = (array)get_post_meta( $post->ID, 'sp_stats', true );
// Generate array of all division ids // Generate array of all division ids
@@ -63,7 +64,7 @@ function sp_team_stats_meta( $post ) {
), ),
'tax_query' => array( 'tax_query' => array(
array( array(
'taxonomy' => 'sp_division', 'taxonomy' => 'sp_div',
'field' => 'id', 'field' => 'id',
'terms' => $division_id 'terms' => $division_id
) )
@@ -79,7 +80,7 @@ function sp_team_stats_meta( $post ) {
// Add first column label // Add first column label
array_unshift( $columns, __( 'Division', 'sportspress' ) ); array_unshift( $columns, __( 'Division', 'sportspress' ) );
sp_stats_table( $data, $placeholders, 0, $columns, false, 'sp_division' ); sp_stats_table( $data, $placeholders, 0, $columns, false, 'sp_div' );
sp_nonce(); sp_nonce();
} }
?> ?>