Responsive tables and individual content filters
This commit is contained in:
@@ -18,20 +18,28 @@ function sportspress_admin_menu( $position ) {
|
||||
endif;
|
||||
|
||||
// Remove "Venues" and "Positions" links from Media submenu
|
||||
$submenu['upload.php'] = array_filter( $submenu['upload.php'], 'sportspress_admin_menu_remove_venues' );
|
||||
$submenu['upload.php'] = array_filter( $submenu['upload.php'], 'sportspress_admin_menu_remove_positions' );
|
||||
if ( isset( $submenu['upload.php'] ) ):
|
||||
$submenu['upload.php'] = array_filter( $submenu['upload.php'], 'sportspress_admin_menu_remove_venues' );
|
||||
$submenu['upload.php'] = array_filter( $submenu['upload.php'], 'sportspress_admin_menu_remove_positions' );
|
||||
endif;
|
||||
|
||||
// Remove "Leagues" and "Seasons" links from Events submenu
|
||||
$submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], 'sportspress_admin_menu_remove_leagues' );
|
||||
$submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], 'sportspress_admin_menu_remove_seasons' );
|
||||
if ( isset( $submenu['edit.php?post_type=sp_event'] ) ):
|
||||
$submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], 'sportspress_admin_menu_remove_leagues' );
|
||||
$submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], 'sportspress_admin_menu_remove_seasons' );
|
||||
endif;
|
||||
|
||||
// Remove "Leagues" and "Seasons" links from Players submenu
|
||||
$submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], 'sportspress_admin_menu_remove_leagues' );
|
||||
$submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], 'sportspress_admin_menu_remove_seasons' );
|
||||
if ( isset( $submenu['edit.php?post_type=sp_player'] ) ):
|
||||
$submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], 'sportspress_admin_menu_remove_leagues' );
|
||||
$submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], 'sportspress_admin_menu_remove_seasons' );
|
||||
endif;
|
||||
|
||||
// Remove "Leagues" and "Seasons" links from Staff submenu
|
||||
$submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], 'sportspress_admin_menu_remove_leagues' );
|
||||
$submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], 'sportspress_admin_menu_remove_seasons' );
|
||||
if ( isset( $submenu['edit.php?post_type=sp_staff'] ) ):
|
||||
$submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], 'sportspress_admin_menu_remove_leagues' );
|
||||
$submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], 'sportspress_admin_menu_remove_seasons' );
|
||||
endif;
|
||||
|
||||
}
|
||||
add_action( 'admin_menu', 'sportspress_admin_menu' );
|
||||
|
||||
@@ -1,119 +1,111 @@
|
||||
<?php
|
||||
function sportspress_activation_hook() {
|
||||
|
||||
$admin_capabilites = array(
|
||||
'read_sp_events',
|
||||
'read_private_sp_events',
|
||||
'edit_sp_event',
|
||||
'edit_sp_events',
|
||||
'edit_published_sp_events',
|
||||
'edit_private_sp_events',
|
||||
'edit_others_sp_events',
|
||||
'delete_sp_event',
|
||||
'delete_published_sp_events',
|
||||
'delete_private_sp_events',
|
||||
'delete_others_sp_events',
|
||||
'publish_sp_events',
|
||||
'read_sp_calendars',
|
||||
'read_private_sp_calendars',
|
||||
'edit_sp_calendar',
|
||||
'edit_sp_calendars',
|
||||
'edit_published_sp_calendars',
|
||||
'edit_private_sp_calendars',
|
||||
'edit_others_sp_calendars',
|
||||
'delete_sp_calendar',
|
||||
'delete_published_sp_calendars',
|
||||
'delete_private_sp_calendars',
|
||||
'delete_others_sp_calendars',
|
||||
'publish_sp_calendars',
|
||||
'read_sp_teams',
|
||||
'read_private_sp_teams',
|
||||
'edit_sp_team',
|
||||
'edit_sp_teams',
|
||||
'edit_published_sp_teams',
|
||||
'edit_private_sp_teams',
|
||||
'edit_others_sp_teams',
|
||||
'delete_sp_team',
|
||||
'delete_published_sp_teams',
|
||||
'delete_private_sp_teams',
|
||||
'delete_others_sp_teams',
|
||||
'publish_sp_teams',
|
||||
'read_sp_tables',
|
||||
'read_private_sp_tables',
|
||||
'edit_sp_table',
|
||||
'edit_sp_tables',
|
||||
'edit_published_sp_tables',
|
||||
'edit_private_sp_tables',
|
||||
'edit_others_sp_tables',
|
||||
'delete_sp_table',
|
||||
'delete_published_sp_tables',
|
||||
'delete_private_sp_tables',
|
||||
'delete_others_sp_tables',
|
||||
'publish_sp_tables',
|
||||
'read_sp_players',
|
||||
'read_private_sp_players',
|
||||
'edit_sp_player',
|
||||
'edit_sp_players',
|
||||
'edit_published_sp_players',
|
||||
'edit_private_sp_players',
|
||||
'edit_others_sp_players',
|
||||
'delete_sp_player',
|
||||
'delete_published_sp_players',
|
||||
'delete_private_sp_players',
|
||||
'delete_others_sp_players',
|
||||
'publish_sp_players',
|
||||
'read_sp_lists',
|
||||
'read_private_sp_lists',
|
||||
'edit_sp_list',
|
||||
'edit_sp_lists',
|
||||
'edit_published_sp_lists',
|
||||
'edit_private_sp_lists',
|
||||
'edit_others_sp_lists',
|
||||
'delete_sp_list',
|
||||
'delete_published_sp_lists',
|
||||
'delete_private_sp_lists',
|
||||
'delete_others_sp_lists',
|
||||
'publish_sp_lists',
|
||||
'read_sp_staffs',
|
||||
'read_private_sp_staffs',
|
||||
'edit_sp_staff',
|
||||
'edit_sp_staffs',
|
||||
'edit_published_sp_staffs',
|
||||
'edit_private_sp_staffs',
|
||||
'edit_others_sp_staffs',
|
||||
'delete_sp_staff',
|
||||
'delete_published_sp_staffs',
|
||||
'delete_private_sp_staffs',
|
||||
'delete_others_sp_staffs',
|
||||
'publish_sp_staffs',
|
||||
'read_sp_configs',
|
||||
'read_private_sp_configs',
|
||||
'edit_sp_config',
|
||||
'edit_sp_configs',
|
||||
'edit_published_sp_configs',
|
||||
'edit_private_sp_configs',
|
||||
'edit_others_sp_configs',
|
||||
'delete_sp_config',
|
||||
'delete_published_sp_configs',
|
||||
'delete_private_sp_configs',
|
||||
'delete_others_sp_configs',
|
||||
'publish_sp_configs',
|
||||
);
|
||||
|
||||
// Site Admin
|
||||
$role = get_role( 'administrator' );
|
||||
|
||||
// Events
|
||||
$role->add_cap( 'read_sp_events' );
|
||||
$role->add_cap( 'read_private_sp_events' );
|
||||
$role->add_cap( 'edit_sp_event' );
|
||||
$role->add_cap( 'edit_sp_events' );
|
||||
$role->add_cap( 'edit_published_sp_events' );
|
||||
$role->add_cap( 'edit_private_sp_events' );
|
||||
$role->add_cap( 'edit_others_sp_events' );
|
||||
$role->add_cap( 'delete_sp_event' );
|
||||
$role->add_cap( 'delete_published_sp_events' );
|
||||
$role->add_cap( 'delete_private_sp_events' );
|
||||
$role->add_cap( 'delete_others_sp_events' );
|
||||
$role->add_cap( 'publish_sp_events' );
|
||||
|
||||
// Calendars
|
||||
$role->add_cap( 'read_sp_calendars' );
|
||||
$role->add_cap( 'read_private_sp_calendars' );
|
||||
$role->add_cap( 'edit_sp_calendar' );
|
||||
$role->add_cap( 'edit_sp_calendars' );
|
||||
$role->add_cap( 'edit_published_sp_calendars' );
|
||||
$role->add_cap( 'edit_private_sp_calendars' );
|
||||
$role->add_cap( 'edit_others_sp_calendars' );
|
||||
$role->add_cap( 'delete_sp_calendar' );
|
||||
$role->add_cap( 'delete_published_sp_calendars' );
|
||||
$role->add_cap( 'delete_private_sp_calendars' );
|
||||
$role->add_cap( 'delete_others_sp_calendars' );
|
||||
$role->add_cap( 'publish_sp_calendars' );
|
||||
|
||||
// Teams
|
||||
$role->add_cap( 'read_sp_teams' );
|
||||
$role->add_cap( 'read_private_sp_teams' );
|
||||
$role->add_cap( 'edit_sp_team' );
|
||||
$role->add_cap( 'edit_sp_teams' );
|
||||
$role->add_cap( 'edit_published_sp_teams' );
|
||||
$role->add_cap( 'edit_private_sp_teams' );
|
||||
$role->add_cap( 'edit_others_sp_teams' );
|
||||
$role->add_cap( 'delete_sp_team' );
|
||||
$role->add_cap( 'delete_published_sp_teams' );
|
||||
$role->add_cap( 'delete_private_sp_teams' );
|
||||
$role->add_cap( 'delete_others_sp_teams' );
|
||||
$role->add_cap( 'publish_sp_teams' );
|
||||
|
||||
// League Tables
|
||||
$role->add_cap( 'read_sp_tables' );
|
||||
$role->add_cap( 'read_private_sp_tables' );
|
||||
$role->add_cap( 'edit_sp_table' );
|
||||
$role->add_cap( 'edit_sp_tables' );
|
||||
$role->add_cap( 'edit_published_sp_tables' );
|
||||
$role->add_cap( 'edit_private_sp_tables' );
|
||||
$role->add_cap( 'edit_others_sp_tables' );
|
||||
$role->add_cap( 'delete_sp_table' );
|
||||
$role->add_cap( 'delete_published_sp_tables' );
|
||||
$role->add_cap( 'delete_private_sp_tables' );
|
||||
$role->add_cap( 'delete_others_sp_tables' );
|
||||
$role->add_cap( 'publish_sp_tables' );
|
||||
|
||||
// Players
|
||||
$role->add_cap( 'read_sp_players' );
|
||||
$role->add_cap( 'read_private_sp_players' );
|
||||
$role->add_cap( 'edit_sp_player' );
|
||||
$role->add_cap( 'edit_sp_players' );
|
||||
$role->add_cap( 'edit_published_sp_players' );
|
||||
$role->add_cap( 'edit_private_sp_players' );
|
||||
$role->add_cap( 'edit_others_sp_players' );
|
||||
$role->add_cap( 'delete_sp_player' );
|
||||
$role->add_cap( 'delete_published_sp_players' );
|
||||
$role->add_cap( 'delete_private_sp_players' );
|
||||
$role->add_cap( 'delete_others_sp_players' );
|
||||
$role->add_cap( 'publish_sp_players' );
|
||||
|
||||
// Player Lists
|
||||
$role->add_cap( 'read_sp_lists' );
|
||||
$role->add_cap( 'read_private_sp_lists' );
|
||||
$role->add_cap( 'edit_sp_list' );
|
||||
$role->add_cap( 'edit_sp_lists' );
|
||||
$role->add_cap( 'edit_published_sp_lists' );
|
||||
$role->add_cap( 'edit_private_sp_lists' );
|
||||
$role->add_cap( 'edit_others_sp_lists' );
|
||||
$role->add_cap( 'delete_sp_list' );
|
||||
$role->add_cap( 'delete_published_sp_lists' );
|
||||
$role->add_cap( 'delete_private_sp_lists' );
|
||||
$role->add_cap( 'delete_others_sp_lists' );
|
||||
$role->add_cap( 'publish_sp_lists' );
|
||||
|
||||
// Staff
|
||||
$role->add_cap( 'read_sp_staffs' );
|
||||
$role->add_cap( 'read_private_sp_staffs' );
|
||||
$role->add_cap( 'edit_sp_staff' );
|
||||
$role->add_cap( 'edit_sp_staffs' );
|
||||
$role->add_cap( 'edit_published_sp_staffs' );
|
||||
$role->add_cap( 'edit_private_sp_staffs' );
|
||||
$role->add_cap( 'edit_others_sp_staffs' );
|
||||
$role->add_cap( 'delete_sp_staff' );
|
||||
$role->add_cap( 'delete_published_sp_staffs' );
|
||||
$role->add_cap( 'delete_private_sp_staffs' );
|
||||
$role->add_cap( 'delete_others_sp_staffs' );
|
||||
$role->add_cap( 'publish_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' );
|
||||
foreach( $admin_capabilities as $capability ):
|
||||
$role->add_cap( $capability );
|
||||
endforeach;
|
||||
|
||||
// Team Manager
|
||||
remove_role( 'sp_team_manager' );
|
||||
|
||||
@@ -1,66 +1,68 @@
|
||||
<?php
|
||||
function sportspress_the_content( $content ) {
|
||||
sportspress_set_post_views( get_the_ID() );
|
||||
|
||||
if ( is_singular( 'sp_event' ) && in_the_loop() ):
|
||||
$content = apply_filters( 'sportspress_event_content', $content );
|
||||
elseif ( is_singular( 'sp_calendar' ) && in_the_loop() ):
|
||||
$content = apply_filters( 'sportspress_calendar_content', $content );
|
||||
elseif ( is_singular( 'sp_team' ) && in_the_loop() ):
|
||||
$content = apply_filters( 'sportspress_team_content', $content );
|
||||
elseif ( is_singular( 'sp_table' ) && in_the_loop() ):
|
||||
$content = apply_filters( 'sportspress_table_content', $content );
|
||||
elseif ( is_singular( 'sp_list' ) && in_the_loop() ):
|
||||
$content = apply_filters( 'sportspress_list_content', $content );
|
||||
elseif ( is_singular( 'sp_player' ) && in_the_loop() ):
|
||||
$content = apply_filters( 'sportspress_player_content', $content );
|
||||
endif;
|
||||
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'the_content', 'sportspress_the_content' );
|
||||
add_filter( 'get_the_content', 'sportspress_the_content' );
|
||||
|
||||
function sportspress_default_event_content( $content ) {
|
||||
$details = sportspress_event_details();
|
||||
$results = sportspress_event_results();
|
||||
$players = sportspress_event_players();
|
||||
$staff = sportspress_event_staff();
|
||||
if ( ! empty( $results ) )
|
||||
return $results . $details . $players . $staff . $content;
|
||||
$venue = sportspress_event_venue();
|
||||
return $details . $venue . $players . $staff . $content;
|
||||
if ( is_singular( 'sp_event' ) && in_the_loop() ):
|
||||
$details = sportspress_event_details();
|
||||
$results = sportspress_event_results();
|
||||
$players = sportspress_event_players();
|
||||
$staff = sportspress_event_staff();
|
||||
if ( ! empty( $results ) )
|
||||
return $results . $details . $players . $staff . $content;
|
||||
$venue = sportspress_event_venue();
|
||||
$content = $details . $venue . $players . $staff . $content;
|
||||
endif;
|
||||
}
|
||||
add_filter( 'sportspress_event_content', 'sportspress_default_event_content' );
|
||||
add_filter( 'the_content', 'sportspress_default_event_content' );
|
||||
|
||||
function sportspress_default_calendar_content( $content ) {
|
||||
if ( is_singular( 'sp_calendar' ) && in_the_loop() ):
|
||||
$calendar = sportspress_events_calendar();
|
||||
return $calendar . $content;
|
||||
$content = $calendar . $content;
|
||||
endif;
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'sportspress_calendar_content', 'sportspress_default_calendar_content' );
|
||||
add_filter( 'the_content', 'sportspress_default_calendar_content' );
|
||||
|
||||
function sportspress_default_team_content( $content ) {
|
||||
$columns = sportspress_team_columns();
|
||||
return $content . $columns;
|
||||
if ( is_singular( 'sp_team' ) && in_the_loop() ):
|
||||
$columns = sportspress_team_columns();
|
||||
$content = $content . $columns;
|
||||
endif;
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'sportspress_team_content', 'sportspress_default_team_content' );
|
||||
add_filter( 'the_content', 'sportspress_default_team_content' );
|
||||
|
||||
function sportspress_default_table_content( $content ) {
|
||||
$table = sportspress_league_table();
|
||||
$excerpt = has_excerpt() ? wpautop( get_the_excerpt() ) : '';
|
||||
return $table . $content . $excerpt;
|
||||
if ( is_singular( 'sp_table' ) && in_the_loop() ):
|
||||
$table = sportspress_league_table();
|
||||
$excerpt = has_excerpt() ? wpautop( get_the_excerpt() ) : '';
|
||||
$content = $table . $content . $excerpt;
|
||||
endif;
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'sportspress_table_content', 'sportspress_default_table_content' );
|
||||
add_filter( 'the_content', 'sportspress_default_table_content' );
|
||||
|
||||
function sportspress_default_player_content( $content ) {
|
||||
$metrics = sportspress_player_metrics();
|
||||
$statistics = sportspress_player_statistics();
|
||||
return $metrics . $statistics . $content;
|
||||
if ( is_singular( 'sp_list' ) && in_the_loop() ):
|
||||
$metrics = sportspress_player_metrics();
|
||||
$statistics = sportspress_player_statistics();
|
||||
$content = $metrics . $statistics . $content;
|
||||
endif;
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'sportspress_player_content', 'sportspress_default_player_content' );
|
||||
add_filter( 'the_content', 'sportspress_default_player_content' );
|
||||
|
||||
function sportspress_default_list_content( $content ) {
|
||||
$list = sportspress_player_list( get_the_ID() );
|
||||
return $list . $content;
|
||||
if ( is_singular( 'sp_player' ) && in_the_loop() ):
|
||||
$list = sportspress_player_list( get_the_ID() );
|
||||
$content = $list . $content;
|
||||
endif;
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'sportspress_list_content', 'sportspress_default_list_content' );
|
||||
add_filter( 'the_content', 'sportspress_default_list_content' );
|
||||
|
||||
Reference in New Issue
Block a user