Fix bugs, use plural post slugs, move actions and filters into hooks folder
This commit is contained in:
@@ -509,7 +509,7 @@ if ( !function_exists( 'sportspress_edit_league_table' ) ) {
|
|||||||
?>
|
?>
|
||||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||||
<td>
|
<td>
|
||||||
<?php echo get_the_title( $team_id ); ?>
|
<input type="text" name="sp_teams[<?php echo $team_id; ?>][name]" class="name" value="<?php echo sportspress_array_value( $team_stats, 'name', '' ); ?>" placeholder="<?php echo get_the_title( $team_id ); ?>">
|
||||||
</td>
|
</td>
|
||||||
<?php foreach( $columns as $column => $label ):
|
<?php foreach( $columns as $column => $label ):
|
||||||
$value = sportspress_array_value( $team_stats, $column, '' );
|
$value = sportspress_array_value( $team_stats, $column, '' );
|
||||||
@@ -948,8 +948,8 @@ if ( !function_exists( 'sportspress_solve' ) ) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !function_exists( 'sportspress_get_table' ) ) {
|
if ( !function_exists( 'sportspress_get_league_table_data' ) ) {
|
||||||
function sportspress_get_table( $post_id, $breakdown = false ) {
|
function sportspress_get_league_table_data( $post_id, $breakdown = false ) {
|
||||||
$div_id = sportspress_get_the_term_id( $post_id, 'sp_season', 0 );
|
$div_id = sportspress_get_the_term_id( $post_id, 'sp_season', 0 );
|
||||||
$team_ids = (array)get_post_meta( $post_id, 'sp_team', false );
|
$team_ids = (array)get_post_meta( $post_id, 'sp_team', false );
|
||||||
$table_stats = (array)get_post_meta( $post_id, 'sp_teams', true );
|
$table_stats = (array)get_post_meta( $post_id, 'sp_teams', true );
|
||||||
@@ -1017,10 +1017,13 @@ if ( !function_exists( 'sportspress_get_table' ) ) {
|
|||||||
|
|
||||||
foreach ( $results as $team_id => $team_result ):
|
foreach ( $results as $team_id => $team_result ):
|
||||||
|
|
||||||
|
if ( ! in_array( $team_id, $team_ids ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
foreach ( $team_result as $key => $value ):
|
foreach ( $team_result as $key => $value ):
|
||||||
|
|
||||||
if ( $key == 'outcome' ):
|
if ( $key == 'outcome' ):
|
||||||
if ( array_key_exists( $value, $totals[ $team_id ] ) ):
|
if ( array_key_exists( $team_id, $totals ) && is_array( $totals[ $team_id ] ) && array_key_exists( $value, $totals[ $team_id ] ) ):
|
||||||
$totals[ $team_id ]['eventsplayed']++;
|
$totals[ $team_id ]['eventsplayed']++;
|
||||||
$totals[ $team_id ][ $value ]++;
|
$totals[ $team_id ][ $value ]++;
|
||||||
endif;
|
endif;
|
||||||
@@ -1033,7 +1036,7 @@ if ( !function_exists( 'sportspress_get_table' ) ) {
|
|||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
else:
|
else:
|
||||||
if ( array_key_exists( $key . 'for', $totals[ $team_id ] ) ):
|
if ( array_key_exists( $team_id, $totals ) && is_array( $totals[ $team_id ] ) && array_key_exists( $key . 'for', $totals[ $team_id ] ) ):
|
||||||
$totals[ $team_id ][ $key . 'for' ] += $value;
|
$totals[ $team_id ][ $key . 'for' ] += $value;
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
@@ -1119,7 +1122,9 @@ if ( !function_exists( 'sportspress_get_table' ) ) {
|
|||||||
foreach( $placeholders as $team_id => $team_data ):
|
foreach( $placeholders as $team_id => $team_data ):
|
||||||
|
|
||||||
// Add team name to row
|
// Add team name to row
|
||||||
$merged[ $team_id ] = array( 'name' => get_the_title( $team_id ) );
|
$merged[ $team_id ] = array();
|
||||||
|
|
||||||
|
$team_data['name'] = get_the_title( $team_id );
|
||||||
|
|
||||||
foreach( $team_data as $key => $value ):
|
foreach( $team_data as $key => $value ):
|
||||||
|
|
||||||
@@ -1173,8 +1178,8 @@ if ( !function_exists( 'sportspress_get_table' ) ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !function_exists( 'sportspress_get_list' ) ) {
|
if ( !function_exists( 'sportspress_get_player_list_data' ) ) {
|
||||||
function sportspress_get_list( $post_id, $breakdown = false ) {
|
function sportspress_get_player_list_data( $post_id, $breakdown = false ) {
|
||||||
$div_id = sportspress_get_the_term_id( $post_id, 'sp_season', 0 );
|
$div_id = sportspress_get_the_term_id( $post_id, 'sp_season', 0 );
|
||||||
$team_id = get_post_meta( $post_id, 'sp_team', true );
|
$team_id = get_post_meta( $post_id, 'sp_team', true );
|
||||||
$player_ids = (array)get_post_meta( $post_id, 'sp_player', false );
|
$player_ids = (array)get_post_meta( $post_id, 'sp_player', false );
|
||||||
@@ -1250,6 +1255,9 @@ if ( !function_exists( 'sportspress_get_list' ) ) {
|
|||||||
|
|
||||||
foreach ( $players as $player_id => $player_statistics ):
|
foreach ( $players as $player_id => $player_statistics ):
|
||||||
|
|
||||||
|
if ( ! $player_id || ! in_array( $player_id, $player_ids ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
// Increment events played
|
// Increment events played
|
||||||
$totals[ $player_id ]['eventsplayed']++;
|
$totals[ $player_id ]['eventsplayed']++;
|
||||||
|
|
||||||
@@ -1311,20 +1319,9 @@ if ( !function_exists( 'sportspress_get_list' ) ) {
|
|||||||
foreach ( $statistics as $statistic ):
|
foreach ( $statistics as $statistic ):
|
||||||
if ( sportspress_array_value( $placeholders[ $player_id ], $statistic->post_name, '' ) == '' ):
|
if ( sportspress_array_value( $placeholders[ $player_id ], $statistic->post_name, '' ) == '' ):
|
||||||
|
|
||||||
if ( empty( $statistic->equation ) ):
|
// Reflect totals
|
||||||
|
$placeholders[ $player_id ][ $statistic->post_name ] = sportspress_array_value( sportspress_array_value( $totals, $player_id, array() ), $statistic->post_name, 0 );
|
||||||
|
|
||||||
// Reflect totals
|
|
||||||
$placeholders[ $player_id ][ $statistic->post_name ] = sportspress_array_value( sportspress_array_value( $totals, $player_id, array() ), $key, 0 );
|
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
// Calculate value
|
|
||||||
if ( sizeof( $events ) > 0 ):
|
|
||||||
$placeholders[ $player_id ][ $statistic->post_name ] = sportspress_solve( $statistic->equation, sportspress_array_value( $totals, $player_id, array() ) );
|
|
||||||
else:
|
|
||||||
$placeholders[ $player_id ][ $statistic->post_name ] = 0;
|
|
||||||
endif;
|
|
||||||
endif;
|
|
||||||
endif;
|
endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
endforeach;
|
endforeach;
|
||||||
@@ -1334,7 +1331,7 @@ if ( !function_exists( 'sportspress_get_list' ) ) {
|
|||||||
|
|
||||||
foreach( $placeholders as $player_id => $player_data ):
|
foreach( $placeholders as $player_id => $player_data ):
|
||||||
|
|
||||||
// Add team name to row
|
// Add player name to row
|
||||||
$merged[ $player_id ] = array( 'name' => get_the_title( $player_id ) );
|
$merged[ $player_id ] = array( 'name' => get_the_title( $player_id ) );
|
||||||
|
|
||||||
foreach( $player_data as $key => $value ):
|
foreach( $player_data as $key => $value ):
|
||||||
|
|||||||
@@ -1,158 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_admin_init() {
|
|
||||||
|
|
||||||
$installed = get_option( 'sportspress_installed', false );
|
|
||||||
|
|
||||||
// Define roles and capabilities
|
|
||||||
if ( ! $installed ):
|
|
||||||
|
|
||||||
$role = get_role( 'administrator' );
|
|
||||||
|
|
||||||
// Events
|
|
||||||
$role->add_cap( 'edit_sp_event' );
|
|
||||||
$role->add_cap( 'edit_sp_events' );
|
|
||||||
$role->add_cap( 'edit_others_sp_events' );
|
|
||||||
$role->add_cap( 'delete_sp_event' );
|
|
||||||
$role->add_cap( 'publish_sp_events' );
|
|
||||||
$role->add_cap( 'read_sp_events' );
|
|
||||||
$role->add_cap( 'read_private_sp_events' );
|
|
||||||
|
|
||||||
// Teams
|
|
||||||
$role->add_cap( 'edit_sp_team' );
|
|
||||||
$role->add_cap( 'edit_sp_teams' );
|
|
||||||
$role->add_cap( 'edit_others_sp_teams' );
|
|
||||||
$role->add_cap( 'delete_sp_team' );
|
|
||||||
$role->add_cap( 'publish_sp_teams' );
|
|
||||||
$role->add_cap( 'read_sp_teams' );
|
|
||||||
$role->add_cap( 'read_private_sp_teams' );
|
|
||||||
|
|
||||||
// League Tables
|
|
||||||
$role->add_cap( 'edit_sp_table' );
|
|
||||||
$role->add_cap( 'edit_sp_tables' );
|
|
||||||
$role->add_cap( 'edit_others_sp_tables' );
|
|
||||||
$role->add_cap( 'delete_sp_table' );
|
|
||||||
$role->add_cap( 'publish_sp_tables' );
|
|
||||||
$role->add_cap( 'read_sp_tables' );
|
|
||||||
$role->add_cap( 'read_private_sp_tables' );
|
|
||||||
|
|
||||||
// Players
|
|
||||||
$role->add_cap( 'edit_sp_player' );
|
|
||||||
$role->add_cap( 'edit_sp_players' );
|
|
||||||
$role->add_cap( 'edit_others_sp_players' );
|
|
||||||
$role->add_cap( 'delete_sp_player' );
|
|
||||||
$role->add_cap( 'publish_sp_players' );
|
|
||||||
$role->add_cap( 'read_sp_players' );
|
|
||||||
$role->add_cap( 'read_private_sp_players' );
|
|
||||||
|
|
||||||
// Player Lists
|
|
||||||
$role->add_cap( 'edit_sp_list' );
|
|
||||||
$role->add_cap( 'edit_sp_lists' );
|
|
||||||
$role->add_cap( 'edit_others_sp_lists' );
|
|
||||||
$role->add_cap( 'delete_sp_list' );
|
|
||||||
$role->add_cap( 'publish_sp_lists' );
|
|
||||||
$role->add_cap( 'read_sp_lists' );
|
|
||||||
$role->add_cap( 'read_private_sp_lists' );
|
|
||||||
|
|
||||||
// Staff
|
|
||||||
$role->add_cap( 'edit_sp_staff' );
|
|
||||||
$role->add_cap( 'edit_sp_staffs' );
|
|
||||||
$role->add_cap( 'edit_others_sp_staffs' );
|
|
||||||
$role->add_cap( 'delete_sp_staff' );
|
|
||||||
$role->add_cap( 'publish_sp_staffs' );
|
|
||||||
$role->add_cap( 'read_sp_staffs' );
|
|
||||||
$role->add_cap( 'read_private_sp_staffs' );
|
|
||||||
|
|
||||||
// Settings
|
|
||||||
$role->add_cap( 'read_sp_configs' );
|
|
||||||
$role->add_cap( 'read_private_sp_configs' );
|
|
||||||
$role->add_cap( 'edit_sp_config' );
|
|
||||||
$role->add_cap( 'edit_sp_configs' );
|
|
||||||
$role->add_cap( 'edit_published_sp_configs' );
|
|
||||||
$role->add_cap( 'edit_private_sp_configs' );
|
|
||||||
$role->add_cap( 'edit_others_sp_configs' );
|
|
||||||
$role->add_cap( 'delete_sp_config' );
|
|
||||||
$role->add_cap( 'delete_published_sp_configs' );
|
|
||||||
$role->add_cap( 'delete_private_sp_configs' );
|
|
||||||
$role->add_cap( 'delete_others_sp_configs' );
|
|
||||||
$role->add_cap( 'publish_sp_configs' );
|
|
||||||
|
|
||||||
// Team Manager
|
|
||||||
remove_role( 'sp_team_manager' );
|
|
||||||
add_role(
|
|
||||||
'sp_team_manager',
|
|
||||||
__( 'Team Manager', 'sportspress' ),
|
|
||||||
array(
|
|
||||||
'read' => true,
|
|
||||||
'edit_posts' => true,
|
|
||||||
'delete_posts' => true,
|
|
||||||
'read_sp_players' => true,
|
|
||||||
'edit_sp_players' => true,
|
|
||||||
'edit_others_sp_players' => true,
|
|
||||||
'delete_sp_player' => true,
|
|
||||||
'publish_sp_players' => true,
|
|
||||||
'read_sp_staffs' => true,
|
|
||||||
'edit_sp_staffs' => true,
|
|
||||||
'edit_others_sp_staffs' => true,
|
|
||||||
'delete_sp_staff' => true,
|
|
||||||
'publish_sp_staffs' => true
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Staff
|
|
||||||
remove_role( 'sp_staff' );
|
|
||||||
add_role(
|
|
||||||
'sp_staff',
|
|
||||||
__( 'Staff', 'sportspress' ),
|
|
||||||
array(
|
|
||||||
'read' => true,
|
|
||||||
'edit_posts' => true,
|
|
||||||
'delete_posts' => true,
|
|
||||||
'read_sp_staffs' => true,
|
|
||||||
'edit_sp_staffs' => true,
|
|
||||||
'delete_sp_staff' => true
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Player
|
|
||||||
remove_role( 'sp_player' );
|
|
||||||
add_role(
|
|
||||||
'sp_player',
|
|
||||||
__( 'Player', 'sportspress' ),
|
|
||||||
array(
|
|
||||||
'read' => true,
|
|
||||||
'edit_posts' => true,
|
|
||||||
'delete_posts' => true,
|
|
||||||
'read_sp_players' => true,
|
|
||||||
'edit_sp_players' => true,
|
|
||||||
'delete_sp_player' => true
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
update_option( 'sportspress_installed', 1 );
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
// Add settings sections
|
|
||||||
register_setting(
|
|
||||||
'sportspress_general',
|
|
||||||
'sportspress',
|
|
||||||
'sportspress_validate'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_section(
|
|
||||||
'general',
|
|
||||||
'',
|
|
||||||
'',
|
|
||||||
'sportspress_general'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'sport',
|
|
||||||
__( 'Sport', 'sportspress' ),
|
|
||||||
'sportspress_sport_callback',
|
|
||||||
'sportspress_general',
|
|
||||||
'general'
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
add_action( 'admin_init', 'sportspress_admin_init', 1 );
|
|
||||||
130
admin/hooks/admin-init.php
Normal file
130
admin/hooks/admin-init.php
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
function sportspress_admin_init() {
|
||||||
|
|
||||||
|
$installed = get_option( 'sportspress_installed', false );
|
||||||
|
|
||||||
|
// General settings
|
||||||
|
register_setting(
|
||||||
|
'sportspress_general',
|
||||||
|
'sportspress',
|
||||||
|
'sportspress_validate'
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_section(
|
||||||
|
'general',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'sportspress_general'
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'sport',
|
||||||
|
__( 'Sport', 'sportspress' ),
|
||||||
|
'sportspress_sport_callback',
|
||||||
|
'sportspress_general',
|
||||||
|
'general'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Event Settings
|
||||||
|
register_setting(
|
||||||
|
'sportspress_events',
|
||||||
|
'sportspress',
|
||||||
|
'sportspress_validate'
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_section(
|
||||||
|
'events',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'sportspress_events'
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'sport',
|
||||||
|
__( 'Sport', 'sportspress' ),
|
||||||
|
'sportspress_sport_callback',
|
||||||
|
'sportspress_events',
|
||||||
|
'events'
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
add_action( 'admin_init', 'sportspress_admin_init', 1 );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function sportspress_validate( $input ) {
|
||||||
|
|
||||||
|
$options = get_option( 'sportspress' );
|
||||||
|
|
||||||
|
// Do nothing if sport is the same as currently selected
|
||||||
|
if ( sportspress_array_value( $options, 'sport', null ) == sportspress_array_value( $input, 'sport', null ) )
|
||||||
|
|
||||||
|
return $input;
|
||||||
|
|
||||||
|
// Get sports presets
|
||||||
|
global $sportspress_sports;
|
||||||
|
|
||||||
|
// Get array of post types to insert
|
||||||
|
$post_groups = sportspress_array_value( sportspress_array_value( $sportspress_sports, sportspress_array_value( $input, 'sport', null ), array() ), 'posts', array() );
|
||||||
|
|
||||||
|
// Loop through each post type
|
||||||
|
foreach( $post_groups as $post_type => $posts ):
|
||||||
|
|
||||||
|
$args = array(
|
||||||
|
'post_type' => $post_type,
|
||||||
|
'numberposts' => -1,
|
||||||
|
'posts_per_page' => -1,
|
||||||
|
'meta_query' => array(
|
||||||
|
array(
|
||||||
|
'key' => 'sp_preset',
|
||||||
|
'value' => 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Delete posts
|
||||||
|
$old_posts = get_posts( $args );
|
||||||
|
|
||||||
|
foreach( $old_posts as $post ):
|
||||||
|
wp_delete_post( $post->ID, true);
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
// Add posts
|
||||||
|
foreach( $posts as $index => $post ):
|
||||||
|
|
||||||
|
// Make sure post doesn't overlap
|
||||||
|
if ( ! get_page_by_path( $post['post_name'], OBJECT, $post_type ) ):
|
||||||
|
|
||||||
|
// Translate post title
|
||||||
|
$post['post_title'] = __( $post['post_title'], 'sportspress' );
|
||||||
|
|
||||||
|
// Set post type
|
||||||
|
$post['post_type'] = $post_type;
|
||||||
|
|
||||||
|
// Increment menu order by 2 and publish post
|
||||||
|
$post['menu_order'] = $index * 2 + 2;
|
||||||
|
$post['post_status'] = 'publish';
|
||||||
|
$id = wp_insert_post( $post );
|
||||||
|
|
||||||
|
// Flag as preset
|
||||||
|
update_post_meta( $id, 'sp_preset', 1 );
|
||||||
|
|
||||||
|
// Update meta
|
||||||
|
if ( array_key_exists( 'meta', $post ) ):
|
||||||
|
|
||||||
|
foreach ( $post['meta'] as $key => $value ):
|
||||||
|
|
||||||
|
update_post_meta( $id, $key, $value );
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
@@ -72,7 +72,16 @@ function sportspress_manage_posts_custom_column( $column, $post_id ) {
|
|||||||
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' ) : '—';
|
||||||
break;
|
break;
|
||||||
case 'sp_kickoff':
|
case 'sp_kickoff':
|
||||||
echo ( $post->post_status == 'future' ? __( 'Scheduled' ) : __( 'Played', 'sportspress' ) ) . '<br />' . date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) );
|
if ( $post->post_status == 'future' ):
|
||||||
|
_e( 'Scheduled', 'sportspress' );
|
||||||
|
elseif( $post->post_status == 'publish' ):
|
||||||
|
_e( 'Played', 'sportspress' );
|
||||||
|
elseif( $post->post_status == 'draft' ):
|
||||||
|
_e( 'Draft', 'sportspress' );
|
||||||
|
else:
|
||||||
|
_e( 'Pending Review', 'sportspress' );
|
||||||
|
endif;
|
||||||
|
echo '<br />' . date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) );
|
||||||
break;
|
break;
|
||||||
case 'sp_address':
|
case 'sp_address':
|
||||||
echo get_post_meta( $post_id, 'sp_address', true ) ? get_post_meta( $post_id, 'sp_address', true ) : '—';
|
echo get_post_meta( $post_id, 'sp_address', true ) ? get_post_meta( $post_id, 'sp_address', true ) : '—';
|
||||||
9
admin/hooks/plugin-action-links.php
Normal file
9
admin/hooks/plugin-action-links.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
function sportspress_plugin_action_links( $links ) {
|
||||||
|
$settings_link = '<a href="options-general.php?page=sportspress">' . __( 'Settings', 'sportspress' ) . '</a>';
|
||||||
|
array_unshift( $links, $settings_link );
|
||||||
|
return $links;
|
||||||
|
}
|
||||||
|
|
||||||
|
$plugin = SPORTSPRESS_PLUGIN_BASENAME;
|
||||||
|
add_filter( "plugin_action_links_$plugin", 'sportspress_plugin_action_links' );
|
||||||
141
admin/hooks/register-activation-hook.php
Normal file
141
admin/hooks/register-activation-hook.php
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
<?php
|
||||||
|
function sportspress_activation_hook() {
|
||||||
|
|
||||||
|
$role = get_role( 'administrator' );
|
||||||
|
|
||||||
|
// Events
|
||||||
|
$role->add_cap( 'edit_sp_event' );
|
||||||
|
$role->add_cap( 'edit_sp_events' );
|
||||||
|
$role->add_cap( 'edit_others_sp_events' );
|
||||||
|
$role->add_cap( 'delete_sp_event' );
|
||||||
|
$role->add_cap( 'publish_sp_events' );
|
||||||
|
$role->add_cap( 'read_sp_events' );
|
||||||
|
$role->add_cap( 'read_private_sp_events' );
|
||||||
|
|
||||||
|
// Teams
|
||||||
|
$role->add_cap( 'edit_sp_team' );
|
||||||
|
$role->add_cap( 'edit_sp_teams' );
|
||||||
|
$role->add_cap( 'edit_others_sp_teams' );
|
||||||
|
$role->add_cap( 'delete_sp_team' );
|
||||||
|
$role->add_cap( 'publish_sp_teams' );
|
||||||
|
$role->add_cap( 'read_sp_teams' );
|
||||||
|
$role->add_cap( 'read_private_sp_teams' );
|
||||||
|
|
||||||
|
// League Tables
|
||||||
|
$role->add_cap( 'edit_sp_table' );
|
||||||
|
$role->add_cap( 'edit_sp_tables' );
|
||||||
|
$role->add_cap( 'edit_others_sp_tables' );
|
||||||
|
$role->add_cap( 'delete_sp_table' );
|
||||||
|
$role->add_cap( 'publish_sp_tables' );
|
||||||
|
$role->add_cap( 'read_sp_tables' );
|
||||||
|
$role->add_cap( 'read_private_sp_tables' );
|
||||||
|
|
||||||
|
// Players
|
||||||
|
$role->add_cap( 'edit_sp_player' );
|
||||||
|
$role->add_cap( 'edit_sp_players' );
|
||||||
|
$role->add_cap( 'edit_others_sp_players' );
|
||||||
|
$role->add_cap( 'delete_sp_player' );
|
||||||
|
$role->add_cap( 'publish_sp_players' );
|
||||||
|
$role->add_cap( 'read_sp_players' );
|
||||||
|
$role->add_cap( 'read_private_sp_players' );
|
||||||
|
|
||||||
|
// Player Lists
|
||||||
|
$role->add_cap( 'edit_sp_list' );
|
||||||
|
$role->add_cap( 'edit_sp_lists' );
|
||||||
|
$role->add_cap( 'edit_others_sp_lists' );
|
||||||
|
$role->add_cap( 'delete_sp_list' );
|
||||||
|
$role->add_cap( 'publish_sp_lists' );
|
||||||
|
$role->add_cap( 'read_sp_lists' );
|
||||||
|
$role->add_cap( 'read_private_sp_lists' );
|
||||||
|
|
||||||
|
// Staff
|
||||||
|
$role->add_cap( 'edit_sp_staff' );
|
||||||
|
$role->add_cap( 'edit_sp_staffs' );
|
||||||
|
$role->add_cap( 'edit_others_sp_staffs' );
|
||||||
|
$role->add_cap( 'delete_sp_staff' );
|
||||||
|
$role->add_cap( 'publish_sp_staffs' );
|
||||||
|
$role->add_cap( 'read_sp_staffs' );
|
||||||
|
$role->add_cap( 'read_private_sp_staffs' );
|
||||||
|
|
||||||
|
// Settings
|
||||||
|
$role->add_cap( 'read_sp_configs' );
|
||||||
|
$role->add_cap( 'read_private_sp_configs' );
|
||||||
|
$role->add_cap( 'edit_sp_config' );
|
||||||
|
$role->add_cap( 'edit_sp_configs' );
|
||||||
|
$role->add_cap( 'edit_published_sp_configs' );
|
||||||
|
$role->add_cap( 'edit_private_sp_configs' );
|
||||||
|
$role->add_cap( 'edit_others_sp_configs' );
|
||||||
|
$role->add_cap( 'delete_sp_config' );
|
||||||
|
$role->add_cap( 'delete_published_sp_configs' );
|
||||||
|
$role->add_cap( 'delete_private_sp_configs' );
|
||||||
|
$role->add_cap( 'delete_others_sp_configs' );
|
||||||
|
$role->add_cap( 'publish_sp_configs' );
|
||||||
|
|
||||||
|
// Team Manager
|
||||||
|
remove_role( 'sp_team_manager' );
|
||||||
|
add_role(
|
||||||
|
'sp_team_manager',
|
||||||
|
__( 'Team Manager', 'sportspress' ),
|
||||||
|
array(
|
||||||
|
'read' => true,
|
||||||
|
'edit_posts' => true,
|
||||||
|
'delete_posts' => true,
|
||||||
|
'read_sp_players' => true,
|
||||||
|
'edit_sp_players' => true,
|
||||||
|
'edit_others_sp_players' => true,
|
||||||
|
'delete_sp_player' => true,
|
||||||
|
'publish_sp_players' => true,
|
||||||
|
'read_sp_staffs' => true,
|
||||||
|
'edit_sp_staffs' => true,
|
||||||
|
'edit_others_sp_staffs' => true,
|
||||||
|
'delete_sp_staff' => true,
|
||||||
|
'publish_sp_staffs' => true
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Staff
|
||||||
|
remove_role( 'sp_staff' );
|
||||||
|
add_role(
|
||||||
|
'sp_staff',
|
||||||
|
__( 'Staff', 'sportspress' ),
|
||||||
|
array(
|
||||||
|
'read' => true,
|
||||||
|
'edit_posts' => true,
|
||||||
|
'delete_posts' => true,
|
||||||
|
'read_sp_staffs' => true,
|
||||||
|
'edit_sp_staffs' => true,
|
||||||
|
'delete_sp_staff' => true
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Player
|
||||||
|
remove_role( 'sp_player' );
|
||||||
|
add_role(
|
||||||
|
'sp_player',
|
||||||
|
__( 'Player', 'sportspress' ),
|
||||||
|
array(
|
||||||
|
'read' => true,
|
||||||
|
'edit_posts' => true,
|
||||||
|
'delete_posts' => true,
|
||||||
|
'read_sp_players' => true,
|
||||||
|
'edit_sp_players' => true,
|
||||||
|
'delete_sp_player' => true
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Flush rewrite rules
|
||||||
|
sportspress_event_post_init();
|
||||||
|
sportspress_result_post_init();
|
||||||
|
sportspress_outcome_post_init();
|
||||||
|
sportspress_column_post_init();
|
||||||
|
sportspress_statistic_post_init();
|
||||||
|
sportspress_team_post_init();
|
||||||
|
sportspress_table_post_init();
|
||||||
|
sportspress_player_post_init();
|
||||||
|
sportspress_list_post_init();
|
||||||
|
sportspress_staff_post_init();
|
||||||
|
sportspress_position_term_init();
|
||||||
|
sportspress_season_term_init();
|
||||||
|
flush_rewrite_rules();
|
||||||
|
}
|
||||||
|
register_activation_hook( SPORTSPRESS_PLUGIN_FILE, 'sportspress_activation_hook' );
|
||||||
@@ -20,4 +20,5 @@ function sportspress_the_content( $content ) {
|
|||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
add_filter('the_content', 'sportspress_the_content');
|
add_filter( 'the_content', 'sportspress_the_content' );
|
||||||
|
add_filter( 'get_the_content', 'sportspress_the_content' );
|
||||||
@@ -11,7 +11,7 @@ function sportspress_event_post_init() {
|
|||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'author', 'comments' ),
|
'supports' => array( 'title', 'author', 'comments' ),
|
||||||
'register_meta_box_cb' => 'sportspress_event_meta_init',
|
'register_meta_box_cb' => 'sportspress_event_meta_init',
|
||||||
'rewrite' => array( 'slug' => get_option( 'sp_event_slug', 'event' ) ),
|
'rewrite' => array( 'slug' => get_option( 'sp_event_slug', 'events' ) ),
|
||||||
'menu_icon' => 'dashicons-calendar',
|
'menu_icon' => 'dashicons-calendar',
|
||||||
'capability_type' => 'sp_event'
|
'capability_type' => 'sp_event'
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ function sportspress_list_post_init() {
|
|||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'author' ),
|
'supports' => array( 'title', 'author' ),
|
||||||
'register_meta_box_cb' => 'sportspress_list_meta_init',
|
'register_meta_box_cb' => 'sportspress_list_meta_init',
|
||||||
'rewrite' => array( 'slug' => 'list' ),
|
'rewrite' => array( 'slug' => get_option( 'sp_list_slug', 'lists' ) ),
|
||||||
'show_in_menu' => 'edit.php?post_type=sp_player',
|
'show_in_menu' => 'edit.php?post_type=sp_player',
|
||||||
|
'show_in_admin_bar' => true,
|
||||||
'capability_type' => 'sp_list'
|
'capability_type' => 'sp_list'
|
||||||
);
|
);
|
||||||
register_post_type( 'sp_list', $args );
|
register_post_type( 'sp_list', $args );
|
||||||
@@ -78,7 +79,7 @@ function sportspress_list_player_meta( $post ) {
|
|||||||
|
|
||||||
function sportspress_list_stats_meta( $post ) {
|
function sportspress_list_stats_meta( $post ) {
|
||||||
|
|
||||||
list( $columns, $data, $placeholders, $merged ) = sportspress_get_list( $post->ID, true );
|
list( $columns, $data, $placeholders, $merged ) = sportspress_get_player_list_data( $post->ID, true );
|
||||||
|
|
||||||
sportspress_edit_player_table( $columns, $data, $placeholders );
|
sportspress_edit_player_table( $columns, $data, $placeholders );
|
||||||
sportspress_nonce();
|
sportspress_nonce();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ function sportspress_player_post_init() {
|
|||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'author', 'thumbnail' ),
|
'supports' => array( 'title', 'author', 'thumbnail' ),
|
||||||
'register_meta_box_cb' => 'sportspress_player_meta_init',
|
'register_meta_box_cb' => 'sportspress_player_meta_init',
|
||||||
'rewrite' => array( 'slug' => get_option( 'sp_player_slug', 'player' ) ),
|
'rewrite' => array( 'slug' => get_option( 'sp_player_slug', 'players' ) ),
|
||||||
'menu_icon' => 'dashicons-groups',
|
'menu_icon' => 'dashicons-groups',
|
||||||
'capability_type' => 'sp_player',
|
'capability_type' => 'sp_player',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ function sportspress_table_post_init() {
|
|||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'author', 'excerpt' ),
|
'supports' => array( 'title', 'author', 'excerpt' ),
|
||||||
'register_meta_box_cb' => 'sportspress_table_meta_init',
|
'register_meta_box_cb' => 'sportspress_table_meta_init',
|
||||||
'rewrite' => array( 'slug' => 'table' ),
|
'rewrite' => array( 'slug' => get_option( 'sp_table_slug', 'tables' ) ),
|
||||||
'show_in_menu' => 'edit.php?post_type=sp_team',
|
'show_in_menu' => 'edit.php?post_type=sp_team',
|
||||||
|
'show_in_admin_bar' => true,
|
||||||
// 'capability_type' => 'sp_table'
|
// 'capability_type' => 'sp_table'
|
||||||
);
|
);
|
||||||
register_post_type( 'sp_table', $args );
|
register_post_type( 'sp_table', $args );
|
||||||
@@ -66,7 +67,7 @@ function sportspress_table_team_meta( $post, $test ) {
|
|||||||
|
|
||||||
function sportspress_table_columns_meta( $post ) {
|
function sportspress_table_columns_meta( $post ) {
|
||||||
|
|
||||||
list( $columns, $data, $placeholders, $merged ) = sportspress_get_table( $post->ID, true );
|
list( $columns, $data, $placeholders, $merged ) = sportspress_get_league_table_data( $post->ID, true );
|
||||||
|
|
||||||
sportspress_edit_league_table( $columns, $data, $placeholders );
|
sportspress_edit_league_table( $columns, $data, $placeholders );
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ function sportspress_team_post_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' => 'sportspress_team_meta_init',
|
'register_meta_box_cb' => 'sportspress_team_meta_init',
|
||||||
'rewrite' => array( 'slug' => get_option( 'sp_team_slug', 'team' ) ),
|
'rewrite' => array( 'slug' => get_option( 'sp_team_slug', 'teams' ) ),
|
||||||
'menu_icon' => 'dashicons-shield-alt',
|
'menu_icon' => 'dashicons-shield-alt',
|
||||||
'capability_type' => 'sp_team'
|
'capability_type' => 'sp_team'
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,7 +8,12 @@ function sportspress_settings() {
|
|||||||
|
|
||||||
<h2 class="nav-tab-wrapper">
|
<h2 class="nav-tab-wrapper">
|
||||||
<a href="?page=sportspress" class="nav-tab<?php echo $active_tab == 'general' ? ' nav-tab-active' : ''; ?>"><?php _e( 'SportsPress', 'sportspress' ); ?></a>
|
<a href="?page=sportspress" class="nav-tab<?php echo $active_tab == 'general' ? ' nav-tab-active' : ''; ?>"><?php _e( 'SportsPress', 'sportspress' ); ?></a>
|
||||||
|
<a href="?page=sportspress&tab=events" class="nav-tab<?php echo $active_tab == 'events' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Events', 'sportspress' ); ?></a>
|
||||||
|
<a href="?page=sportspress&tab=teams" class="nav-tab<?php echo $active_tab == 'teams' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Teams', 'sportspress' ); ?></a>
|
||||||
|
<a href="?page=sportspress&tab=players" class="nav-tab<?php echo $active_tab == 'players' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Players', 'sportspress' ); ?></a>
|
||||||
|
<a href="?page=sportspress&tab=staff" class="nav-tab<?php echo $active_tab == 'staff' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Staff', 'sportspress' ); ?></a>
|
||||||
<a href="?page=sportspress&tab=config" class="nav-tab<?php echo $active_tab == 'config' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Configure', 'sportspress' ); ?></a>
|
<a href="?page=sportspress&tab=config" class="nav-tab<?php echo $active_tab == 'config' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Configure', 'sportspress' ); ?></a>
|
||||||
|
<a href="?page=sportspress&tab=advanced" class="nav-tab<?php echo $active_tab == 'advanced' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Advanced', 'sportspress' ); ?></a>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<form method="post" action="options.php">
|
<form method="post" action="options.php">
|
||||||
@@ -27,83 +32,6 @@ function sportspress_settings() {
|
|||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
function sportspress_validate( $input ) {
|
|
||||||
|
|
||||||
$options = get_option( 'sportspress' );
|
|
||||||
|
|
||||||
// Do nothing if sport is the same as currently selected
|
|
||||||
if ( sportspress_array_value( $options, 'sport', null ) == sportspress_array_value( $input, 'sport', null ) )
|
|
||||||
|
|
||||||
return $input;
|
|
||||||
|
|
||||||
// Get sports presets
|
|
||||||
global $sportspress_sports;
|
|
||||||
|
|
||||||
// Get array of post types to insert
|
|
||||||
$post_groups = sportspress_array_value( sportspress_array_value( $sportspress_sports, sportspress_array_value( $input, 'sport', null ), array() ), 'posts', array() );
|
|
||||||
|
|
||||||
// Loop through each post type
|
|
||||||
foreach( $post_groups as $post_type => $posts ):
|
|
||||||
|
|
||||||
$args = array(
|
|
||||||
'post_type' => $post_type,
|
|
||||||
'numberposts' => -1,
|
|
||||||
'posts_per_page' => -1,
|
|
||||||
'meta_query' => array(
|
|
||||||
array(
|
|
||||||
'key' => 'sp_preset',
|
|
||||||
'value' => 1
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Delete posts
|
|
||||||
$old_posts = get_posts( $args );
|
|
||||||
|
|
||||||
foreach( $old_posts as $post ):
|
|
||||||
wp_delete_post( $post->ID, true);
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
// Add posts
|
|
||||||
foreach( $posts as $index => $post ):
|
|
||||||
|
|
||||||
// Make sure post doesn't overlap
|
|
||||||
if ( ! get_page_by_path( $post['post_name'], OBJECT, $post_type ) ):
|
|
||||||
|
|
||||||
// Translate post title
|
|
||||||
$post['post_title'] = __( $post['post_title'], 'sportspress' );
|
|
||||||
|
|
||||||
// Set post type
|
|
||||||
$post['post_type'] = $post_type;
|
|
||||||
|
|
||||||
// Increment menu order by 2 and publish post
|
|
||||||
$post['menu_order'] = $index * 2 + 2;
|
|
||||||
$post['post_status'] = 'publish';
|
|
||||||
$id = wp_insert_post( $post );
|
|
||||||
|
|
||||||
// Flag as preset
|
|
||||||
update_post_meta( $id, 'sp_preset', 1 );
|
|
||||||
|
|
||||||
// Update meta
|
|
||||||
if ( array_key_exists( 'meta', $post ) ):
|
|
||||||
|
|
||||||
foreach ( $post['meta'] as $key => $value ):
|
|
||||||
|
|
||||||
update_post_meta( $id, $key, $value );
|
|
||||||
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
return $input;
|
|
||||||
}
|
|
||||||
|
|
||||||
function sportspress_sport_callback() {
|
function sportspress_sport_callback() {
|
||||||
global $sportspress_sports;
|
global $sportspress_sports;
|
||||||
$options = get_option( 'sportspress' );
|
$options = get_option( 'sportspress' );
|
||||||
@@ -113,7 +41,7 @@ function sportspress_sport_callback() {
|
|||||||
<option value="<?php echo $slug; ?>" <?php selected( $options['sport'], $slug ); ?>><?php _e( $sport['name'], 'sportspress' ); ?></option>
|
<option value="<?php echo $slug; ?>" <?php selected( $options['sport'], $slug ); ?>><?php _e( $sport['name'], 'sportspress' ); ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
<?
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
function sportspress_team_stats_callback() {
|
function sportspress_team_stats_callback() {
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ table.widefat.sp-data-table input[type="number"] {
|
|||||||
min-width: 14px;
|
min-width: 14px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
table.widefat.sp-data-table input.name {
|
||||||
|
min-width: 0;
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
.sp-admin-config-table th,
|
.sp-admin-config-table th,
|
||||||
.sp-admin-config-table td {
|
.sp-admin-config-table td {
|
||||||
width: 20%;
|
width: 20%;
|
||||||
|
|||||||
@@ -1,12 +1,27 @@
|
|||||||
/* SportsPress */
|
/* SportsPress */
|
||||||
|
|
||||||
/* Data Tables */
|
/* Data Tables */
|
||||||
.sp-data-table thead .sorting {
|
.sp-data-table thead .sorting,
|
||||||
|
.sp-data-table thead .sorting_asc,
|
||||||
|
.sp-data-table thead .sorting_desc {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
.sp-data-table .sorting:after,
|
||||||
|
.sp-data-table .sorting_asc:after,
|
||||||
|
.sp-data-table .sorting_desc:after {
|
||||||
|
font-family: 'Courier New', Courier, monospace;
|
||||||
|
}
|
||||||
|
.sp-data-table .sorting:after {
|
||||||
|
content: ' \A0';
|
||||||
|
}
|
||||||
.sp-data-table .sorting_asc:after {
|
.sp-data-table .sorting_asc:after {
|
||||||
content: ' \25B2';
|
content: ' \25B2';
|
||||||
}
|
}
|
||||||
.sp-data-table .sorting_desc:after {
|
.sp-data-table .sorting_desc:after {
|
||||||
content: ' \25BC';
|
content: ' \25BC';
|
||||||
}
|
}
|
||||||
|
.sp-data-table .column-name .logo {
|
||||||
|
vertical-align: middle;
|
||||||
|
height: 2em;
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
// Data tables
|
// Data tables
|
||||||
$('.sp-data-table').dataTable({
|
$('.sp-data-table').dataTable({
|
||||||
'aaSorting': [],
|
'aaSorting': [],
|
||||||
|
'bAutoWidth': false,
|
||||||
'bFilter': false,
|
'bFilter': false,
|
||||||
'bInfo': false,
|
'bInfo': false,
|
||||||
'bPaginate': false,
|
'bPaginate': false,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
if ( !function_exists( 'sportspress_league_table' ) ) {
|
if ( !function_exists( 'sportspress_league_table' ) ) {
|
||||||
function sportspress_league_table( $id ) {
|
function sportspress_league_table( $id ) {
|
||||||
|
|
||||||
$data = sportspress_get_table( $id );
|
$data = sportspress_get_league_table_data( $id );
|
||||||
|
|
||||||
$output = '<table class="sp-league-table sp-data-table">' . '<thead>' . '<tr>';
|
$output = '<table class="sp-league-table sp-data-table">' . '<thead>' . '<tr>';
|
||||||
|
|
||||||
@@ -12,6 +12,7 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
|
|||||||
// Remove the first row to leave us with the actual data
|
// Remove the first row to leave us with the actual data
|
||||||
unset( $data[0] );
|
unset( $data[0] );
|
||||||
|
|
||||||
|
$output .= '<th class="column-number">' . __( '#', 'sportspress' ) . '</th>';
|
||||||
foreach( $labels as $key => $label ):
|
foreach( $labels as $key => $label ):
|
||||||
$output .= '<th class="column-' . ( $key ? $key : 'name' ) . '">' . $label . '</th>';
|
$output .= '<th class="column-' . ( $key ? $key : 'name' ) . '">' . $label . '</th>';
|
||||||
endforeach;
|
endforeach;
|
||||||
@@ -24,11 +25,14 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
|
|||||||
|
|
||||||
$output .= '<tr class="' . ( $i % 2 ? 'odd' : 'even' ) . '">';
|
$output .= '<tr class="' . ( $i % 2 ? 'odd' : 'even' ) . '">';
|
||||||
|
|
||||||
|
// Position as number
|
||||||
|
$output .= '<td class="column-number">' . $i . '</td>';
|
||||||
|
|
||||||
// Thumbnail and name as link
|
// Thumbnail and name as link
|
||||||
$permalink = get_post_permalink( $team_id );
|
$permalink = get_post_permalink( $team_id );
|
||||||
$thumbnail = get_the_post_thumbnail( $team_id, 'sp_icon' );
|
$thumbnail = get_the_post_thumbnail( $team_id, 'thumbnail', array( 'class' => 'logo' ) );
|
||||||
$name = sportspress_array_value( $row, 'name', ' ' );
|
$name = sportspress_array_value( $row, 'name', sportspress_array_value( $row, 'name', ' ' ) );
|
||||||
$output .= '<td class="column-name">' . $i . '. ' . ( $thumbnail ? $thumbnail . ' ' : '' ) . '<a href="' . $permalink . '">' . $name . '</a></td>';
|
$output .= '<td class="column-name">' . ( $thumbnail ? $thumbnail . ' ' : '' ) . '<a href="' . $permalink . '">' . $name . '</a></td>';
|
||||||
|
|
||||||
foreach( $labels as $key => $value ):
|
foreach( $labels as $key => $value ):
|
||||||
if ( $key == 'name' )
|
if ( $key == 'name' )
|
||||||
@@ -52,7 +56,7 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
|
|||||||
if ( !function_exists( 'sportspress_player_list' ) ) {
|
if ( !function_exists( 'sportspress_player_list' ) ) {
|
||||||
function sportspress_player_list( $id ) {
|
function sportspress_player_list( $id ) {
|
||||||
|
|
||||||
$data = sportspress_get_list( $id );
|
$data = sportspress_get_player_list_data( $id );
|
||||||
|
|
||||||
$output = '<table class="sp-player-list sp-data-table">' . '<thead>' . '<tr>';
|
$output = '<table class="sp-player-list sp-data-table">' . '<thead>' . '<tr>';
|
||||||
|
|
||||||
@@ -62,25 +66,32 @@ if ( !function_exists( 'sportspress_player_list' ) ) {
|
|||||||
// Remove the first row to leave us with the actual data
|
// Remove the first row to leave us with the actual data
|
||||||
unset( $data[0] );
|
unset( $data[0] );
|
||||||
|
|
||||||
foreach( $labels as $label ):
|
$output .= '<th class="column-number">' . __( '#', 'sportspress' ) . '</th>';
|
||||||
$output .= '<th>' . $label . '</th>';
|
foreach( $labels as $key => $label ):
|
||||||
|
$output .= '<th class="column-' . ( $key ? $key : 'name' ) . '">' . $label . '</th>';
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
$output .= '</tr>' . '</th>' . '</thead>' . '<tbody>';
|
$output .= '</tr>' . '</th>' . '</thead>' . '<tbody>';
|
||||||
|
|
||||||
|
$i = 1;
|
||||||
|
|
||||||
foreach( $data as $player_id => $row ):
|
foreach( $data as $player_id => $row ):
|
||||||
|
|
||||||
$output .= '<tr>';
|
$output .= '<tr>';
|
||||||
|
|
||||||
|
// Player number
|
||||||
|
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||||
|
$output .= '<td class="column-number">' . ( $number ? $number : ' ' ) . '</td>';
|
||||||
|
|
||||||
// Name as link
|
// Name as link
|
||||||
$permalink = get_post_permalink( $player_id );
|
$permalink = get_post_permalink( $player_id );
|
||||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
$name = sportspress_array_value( $row, 'name', sportspress_array_value( $row, 'name', ' ' ) );
|
||||||
$output .= '<td>' . ( $number ? $number . '. ' : '' ) . '<a href="' . $permalink . '">' . sportspress_array_value( $row, 'name', ' ' ) . '</a></td>';
|
$output .= '<td class="column-name">' . '<a href="' . $permalink . '">' . $name . '</a></td>';
|
||||||
|
|
||||||
foreach( $labels as $key => $value ):
|
foreach( $labels as $key => $value ):
|
||||||
if ( $key == 'name' )
|
if ( $key == 'name' )
|
||||||
continue;
|
continue;
|
||||||
$output .= '<td>' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
$output .= '<td class="column-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
$output .= '</tr>';
|
$output .= '</tr>';
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ if ( !function_exists( 'add_action' ) ) {
|
|||||||
define( 'SPORTSPRESS_VERSION', '0.1.3' );
|
define( 'SPORTSPRESS_VERSION', '0.1.3' );
|
||||||
define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||||
define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
||||||
|
define( 'SPORTSPRESS_PLUGIN_FILE', __FILE__ );
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
include dirname( __FILE__ ) . '/lib/eos/eos.class.php' ;
|
include dirname( __FILE__ ) . '/lib/eos/eos.class.php' ;
|
||||||
@@ -71,44 +72,31 @@ include_once dirname( __FILE__ ) . '/admin/presets/tennis.php';
|
|||||||
include_once dirname( __FILE__ ) . '/admin/presets/volleyball.php';
|
include_once dirname( __FILE__ ) . '/admin/presets/volleyball.php';
|
||||||
|
|
||||||
// Typical request actions
|
// Typical request actions
|
||||||
require_once dirname( __FILE__ ) . '/admin/actions/plugins-loaded.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/plugins-loaded.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/actions/after-setup-theme.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/after-setup-theme.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/actions/wp-enqueue-scripts.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/wp-enqueue-scripts.php';
|
||||||
|
|
||||||
// Admin request actions
|
// Admin request actions
|
||||||
require_once dirname( __FILE__ ) . '/admin/actions/admin-menu.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/admin-menu.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/actions/admin-init.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/admin-init.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/actions/admin-enqueue-scripts.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/admin-enqueue-scripts.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/actions/admin-head.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/admin-head.php';
|
||||||
|
|
||||||
// Administrative actions
|
// Administrative actions
|
||||||
require_once dirname( __FILE__ ) . '/admin/actions/manage-posts-custom-column.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/manage-posts-custom-column.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/actions/post-thumbnail-html.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/post-thumbnail-html.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/actions/restrict-manage-posts.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/restrict-manage-posts.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/actions/save-post.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/save-post.php';
|
||||||
|
|
||||||
// Filters
|
// Filters
|
||||||
require_once dirname( __FILE__ ) . '/admin/filters/admin-post-thumbnail-html.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/admin-post-thumbnail-html.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/filters/gettext.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/gettext.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/filters/pre-get-posts.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/pre-get-posts.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/filters/sanitize-title.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/sanitize-title.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/filters/the-content.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/the-content.php';
|
||||||
require_once dirname( __FILE__ ) . '/admin/filters/wp-insert-post-data.php';
|
require_once dirname( __FILE__ ) . '/admin/hooks/wp-insert-post-data.php';
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/hooks/plugin-action-links.php';
|
||||||
|
|
||||||
|
// Register activation hook
|
||||||
|
require_once dirname( __FILE__ ) . '/admin/hooks/register-activation-hook.php';
|
||||||
|
|
||||||
// Flush rewrite rules on activation
|
|
||||||
function sportspress_rewrite_flush() {
|
|
||||||
sportspress_event_post_init();
|
|
||||||
sportspress_result_post_init();
|
|
||||||
sportspress_outcome_post_init();
|
|
||||||
sportspress_column_post_init();
|
|
||||||
sportspress_statistic_post_init();
|
|
||||||
sportspress_team_post_init();
|
|
||||||
sportspress_table_post_init();
|
|
||||||
sportspress_player_post_init();
|
|
||||||
sportspress_list_post_init();
|
|
||||||
sportspress_staff_post_init();
|
|
||||||
sportspress_position_term_init();
|
|
||||||
sportspress_season_term_init();
|
|
||||||
flush_rewrite_rules();
|
|
||||||
}
|
|
||||||
register_activation_hook( __FILE__, 'sportspress_rewrite_flush' );
|
|
||||||
Reference in New Issue
Block a user