Modularize!
This commit is contained in:
@@ -6,30 +6,37 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#dashboard_right_now .sp-event-count a:before,
|
#dashboard_right_now .sp_event-count a:before,
|
||||||
#dashboard_right_now .sp-event-count span:before,
|
#dashboard_right_now .sp_event-count span:before,
|
||||||
#dashboard_right_now .sp-team-count a:before,
|
#dashboard_right_now .sp_team-count a:before,
|
||||||
#dashboard_right_now .sp-team-count span:before,
|
#dashboard_right_now .sp_team-count span:before,
|
||||||
#dashboard_right_now .sp-player-count a:before,
|
#dashboard_right_now .sp_player-count a:before,
|
||||||
#dashboard_right_now .sp-player-count span:before {
|
#dashboard_right_now .sp_player-count span:before,
|
||||||
|
#dashboard_right_now .sp_staff-count a:before,
|
||||||
|
#dashboard_right_now .sp_staff-count span:before {
|
||||||
font-family: 'sportspress';
|
font-family: 'sportspress';
|
||||||
}
|
}
|
||||||
|
|
||||||
#dashboard_right_now .sp-event-count a:before,
|
#dashboard_right_now .sp_event-count a:before,
|
||||||
#dashboard_right_now .sp-event-count span:before {
|
#dashboard_right_now .sp_event-count span:before {
|
||||||
content: "\f145";
|
content: "\f145";
|
||||||
}
|
}
|
||||||
|
|
||||||
#dashboard_right_now .sp-team-count a:before,
|
#dashboard_right_now .sp_team-count a:before,
|
||||||
#dashboard_right_now .sp-team-count span:before {
|
#dashboard_right_now .sp_team-count span:before {
|
||||||
content: "\f334";
|
content: "\f334";
|
||||||
}
|
}
|
||||||
|
|
||||||
#dashboard_right_now .sp-player-count a:before,
|
#dashboard_right_now .sp_player-count a:before,
|
||||||
#dashboard_right_now .sp-player-count span:before {
|
#dashboard_right_now .sp_player-count span:before {
|
||||||
content: "\f307";
|
content: "\f307";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#dashboard_right_now .sp_staff-count a:before,
|
||||||
|
#dashboard_right_now .sp_staff-count span:before {
|
||||||
|
content: "\f338";
|
||||||
|
}
|
||||||
|
|
||||||
#sportspress_dashboard_status .sp_status_list {
|
#sportspress_dashboard_status .sp_status_list {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|||||||
@@ -11,12 +11,6 @@ $options = array(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( 'yes' == get_option( 'sportspress_load_calendars_module', 'yes' ) ) {
|
|
||||||
$options['event'][] = 'calendar';
|
|
||||||
$options['event'][] = 'list';
|
|
||||||
$options['event'][] = 'blocks';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) {
|
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) {
|
||||||
$options['table'] = array( 'table' );
|
$options['table'] = array( 'table' );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class SP_Admin_Dashboard {
|
|||||||
* Add links to At a Glance
|
* Add links to At a Glance
|
||||||
*/
|
*/
|
||||||
function glance_items( $items = array() ) {
|
function glance_items( $items = array() ) {
|
||||||
$post_types = array( 'sp_event', 'sp_team', 'sp_player' );
|
$post_types = apply_filters( 'sportspress_glance_items', array( 'sp_event', 'sp_team', 'sp_player', 'sp_staff' ) );
|
||||||
foreach ( $post_types as $type ):
|
foreach ( $post_types as $type ):
|
||||||
if ( ! post_type_exists( $type ) ) continue;
|
if ( ! post_type_exists( $type ) ) continue;
|
||||||
$num_posts = wp_count_posts( $type );
|
$num_posts = wp_count_posts( $type );
|
||||||
@@ -49,12 +49,11 @@ class SP_Admin_Dashboard {
|
|||||||
$text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'sportspress' );
|
$text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'sportspress' );
|
||||||
$text = sprintf( $text, number_format_i18n( $published ) );
|
$text = sprintf( $text, number_format_i18n( $published ) );
|
||||||
if ( current_user_can( $post_type->cap->edit_posts ) ):
|
if ( current_user_can( $post_type->cap->edit_posts ) ):
|
||||||
$output = '<a href="edit.php?post_type=' . $post_type->name . '">' . $text . '</a>';
|
$output = '<a href="edit.php?post_type=' . $post_type->name . '">' . $text . '</a>';
|
||||||
echo '<li class="post-count ' . str_replace( '_', '-', $post_type->name ) . '-count">' . $output . '</li>';
|
|
||||||
else:
|
else:
|
||||||
$output = '<span>' . $text . '</span>';
|
$output = '<span>' . $text . '</span>';
|
||||||
echo '<li class="post-count ' . str_replace( '_', '-', $post_type->name ) . '-count">' . $output . '</li>';
|
|
||||||
endif;
|
endif;
|
||||||
|
echo '<li class="post-count ' . $post_type->name . '-count">' . $output . '</li>';
|
||||||
endif;
|
endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
return $items;
|
return $items;
|
||||||
|
|||||||
@@ -28,12 +28,32 @@ class SP_Admin_Importers {
|
|||||||
* Add menu items
|
* Add menu items
|
||||||
*/
|
*/
|
||||||
public function register_importers() {
|
public function register_importers() {
|
||||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
$importers = apply_filters( 'sportspress_importers', array(
|
||||||
register_importer( 'sp_event_csv', __( 'SportsPress Events (CSV)', 'sportspress' ), __( 'Import <strong>events</strong> from a csv file.', 'sportspress'), array( $this, 'events_importer' ) );
|
'sp_event_csv' => array(
|
||||||
register_importer( 'sp_team_csv', __( 'SportsPress Teams (CSV)', 'sportspress' ), __( 'Import <strong>teams</strong> from a csv file.', 'sportspress'), array( $this, 'teams_importer' ) );
|
'name' => __( 'SportsPress Events (CSV)', 'sportspress' ),
|
||||||
|
'description' => __( 'Import <strong>events</strong> from a csv file.', 'sportspress'),
|
||||||
|
'callback' => array( $this, 'events_importer' ),
|
||||||
|
),
|
||||||
|
'sp_team_csv' => array(
|
||||||
|
'name' => __( 'SportsPress Teams (CSV)', 'sportspress' ),
|
||||||
|
'description' => __( 'Import <strong>teams</strong> from a csv file.', 'sportspress'),
|
||||||
|
'callback' => array( $this, 'teams_importer' ),
|
||||||
|
),
|
||||||
|
'sp_player_csv' => array(
|
||||||
|
'name' => __( 'SportsPress Players (CSV)', 'sportspress' ),
|
||||||
|
'description' => __( 'Import <strong>players</strong> from a csv file.', 'sportspress'),
|
||||||
|
'callback' => array( $this, 'players_importer' ),
|
||||||
|
),
|
||||||
|
'sp_staff_csv' => array(
|
||||||
|
'name' => __( 'SportsPress Staff (CSV)', 'sportspress' ),
|
||||||
|
'description' => __( 'Import <strong>staff</strong> from a csv file.', 'sportspress'),
|
||||||
|
'callback' => array( $this, 'staff_importer' ),
|
||||||
|
),
|
||||||
|
) );
|
||||||
|
|
||||||
|
foreach ( $importers as $id => $importer ) {
|
||||||
|
register_importer( $id, $importer['name'], $importer['description'], $importer['callback'] );
|
||||||
}
|
}
|
||||||
register_importer( 'sp_player_csv', __( 'SportsPress Players (CSV)', 'sportspress' ), __( 'Import <strong>players</strong> from a csv file.', 'sportspress'), array( $this, 'players_importer' ) );
|
|
||||||
register_importer( 'sp_staff_csv', __( 'SportsPress Staff (CSV)', 'sportspress' ), __( 'Import <strong>staff</strong> from a csv file.', 'sportspress'), array( $this, 'staff_importer' ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -85,16 +85,17 @@ class SP_Admin_Menus {
|
|||||||
public function menu_highlight() {
|
public function menu_highlight() {
|
||||||
global $typenow;
|
global $typenow;
|
||||||
$screen = get_current_screen();
|
$screen = get_current_screen();
|
||||||
if ( $screen->id == 'sp_role' )
|
if ( $screen->id == 'sp_role' ) {
|
||||||
$this->highlight_admin_menu( 'edit.php?post_type=sp_staff', 'edit-tags.php?taxonomy=sp_role&post_type=sp_staff' );
|
$this->highlight_admin_menu( 'edit.php?post_type=sp_staff', 'edit-tags.php?taxonomy=sp_role&post_type=sp_staff' );
|
||||||
elseif ( is_sp_config_type( $typenow ) )
|
} elseif ( is_sp_config_type( $typenow ) ) {
|
||||||
$this->highlight_admin_menu( 'sportspress', 'sportspress-config' );
|
$this->highlight_admin_menu( 'sportspress', 'sportspress-config' );
|
||||||
elseif ( $typenow == 'sp_calendar' )
|
} elseif ( $typenow == 'sp_calendar' ) {
|
||||||
$this->highlight_admin_menu( 'edit.php?post_type=sp_event', 'edit.php?post_type=sp_calendar' );
|
$this->highlight_admin_menu( 'edit.php?post_type=sp_event', 'edit.php?post_type=sp_calendar' );
|
||||||
elseif ( $typenow == 'sp_table' )
|
} elseif ( $typenow == 'sp_table' ) {
|
||||||
$this->highlight_admin_menu( 'edit.php?post_type=sp_team', 'edit.php?post_type=sp_table' );
|
$this->highlight_admin_menu( 'edit.php?post_type=sp_team', 'edit.php?post_type=sp_table' );
|
||||||
elseif ( $typenow == 'sp_list' )
|
} elseif ( $typenow == 'sp_list' ) {
|
||||||
$this->highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_list' );
|
$this->highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_list' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -30,23 +30,21 @@ class SP_Admin_Post_Types {
|
|||||||
* Conditonally load classes and functions only needed when viewing a post type.
|
* Conditonally load classes and functions only needed when viewing a post type.
|
||||||
*/
|
*/
|
||||||
public function include_post_type_handlers() {
|
public function include_post_type_handlers() {
|
||||||
include( 'post-types/class-sp-admin-meta-boxes.php' );
|
include_once( 'post-types/class-sp-admin-meta-boxes.php' );
|
||||||
include( 'post-types/class-sp-admin-cpt-result.php' );
|
include_once( 'post-types/class-sp-admin-cpt-result.php' );
|
||||||
include( 'post-types/class-sp-admin-cpt-outcome.php' );
|
include_once( 'post-types/class-sp-admin-cpt-outcome.php' );
|
||||||
include( 'post-types/class-sp-admin-cpt-performance.php' );
|
include_once( 'post-types/class-sp-admin-cpt-performance.php' );
|
||||||
include( 'post-types/class-sp-admin-cpt-column.php' );
|
include_once( 'post-types/class-sp-admin-cpt-column.php' );
|
||||||
include( 'post-types/class-sp-admin-cpt-metric.php' );
|
include_once( 'post-types/class-sp-admin-cpt-metric.php' );
|
||||||
include( 'post-types/class-sp-admin-cpt-statistic.php' );
|
include_once( 'post-types/class-sp-admin-cpt-statistic.php' );
|
||||||
include( 'post-types/class-sp-admin-cpt-event.php' );
|
include_once( 'post-types/class-sp-admin-cpt-event.php' );
|
||||||
if ( 'yes' == get_option( 'sportspress_load_calendars_module', 'yes' ) )
|
include_once( 'post-types/class-sp-admin-cpt-team.php' );
|
||||||
include( 'post-types/class-sp-admin-cpt-calendar.php' );
|
|
||||||
include( 'post-types/class-sp-admin-cpt-team.php' );
|
|
||||||
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) )
|
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) )
|
||||||
include( 'post-types/class-sp-admin-cpt-table.php' );
|
include_once( 'post-types/class-sp-admin-cpt-table.php' );
|
||||||
include( 'post-types/class-sp-admin-cpt-player.php' );
|
include_once( 'post-types/class-sp-admin-cpt-player.php' );
|
||||||
if ( 'yes' == get_option( 'sportspress_load_player_lists_module', 'yes' ) )
|
if ( 'yes' == get_option( 'sportspress_load_player_lists_module', 'yes' ) )
|
||||||
include( 'post-types/class-sp-admin-cpt-list.php' );
|
include_once( 'post-types/class-sp-admin-cpt-list.php' );
|
||||||
include( 'post-types/class-sp-admin-cpt-staff.php' );
|
include_once( 'post-types/class-sp-admin-cpt-staff.php' );
|
||||||
do_action( 'sportspress_include_post_type_handlers' );
|
do_action( 'sportspress_include_post_type_handlers' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,40 +128,6 @@ class SP_Admin_Sample_Data {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
|
||||||
* Insert teams
|
|
||||||
*/
|
|
||||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
|
||||||
foreach ( $teams as $index => $team ) {
|
|
||||||
$post['post_title'] = $team['name'];
|
|
||||||
$post['post_type'] = 'sp_team';
|
|
||||||
$post['post_status'] = 'publish';
|
|
||||||
$post['post_content'] = sprintf( $sample_content, __( 'Team', 'sportspress' ), __( 'Teams', 'sportspress' ), admin_url() );
|
|
||||||
|
|
||||||
// Terms
|
|
||||||
$post['tax_input'] = array();
|
|
||||||
$taxonomies = array( 'sp_league', 'sp_season' );
|
|
||||||
foreach ( $taxonomies as $taxonomy ) {
|
|
||||||
$post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids' ) );
|
|
||||||
};
|
|
||||||
|
|
||||||
$post['tax_input']['sp_venue'] = get_terms( 'sp_venue', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1, 'offset' => $index ) );
|
|
||||||
|
|
||||||
// Insert post
|
|
||||||
$id = wp_insert_post( $post );
|
|
||||||
|
|
||||||
// Add to inserted ids array
|
|
||||||
$inserted_ids['sp_team'][] = $id;
|
|
||||||
|
|
||||||
// Flag as sample
|
|
||||||
update_post_meta( $id, '_sp_sample', 1 );
|
|
||||||
|
|
||||||
// Update meta
|
|
||||||
update_post_meta( $id, 'sp_abbreviation', $team['abbreviation'] );
|
|
||||||
update_post_meta( $id, 'sp_url', $team['url'] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define players
|
// Define players
|
||||||
$players = array(
|
$players = array(
|
||||||
'Mario Bellucci',
|
'Mario Bellucci',
|
||||||
@@ -193,6 +159,38 @@ class SP_Admin_Sample_Data {
|
|||||||
// Get countries
|
// Get countries
|
||||||
$countries = new SP_Countries();
|
$countries = new SP_Countries();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insert teams
|
||||||
|
*/
|
||||||
|
foreach ( $teams as $index => $team ) {
|
||||||
|
$post['post_title'] = $team['name'];
|
||||||
|
$post['post_type'] = 'sp_team';
|
||||||
|
$post['post_status'] = 'publish';
|
||||||
|
$post['post_content'] = sprintf( $sample_content, __( 'Team', 'sportspress' ), __( 'Teams', 'sportspress' ), admin_url() );
|
||||||
|
|
||||||
|
// Terms
|
||||||
|
$post['tax_input'] = array();
|
||||||
|
$taxonomies = array( 'sp_league', 'sp_season' );
|
||||||
|
foreach ( $taxonomies as $taxonomy ) {
|
||||||
|
$post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids' ) );
|
||||||
|
};
|
||||||
|
|
||||||
|
$post['tax_input']['sp_venue'] = get_terms( 'sp_venue', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1, 'offset' => $index ) );
|
||||||
|
|
||||||
|
// Insert post
|
||||||
|
$id = wp_insert_post( $post );
|
||||||
|
|
||||||
|
// Add to inserted ids array
|
||||||
|
$inserted_ids['sp_team'][] = $id;
|
||||||
|
|
||||||
|
// Flag as sample
|
||||||
|
update_post_meta( $id, '_sp_sample', 1 );
|
||||||
|
|
||||||
|
// Update meta
|
||||||
|
update_post_meta( $id, 'sp_abbreviation', $team['abbreviation'] );
|
||||||
|
update_post_meta( $id, 'sp_url', $team['url'] );
|
||||||
|
}
|
||||||
|
|
||||||
// Get columns
|
// Get columns
|
||||||
$columns = array( 'team' );
|
$columns = array( 'team' );
|
||||||
$args = array(
|
$args = array(
|
||||||
@@ -347,175 +345,31 @@ class SP_Admin_Sample_Data {
|
|||||||
/*
|
/*
|
||||||
* Insert events
|
* Insert events
|
||||||
*/
|
*/
|
||||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
for ( $index = 0; $index < 6; $index ++ ) {
|
||||||
for ( $index = 0; $index < 6; $index ++ ) {
|
// Determine team index and post status
|
||||||
// Determine team index and post status
|
$i = $index % 3;
|
||||||
$i = $index % 3;
|
if ( $index < 3 ) {
|
||||||
if ( $index < 3 ) {
|
$post_status = 'publish';
|
||||||
$post_status = 'publish';
|
$post_year = $current_year - 1;
|
||||||
$post_year = $current_year - 1;
|
$event_season = get_terms( 'sp_season', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) );
|
||||||
$event_season = get_terms( 'sp_season', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) );
|
} else {
|
||||||
} else {
|
$post_status = 'future';
|
||||||
$post_status = 'future';
|
$post_year = $current_year + 1;
|
||||||
$post_year = $current_year + 1;
|
$event_season = get_terms( 'sp_season', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'DESC', 'number' => 1 ) );
|
||||||
$event_season = get_terms( 'sp_season', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'DESC', 'number' => 1 ) );
|
|
||||||
}
|
|
||||||
// The away team should be the next inserted team, or the first if this is the last event
|
|
||||||
if ( $i == 2 ) $away_index = 0;
|
|
||||||
else $away_index = $i + 1;
|
|
||||||
$post = array(
|
|
||||||
'post_title' => $teams[ $i ]['name'] . ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ' . $teams[ $away_index ]['name'],
|
|
||||||
'post_type' => 'sp_event',
|
|
||||||
'post_status' => $post_status,
|
|
||||||
'post_content' => sprintf( $sample_content, __( 'Event', 'sportspress' ), __( 'Events', 'sportspress' ), admin_url() ),
|
|
||||||
'post_date' => $post_year . '-' . sprintf( '%02d', 3 + $i * 3 ) . '-' . sprintf( '%02d', 5 + $i * 10 ) . ' ' . ( 18 + $i ) . ':00:00',
|
|
||||||
'tax_input' => array(
|
|
||||||
'sp_league' => get_terms( 'sp_league', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) ),
|
|
||||||
'sp_season' => $event_season,
|
|
||||||
'sp_venue' => get_terms( 'sp_venue', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1, 'offset' => $i ) ),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Insert post
|
|
||||||
$id = wp_insert_post( $post );
|
|
||||||
|
|
||||||
// Add to inserted ids array
|
|
||||||
$inserted_ids['sp_event'][] = $id;
|
|
||||||
|
|
||||||
// Flag as sample
|
|
||||||
update_post_meta( $id, '_sp_sample', 1 );
|
|
||||||
|
|
||||||
// Calculate home and away team ids
|
|
||||||
$home_team_index = ( $i ) % 3;
|
|
||||||
$away_team_index = ( $i + 1 ) % 3;
|
|
||||||
$home_team_id = sp_array_value( $inserted_ids['sp_team'], $home_team_index, 0 );
|
|
||||||
$away_team_id = sp_array_value( $inserted_ids['sp_team'], $away_team_index, 0 );
|
|
||||||
$event_teams = array(
|
|
||||||
$home_team_id,
|
|
||||||
$away_team_id,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Initialize meta
|
|
||||||
$event_players = array( 0 );
|
|
||||||
$performance = $results = array();
|
|
||||||
|
|
||||||
if ( $home_team_id ) {
|
|
||||||
// Add home team player performance
|
|
||||||
$performance[ $home_team_id ] = array();
|
|
||||||
for ( $j = 0; $j < 4; $j ++ ) {
|
|
||||||
$player_id = sp_array_value( $inserted_ids['sp_player'], $home_team_index * 4 + $j );
|
|
||||||
$event_players[] = $player_id;
|
|
||||||
$player_performance = array();
|
|
||||||
foreach ( $performance_posts as $performance_post ) {
|
|
||||||
$player_performance[ $performance_post->post_name ] = rand( 0, 1 );
|
|
||||||
}
|
|
||||||
$performance[ $home_team_id ][ $player_id ] = $player_performance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add home team results
|
|
||||||
$results[ $home_team_id ] = array();
|
|
||||||
foreach ( $result_posts as $result_post_index => $result_post ) {
|
|
||||||
$results[ $home_team_id ][ $result_post->post_name ] = 1 + $result_post_index;
|
|
||||||
}
|
|
||||||
$outcome = reset( $outcome_posts );
|
|
||||||
if ( is_object( $outcome ) ) $results[ $home_team_id ]['outcome'] = array( $outcome->post_name );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Separate teams with zero
|
|
||||||
$event_players[] = 0;
|
|
||||||
|
|
||||||
if ( $away_team_id ) {
|
|
||||||
$performance[ $away_team_id ] = array();
|
|
||||||
for ( $j = 0; $j < 4; $j ++ ) {
|
|
||||||
$player_id = sp_array_value( $inserted_ids['sp_player'], $away_team_index * 4 + $j );
|
|
||||||
$event_players[] = $player_id;
|
|
||||||
$player_performance = array();
|
|
||||||
foreach ( $performance_posts as $performance_post ) {
|
|
||||||
$player_performance[ $performance_post->post_name ] = rand( 0, 1 );
|
|
||||||
}
|
|
||||||
$performance[ $away_team_id ][ $player_id ] = $player_performance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add away team results
|
|
||||||
$results[ $away_team_id ] = array();
|
|
||||||
foreach ( $result_posts as $result_post ) {
|
|
||||||
$results[ $away_team_id ][ $result_post->post_name ] = '0';
|
|
||||||
}
|
|
||||||
$outcome = next( $outcome_posts );
|
|
||||||
if ( is_object( $outcome ) ) $results[ $away_team_id ]['outcome'] = array( $outcome->post_name );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( 'publish' === $post_status ) {
|
|
||||||
// Swap results for last event only
|
|
||||||
if ( $i == 2 ) {
|
|
||||||
$k = array_keys( $results );
|
|
||||||
$v = array_values( $results );
|
|
||||||
$rv = array_reverse( $v );
|
|
||||||
$results = array_combine( $k, $rv );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update future post meta
|
|
||||||
update_post_meta( $id, 'sp_players', $performance );
|
|
||||||
update_post_meta( $id, 'sp_results', $results );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update general meta
|
|
||||||
sp_update_post_meta_recursive( $id, 'sp_team', $event_teams );
|
|
||||||
sp_update_post_meta_recursive( $id, 'sp_player', $event_players );
|
|
||||||
update_post_meta( $id, 'sp_columns', $columns );
|
|
||||||
update_post_meta( $id, 'sp_format', 'league' );
|
|
||||||
update_post_meta( $id, 'sp_video', $event_videos[ $i ] );
|
|
||||||
}
|
}
|
||||||
}
|
// The away team should be the next inserted team, or the first if this is the last event
|
||||||
|
if ( $i == 2 ) $away_index = 0;
|
||||||
/*
|
else $away_index = $i + 1;
|
||||||
* Insert calendar
|
|
||||||
*/
|
|
||||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
|
||||||
$post = array(
|
$post = array(
|
||||||
'post_title' => _x( 'Fixtures & Results', 'example', 'sportspress' ),
|
'post_title' => $teams[ $i ]['name'] . ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ' . $teams[ $away_index ]['name'],
|
||||||
'post_type' => 'sp_calendar',
|
'post_type' => 'sp_event',
|
||||||
'post_status' => 'publish',
|
'post_status' => $post_status,
|
||||||
'post_content' => sprintf( $sample_content, __( 'Calendar', 'sportspress' ), __( 'Calendars', 'sportspress' ), admin_url() )
|
'post_content' => sprintf( $sample_content, __( 'Event', 'sportspress' ), __( 'Events', 'sportspress' ), admin_url() ),
|
||||||
);
|
'post_date' => $post_year . '-' . sprintf( '%02d', 3 + $i * 3 ) . '-' . sprintf( '%02d', 5 + $i * 10 ) . ' ' . ( 18 + $i ) . ':00:00',
|
||||||
|
|
||||||
// Insert post
|
|
||||||
$id = wp_insert_post( $post );
|
|
||||||
|
|
||||||
// Add to inserted ids array
|
|
||||||
$inserted_ids['sp_calendar'][] = $id;
|
|
||||||
|
|
||||||
// Flag as sample
|
|
||||||
update_post_meta( $id, '_sp_sample', 1 );
|
|
||||||
|
|
||||||
// Define columns
|
|
||||||
$columns = array( 'event', 'time', 'article' );
|
|
||||||
|
|
||||||
// Update meta
|
|
||||||
update_post_meta( $id, 'sp_format', 'list' );
|
|
||||||
update_post_meta( $id, 'sp_status', 'any' );
|
|
||||||
update_post_meta( $id, 'sp_date', 0 );
|
|
||||||
update_post_meta( $id, 'sp_team', 0 );
|
|
||||||
update_post_meta( $id, 'sp_order', 'ASC' );
|
|
||||||
update_post_meta( $id, 'sp_columns', $columns );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Insert league table
|
|
||||||
*/
|
|
||||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
|
||||||
$leagues = get_terms( 'sp_league', array( 'hide_empty' => 0, 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) );
|
|
||||||
$league = reset( $leagues );
|
|
||||||
$seasons = get_terms( 'sp_season', array( 'hide_empty' => 0, 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) );
|
|
||||||
$season = reset( $seasons );
|
|
||||||
$post = array(
|
|
||||||
'post_title' => $league->name . ' ' . $season->name,
|
|
||||||
'post_type' => 'sp_table',
|
|
||||||
'post_status' => 'publish',
|
|
||||||
'post_content' => sprintf( $sample_content, __( 'League Table', 'sportspress' ), __( 'League Tables', 'sportspress' ), admin_url() ),
|
|
||||||
'tax_input' => array(
|
'tax_input' => array(
|
||||||
'sp_league' => $league->term_id,
|
'sp_league' => get_terms( 'sp_league', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) ),
|
||||||
'sp_season' => $season->term_id,
|
'sp_season' => $event_season,
|
||||||
|
'sp_venue' => get_terms( 'sp_venue', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1, 'offset' => $i ) ),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -523,16 +377,196 @@ class SP_Admin_Sample_Data {
|
|||||||
$id = wp_insert_post( $post );
|
$id = wp_insert_post( $post );
|
||||||
|
|
||||||
// Add to inserted ids array
|
// Add to inserted ids array
|
||||||
$inserted_ids['sp_table'][] = $id;
|
$inserted_ids['sp_event'][] = $id;
|
||||||
|
|
||||||
// Flag as sample
|
// Flag as sample
|
||||||
update_post_meta( $id, '_sp_sample', 1 );
|
update_post_meta( $id, '_sp_sample', 1 );
|
||||||
|
|
||||||
|
// Calculate home and away team ids
|
||||||
|
$home_team_index = ( $i ) % 3;
|
||||||
|
$away_team_index = ( $i + 1 ) % 3;
|
||||||
|
$home_team_id = sp_array_value( $inserted_ids['sp_team'], $home_team_index, 0 );
|
||||||
|
$away_team_id = sp_array_value( $inserted_ids['sp_team'], $away_team_index, 0 );
|
||||||
|
$event_teams = array(
|
||||||
|
$home_team_id,
|
||||||
|
$away_team_id,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Initialize meta
|
||||||
|
$event_players = array( 0 );
|
||||||
|
$performance = $results = array();
|
||||||
|
|
||||||
|
if ( $home_team_id ) {
|
||||||
|
// Add home team player performance
|
||||||
|
$performance[ $home_team_id ] = array();
|
||||||
|
for ( $j = 0; $j < 4; $j ++ ) {
|
||||||
|
$player_id = sp_array_value( $inserted_ids['sp_player'], $home_team_index * 4 + $j );
|
||||||
|
$event_players[] = $player_id;
|
||||||
|
$player_performance = array();
|
||||||
|
foreach ( $performance_posts as $performance_post ) {
|
||||||
|
$player_performance[ $performance_post->post_name ] = rand( 0, 1 );
|
||||||
|
}
|
||||||
|
$performance[ $home_team_id ][ $player_id ] = $player_performance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add home team results
|
||||||
|
$results[ $home_team_id ] = array();
|
||||||
|
foreach ( $result_posts as $result_post_index => $result_post ) {
|
||||||
|
$results[ $home_team_id ][ $result_post->post_name ] = 1 + $result_post_index;
|
||||||
|
}
|
||||||
|
$outcome = reset( $outcome_posts );
|
||||||
|
if ( is_object( $outcome ) ) $results[ $home_team_id ]['outcome'] = array( $outcome->post_name );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Separate teams with zero
|
||||||
|
$event_players[] = 0;
|
||||||
|
|
||||||
|
if ( $away_team_id ) {
|
||||||
|
$performance[ $away_team_id ] = array();
|
||||||
|
for ( $j = 0; $j < 4; $j ++ ) {
|
||||||
|
$player_id = sp_array_value( $inserted_ids['sp_player'], $away_team_index * 4 + $j );
|
||||||
|
$event_players[] = $player_id;
|
||||||
|
$player_performance = array();
|
||||||
|
foreach ( $performance_posts as $performance_post ) {
|
||||||
|
$player_performance[ $performance_post->post_name ] = rand( 0, 1 );
|
||||||
|
}
|
||||||
|
$performance[ $away_team_id ][ $player_id ] = $player_performance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add away team results
|
||||||
|
$results[ $away_team_id ] = array();
|
||||||
|
foreach ( $result_posts as $result_post ) {
|
||||||
|
$results[ $away_team_id ][ $result_post->post_name ] = '0';
|
||||||
|
}
|
||||||
|
$outcome = next( $outcome_posts );
|
||||||
|
if ( is_object( $outcome ) ) $results[ $away_team_id ]['outcome'] = array( $outcome->post_name );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( 'publish' === $post_status ) {
|
||||||
|
// Swap results for last event only
|
||||||
|
if ( $i == 2 ) {
|
||||||
|
$k = array_keys( $results );
|
||||||
|
$v = array_values( $results );
|
||||||
|
$rv = array_reverse( $v );
|
||||||
|
$results = array_combine( $k, $rv );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update future post meta
|
||||||
|
update_post_meta( $id, 'sp_players', $performance );
|
||||||
|
update_post_meta( $id, 'sp_results', $results );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update general meta
|
||||||
|
sp_update_post_meta_recursive( $id, 'sp_team', $event_teams );
|
||||||
|
sp_update_post_meta_recursive( $id, 'sp_player', $event_players );
|
||||||
|
update_post_meta( $id, 'sp_columns', $columns );
|
||||||
|
update_post_meta( $id, 'sp_format', 'league' );
|
||||||
|
update_post_meta( $id, 'sp_video', $event_videos[ $i ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insert calendar
|
||||||
|
*/
|
||||||
|
$post = array(
|
||||||
|
'post_title' => _x( 'Fixtures & Results', 'example', 'sportspress' ),
|
||||||
|
'post_type' => 'sp_calendar',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'post_content' => sprintf( $sample_content, __( 'Calendar', 'sportspress' ), __( 'Calendars', 'sportspress' ), admin_url() )
|
||||||
|
);
|
||||||
|
|
||||||
|
// Insert post
|
||||||
|
$id = wp_insert_post( $post );
|
||||||
|
|
||||||
|
// Add to inserted ids array
|
||||||
|
$inserted_ids['sp_calendar'][] = $id;
|
||||||
|
|
||||||
|
// Flag as sample
|
||||||
|
update_post_meta( $id, '_sp_sample', 1 );
|
||||||
|
|
||||||
|
// Define columns
|
||||||
|
$columns = array( 'event', 'time', 'article' );
|
||||||
|
|
||||||
|
// Update meta
|
||||||
|
update_post_meta( $id, 'sp_format', 'list' );
|
||||||
|
update_post_meta( $id, 'sp_status', 'any' );
|
||||||
|
update_post_meta( $id, 'sp_date', 0 );
|
||||||
|
update_post_meta( $id, 'sp_team', 0 );
|
||||||
|
update_post_meta( $id, 'sp_order', 'ASC' );
|
||||||
|
update_post_meta( $id, 'sp_columns', $columns );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insert league table
|
||||||
|
*/
|
||||||
|
$leagues = get_terms( 'sp_league', array( 'hide_empty' => 0, 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) );
|
||||||
|
$league = reset( $leagues );
|
||||||
|
$seasons = get_terms( 'sp_season', array( 'hide_empty' => 0, 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) );
|
||||||
|
$season = reset( $seasons );
|
||||||
|
$post = array(
|
||||||
|
'post_title' => $league->name . ' ' . $season->name,
|
||||||
|
'post_type' => 'sp_table',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'post_content' => sprintf( $sample_content, __( 'League Table', 'sportspress' ), __( 'League Tables', 'sportspress' ), admin_url() ),
|
||||||
|
'tax_input' => array(
|
||||||
|
'sp_league' => $league->term_id,
|
||||||
|
'sp_season' => $season->term_id,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Insert post
|
||||||
|
$id = wp_insert_post( $post );
|
||||||
|
|
||||||
|
// Add to inserted ids array
|
||||||
|
$inserted_ids['sp_table'][] = $id;
|
||||||
|
|
||||||
|
// Flag as sample
|
||||||
|
update_post_meta( $id, '_sp_sample', 1 );
|
||||||
|
|
||||||
|
// Get columns
|
||||||
|
$columns = array();
|
||||||
|
$args = array(
|
||||||
|
'post_type' => 'sp_column',
|
||||||
|
'posts_per_page' => 8,
|
||||||
|
'orderby' => 'menu_order',
|
||||||
|
'order' => 'ASC',
|
||||||
|
);
|
||||||
|
$column_posts = get_posts( $args );
|
||||||
|
foreach ( $column_posts as $column_post ) {
|
||||||
|
$columns[] = $column_post->post_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update meta
|
||||||
|
sp_update_post_meta_recursive( $id, 'sp_team', $inserted_ids['sp_team'] );
|
||||||
|
update_post_meta( $id, 'sp_columns', $columns );
|
||||||
|
update_post_meta( $id, 'sp_highlight', reset( $inserted_ids['sp_team'] ) );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insert player list for each team
|
||||||
|
*/
|
||||||
|
foreach ( $inserted_ids['sp_team'] as $index => $team_id ) {
|
||||||
|
$post = array(
|
||||||
|
'post_title' => get_the_title( $team_id ) . ' ' . _x( 'Roster', 'example', 'sportspress' ),
|
||||||
|
'post_type' => 'sp_list',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'post_content' => sprintf( $sample_content, __( 'Player List', 'sportspress' ), __( 'Player Lists', 'sportspress' ), admin_url() ),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Insert post
|
||||||
|
$id = wp_insert_post( $post );
|
||||||
|
|
||||||
|
// Add to inserted ids array
|
||||||
|
$inserted_ids['sp_list'][] = $id;
|
||||||
|
|
||||||
|
// Flag as sample
|
||||||
|
update_post_meta( $id, '_sp_sample', 1 );
|
||||||
|
|
||||||
|
// Get players from team
|
||||||
|
$list_players = array_slice( $inserted_ids['sp_player'], $index * 4, 4 );
|
||||||
|
|
||||||
// Get columns
|
// Get columns
|
||||||
$columns = array();
|
$columns = array();
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_column',
|
'post_type' => array( 'sp_metric' ),
|
||||||
'posts_per_page' => 8,
|
'posts_per_page' => 2,
|
||||||
'orderby' => 'menu_order',
|
'orderby' => 'menu_order',
|
||||||
'order' => 'ASC',
|
'order' => 'ASC',
|
||||||
);
|
);
|
||||||
@@ -542,57 +576,13 @@ class SP_Admin_Sample_Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update meta
|
// Update meta
|
||||||
sp_update_post_meta_recursive( $id, 'sp_team', $inserted_ids['sp_team'] );
|
update_post_meta( $id, 'sp_format', 'list' );
|
||||||
|
sp_update_post_meta_recursive( $id, 'sp_player', $list_players );
|
||||||
update_post_meta( $id, 'sp_columns', $columns );
|
update_post_meta( $id, 'sp_columns', $columns );
|
||||||
update_post_meta( $id, 'sp_highlight', reset( $inserted_ids['sp_team'] ) );
|
update_post_meta( $id, 'sp_grouping', 'position' );
|
||||||
}
|
update_post_meta( $id, 'sp_orderby', 'name' );
|
||||||
|
update_post_meta( $id, 'sp_order', 'ASC' );
|
||||||
/*
|
update_post_meta( $id, 'sp_team', $team_id );
|
||||||
* Insert player list for each team
|
|
||||||
*/
|
|
||||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
|
||||||
foreach ( $inserted_ids['sp_team'] as $index => $team_id ) {
|
|
||||||
$post = array(
|
|
||||||
'post_title' => get_the_title( $team_id ) . ' ' . _x( 'Roster', 'example', 'sportspress' ),
|
|
||||||
'post_type' => 'sp_list',
|
|
||||||
'post_status' => 'publish',
|
|
||||||
'post_content' => sprintf( $sample_content, __( 'Player List', 'sportspress' ), __( 'Player Lists', 'sportspress' ), admin_url() ),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Insert post
|
|
||||||
$id = wp_insert_post( $post );
|
|
||||||
|
|
||||||
// Add to inserted ids array
|
|
||||||
$inserted_ids['sp_list'][] = $id;
|
|
||||||
|
|
||||||
// Flag as sample
|
|
||||||
update_post_meta( $id, '_sp_sample', 1 );
|
|
||||||
|
|
||||||
// Get players from team
|
|
||||||
$list_players = array_slice( $inserted_ids['sp_player'], $index * 4, 4 );
|
|
||||||
|
|
||||||
// Get columns
|
|
||||||
$columns = array();
|
|
||||||
$args = array(
|
|
||||||
'post_type' => array( 'sp_metric' ),
|
|
||||||
'posts_per_page' => 2,
|
|
||||||
'orderby' => 'menu_order',
|
|
||||||
'order' => 'ASC',
|
|
||||||
);
|
|
||||||
$column_posts = get_posts( $args );
|
|
||||||
foreach ( $column_posts as $column_post ) {
|
|
||||||
$columns[] = $column_post->post_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update meta
|
|
||||||
update_post_meta( $id, 'sp_format', 'list' );
|
|
||||||
sp_update_post_meta_recursive( $id, 'sp_player', $list_players );
|
|
||||||
update_post_meta( $id, 'sp_columns', $columns );
|
|
||||||
update_post_meta( $id, 'sp_grouping', 'position' );
|
|
||||||
update_post_meta( $id, 'sp_orderby', 'name' );
|
|
||||||
update_post_meta( $id, 'sp_order', 'ASC' );
|
|
||||||
update_post_meta( $id, 'sp_team', $team_id );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -630,11 +620,9 @@ class SP_Admin_Sample_Data {
|
|||||||
/*
|
/*
|
||||||
* Update player list and league table per team
|
* Update player list and league table per team
|
||||||
*/
|
*/
|
||||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
foreach ( $inserted_ids['sp_team'] as $index => $team_id ) {
|
||||||
foreach ( $inserted_ids['sp_team'] as $index => $team_id ) {
|
update_post_meta( $team_id, 'sp_list', sp_array_value( $inserted_ids['sp_list'], $index, 0 ) );
|
||||||
update_post_meta( $team_id, 'sp_list', sp_array_value( $inserted_ids['sp_list'], $index, 0 ) );
|
update_post_meta( $team_id, 'sp_table', sp_array_value( $inserted_ids['sp_table'], 0 ) );
|
||||||
update_post_meta( $team_id, 'sp_table', sp_array_value( $inserted_ids['sp_table'], 0 ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,10 +34,7 @@ class SP_Admin_Settings {
|
|||||||
$settings[] = include( 'settings/class-sp-settings-modules.php' );
|
$settings[] = include( 'settings/class-sp-settings-modules.php' );
|
||||||
$settings[] = include( 'settings/class-sp-settings-general.php' );
|
$settings[] = include( 'settings/class-sp-settings-general.php' );
|
||||||
$settings[] = include( 'settings/class-sp-settings-events.php' );
|
$settings[] = include( 'settings/class-sp-settings-events.php' );
|
||||||
|
$settings[] = include( 'settings/class-sp-settings-teams.php' );
|
||||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) )
|
|
||||||
$settings[] = include( 'settings/class-sp-settings-teams.php' );
|
|
||||||
|
|
||||||
$settings[] = include( 'settings/class-sp-settings-players.php' );
|
$settings[] = include( 'settings/class-sp-settings-players.php' );
|
||||||
$settings[] = include( 'settings/class-sp-settings-staff.php' );
|
$settings[] = include( 'settings/class-sp-settings-staff.php' );
|
||||||
|
|
||||||
|
|||||||
@@ -166,8 +166,8 @@ class SP_Admin_Welcome {
|
|||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
if ( isset( $_POST['sportspress_mode'] ) ):
|
if ( isset( $_POST['sportspress_load_individual_mode_module'] ) ):
|
||||||
update_option( 'sportspress_mode', $_POST['sportspress_mode'] );
|
update_option( 'sportspress_load_individual_mode_module', $_POST['sportspress_load_individual_mode_module'] );
|
||||||
endif;
|
endif;
|
||||||
if ( isset( $_POST['add_sample_data'] ) ):
|
if ( isset( $_POST['add_sample_data'] ) ):
|
||||||
SP_Admin_Sample_Data::delete_posts();
|
SP_Admin_Sample_Data::delete_posts();
|
||||||
@@ -194,20 +194,39 @@ class SP_Admin_Welcome {
|
|||||||
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress', 'tab' => 'general' ), 'admin.php' ) ) ); ?>"><i class="dashicons dashicons-edit"></i> <?php _e( 'Change', 'sportspress' ); ?></a>
|
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress', 'tab' => 'general' ), 'admin.php' ) ) ); ?>"><i class="dashicons dashicons-edit"></i> <?php _e( 'Change', 'sportspress' ); ?></a>
|
||||||
|
|
||||||
<h4><?php _e( 'Mode', 'sportspress' ); ?></h4>
|
<h4><?php _e( 'Mode', 'sportspress' ); ?></h4>
|
||||||
<?php echo ( 'team' == get_option( 'sportspress_mode', 'team' ) ? __( 'Teams', 'sportspress' ) : __( 'Players', 'sportspress' ) . ' ' . __( '(Beta)', 'sportspress' ) ); ?>
|
<?php echo ( 'yes' == get_option( 'sportspress_load_individual_mode_module', 'no' ) ? __( 'Player vs player', 'sportspress' ) : __( 'Team vs team', 'sportspress' ) ); ?>
|
||||||
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress', 'tab' => 'general' ), 'admin.php' ) ) ); ?>"><i class="dashicons dashicons-edit"></i> <?php _e( 'Change', 'sportspress' ); ?></a>
|
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress', 'tab' => 'general' ), 'admin.php' ) ) ); ?>"><i class="dashicons dashicons-edit"></i> <?php _e( 'Change', 'sportspress' ); ?></a>
|
||||||
|
|
||||||
<h4><?php _e( 'Next Steps', 'sportspress' ); ?></h4>
|
<h4><?php _e( 'Next Steps', 'sportspress' ); ?></h4>
|
||||||
<p><?php _e( 'We’ve assembled some links to get you started:', 'sportspress' ); ?></p>
|
<p><?php _e( 'We’ve assembled some links to get you started:', 'sportspress' ); ?></p>
|
||||||
|
<?php
|
||||||
|
$steps = apply_filters( 'sportspress_next_steps', array(
|
||||||
|
'teams' => array(
|
||||||
|
'link' => admin_url( add_query_arg( array( 'post_type' => 'sp_team' ), 'edit.php' ) ),
|
||||||
|
'icon' => 'dashicons-shield-alt',
|
||||||
|
'label' => __( 'Add New Team', 'sportspress' ),
|
||||||
|
),
|
||||||
|
'players' => array(
|
||||||
|
'link' => admin_url( add_query_arg( array( 'post_type' => 'sp_player' ), 'edit.php' ) ),
|
||||||
|
'icon' => 'dashicons-groups',
|
||||||
|
'label' => __( 'Add New Player', 'sportspress' ),
|
||||||
|
),
|
||||||
|
'events' => array(
|
||||||
|
'link' => admin_url( add_query_arg( array( 'post_type' => 'sp_event' ), 'edit.php' ) ),
|
||||||
|
'icon' => 'dashicons-calendar',
|
||||||
|
'label' => __( 'Add New Event', 'sportspress' ),
|
||||||
|
),
|
||||||
|
) );
|
||||||
|
?>
|
||||||
|
<?php if ( sizeof ( $steps ) ) { ?>
|
||||||
<div class="sportspress-steps">
|
<div class="sportspress-steps">
|
||||||
<ul>
|
<ul>
|
||||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
<?php foreach ( $steps as $step ) { ?>
|
||||||
<li><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => 'sp_team' ), 'edit.php' ) ) ); ?>" class="welcome-icon sp-welcome-icon dashicons-shield-alt"><?php _e( 'Add New Team', 'sportspress' ); ?></a></li>
|
<li><a href="<?php echo esc_url( $step['link'] ); ?>" class="welcome-icon sp-welcome-icon <?php echo sp_array_value( $step, 'icon' ); ?>"><?php echo $step['label']; ?></a></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<li><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => 'sp_player' ), 'edit.php' ) ) ); ?>" class="welcome-icon sp-welcome-icon dashicons-groups"><?php _e( 'Add New Player', 'sportspress' ); ?></a></li>
|
|
||||||
<li><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => 'sp_event' ), 'edit.php' ) ) ); ?>" class="welcome-icon sp-welcome-icon dashicons-calendar"><?php _e( 'Add New Event', 'sportspress' ); ?></a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<?php } ?>
|
||||||
<div class="return-to-dashboard">
|
<div class="return-to-dashboard">
|
||||||
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress', 'tab' => 'general' ), 'admin.php' ) ) ); ?>"><?php _e( 'Go to SportsPress Settings', 'sportspress' ); ?></a>
|
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress', 'tab' => 'general' ), 'admin.php' ) ) ); ?>"><?php _e( 'Go to SportsPress Settings', 'sportspress' ); ?></a>
|
||||||
</div>
|
</div>
|
||||||
@@ -262,12 +281,12 @@ class SP_Admin_Welcome {
|
|||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Mode', 'sportspress' ),
|
'title' => __( 'Mode', 'sportspress' ),
|
||||||
'id' => 'sportspress_mode',
|
'id' => 'sportspress_load_individual_mode_module',
|
||||||
'default' => 'team',
|
'default' => 'no',
|
||||||
'type' => 'radio',
|
'type' => 'radio',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'team' => __( 'Teams', 'sportspress' ),
|
'no' => __( 'Team vs team', 'sportspress' ),
|
||||||
'player' => __( 'Players', 'sportspress' ) . ' ' . __( '(Beta)', 'sportspress' ),
|
'yes' => __( 'Player vs player', 'sportspress' ),
|
||||||
),
|
),
|
||||||
'desc_tip' => _x( 'Who competes in events?', 'mode setting description', 'sportspress' ),
|
'desc_tip' => _x( 'Who competes in events?', 'mode setting description', 'sportspress' ),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -17,40 +17,148 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||||||
*/
|
*/
|
||||||
class SP_Admin_Meta_Boxes {
|
class SP_Admin_Meta_Boxes {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $meta_boxes = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
|
$meta_boxes = array(
|
||||||
|
'sp_result' => array(
|
||||||
|
'details' => array(
|
||||||
|
'title' => __( 'Details', 'sportspress' ),
|
||||||
|
'save' => 'SP_Meta_Box_Result_Details::save',
|
||||||
|
'output' => 'SP_Meta_Box_Result_Details::output',
|
||||||
|
'context' => 'normal',
|
||||||
|
'priority' => 'high',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'sp_outcome' => array(
|
||||||
|
'details' => array(
|
||||||
|
'title' => __( 'Details', 'sportspress' ),
|
||||||
|
'save' => 'SP_Meta_Box_Outcome_Details::save',
|
||||||
|
'output' => 'SP_Meta_Box_Outcome_Details::output',
|
||||||
|
'context' => 'normal',
|
||||||
|
'priority' => 'high',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'sp_metric' => array(
|
||||||
|
'details' => array(
|
||||||
|
'title' => __( 'Details', 'sportspress' ),
|
||||||
|
'save' => 'SP_Meta_Box_Metric_Details::save',
|
||||||
|
'output' => 'SP_Meta_Box_Metric_Details::output',
|
||||||
|
'context' => 'normal',
|
||||||
|
'priority' => 'high',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'sp_outcome' => array(
|
||||||
|
'details' => array(
|
||||||
|
'title' => __( 'Details', 'sportspress' ),
|
||||||
|
'save' => 'SP_Meta_Box_Metric_Details::save',
|
||||||
|
'output' => 'SP_Meta_Box_Metric_Details::output',
|
||||||
|
'context' => 'normal',
|
||||||
|
'priority' => 'high',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'sp_performance' => array(
|
||||||
|
'details' => array(
|
||||||
|
'title' => __( 'Details', 'sportspress' ),
|
||||||
|
'save' => 'SP_Meta_Box_Performance_Details::save',
|
||||||
|
'output' => 'SP_Meta_Box_Performance_Details::output',
|
||||||
|
'context' => 'normal',
|
||||||
|
'priority' => 'high',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'sp_statistic' => array(
|
||||||
|
'details' => array(
|
||||||
|
'title' => __( 'Details', 'sportspress' ),
|
||||||
|
'save' => 'SP_Meta_Box_Statistic_Details::save',
|
||||||
|
'output' => 'SP_Meta_Box_Statistic_Details::output',
|
||||||
|
'context' => 'side',
|
||||||
|
'priority' => 'default',
|
||||||
|
),
|
||||||
|
'equation' => array(
|
||||||
|
'title' => __( 'Equation', 'sportspress' ),
|
||||||
|
'save' => 'SP_Meta_Box_Statistic_Equation::save',
|
||||||
|
'output' => 'SP_Meta_Box_Statistic_Equation::output',
|
||||||
|
'context' => 'normal',
|
||||||
|
'priority' => 'high',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'sp_column' => array(
|
||||||
|
'details' => array(
|
||||||
|
'title' => __( 'Details', 'sportspress' ),
|
||||||
|
'save' => 'SP_Meta_Box_Column_Details::save',
|
||||||
|
'output' => 'SP_Meta_Box_Column_Details::output',
|
||||||
|
'context' => 'side',
|
||||||
|
'priority' => 'default',
|
||||||
|
),
|
||||||
|
'equation' => array(
|
||||||
|
'title' => __( 'Equation', 'sportspress' ),
|
||||||
|
'save' => 'SP_Meta_Box_Column_Equation::save',
|
||||||
|
'output' => 'SP_Meta_Box_Column_Equation::output',
|
||||||
|
'context' => 'normal',
|
||||||
|
'priority' => 'high',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'sp_event' => array(
|
||||||
|
'shortcode' => array(
|
||||||
|
'title' => __( 'Shortcodes', 'sportspress' ),
|
||||||
|
'output' => 'SP_Meta_Box_Event_Shortcode::output',
|
||||||
|
'context' => 'side',
|
||||||
|
'priority' => 'default',
|
||||||
|
),
|
||||||
|
'format' => array(
|
||||||
|
'title' => __( 'Format', 'sportspress' ),
|
||||||
|
'save' => 'SP_Meta_Box_Event_Format::save',
|
||||||
|
'output' => 'SP_Meta_Box_Event_Format::output',
|
||||||
|
'context' => 'side',
|
||||||
|
'priority' => 'default',
|
||||||
|
),
|
||||||
|
'details' => array(
|
||||||
|
'title' => __( 'Details', 'sportspress' ),
|
||||||
|
'save' => 'SP_Meta_Box_Event_Details::save',
|
||||||
|
'output' => 'SP_Meta_Box_Event_Details::output',
|
||||||
|
'context' => 'side',
|
||||||
|
'priority' => 'default',
|
||||||
|
),
|
||||||
|
'team' => array(
|
||||||
|
'title' => __( 'Teams', 'sportspress' ),
|
||||||
|
'save' => 'SP_Meta_Box_Event_Teams::save',
|
||||||
|
'output' => 'SP_Meta_Box_Event_Teams::output',
|
||||||
|
'context' => 'side',
|
||||||
|
'priority' => 'default',
|
||||||
|
),
|
||||||
|
'editor' => array(
|
||||||
|
'title' => __( 'Article', 'sportspress' ),
|
||||||
|
'output' => 'SP_Meta_Box_Event_Editor::output',
|
||||||
|
'context' => 'normal',
|
||||||
|
'priority' => 'low',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->meta_boxes = apply_filters( 'sportspress_meta_boxes', $meta_boxes );
|
||||||
|
|
||||||
|
foreach ( $this->meta_boxes as $post_type => $meta_boxes ) {
|
||||||
|
$i = 0;
|
||||||
|
foreach ( $meta_boxes as $id => $meta_box ) {
|
||||||
|
if ( array_key_exists( 'save', $meta_box ) ) {
|
||||||
|
add_action( 'sportspress_process_' . $post_type . '_meta', $meta_box['save'], ( $i + 1 ) * 10, 2 );
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
add_action( 'add_meta_boxes', array( $this, 'remove_meta_boxes' ), 10 );
|
add_action( 'add_meta_boxes', array( $this, 'remove_meta_boxes' ), 10 );
|
||||||
add_action( 'add_meta_boxes', array( $this, 'rename_meta_boxes' ), 20 );
|
add_action( 'add_meta_boxes', array( $this, 'rename_meta_boxes' ), 20 );
|
||||||
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 30 );
|
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 30 );
|
||||||
add_action( 'save_post', array( $this, 'save_meta_boxes' ), 1, 2 );
|
add_action( 'save_post', array( $this, 'save_meta_boxes' ), 1, 2 );
|
||||||
|
|
||||||
// Save Result Meta Boxes
|
|
||||||
add_action( 'sportspress_process_sp_result_meta', 'SP_Meta_Box_Result_Details::save', 10, 2 );
|
|
||||||
|
|
||||||
// Save Outcome Meta Boxes
|
|
||||||
add_action( 'sportspress_process_sp_outcome_meta', 'SP_Meta_Box_Outcome_Details::save', 10, 2 );
|
|
||||||
|
|
||||||
// Save Metric Meta Boxes
|
|
||||||
add_action( 'sportspress_process_sp_metric_meta', 'SP_Meta_Box_Metric_Details::save', 10, 2 );
|
|
||||||
|
|
||||||
// Save Performance Meta Boxes
|
|
||||||
add_action( 'sportspress_process_sp_performance_meta', 'SP_Meta_Box_Performance_Details::save', 10, 2 );
|
|
||||||
|
|
||||||
// Save Statistic Meta Boxes
|
|
||||||
add_action( 'sportspress_process_sp_statistic_meta', 'SP_Meta_Box_Statistic_Details::save', 10, 2 );
|
|
||||||
add_action( 'sportspress_process_sp_statistic_meta', 'SP_Meta_Box_Statistic_Equation::save', 20, 2 );
|
|
||||||
|
|
||||||
// Save Column Meta Boxes
|
|
||||||
add_action( 'sportspress_process_sp_column_meta', 'SP_Meta_Box_Column_Details::save', 10, 2 );
|
|
||||||
add_action( 'sportspress_process_sp_column_meta', 'SP_Meta_Box_Column_Equation::save', 20, 2 );
|
|
||||||
|
|
||||||
// Save Event Meta Boxes
|
// Save Event Meta Boxes
|
||||||
add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Format::save', 10, 2 );
|
|
||||||
add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Details::save', 20, 2 );
|
|
||||||
add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Teams::save', 30, 2 );
|
|
||||||
add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Video::save', 40, 2 );
|
|
||||||
add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Results::save', 50, 2 );
|
add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Results::save', 50, 2 );
|
||||||
add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Performance::save', 60, 2 );
|
add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Performance::save', 60, 2 );
|
||||||
|
|
||||||
@@ -95,61 +203,29 @@ class SP_Admin_Meta_Boxes {
|
|||||||
public function add_meta_boxes() {
|
public function add_meta_boxes() {
|
||||||
global $post;
|
global $post;
|
||||||
|
|
||||||
|
foreach ( $this->meta_boxes as $post_type => $meta_boxes ) {
|
||||||
|
foreach ( $meta_boxes as $id => $meta_box ) {
|
||||||
|
if ( array_key_exists( 'output', $meta_box ) ) {
|
||||||
|
add_meta_box( 'sp_' . $id . 'div', $meta_box['title'], $meta_box['output'], $post_type, $meta_box['context'], $meta_box['priority'] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get post meta array
|
// Get post meta array
|
||||||
if ( isset( $post ) && isset( $post->ID ) )
|
if ( isset( $post ) && isset( $post->ID ) )
|
||||||
$post_meta = get_post_meta( $post->ID );
|
$post_meta = get_post_meta( $post->ID );
|
||||||
else
|
else
|
||||||
$post_meta = array();
|
$post_meta = array();
|
||||||
|
|
||||||
// Results
|
|
||||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Result_Details::output', 'sp_result', 'normal', 'high' );
|
|
||||||
|
|
||||||
// Outcomes
|
|
||||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Outcome_Details::output', 'sp_outcome', 'normal', 'high' );
|
|
||||||
|
|
||||||
// Columns
|
|
||||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Column_Details::output', 'sp_column', 'side', 'default' );
|
|
||||||
add_meta_box( 'sp_equationdiv', __( 'Equation', 'sportspress' ), 'SP_Meta_Box_Column_Equation::output', 'sp_column', 'normal', 'high' );
|
|
||||||
|
|
||||||
// Metrics
|
|
||||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Metric_Details::output', 'sp_metric', 'normal', 'high' );
|
|
||||||
|
|
||||||
// Performance
|
|
||||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Performance_Details::output', 'sp_performance', 'normal', 'high' );
|
|
||||||
|
|
||||||
// Statistics
|
|
||||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Statistic_Details::output', 'sp_statistic', 'side', 'default' );
|
|
||||||
add_meta_box( 'sp_equationdiv', __( 'Equation', 'sportspress' ), 'SP_Meta_Box_Statistic_Equation::output', 'sp_statistic', 'normal', 'high' );
|
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
add_meta_box( 'sp_shortcodediv', __( 'Shortcodes', 'sportspress' ), 'SP_Meta_Box_Event_Shortcode::output', 'sp_event', 'side', 'default' );
|
$teams = array_filter( sp_array_value( $post_meta, 'sp_team', array() ), 'sp_filter_positive' );
|
||||||
add_meta_box( 'sp_formatdiv', __( 'Format', 'sportspress' ), 'SP_Meta_Box_Event_Format::output', 'sp_event', 'side', 'default' );
|
|
||||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Event_Details::output', 'sp_event', 'side', 'default' );
|
|
||||||
add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'SP_Meta_Box_Event_Teams::output', 'sp_event', 'side', 'default' );
|
|
||||||
if ( 'yes' == get_option( 'sportspress_load_videos_module', 'yes' ) ) {
|
|
||||||
add_meta_box( 'sp_videodiv', __( 'Video', 'sportspress' ), 'SP_Meta_Box_Event_Video::output', 'sp_event', 'side', 'low' );
|
|
||||||
}
|
|
||||||
$teams = array_filter( sp_array_value( $post_meta, 'sp_team', array() ), array( $this, 'positive' ) );
|
|
||||||
if ( ! empty( $teams ) ) {
|
if ( ! empty( $teams ) ) {
|
||||||
add_meta_box( 'sp_resultsdiv', __( 'Team Results', 'sportspress' ), 'SP_Meta_Box_Event_Results::output', 'sp_event', 'normal', 'high' );
|
add_meta_box( 'sp_resultsdiv', __( 'Event Results', 'sportspress' ), 'SP_Meta_Box_Event_Results::output', 'sp_event', 'normal', 'high' );
|
||||||
}
|
}
|
||||||
$players = array_filter( sp_array_value( $post_meta, 'sp_player', array() ), array( $this, 'positive' ) );
|
$players = array_filter( sp_array_value( $post_meta, 'sp_player', array() ), 'sp_filter_positive' );
|
||||||
if ( ! empty( $players ) ) {
|
if ( ! empty( $players ) ) {
|
||||||
add_meta_box( 'sp_performancediv', __( 'Player Performance', 'sportspress' ), 'SP_Meta_Box_Event_Performance::output', 'sp_event', 'normal', 'high' );
|
add_meta_box( 'sp_performancediv', __( 'Player Performance', 'sportspress' ), 'SP_Meta_Box_Event_Performance::output', 'sp_event', 'normal', 'high' );
|
||||||
}
|
}
|
||||||
add_meta_box( 'sp_editordiv', __( 'Article', 'sportspress' ), 'SP_Meta_Box_Event_Editor::output', 'sp_event', 'normal', 'low' );
|
|
||||||
|
|
||||||
if ( 'yes' == get_option( 'sportspress_load_calendars_module', 'yes' ) ) {
|
|
||||||
// Calendars
|
|
||||||
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_Calendar_Shortcode::output', 'sp_calendar', 'side', 'default' );
|
|
||||||
if ( isset( $post ) && 'publish' == $post->post_status ):
|
|
||||||
add_meta_box( 'sp_feedsdiv', __( 'Feeds', 'sportspress' ), 'SP_Meta_Box_Calendar_Feeds::output', 'sp_calendar', 'side', 'default' );
|
|
||||||
endif;
|
|
||||||
add_meta_box( 'sp_formatdiv', __( 'Layout', 'sportspress' ), 'SP_Meta_Box_Calendar_Format::output', 'sp_calendar', 'side', 'default' );
|
|
||||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Calendar_Details::output', 'sp_calendar', 'side', 'default' );
|
|
||||||
add_meta_box( 'sp_datadiv', __( 'Events', 'sportspress' ), 'SP_Meta_Box_Calendar_Data::output', 'sp_calendar', 'normal', 'high' );
|
|
||||||
add_meta_box( 'sp_editordiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_Calendar_Editor::output', 'sp_calendar', 'normal', 'low' );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Teams
|
// Teams
|
||||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Team_Details::output', 'sp_team', 'side', 'default' );
|
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Team_Details::output', 'sp_team', 'side', 'default' );
|
||||||
@@ -269,13 +345,6 @@ class SP_Admin_Meta_Boxes {
|
|||||||
do_action( 'sportspress_process_' . $post->post_type . '_meta', $post_id, $post );
|
do_action( 'sportspress_process_' . $post->post_type . '_meta', $post_id, $post );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Array filter removes values that are not positive.
|
|
||||||
*/
|
|
||||||
public function positive( $var = 0 ) {
|
|
||||||
return $var > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new SP_Admin_Meta_Boxes();
|
new SP_Admin_Meta_Boxes();
|
||||||
|
|||||||
@@ -104,23 +104,21 @@ class SP_Meta_Box_Calendar_Details {
|
|||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
|
||||||
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
|
<p>
|
||||||
<p>
|
<?php
|
||||||
<?php
|
$args = array(
|
||||||
$args = array(
|
'show_option_all' => __( 'All', 'sportspress' ),
|
||||||
'show_option_all' => __( 'All', 'sportspress' ),
|
'post_type' => 'sp_team',
|
||||||
'post_type' => 'sp_team',
|
'name' => 'sp_team',
|
||||||
'name' => 'sp_team',
|
'selected' => $team_id,
|
||||||
'selected' => $team_id,
|
'values' => 'ID'
|
||||||
'values' => 'ID'
|
);
|
||||||
);
|
if ( ! sp_dropdown_pages( $args ) ):
|
||||||
if ( ! sp_dropdown_pages( $args ) ):
|
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||||
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
|
endif;
|
||||||
endif;
|
?>
|
||||||
?>
|
</p>
|
||||||
</p>
|
|
||||||
<?php } ?>
|
|
||||||
<p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p>
|
||||||
<p>
|
<p>
|
||||||
<select name="sp_order">
|
<select name="sp_order">
|
||||||
@@ -144,8 +142,6 @@ class SP_Meta_Box_Calendar_Details {
|
|||||||
update_post_meta( $post_id, 'sp_date_from', sp_array_value( $_POST, 'sp_date_from', null ) );
|
update_post_meta( $post_id, 'sp_date_from', sp_array_value( $_POST, 'sp_date_from', null ) );
|
||||||
update_post_meta( $post_id, 'sp_date_to', sp_array_value( $_POST, 'sp_date_to', null ) );
|
update_post_meta( $post_id, 'sp_date_to', sp_array_value( $_POST, 'sp_date_to', null ) );
|
||||||
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', array() ) );
|
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', array() ) );
|
||||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', 0 ) );
|
||||||
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', 0 ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,31 +53,32 @@ class SP_Meta_Box_Event_Teams {
|
|||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
<p class="sp-tab-select sp-title-generator">
|
||||||
<p class="sp-tab-select sp-title-generator">
|
<?php
|
||||||
<?php
|
$args = array(
|
||||||
$args = array(
|
'post_type' => 'sp_team',
|
||||||
'post_type' => 'sp_team',
|
'name' => 'sp_team[]',
|
||||||
'name' => 'sp_team[]',
|
'class' => 'sportspress-pages',
|
||||||
'class' => 'sportspress-pages',
|
'show_option_none' => __( '— None —', 'sportspress' ),
|
||||||
'show_option_none' => __( '— None —', 'sportspress' ),
|
'values' => 'ID',
|
||||||
'values' => 'ID',
|
'selected' => $team,
|
||||||
'selected' => $team,
|
);
|
||||||
);
|
sp_dropdown_pages( $args );
|
||||||
sp_dropdown_pages( $args );
|
?>
|
||||||
?>
|
</p>
|
||||||
</p>
|
<?php $tabs = apply_filters( 'sportspress_event_team_tabs', array( 'sp_player', 'sp_staff' ) ); ?>
|
||||||
<?php } else { ?>
|
<?php if ( $tabs ) { ?>
|
||||||
<input type="hidden" name="sp_team[]" value="0">
|
|
||||||
<?php } ?>
|
|
||||||
<ul id="sp_team-tabs" class="wp-tab-bar sp-tab-bar">
|
<ul id="sp_team-tabs" class="wp-tab-bar sp-tab-bar">
|
||||||
<li class="wp-tab-active"><a href="#sp_player-all"><?php _e( 'Players', 'sportspress' ); ?></a></li>
|
<?php foreach ( $tabs as $index => $post_type ) { $object = get_post_type_object( $post_type ); ?>
|
||||||
<li class="wp-tab"><a href="#sp_staff-all"><?php _e( 'Staff', 'sportspress' ); ?></a></li>
|
<li class="wp-tab<?php if ( 0 == $index ) { ?>-active<?php } ?>"><a href="#<?php echo $post_type; ?>-all"><?php echo $object->labels->name; ?></a></li>
|
||||||
|
<?php } ?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php
|
<?php
|
||||||
sp_post_checklist( $post->ID, 'sp_player', 'block', array( 'sp_league', 'sp_season', 'sp_current_team' ), $i );
|
foreach ( $tabs as $index => $post_type ) {
|
||||||
sp_post_checklist( $post->ID, 'sp_staff', 'none', array( 'sp_league', 'sp_season', 'sp_current_team' ), $i );
|
sp_post_checklist( $post->ID, $post_type, ( 0 == $index ? 'block' : 'none' ), array( 'sp_league', 'sp_season', 'sp_current_team' ), $i );
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
endfor;
|
endfor;
|
||||||
@@ -88,7 +89,11 @@ class SP_Meta_Box_Event_Teams {
|
|||||||
*/
|
*/
|
||||||
public static function save( $post_id, $post ) {
|
public static function save( $post_id, $post ) {
|
||||||
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() ) );
|
||||||
sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) );
|
$tabs = apply_filters( 'sportspress_event_team_tabs', array( 'sp_player', 'sp_staff' ) );
|
||||||
sp_update_post_meta_recursive( $post_id, 'sp_staff', sp_array_value( $_POST, 'sp_staff', array() ) );
|
if ( $tabs ) {
|
||||||
|
foreach ( $tabs as $post_type ) {
|
||||||
|
sp_update_post_meta_recursive( $post_id, $post_type, sp_array_value( $_POST, $post_type, array() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,12 +52,10 @@ class SP_Meta_Box_List_Data {
|
|||||||
<?php echo 'number' == $orderby ? '#' : __( 'Rank', 'sportspress' ); ?>
|
<?php echo 'number' == $orderby ? '#' : __( 'Rank', 'sportspress' ); ?>
|
||||||
</label></th>
|
</label></th>
|
||||||
<th><?php _e( 'Player', 'sportspress' ); ?></th>
|
<th><?php _e( 'Player', 'sportspress' ); ?></th>
|
||||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
<th><label for="sp_columns_team">
|
||||||
<th><label for="sp_columns_team">
|
<input type="checkbox" name="sp_columns[]" value="team" id="sp_columns_team" <?php checked( ! is_array( $columns ) || array_key_exists( 'team', $columns ) ); ?>>
|
||||||
<input type="checkbox" name="sp_columns[]" value="team" id="sp_columns_team" <?php checked( ! is_array( $columns ) || array_key_exists( 'team', $columns ) ); ?>>
|
<?php _e( 'Team', 'sportspress' ); ?>
|
||||||
<?php _e( 'Team', 'sportspress' ); ?>
|
</label></th>
|
||||||
</label></th>
|
|
||||||
<?php } ?>
|
|
||||||
<?php foreach ( $columns as $key => $label ): ?>
|
<?php foreach ( $columns as $key => $label ): ?>
|
||||||
<?php if ( in_array( $key, array( 'number', 'team' ) ) ) continue; ?>
|
<?php if ( in_array( $key, array( 'number', 'team' ) ) ) continue; ?>
|
||||||
<th><label for="sp_columns_<?php echo $key; ?>">
|
<th><label for="sp_columns_<?php echo $key; ?>">
|
||||||
@@ -102,23 +100,21 @@ class SP_Meta_Box_List_Data {
|
|||||||
<a class="button button-primary sp-save"><?php _e( 'Save', 'sportspress' ); ?></a>
|
<a class="button button-primary sp-save"><?php _e( 'Save', 'sportspress' ); ?></a>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
<td>
|
||||||
<td>
|
<?php
|
||||||
<?php
|
$selected = sp_array_value( $player_stats, 'team', get_post_meta( get_the_ID(), 'sp_team', true ) );
|
||||||
$selected = sp_array_value( $player_stats, 'team', get_post_meta( get_the_ID(), 'sp_team', true ) );
|
if ( ! $selected ) $selected = get_post_meta( $player_id, 'sp_team', true );
|
||||||
if ( ! $selected ) $selected = get_post_meta( $player_id, 'sp_team', true );
|
$include = get_post_meta( $player_id, 'sp_team' );
|
||||||
$include = get_post_meta( $player_id, 'sp_team' );
|
$args = array(
|
||||||
$args = array(
|
'post_type' => 'sp_team',
|
||||||
'post_type' => 'sp_team',
|
'name' => 'sp_players[' . $player_id . '][team]',
|
||||||
'name' => 'sp_players[' . $player_id . '][team]',
|
'include' => $include,
|
||||||
'include' => $include,
|
'selected' => $selected,
|
||||||
'selected' => $selected,
|
'values' => 'ID',
|
||||||
'values' => 'ID',
|
);
|
||||||
);
|
wp_dropdown_pages( $args );
|
||||||
wp_dropdown_pages( $args );
|
?>
|
||||||
?>
|
</td>
|
||||||
</td>
|
|
||||||
<?php } ?>
|
|
||||||
<?php foreach( $columns as $column => $label ):
|
<?php foreach( $columns as $column => $label ):
|
||||||
if ( in_array( $column, array( 'number', 'team' ) ) ) continue;
|
if ( in_array( $column, array( 'number', 'team' ) ) ) continue;
|
||||||
$value = sp_array_value( $player_stats, $column, '' );
|
$value = sp_array_value( $player_stats, $column, '' );
|
||||||
@@ -134,7 +130,7 @@ class SP_Meta_Box_List_Data {
|
|||||||
?>
|
?>
|
||||||
<tr class="sp-row alternate">
|
<tr class="sp-row alternate">
|
||||||
<td colspan="<?php $colspan = sizeof( $columns ) + 3; echo $colspan; ?>">
|
<td colspan="<?php $colspan = sizeof( $columns ) + 3; echo $colspan; ?>">
|
||||||
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Players', 'sportspress' ) ); ?>
|
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Data', 'sportspress' ) ); ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
@@ -182,7 +178,7 @@ class SP_Meta_Box_List_Data {
|
|||||||
?>
|
?>
|
||||||
<tr class="sp-row alternate">
|
<tr class="sp-row alternate">
|
||||||
<td colspan="<?php $colspan = sizeof( $columns ) + 3; echo $colspan; ?>">
|
<td colspan="<?php $colspan = sizeof( $columns ) + 3; echo $colspan; ?>">
|
||||||
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Players', 'sportspress' ) ); ?>
|
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Details', 'sportspress' ) ); ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
@@ -62,22 +62,22 @@ class SP_Meta_Box_List_Details {
|
|||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
<?php if ( apply_filters( 'sportspress_list_team_selector', true ) ) { ?>
|
||||||
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
|
||||||
<p class="sp-tab-select">
|
<p class="sp-tab-select">
|
||||||
<?php
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_team',
|
'post_type' => 'sp_team',
|
||||||
'name' => 'sp_team',
|
'name' => 'sp_team',
|
||||||
'show_option_all' => __( 'All', 'sportspress' ),
|
'show_option_all' => __( 'All', 'sportspress' ),
|
||||||
'selected' => $team_id,
|
'selected' => $team_id,
|
||||||
'values' => 'ID',
|
'values' => 'ID',
|
||||||
);
|
);
|
||||||
if ( ! sp_dropdown_pages( $args ) ):
|
if ( ! sp_dropdown_pages( $args ) ):
|
||||||
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
|
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<p><strong><?php _e( 'Grouping', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Grouping', 'sportspress' ); ?></strong></p>
|
||||||
<p>
|
<p>
|
||||||
@@ -128,9 +128,7 @@ class SP_Meta_Box_List_Details {
|
|||||||
* Save meta box data
|
* Save meta box data
|
||||||
*/
|
*/
|
||||||
public static function save( $post_id, $post ) {
|
public static function save( $post_id, $post ) {
|
||||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
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_league', 0 ), 'sp_league' );
|
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
|
||||||
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
||||||
update_post_meta( $post_id, 'sp_grouping', sp_array_value( $_POST, 'sp_grouping', array() ) );
|
update_post_meta( $post_id, 'sp_grouping', sp_array_value( $_POST, 'sp_grouping', array() ) );
|
||||||
|
|||||||
@@ -83,37 +83,35 @@ class SP_Meta_Box_Player_Details {
|
|||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
?></p>
|
?></p>
|
||||||
|
|
||||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
<p><strong><?php _e( 'Current Teams', 'sportspress' ); ?></strong></p>
|
||||||
<p><strong><?php _e( 'Current Teams', 'sportspress' ); ?></strong></p>
|
<p><?php
|
||||||
<p><?php
|
$args = array(
|
||||||
$args = array(
|
'post_type' => 'sp_team',
|
||||||
'post_type' => 'sp_team',
|
'name' => 'sp_current_team[]',
|
||||||
'name' => 'sp_current_team[]',
|
'selected' => $current_teams,
|
||||||
'selected' => $current_teams,
|
'values' => 'ID',
|
||||||
'values' => 'ID',
|
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
|
||||||
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
|
'class' => 'sp-current-teams widefat',
|
||||||
'class' => 'sp-current-teams widefat',
|
'property' => 'multiple',
|
||||||
'property' => 'multiple',
|
'chosen' => true,
|
||||||
'chosen' => true,
|
);
|
||||||
);
|
sp_dropdown_pages( $args );
|
||||||
sp_dropdown_pages( $args );
|
?></p>
|
||||||
?></p>
|
|
||||||
|
|
||||||
<p><strong><?php _e( 'Past Teams', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Past Teams', 'sportspress' ); ?></strong></p>
|
||||||
<p><?php
|
<p><?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_team',
|
'post_type' => 'sp_team',
|
||||||
'name' => 'sp_past_team[]',
|
'name' => 'sp_past_team[]',
|
||||||
'selected' => $past_teams,
|
'selected' => $past_teams,
|
||||||
'values' => 'ID',
|
'values' => 'ID',
|
||||||
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
|
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
|
||||||
'class' => 'sp-past-teams widefat',
|
'class' => 'sp-past-teams widefat',
|
||||||
'property' => 'multiple',
|
'property' => 'multiple',
|
||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
);
|
);
|
||||||
sp_dropdown_pages( $args );
|
sp_dropdown_pages( $args );
|
||||||
?></p>
|
?></p>
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
<p><strong><?php _e( 'Competitions', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Competitions', 'sportspress' ); ?></strong></p>
|
||||||
<p><?php
|
<p><?php
|
||||||
@@ -153,10 +151,8 @@ class SP_Meta_Box_Player_Details {
|
|||||||
public static function save( $post_id, $post ) {
|
public static function save( $post_id, $post ) {
|
||||||
update_post_meta( $post_id, 'sp_number', sp_array_value( $_POST, 'sp_number', '' ) );
|
update_post_meta( $post_id, 'sp_number', sp_array_value( $_POST, 'sp_number', '' ) );
|
||||||
update_post_meta( $post_id, 'sp_nationality', sp_array_value( $_POST, 'sp_nationality', '' ) );
|
update_post_meta( $post_id, 'sp_nationality', sp_array_value( $_POST, 'sp_nationality', '' ) );
|
||||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array() ) );
|
||||||
sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array() ) );
|
sp_update_post_meta_recursive( $post_id, 'sp_past_team', sp_array_value( $_POST, 'sp_past_team', array() ) );
|
||||||
sp_update_post_meta_recursive( $post_id, 'sp_past_team', sp_array_value( $_POST, 'sp_past_team', array() ) );
|
sp_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sp_array_value( $_POST, 'sp_current_team', array() ) ), sp_array_value( $_POST, 'sp_past_team', array() ) ) );
|
||||||
sp_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sp_array_value( $_POST, 'sp_current_team', array() ) ), sp_array_value( $_POST, 'sp_past_team', array() ) ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,19 +61,17 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php _e( 'Season', 'sportspress' ); ?></th>
|
<th><?php _e( 'Season', 'sportspress' ); ?></th>
|
||||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ): ?>
|
<?php if ( $league_id ): ?>
|
||||||
<?php if ( $league_id ): ?>
|
<th>
|
||||||
<th>
|
<?php if ( $has_checkboxes ): ?>
|
||||||
<?php if ( $has_checkboxes ): ?>
|
<label for="sp_columns_team">
|
||||||
<label for="sp_columns_team">
|
<input type="checkbox" name="sp_columns[]" value="team" id="sp_columns_team" <?php checked( ! is_array( $columns ) || array_key_exists( 'team', $columns ) ); ?>>
|
||||||
<input type="checkbox" name="sp_columns[]" value="team" id="sp_columns_team" <?php checked( ! is_array( $columns ) || array_key_exists( 'team', $columns ) ); ?>>
|
|
||||||
<?php _e( 'Team', 'sportspress' ); ?>
|
|
||||||
</label>
|
|
||||||
<?php else: ?>
|
|
||||||
<?php _e( 'Team', 'sportspress' ); ?>
|
<?php _e( 'Team', 'sportspress' ); ?>
|
||||||
<?php endif; ?>
|
</label>
|
||||||
</th>
|
<?php else: ?>
|
||||||
<?php endif; ?>
|
<?php _e( 'Team', 'sportspress' ); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</th>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php foreach ( $columns as $key => $label ): if ( $key == 'team' ) continue; ?>
|
<?php foreach ( $columns as $key => $label ): if ( $key == 'team' ) continue; ?>
|
||||||
<th><?php echo $label; ?></th>
|
<th><?php echo $label; ?></th>
|
||||||
@@ -89,7 +87,7 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
?>
|
?>
|
||||||
<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 if ( 'team' != get_option( 'sportspress_mode', 'team' ) && 0 !== $div_id ): ?>
|
<?php if ( 0 !== $div_id ): ?>
|
||||||
<label>
|
<label>
|
||||||
<?php $value = sp_array_value( $leagues, $div_id, '-1' ); ?>
|
<?php $value = sp_array_value( $leagues, $div_id, '-1' ); ?>
|
||||||
<input type="checkbox" name="sp_leagues[<?php echo $league_id; ?>][<?php echo $div_id; ?>]" value="1" <?php checked( $value ); ?>>
|
<input type="checkbox" name="sp_leagues[<?php echo $league_id; ?>][<?php echo $div_id; ?>]" value="1" <?php checked( $value ); ?>>
|
||||||
@@ -105,43 +103,41 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
?>
|
?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</td>
|
</td>
|
||||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ): ?>
|
<?php if ( $league_id ): ?>
|
||||||
<?php if ( $league_id ): ?>
|
<?php if ( $div_id == 0 ): ?>
|
||||||
<?php if ( $div_id == 0 ): ?>
|
<td> </td>
|
||||||
<td> </td>
|
<?php else: ?>
|
||||||
<?php else: ?>
|
<td>
|
||||||
<td>
|
<?php $value = sp_array_value( $leagues, $div_id, '-1' ); ?>
|
||||||
<?php $value = sp_array_value( $leagues, $div_id, '-1' ); ?>
|
<?php
|
||||||
<?php
|
$args = array(
|
||||||
$args = array(
|
'post_type' => 'sp_team',
|
||||||
'post_type' => 'sp_team',
|
'name' => 'sp_leagues[' . $league_id . '][' . $div_id . ']',
|
||||||
'name' => 'sp_leagues[' . $league_id . '][' . $div_id . ']',
|
'show_option_none' => __( '— None —', 'sportspress' ),
|
||||||
'show_option_none' => __( '— None —', 'sportspress' ),
|
'sort_order' => 'ASC',
|
||||||
'sort_order' => 'ASC',
|
'sort_column' => 'menu_order',
|
||||||
'sort_column' => 'menu_order',
|
'selected' => $value,
|
||||||
'selected' => $value,
|
'values' => 'ID',
|
||||||
'values' => 'ID',
|
'include' => $teams,
|
||||||
'include' => $teams,
|
'tax_query' => array(
|
||||||
'tax_query' => array(
|
'relation' => 'AND',
|
||||||
'relation' => 'AND',
|
array(
|
||||||
array(
|
'taxonomy' => 'sp_league',
|
||||||
'taxonomy' => 'sp_league',
|
'terms' => $league_id,
|
||||||
'terms' => $league_id,
|
'field' => 'id',
|
||||||
'field' => 'id',
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'taxonomy' => 'sp_season',
|
|
||||||
'terms' => $div_id,
|
|
||||||
'field' => 'id',
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
array(
|
||||||
if ( ! sp_dropdown_pages( $args ) ):
|
'taxonomy' => 'sp_season',
|
||||||
_e( '— None —', 'sportspress' );
|
'terms' => $div_id,
|
||||||
endif;
|
'field' => 'id',
|
||||||
?>
|
),
|
||||||
</td>
|
),
|
||||||
<?php endif; ?>
|
);
|
||||||
|
if ( ! sp_dropdown_pages( $args ) ):
|
||||||
|
_e( '— None —', 'sportspress' );
|
||||||
|
endif;
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php foreach ( $columns as $column => $label ): if ( $column == 'team' ) continue;
|
<?php foreach ( $columns as $column => $label ): if ( $column == 'team' ) continue;
|
||||||
|
|||||||
@@ -81,37 +81,35 @@ class SP_Meta_Box_Staff_Details {
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select></p>
|
</select></p>
|
||||||
|
|
||||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
|
||||||
<p><strong><?php _e( 'Current Teams', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Current Teams', 'sportspress' ); ?></strong></p>
|
||||||
<p><?php
|
<p><?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_team',
|
'post_type' => 'sp_team',
|
||||||
'name' => 'sp_current_team[]',
|
'name' => 'sp_current_team[]',
|
||||||
'selected' => $current_teams,
|
'selected' => $current_teams,
|
||||||
'values' => 'ID',
|
'values' => 'ID',
|
||||||
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
|
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
|
||||||
'class' => 'sp-current-teams widefat',
|
'class' => 'sp-current-teams widefat',
|
||||||
'property' => 'multiple',
|
'property' => 'multiple',
|
||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
);
|
);
|
||||||
sp_dropdown_pages( $args );
|
sp_dropdown_pages( $args );
|
||||||
?></p>
|
?></p>
|
||||||
|
|
||||||
<p><strong><?php _e( 'Past Teams', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Past Teams', 'sportspress' ); ?></strong></p>
|
||||||
<p><?php
|
<p><?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_team',
|
'post_type' => 'sp_team',
|
||||||
'name' => 'sp_past_team[]',
|
'name' => 'sp_past_team[]',
|
||||||
'selected' => $past_teams,
|
'selected' => $past_teams,
|
||||||
'values' => 'ID',
|
'values' => 'ID',
|
||||||
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
|
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
|
||||||
'class' => 'sp-past-teams widefat',
|
'class' => 'sp-past-teams widefat',
|
||||||
'property' => 'multiple',
|
'property' => 'multiple',
|
||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
);
|
);
|
||||||
sp_dropdown_pages( $args );
|
sp_dropdown_pages( $args );
|
||||||
?></p>
|
?></p>
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
<p><strong><?php _e( 'Competitions', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Competitions', 'sportspress' ); ?></strong></p>
|
||||||
<p><?php
|
<p><?php
|
||||||
@@ -152,10 +150,8 @@ class SP_Meta_Box_Staff_Details {
|
|||||||
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_role', null ), 'sp_role', false );
|
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_role', null ), 'sp_role', false );
|
||||||
update_post_meta( $post_id, 'sp_nationality', sp_array_value( $_POST, 'sp_nationality', '' ) );
|
update_post_meta( $post_id, 'sp_nationality', sp_array_value( $_POST, 'sp_nationality', '' ) );
|
||||||
|
|
||||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array() ) );
|
||||||
sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array() ) );
|
sp_update_post_meta_recursive( $post_id, 'sp_past_team', sp_array_value( $_POST, 'sp_past_team', array() ) );
|
||||||
sp_update_post_meta_recursive( $post_id, 'sp_past_team', sp_array_value( $_POST, 'sp_past_team', array() ) );
|
sp_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sp_array_value( $_POST, 'sp_current_team', array() ) ), sp_array_value( $_POST, 'sp_past_team', array() ) ) );
|
||||||
sp_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sp_array_value( $_POST, 'sp_current_team', array() ) ), sp_array_value( $_POST, 'sp_past_team', array() ) ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,6 +23,7 @@ class SP_Meta_Box_Statistic_Equation extends SP_Meta_Box_Equation {
|
|||||||
*/
|
*/
|
||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
$equation = get_post_meta( $post->ID, 'sp_equation', true );
|
$equation = get_post_meta( $post->ID, 'sp_equation', true );
|
||||||
self::builder( $post->post_title, $equation, array( 'player_event', 'outcome', 'performance', 'metric' ) );
|
$groups = array( 'player_event', 'outcome', 'performance', 'metric' );
|
||||||
|
self::builder( $post->post_title, $equation, $groups );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ class SP_Meta_Box_Table_Data {
|
|||||||
?>
|
?>
|
||||||
<tr class="sp-row alternate">
|
<tr class="sp-row alternate">
|
||||||
<td colspan="<?php $colspan = sizeof( $columns ) + 2; echo $colspan; ?>">
|
<td colspan="<?php $colspan = sizeof( $columns ) + 2; echo $colspan; ?>">
|
||||||
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ); ?>
|
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Data', 'sportspress' ) ); ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
@@ -147,7 +147,7 @@ class SP_Meta_Box_Table_Data {
|
|||||||
?>
|
?>
|
||||||
<tr class="sp-row alternate">
|
<tr class="sp-row alternate">
|
||||||
<td colspan="<?php $colspan = sizeof( $columns ) + 1; echo $colspan; ?>">
|
<td colspan="<?php $colspan = sizeof( $columns ) + 1; echo $colspan; ?>">
|
||||||
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ); ?>
|
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Data', 'sportspress' ) ); ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ class SP_Meta_Box_Table_Details {
|
|||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
<p><strong><?php _e( 'Teams', 'sportspress' ); ?></strong></p>
|
<p><strong>
|
||||||
|
<?php _e( 'Teams', 'sportspress' ); ?>
|
||||||
|
</strong></p>
|
||||||
<p class="sp-select-setting">
|
<p class="sp-select-setting">
|
||||||
<select name="sp_select">
|
<select name="sp_select">
|
||||||
<option value="auto" <?php selected( 'auto', $select ); ?>><?php _e( 'Auto', 'sportspress' ); ?></option>
|
<option value="auto" <?php selected( 'auto', $select ); ?>><?php _e( 'Auto', 'sportspress' ); ?></option>
|
||||||
|
|||||||
@@ -193,139 +193,6 @@ class SP_Settings_Events extends SP_Settings_Page {
|
|||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( 'yes' == get_option( 'sportspress_load_calendars_module', 'yes' ) ) {
|
|
||||||
|
|
||||||
$settings = array_merge( $settings,
|
|
||||||
|
|
||||||
array(
|
|
||||||
array( 'title' => __( 'Event List', 'sportspress' ), 'type' => 'title', 'id' => 'event_list_options' ),
|
|
||||||
),
|
|
||||||
|
|
||||||
apply_filters( 'sportspress_event_list_options', array(
|
|
||||||
array(
|
|
||||||
'title' => __( 'Teams', 'sportspress' ),
|
|
||||||
'desc' => __( 'Display logos', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_event_list_show_logos',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Title Format', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_event_list_title_format',
|
|
||||||
'default' => 'title',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'title' => __( 'Title', 'sportspress' ),
|
|
||||||
'teams' => __( 'Teams', 'sportspress' ),
|
|
||||||
'homeaway' => sprintf( '%s | %s', __( 'Home', 'sportspress' ), __( 'Away', 'sportspress' ) ),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Time/Results Format', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_event_list_time_format',
|
|
||||||
'default' => 'combined',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'combined' => __( 'Combined', 'sportspress' ),
|
|
||||||
'separate' => __( 'Separate', 'sportspress' ),
|
|
||||||
'time' => __( 'Time Only', 'sportspress' ),
|
|
||||||
'results' => __( 'Results Only', 'sportspress' ),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Pagination', 'sportspress' ),
|
|
||||||
'desc' => __( 'Paginate', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_event_list_paginated',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Limit', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_event_list_rows',
|
|
||||||
'class' => 'small-text',
|
|
||||||
'default' => '10',
|
|
||||||
'desc' => __( 'events', 'sportspress' ),
|
|
||||||
'type' => 'number',
|
|
||||||
'custom_attributes' => array(
|
|
||||||
'min' => 1,
|
|
||||||
'step' => 1
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
|
|
||||||
array(
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'event_list_options' ),
|
|
||||||
array( 'title' => __( 'Event Blocks', 'sportspress' ), 'type' => 'title', 'id' => 'event_blocks_options' ),
|
|
||||||
),
|
|
||||||
|
|
||||||
apply_filters( 'sportspress_event_blocks_options', array(
|
|
||||||
array(
|
|
||||||
'title' => __( 'Title', 'sportspress' ),
|
|
||||||
'desc' => __( 'Display calendar title', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_event_blocks_show_title',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Details', 'sportspress' ),
|
|
||||||
'desc' => __( 'Display competition', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_event_blocks_show_league',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'start',
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Display season', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_event_blocks_show_season',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => '',
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Display venue', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_event_blocks_show_venue',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'end',
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Pagination', 'sportspress' ),
|
|
||||||
'desc' => __( 'Paginate', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_event_blocks_paginated',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Limit', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_event_blocks_rows',
|
|
||||||
'class' => 'small-text',
|
|
||||||
'default' => '10',
|
|
||||||
'desc' => __( 'events', 'sportspress' ),
|
|
||||||
'type' => 'number',
|
|
||||||
'custom_attributes' => array(
|
|
||||||
'min' => 1,
|
|
||||||
'step' => 1
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
|
|
||||||
array(
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'event_list_options' ),
|
|
||||||
)
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
} // End event settings
|
|
||||||
|
|
||||||
return apply_filters( 'sportspress_event_settings', $settings );
|
return apply_filters( 'sportspress_event_settings', $settings );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,12 +60,12 @@ class SP_Settings_General extends SP_Settings_Page {
|
|||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Mode', 'sportspress' ),
|
'title' => __( 'Mode', 'sportspress' ),
|
||||||
'id' => 'sportspress_mode',
|
'id' => 'sportspress_load_individual_mode_module',
|
||||||
'default' => 'team',
|
'default' => 'no',
|
||||||
'type' => 'radio',
|
'type' => 'radio',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'team' => __( 'Teams', 'sportspress' ),
|
'no' => __( 'Team vs team', 'sportspress' ),
|
||||||
'player' => __( 'Players', 'sportspress' ) . ' ' . __( '(Beta)', 'sportspress' ),
|
'yes' => __( 'Player vs player', 'sportspress' ),
|
||||||
),
|
),
|
||||||
'desc_tip' => _x( 'Who competes in events?', 'mode setting description', 'sportspress' ),
|
'desc_tip' => _x( 'Who competes in events?', 'mode setting description', 'sportspress' ),
|
||||||
),
|
),
|
||||||
@@ -344,8 +344,8 @@ class SP_Settings_General extends SP_Settings_Page {
|
|||||||
*/
|
*/
|
||||||
function current_mode_setting() {
|
function current_mode_setting() {
|
||||||
?>
|
?>
|
||||||
<input type="hidden" name="sportspress_current_mode" value="<?php echo get_option( 'sportspress_mode', 'team' ); ?>">
|
<input type="hidden" name="sportspress_individual_mode_module_loaded" value="<?php echo get_option( 'sportspress_load_individual_mode_module', 'no' ); ?>">
|
||||||
<?php if ( sp_array_value( $_POST, 'sportspress_mode', 'team' ) !== sp_array_value( $_POST, 'sportspress_current_mode', 'team' ) ) { ?>
|
<?php if ( sp_array_value( $_POST, 'sportspress_load_individual_mode_module', 'no' ) !== sp_array_value( $_POST, 'sportspress_individual_mode_module_loaded', 'no' ) ) { ?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
window.location = window.location.href;
|
window.location = window.location.href;
|
||||||
|
|||||||
@@ -195,7 +195,6 @@ class SP_Settings_Modules extends SP_Settings_Page {
|
|||||||
|
|
||||||
<div class="sp-modules-main">
|
<div class="sp-modules-main">
|
||||||
<?php foreach ( SP()->modules->data as $section => $modules ) { ?>
|
<?php foreach ( SP()->modules->data as $section => $modules ) { ?>
|
||||||
<?php if ( 'team' == $section && 'team' != get_option( 'sportspress_mode', 'team' ) ) continue; ?>
|
|
||||||
<table class="sp-modules-table widefat" cellspacing="0">
|
<table class="sp-modules-table widefat" cellspacing="0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr><th>
|
<tr><th>
|
||||||
|
|||||||
@@ -107,53 +107,6 @@ class SP_Settings_Teams extends SP_Settings_Page {
|
|||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) {
|
|
||||||
|
|
||||||
$settings = array_merge( $settings,
|
|
||||||
|
|
||||||
array(
|
|
||||||
array( 'title' => __( 'League Tables', 'sportspress' ), 'type' => 'title', 'id' => 'table_options' ),
|
|
||||||
),
|
|
||||||
|
|
||||||
apply_filters( 'sportspress_table_options', array(
|
|
||||||
array(
|
|
||||||
'title' => __( 'Teams', 'sportspress' ),
|
|
||||||
'desc' => __( 'Display logos', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_table_show_logos',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Pagination', 'sportspress' ),
|
|
||||||
'desc' => __( 'Paginate', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_table_paginated',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Limit', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_table_rows',
|
|
||||||
'class' => 'small-text',
|
|
||||||
'default' => '10',
|
|
||||||
'desc' => __( 'teams', 'sportspress' ),
|
|
||||||
'type' => 'number',
|
|
||||||
'custom_attributes' => array(
|
|
||||||
'min' => 1,
|
|
||||||
'step' => 1
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
|
|
||||||
array(
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'table_options' ),
|
|
||||||
)
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
} // End team settings
|
|
||||||
|
|
||||||
return apply_filters( 'sportspress_team_settings', $settings );
|
return apply_filters( 'sportspress_team_settings', $settings );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,13 +106,6 @@ class SP_Event extends SP_Custom_Post{
|
|||||||
endif;
|
endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Move individual players to top level of array
|
|
||||||
if ( array_key_exists( 0, $performance ) && is_array( $performance[0] ) ) {
|
|
||||||
foreach ( $performance[ 0 ] as $player_id => $player_performance ) {
|
|
||||||
$performance[ $player_id ] = array( $player_id => $player_performance );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$performance[0] = $labels;
|
$performance[0] = $labels;
|
||||||
return $performance;
|
return $performance;
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class SP_Modules {
|
|||||||
'label' => __( 'Calendars', 'sportspress' ),
|
'label' => __( 'Calendars', 'sportspress' ),
|
||||||
'icon' => 'sp-icon-calendar',
|
'icon' => 'sp-icon-calendar',
|
||||||
),
|
),
|
||||||
'videos' => array(
|
'event_videos' => array(
|
||||||
'label' => __( 'Videos', 'sportspress' ),
|
'label' => __( 'Videos', 'sportspress' ),
|
||||||
'icon' => 'dashicons dashicons-video-alt',
|
'icon' => 'dashicons dashicons-video-alt',
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -450,7 +450,7 @@ class SP_Player_List extends SP_Custom_Post {
|
|||||||
foreach( $this->columns as $key ):
|
foreach( $this->columns as $key ):
|
||||||
if ( $key == 'number' ):
|
if ( $key == 'number' ):
|
||||||
$labels[ $key ] = '#';
|
$labels[ $key ] = '#';
|
||||||
elseif ( $key == 'team' && 'team' == get_option( 'sportspress_mode', 'team' ) ):
|
elseif ( $key == 'team' ):
|
||||||
$labels[ $key ] = __( 'Team', 'sportspress' );
|
$labels[ $key ] = __( 'Team', 'sportspress' );
|
||||||
elseif ( array_key_exists( $key, $columns ) ):
|
elseif ( array_key_exists( $key, $columns ) ):
|
||||||
$labels[ $key ] = $columns[ $key ];
|
$labels[ $key ] = $columns[ $key ];
|
||||||
@@ -469,7 +469,7 @@ class SP_Player_List extends SP_Custom_Post {
|
|||||||
$labels = array();
|
$labels = array();
|
||||||
if ( in_array( 'number', $this->columns ) ) $labels['number'] = '#';
|
if ( in_array( 'number', $this->columns ) ) $labels['number'] = '#';
|
||||||
$labels['name'] = __( 'Player', 'sportspress' );
|
$labels['name'] = __( 'Player', 'sportspress' );
|
||||||
if ( in_array( 'team', $this->columns ) && 'team' == get_option( 'sportspress_mode', 'team' ) ) $labels['team'] = __( 'Team', 'sportspress' );
|
if ( in_array( 'team', $this->columns ) ) $labels['team'] = __( 'Team', 'sportspress' );
|
||||||
|
|
||||||
$merged[0] = array_merge( $labels, $columns );
|
$merged[0] = array_merge( $labels, $columns );
|
||||||
return $merged;
|
return $merged;
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ class SP_Post_types {
|
|||||||
apply_filters( 'sportspress_register_post_type_result',
|
apply_filters( 'sportspress_register_post_type_result',
|
||||||
array(
|
array(
|
||||||
'labels' => array(
|
'labels' => array(
|
||||||
'name' => __( 'Team Results', 'sportspress' ),
|
'name' => __( 'Event Results', 'sportspress' ),
|
||||||
'singular_name' => __( 'Result', 'sportspress' ),
|
'singular_name' => __( 'Result', 'sportspress' ),
|
||||||
'add_new_item' => __( 'Add New Result', 'sportspress' ),
|
'add_new_item' => __( 'Add New Result', 'sportspress' ),
|
||||||
'edit_item' => __( 'Edit Result', 'sportspress' ),
|
'edit_item' => __( 'Edit Result', 'sportspress' ),
|
||||||
@@ -396,103 +396,68 @@ class SP_Post_types {
|
|||||||
|
|
||||||
register_post_type( 'sp_event', apply_filters( 'sportspress_register_post_type_event', $args ) );
|
register_post_type( 'sp_event', apply_filters( 'sportspress_register_post_type_event', $args ) );
|
||||||
|
|
||||||
if ( 'yes' == get_option( 'sportspress_load_calendars_module', 'yes' ) ) {
|
register_post_type( 'sp_team',
|
||||||
register_post_type( 'sp_calendar',
|
apply_filters( 'sportspress_register_post_type_team',
|
||||||
apply_filters( 'sportspress_register_post_type_calendar',
|
array(
|
||||||
|
'labels' => array(
|
||||||
|
'name' => __( 'Teams', 'sportspress' ),
|
||||||
|
'singular_name' => __( 'Team', 'sportspress' ),
|
||||||
|
'add_new_item' => __( 'Add New Team', 'sportspress' ),
|
||||||
|
'edit_item' => __( 'Edit Team', 'sportspress' ),
|
||||||
|
'new_item' => __( 'New', 'sportspress' ),
|
||||||
|
'view_item' => __( 'View Team', 'sportspress' ),
|
||||||
|
'search_items' => __( 'Search', 'sportspress' ),
|
||||||
|
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||||
|
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
|
||||||
|
),
|
||||||
|
'public' => true,
|
||||||
|
'show_ui' => true,
|
||||||
|
'capability_type' => 'sp_team',
|
||||||
|
'map_meta_cap' => true,
|
||||||
|
'publicly_queryable' => true,
|
||||||
|
'exclude_from_search' => false,
|
||||||
|
'hierarchical' => true,
|
||||||
|
'rewrite' => array( 'slug' => get_option( 'sportspress_team_slug', 'team' ) ),
|
||||||
|
'supports' => array( 'title', 'author', 'thumbnail', 'page-attributes', 'excerpt' ),
|
||||||
|
'has_archive' => false,
|
||||||
|
'show_in_nav_menus' => true,
|
||||||
|
'menu_icon' => 'dashicons-shield-alt',
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) {
|
||||||
|
register_post_type( 'sp_table',
|
||||||
|
apply_filters( 'sportspress_register_post_type_table',
|
||||||
array(
|
array(
|
||||||
'labels' => array(
|
'labels' => array(
|
||||||
'name' => __( 'Calendars', 'sportspress' ),
|
'name' => __( 'League Tables', 'sportspress' ),
|
||||||
'singular_name' => __( 'Calendar', 'sportspress' ),
|
'singular_name' => __( 'League Table', 'sportspress' ),
|
||||||
'add_new_item' => __( 'Add New Calendar', 'sportspress' ),
|
'add_new_item' => __( 'Add New League Table', 'sportspress' ),
|
||||||
'edit_item' => __( 'Edit Calendar', 'sportspress' ),
|
'edit_item' => __( 'Edit League Table', 'sportspress' ),
|
||||||
'new_item' => __( 'New', 'sportspress' ),
|
'new_item' => __( 'New', 'sportspress' ),
|
||||||
'view_item' => __( 'View Calendar', 'sportspress' ),
|
'view_item' => __( 'View League Table', 'sportspress' ),
|
||||||
'search_items' => __( 'Search', 'sportspress' ),
|
'search_items' => __( 'Search', 'sportspress' ),
|
||||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||||
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
|
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
|
||||||
),
|
),
|
||||||
'public' => true,
|
'public' => true,
|
||||||
'show_ui' => true,
|
'show_ui' => true,
|
||||||
'capability_type' => 'sp_calendar',
|
'capability_type' => 'sp_table',
|
||||||
'map_meta_cap' => true,
|
'map_meta_cap' => true,
|
||||||
'publicly_queryable' => true,
|
'publicly_queryable' => true,
|
||||||
'exclude_from_search' => false,
|
'exclude_from_search' => false,
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'rewrite' => array( 'slug' => get_option( 'sportspress_calendar_slug', 'calendar' ) ),
|
'rewrite' => array( 'slug' => get_option( 'sportspress_table_slug', 'table' ) ),
|
||||||
'supports' => array( 'title', 'author', 'thumbnail' ),
|
'supports' => array( 'title', 'page-attributes', 'thumbnail' ),
|
||||||
'has_archive' => false,
|
'has_archive' => false,
|
||||||
'show_in_nav_menus' => true,
|
'show_in_nav_menus' => true,
|
||||||
'show_in_menu' => 'edit.php?post_type=sp_event',
|
'show_in_menu' => 'edit.php?post_type=sp_team',
|
||||||
'show_in_admin_bar' => true,
|
'show_in_admin_bar' => true,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
|
||||||
register_post_type( 'sp_team',
|
|
||||||
apply_filters( 'sportspress_register_post_type_team',
|
|
||||||
array(
|
|
||||||
'labels' => array(
|
|
||||||
'name' => __( 'Teams', 'sportspress' ),
|
|
||||||
'singular_name' => __( 'Team', 'sportspress' ),
|
|
||||||
'add_new_item' => __( 'Add New Team', 'sportspress' ),
|
|
||||||
'edit_item' => __( 'Edit Team', 'sportspress' ),
|
|
||||||
'new_item' => __( 'New', 'sportspress' ),
|
|
||||||
'view_item' => __( 'View Team', 'sportspress' ),
|
|
||||||
'search_items' => __( 'Search', 'sportspress' ),
|
|
||||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
|
||||||
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'public' => true,
|
|
||||||
'show_ui' => true,
|
|
||||||
'capability_type' => 'sp_team',
|
|
||||||
'map_meta_cap' => true,
|
|
||||||
'publicly_queryable' => true,
|
|
||||||
'exclude_from_search' => false,
|
|
||||||
'hierarchical' => true,
|
|
||||||
'rewrite' => array( 'slug' => get_option( 'sportspress_team_slug', 'team' ) ),
|
|
||||||
'supports' => array( 'title', 'author', 'thumbnail', 'page-attributes', 'excerpt' ),
|
|
||||||
'has_archive' => false,
|
|
||||||
'show_in_nav_menus' => true,
|
|
||||||
'menu_icon' => 'dashicons-shield-alt',
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) {
|
|
||||||
register_post_type( 'sp_table',
|
|
||||||
apply_filters( 'sportspress_register_post_type_table',
|
|
||||||
array(
|
|
||||||
'labels' => array(
|
|
||||||
'name' => __( 'League Tables', 'sportspress' ),
|
|
||||||
'singular_name' => __( 'League Table', 'sportspress' ),
|
|
||||||
'add_new_item' => __( 'Add New League Table', 'sportspress' ),
|
|
||||||
'edit_item' => __( 'Edit League Table', 'sportspress' ),
|
|
||||||
'new_item' => __( 'New', 'sportspress' ),
|
|
||||||
'view_item' => __( 'View League Table', 'sportspress' ),
|
|
||||||
'search_items' => __( 'Search', 'sportspress' ),
|
|
||||||
'not_found' => __( 'No results found.', 'sportspress' ),
|
|
||||||
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'public' => true,
|
|
||||||
'show_ui' => true,
|
|
||||||
'capability_type' => 'sp_table',
|
|
||||||
'map_meta_cap' => true,
|
|
||||||
'publicly_queryable' => true,
|
|
||||||
'exclude_from_search' => false,
|
|
||||||
'hierarchical' => false,
|
|
||||||
'rewrite' => array( 'slug' => get_option( 'sportspress_table_slug', 'table' ) ),
|
|
||||||
'supports' => array( 'title', 'page-attributes', 'thumbnail' ),
|
|
||||||
'has_archive' => false,
|
|
||||||
'show_in_nav_menus' => true,
|
|
||||||
'show_in_menu' => 'edit.php?post_type=sp_team',
|
|
||||||
'show_in_admin_bar' => true,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
register_post_type( 'sp_player',
|
register_post_type( 'sp_player',
|
||||||
apply_filters( 'sportspress_register_post_type_player',
|
apply_filters( 'sportspress_register_post_type_player',
|
||||||
|
|||||||
@@ -23,29 +23,14 @@ class SP_Shortcodes {
|
|||||||
'player_details' => __CLASS__ . '::player_details',
|
'player_details' => __CLASS__ . '::player_details',
|
||||||
'player_statistics' => __CLASS__ . '::player_statistics',
|
'player_statistics' => __CLASS__ . '::player_statistics',
|
||||||
'staff' => __CLASS__ . '::staff',
|
'staff' => __CLASS__ . '::staff',
|
||||||
|
'event_calendar' => __CLASS__ . '::event_calendar',
|
||||||
|
'event_list' => __CLASS__ . '::event_list',
|
||||||
|
'event_blocks' => __CLASS__ . '::event_blocks',
|
||||||
|
'league_table' => __CLASS__ . '::league_table',
|
||||||
|
'player_list' => __CLASS__ . '::player_list',
|
||||||
|
'player_gallery' => __CLASS__ . '::player_gallery',
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( 'yes' == get_option( 'sportspress_load_calendars_module', 'yes' ) ) {
|
|
||||||
$shortcodes = array_merge( $shortcodes, array(
|
|
||||||
'event_calendar' => __CLASS__ . '::event_calendar',
|
|
||||||
'event_list' => __CLASS__ . '::event_list',
|
|
||||||
'event_blocks' => __CLASS__ . '::event_blocks',
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) {
|
|
||||||
$shortcodes = array_merge( $shortcodes, array(
|
|
||||||
'league_table' => __CLASS__ . '::league_table',
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( 'yes' == get_option( 'sportspress_load_player_lists_module', 'yes' ) ) {
|
|
||||||
$shortcodes = array_merge( $shortcodes, array(
|
|
||||||
'player_list' => __CLASS__ . '::player_list',
|
|
||||||
'player_gallery' => __CLASS__ . '::player_gallery',
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ( $shortcodes as $shortcode => $function ) {
|
foreach ( $shortcodes as $shortcode => $function ) {
|
||||||
add_shortcode( $shortcode, $function );
|
add_shortcode( $shortcode, $function );
|
||||||
}
|
}
|
||||||
|
|||||||
312
modules/sportspress-calendars.php
Normal file
312
modules/sportspress-calendars.php
Normal file
@@ -0,0 +1,312 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: SportsPress Calendars
|
||||||
|
Plugin URI: http://themeboy.com/
|
||||||
|
Description: Add event calendars to SportsPress.
|
||||||
|
Author: ThemeBoy
|
||||||
|
Author URI: http://themeboy.com/
|
||||||
|
Version: 1.6
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Exit if accessed directly
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||||
|
|
||||||
|
if ( ! class_exists( 'SportsPress_Calendars' ) ) :
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main SportsPress Calendars Class
|
||||||
|
*
|
||||||
|
* @class SportsPress_Calendars
|
||||||
|
* @version 1.6
|
||||||
|
*/
|
||||||
|
class SportsPress_Calendars {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
// Define constants
|
||||||
|
$this->define_constants();
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
add_action( 'init', array( $this, 'register_post_type' ) );
|
||||||
|
add_action( 'sportspress_include_post_type_handlers', array( $this, 'include_post_type_handler' ) );
|
||||||
|
add_action( 'sportspress_widgets', array( $this, 'include_widgets' ) );
|
||||||
|
|
||||||
|
// Filters
|
||||||
|
add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_boxes' ) );
|
||||||
|
add_filter( 'sportspress_shortcodes', array( $this, 'add_shortcodes' ) );
|
||||||
|
add_filter( 'sportspress_event_settings', array( $this, 'add_settings' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define constants.
|
||||||
|
*/
|
||||||
|
private function define_constants() {
|
||||||
|
if ( !defined( 'SP_CALENDARS_VERSION' ) )
|
||||||
|
define( 'SP_CALENDARS_VERSION', '1.6' );
|
||||||
|
|
||||||
|
if ( !defined( 'SP_CALENDARS_URL' ) )
|
||||||
|
define( 'SP_CALENDARS_URL', plugin_dir_url( __FILE__ ) );
|
||||||
|
|
||||||
|
if ( !defined( 'SP_CALENDARS_DIR' ) )
|
||||||
|
define( 'SP_CALENDARS_DIR', plugin_dir_path( __FILE__ ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register calendars post type
|
||||||
|
*/
|
||||||
|
public static function register_post_type() {
|
||||||
|
register_post_type( 'sp_calendar',
|
||||||
|
apply_filters( 'sportspress_register_post_type_calendar',
|
||||||
|
array(
|
||||||
|
'labels' => array(
|
||||||
|
'name' => __( 'Calendars', 'sportspress' ),
|
||||||
|
'singular_name' => __( 'Calendar', 'sportspress' ),
|
||||||
|
'add_new_item' => __( 'Add New Calendar', 'sportspress' ),
|
||||||
|
'edit_item' => __( 'Edit Calendar', 'sportspress' ),
|
||||||
|
'new_item' => __( 'New', 'sportspress' ),
|
||||||
|
'view_item' => __( 'View Calendar', 'sportspress' ),
|
||||||
|
'search_items' => __( 'Search', 'sportspress' ),
|
||||||
|
'not_found' => __( 'No results found.', 'sportspress' ),
|
||||||
|
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
|
||||||
|
),
|
||||||
|
'public' => true,
|
||||||
|
'show_ui' => true,
|
||||||
|
'capability_type' => 'sp_calendar',
|
||||||
|
'map_meta_cap' => true,
|
||||||
|
'publicly_queryable' => true,
|
||||||
|
'exclude_from_search' => false,
|
||||||
|
'hierarchical' => false,
|
||||||
|
'rewrite' => array( 'slug' => get_option( 'sportspress_calendar_slug', 'calendar' ) ),
|
||||||
|
'supports' => array( 'title', 'author', 'thumbnail' ),
|
||||||
|
'has_archive' => false,
|
||||||
|
'show_in_nav_menus' => true,
|
||||||
|
'show_in_menu' => 'edit.php?post_type=sp_event',
|
||||||
|
'show_in_admin_bar' => true,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conditonally load the class and functions only needed when viewing this post type.
|
||||||
|
*/
|
||||||
|
public function include_post_type_handler() {
|
||||||
|
include_once( SP()->plugin_path() . '/includes/admin/post-types/class-sp-admin-cpt-calendar.php' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add widgets.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function include_widgets() {
|
||||||
|
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-event-calendar.php' );
|
||||||
|
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-event-list.php' );
|
||||||
|
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-event-blocks.php' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add meta boxes to calendars.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function add_meta_boxes( $meta_boxes ) {
|
||||||
|
$meta_boxes['sp_calendar'] = array(
|
||||||
|
'shortcode' => array(
|
||||||
|
'title' => __( 'Shortcode', 'sportspress' ),
|
||||||
|
'output' => 'SP_Meta_Box_Calendar_Shortcode::output',
|
||||||
|
'context' => 'side',
|
||||||
|
'priority' => 'default',
|
||||||
|
),
|
||||||
|
'feeds' => array(
|
||||||
|
'title' => __( 'Feeds', 'sportspress' ),
|
||||||
|
'output' => 'SP_Meta_Box_Calendar_Feeds::output',
|
||||||
|
'context' => 'side',
|
||||||
|
'priority' => 'default',
|
||||||
|
),
|
||||||
|
'format' => array(
|
||||||
|
'title' => __( 'Layout', 'sportspress' ),
|
||||||
|
'save' => 'SP_Meta_Box_Calendar_Format::save',
|
||||||
|
'output' => 'SP_Meta_Box_Calendar_Format::output',
|
||||||
|
'context' => 'side',
|
||||||
|
'priority' => 'default',
|
||||||
|
),
|
||||||
|
'details' => array(
|
||||||
|
'title' => __( 'Details', 'sportspress' ),
|
||||||
|
'save' => 'SP_Meta_Box_Calendar_Details::save',
|
||||||
|
'output' => 'SP_Meta_Box_Calendar_Details::output',
|
||||||
|
'context' => 'side',
|
||||||
|
'priority' => 'default',
|
||||||
|
),
|
||||||
|
'data' => array(
|
||||||
|
'title' => __( 'Events', 'sportspress' ),
|
||||||
|
'save' => 'SP_Meta_Box_Calendar_Data::save',
|
||||||
|
'output' => 'SP_Meta_Box_Calendar_Data::output',
|
||||||
|
'context' => 'normal',
|
||||||
|
'priority' => 'high',
|
||||||
|
),
|
||||||
|
'editor' => array(
|
||||||
|
'title' => __( 'Description', 'sportspress' ),
|
||||||
|
'output' => 'SP_Meta_Box_Calendar_Editor::output',
|
||||||
|
'context' => 'normal',
|
||||||
|
'priority' => 'low',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return $meta_boxes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add shortcodes.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function add_shortcodes( $shortcodes ) {
|
||||||
|
$shortcodes['event'][] = 'calendar';
|
||||||
|
$shortcodes['event'][] = 'list';
|
||||||
|
$shortcodes['event'][] = 'blocks';
|
||||||
|
return $shortcodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add settings.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function add_settings( $settings ) {
|
||||||
|
$settings = array_merge( $settings,
|
||||||
|
array(
|
||||||
|
array( 'title' => __( 'Event List', 'sportspress' ), 'type' => 'title', 'id' => 'event_list_options' ),
|
||||||
|
),
|
||||||
|
|
||||||
|
apply_filters( 'sportspress_event_list_options', array(
|
||||||
|
array(
|
||||||
|
'title' => __( 'Teams', 'sportspress' ),
|
||||||
|
'desc' => __( 'Display logos', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_event_list_show_logos',
|
||||||
|
'default' => 'no',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'title' => __( 'Title Format', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_event_list_title_format',
|
||||||
|
'default' => 'title',
|
||||||
|
'type' => 'select',
|
||||||
|
'options' => array(
|
||||||
|
'title' => __( 'Title', 'sportspress' ),
|
||||||
|
'teams' => __( 'Teams', 'sportspress' ),
|
||||||
|
'homeaway' => sprintf( '%s | %s', __( 'Home', 'sportspress' ), __( 'Away', 'sportspress' ) ),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'title' => __( 'Time/Results Format', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_event_list_time_format',
|
||||||
|
'default' => 'combined',
|
||||||
|
'type' => 'select',
|
||||||
|
'options' => array(
|
||||||
|
'combined' => __( 'Combined', 'sportspress' ),
|
||||||
|
'separate' => __( 'Separate', 'sportspress' ),
|
||||||
|
'time' => __( 'Time Only', 'sportspress' ),
|
||||||
|
'results' => __( 'Results Only', 'sportspress' ),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'title' => __( 'Pagination', 'sportspress' ),
|
||||||
|
'desc' => __( 'Paginate', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_event_list_paginated',
|
||||||
|
'default' => 'yes',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'title' => __( 'Limit', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_event_list_rows',
|
||||||
|
'class' => 'small-text',
|
||||||
|
'default' => '10',
|
||||||
|
'desc' => __( 'events', 'sportspress' ),
|
||||||
|
'type' => 'number',
|
||||||
|
'custom_attributes' => array(
|
||||||
|
'min' => 1,
|
||||||
|
'step' => 1
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
|
||||||
|
array(
|
||||||
|
array( 'type' => 'sectionend', 'id' => 'event_list_options' ),
|
||||||
|
array( 'title' => __( 'Event Blocks', 'sportspress' ), 'type' => 'title', 'id' => 'event_blocks_options' ),
|
||||||
|
),
|
||||||
|
|
||||||
|
apply_filters( 'sportspress_event_blocks_options', array(
|
||||||
|
array(
|
||||||
|
'title' => __( 'Title', 'sportspress' ),
|
||||||
|
'desc' => __( 'Display calendar title', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_event_blocks_show_title',
|
||||||
|
'default' => 'no',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'title' => __( 'Details', 'sportspress' ),
|
||||||
|
'desc' => __( 'Display competition', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_event_blocks_show_league',
|
||||||
|
'default' => 'no',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'checkboxgroup' => 'start',
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'desc' => __( 'Display season', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_event_blocks_show_season',
|
||||||
|
'default' => 'no',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'checkboxgroup' => '',
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'desc' => __( 'Display venue', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_event_blocks_show_venue',
|
||||||
|
'default' => 'no',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'checkboxgroup' => 'end',
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'title' => __( 'Pagination', 'sportspress' ),
|
||||||
|
'desc' => __( 'Paginate', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_event_blocks_paginated',
|
||||||
|
'default' => 'yes',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'title' => __( 'Limit', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_event_blocks_rows',
|
||||||
|
'class' => 'small-text',
|
||||||
|
'default' => '10',
|
||||||
|
'desc' => __( 'events', 'sportspress' ),
|
||||||
|
'type' => 'number',
|
||||||
|
'custom_attributes' => array(
|
||||||
|
'min' => 1,
|
||||||
|
'step' => 1
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
|
||||||
|
array(
|
||||||
|
array( 'type' => 'sectionend', 'id' => 'event_list_options' ),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if ( get_option( 'sportspress_load_calendars_module', 'yes' ) == 'yes' ) {
|
||||||
|
new SportsPress_Calendars();
|
||||||
|
}
|
||||||
70
modules/sportspress-event-videos.php
Normal file
70
modules/sportspress-event-videos.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: SportsPress Event Videos
|
||||||
|
Plugin URI: http://themeboy.com/
|
||||||
|
Description: Add videos to SportsPress events.
|
||||||
|
Author: ThemeBoy
|
||||||
|
Author URI: http://themeboy.com/
|
||||||
|
Version: 1.6
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Exit if accessed directly
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||||
|
|
||||||
|
if ( ! class_exists( 'SportsPress_Event_Videos' ) ) :
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main SportsPress Event Videos Class
|
||||||
|
*
|
||||||
|
* @class SportsPress_Event_Videos
|
||||||
|
* @version 1.6
|
||||||
|
*/
|
||||||
|
class SportsPress_Event_Videos {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
// Define constants
|
||||||
|
$this->define_constants();
|
||||||
|
|
||||||
|
// Filters
|
||||||
|
add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_box' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define constants.
|
||||||
|
*/
|
||||||
|
private function define_constants() {
|
||||||
|
if ( !defined( 'SP_EVENT_VIDEOS_VERSION' ) )
|
||||||
|
define( 'SP_EVENT_VIDEOS_VERSION', '1.6' );
|
||||||
|
|
||||||
|
if ( !defined( 'SP_EVENT_VIDEOS_URL' ) )
|
||||||
|
define( 'SP_EVENT_VIDEOS_URL', plugin_dir_url( __FILE__ ) );
|
||||||
|
|
||||||
|
if ( !defined( 'SP_EVENT_VIDEOS_DIR' ) )
|
||||||
|
define( 'SP_EVENT_VIDEOS_DIR', plugin_dir_path( __FILE__ ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add meta box to events.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function add_meta_box( $meta_boxes ) {
|
||||||
|
$meta_boxes['sp_event']['video'] = array(
|
||||||
|
'title' => __( 'Video', 'sportspress' ),
|
||||||
|
'output' => 'SP_Meta_Box_Event_Video::output',
|
||||||
|
'save' => 'SP_Meta_Box_Event_Video::save',
|
||||||
|
'context' => 'side',
|
||||||
|
'priority' => 'low',
|
||||||
|
);
|
||||||
|
return $meta_boxes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if ( get_option( 'sportspress_load_event_videos_module', 'yes' ) == 'yes' ) {
|
||||||
|
new SportsPress_Event_Videos();
|
||||||
|
}
|
||||||
232
modules/sportspress-individual-mode.php
Normal file
232
modules/sportspress-individual-mode.php
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: SportsPress Individual Mode
|
||||||
|
Plugin URI: http://themeboy.com/
|
||||||
|
Description: Modify SportsPress to work with individual (player vs player) sports.
|
||||||
|
Author: ThemeBoy
|
||||||
|
Author URI: http://themeboy.com/
|
||||||
|
Version: 1.6
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Exit if accessed directly
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||||
|
|
||||||
|
if ( ! class_exists( 'SportsPress_Individual_Mode' ) ) :
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main SportsPress Individual Mode Class
|
||||||
|
*
|
||||||
|
* @class SportsPress_Individual_Mode
|
||||||
|
* @version 1.6
|
||||||
|
*/
|
||||||
|
class SportsPress_Individual_Mode {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
// Define constants
|
||||||
|
$this->define_constants();
|
||||||
|
|
||||||
|
// Filters
|
||||||
|
add_filter( 'gettext', array( $this, 'gettext' ), 99, 3 );
|
||||||
|
add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
|
||||||
|
add_filter( 'sportspress_register_post_type_team', array( $this, 'hide_post_type' ), 99 );
|
||||||
|
add_filter( 'sportspress_register_post_type_table', array( $this, 'move_table_post_type' ), 99 );
|
||||||
|
add_filter( 'sportspress_settings_tabs_array', array( $this, 'remove_team_settings_tab' ), 99 );
|
||||||
|
add_filter( 'sportspress_get_settings_pages', array( $this, 'remove_team_settings' ), 99 );
|
||||||
|
add_filter( 'sportspress_player_options', array( $this, 'add_player_options' ), 99 );
|
||||||
|
add_filter( 'sportspress_player_settings', array( $this, 'add_player_settings' ), 99 );
|
||||||
|
add_filter( 'sportspress_next_steps', array( $this, 'remove_team_step' ), 99 );
|
||||||
|
add_filter( 'sportspress_modules', array( $this, 'rearrange_modules' ), 99 );
|
||||||
|
add_filter( 'sportspress_glance_items', array( $this, 'remove_glance_item' ), 99 );
|
||||||
|
add_filter( 'sportspress_shortcodes', array( $this, 'remove_shortcodes' ), 99 );
|
||||||
|
add_filter( 'sportspress_list_admin_columns', array( $this, 'remove_team_column' ), 99 );
|
||||||
|
add_filter( 'sportspress_importers', array( $this, 'remove_teams_importer' ), 99 );
|
||||||
|
add_filter( 'sportspress_permalink_slugs', array( $this, 'remove_team_permalink_slug' ), 99 );
|
||||||
|
add_filter( 'sportspress_event_team_tabs', '__return_false' );
|
||||||
|
add_filter( 'sportspress_list_team_selector', '__return_false' );
|
||||||
|
|
||||||
|
// Remove templates
|
||||||
|
remove_action( 'sportspress_single_event_content', 'sportspress_output_event_performance', 50 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define constants.
|
||||||
|
*/
|
||||||
|
private function define_constants() {
|
||||||
|
if ( !defined( 'SP_INDIVIDUAL_MODE_VERSION' ) )
|
||||||
|
define( 'SP_INDIVIDUAL_MODE_VERSION', '1.6' );
|
||||||
|
|
||||||
|
if ( !defined( 'SP_INDIVIDUAL_MODE_URL' ) )
|
||||||
|
define( 'SP_INDIVIDUAL_MODE_URL', plugin_dir_url( __FILE__ ) );
|
||||||
|
|
||||||
|
if ( !defined( 'SP_INDIVIDUAL_MODE_DIR' ) )
|
||||||
|
define( 'SP_INDIVIDUAL_MODE_DIR', plugin_dir_path( __FILE__ ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify all team-related strings for players.
|
||||||
|
*/
|
||||||
|
public function gettext( $translated_text, $untranslated_text, $domain ) {
|
||||||
|
if ( 'sportspress' !== $domain ) return $translated_text;
|
||||||
|
|
||||||
|
switch ( $untranslated_text ) {
|
||||||
|
case 'Teams':
|
||||||
|
return __( 'Players', 'sportspress' );
|
||||||
|
break;
|
||||||
|
case 'Team':
|
||||||
|
return __( 'Player', 'sportspress' );
|
||||||
|
break;
|
||||||
|
case 'teams':
|
||||||
|
return __( 'players', 'sportspress' );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $translated_text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify all team post type queries for players.
|
||||||
|
*/
|
||||||
|
public function pre_get_posts( $query ) {
|
||||||
|
if ( 'sp_team' !== $query->get( 'post_type' ) ) return $query;
|
||||||
|
|
||||||
|
$query->set( 'post_type', 'sp_player' );
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide post types.
|
||||||
|
*/
|
||||||
|
public function hide_post_type( $args ) {
|
||||||
|
return array_merge( $args, array(
|
||||||
|
'public' => false,
|
||||||
|
'exclude_from_search' => true,
|
||||||
|
'publicly_queryable' => false,
|
||||||
|
'show_ui' => false,
|
||||||
|
'show_in_nav_menus' => false,
|
||||||
|
'show_in_menu' => false,
|
||||||
|
'show_in_admin_bar' => false,
|
||||||
|
'can_export' => false,
|
||||||
|
) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move league table post type under players.
|
||||||
|
*/
|
||||||
|
public function move_table_post_type( $args ) {
|
||||||
|
return array_merge( $args, array(
|
||||||
|
'show_in_menu' => 'edit.php?post_type=sp_player',
|
||||||
|
) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove team settings tab.
|
||||||
|
*/
|
||||||
|
public function remove_team_settings_tab( $tabs ) {
|
||||||
|
unset( $tabs['teams'] );
|
||||||
|
return $tabs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove team settings section.
|
||||||
|
*/
|
||||||
|
public function remove_team_settings( $settings ) {
|
||||||
|
foreach ( $settings as $index => $section ) {
|
||||||
|
if ( is_a( $section, 'SP_Settings_Teams' ) ) {
|
||||||
|
unset( $settings[ $index ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add options from teams to players tab.
|
||||||
|
*/
|
||||||
|
public function add_player_options( $options ) {
|
||||||
|
return apply_filters( 'sportspress_team_options', $options );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add settings from teams to players tab.
|
||||||
|
*/
|
||||||
|
public function add_player_settings( $settings ) {
|
||||||
|
return apply_filters( 'sportspress_team_settings', $settings );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove team step from welcome screen.
|
||||||
|
*/
|
||||||
|
public function remove_team_step( $steps ) {
|
||||||
|
unset( $steps['teams'] );
|
||||||
|
return $steps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rearrange modules.
|
||||||
|
*/
|
||||||
|
public function rearrange_modules( $modules ) {
|
||||||
|
$modules['player'] = array_merge(
|
||||||
|
sp_array_value( $modules, 'team', array() ),
|
||||||
|
sp_array_value( $modules, 'player' )
|
||||||
|
);
|
||||||
|
unset( $modules['player']['team_colors'] );
|
||||||
|
return $modules;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove teams glance item.
|
||||||
|
*/
|
||||||
|
public function remove_glance_item( $items ) {
|
||||||
|
if ( ( $index = array_search ( 'sp_team', $items ) ) !== false ) {
|
||||||
|
unset( $items[ $index ] );
|
||||||
|
}
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove shortcodes from editor.
|
||||||
|
*/
|
||||||
|
public function remove_shortcodes( $shortcodes ) {
|
||||||
|
if ( array_key_exists( 'event', $shortcodes ) ) {
|
||||||
|
if ( ( $index = array_search ( 'performance', $shortcodes['event'] ) ) !== false ) {
|
||||||
|
unset( $shortcodes['event'][ $index ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $shortcodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove team column from player list admin.
|
||||||
|
*/
|
||||||
|
public function remove_team_column( $columns ) {
|
||||||
|
unset( $columns['sp_team'] );
|
||||||
|
return $columns;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the teams csv importer.
|
||||||
|
*/
|
||||||
|
public function remove_teams_importer( $importers ) {
|
||||||
|
unset( $importers['sp_team_csv'] );
|
||||||
|
return $importers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the team permalink slug setting.
|
||||||
|
*/
|
||||||
|
public function remove_team_permalink_slug( $slugs ) {
|
||||||
|
if ( ( $index = array_search ( array( 'team', __( 'Teams', 'sportspress' ) ), $slugs ) ) !== false ) {
|
||||||
|
unset( $slugs[ $index ] );
|
||||||
|
}
|
||||||
|
return $slugs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if ( get_option( 'sportspress_load_individual_mode_module', 'yes' ) == 'yes' ) {
|
||||||
|
new SportsPress_Individual_Mode();
|
||||||
|
}
|
||||||
104
modules/sportspress-league-tables.php
Normal file
104
modules/sportspress-league-tables.php
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: SportsPress League Tables
|
||||||
|
Plugin URI: http://themeboy.com/
|
||||||
|
Description: Add league tables to SportsPress.
|
||||||
|
Author: ThemeBoy
|
||||||
|
Author URI: http://themeboy.com/
|
||||||
|
Version: 1.6
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Exit if accessed directly
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||||
|
|
||||||
|
if ( ! class_exists( 'SportsPress_League_Tables' ) ) :
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main SportsPress League Tables Class
|
||||||
|
*
|
||||||
|
* @class SportsPress_League_Tables
|
||||||
|
* @version 1.6
|
||||||
|
*/
|
||||||
|
class SportsPress_League_Tables {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
// Define constants
|
||||||
|
$this->define_constants();
|
||||||
|
|
||||||
|
// Mods
|
||||||
|
add_filter( 'sportspress_team_settings', array( $this, 'add_options' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define constants.
|
||||||
|
*/
|
||||||
|
private function define_constants() {
|
||||||
|
if ( !defined( 'SP_LEAGUE_TABLES_VERSION' ) )
|
||||||
|
define( 'SP_LEAGUE_TABLES_VERSION', '1.6' );
|
||||||
|
|
||||||
|
if ( !defined( 'SP_LEAGUE_TABLES_URL' ) )
|
||||||
|
define( 'SP_LEAGUE_TABLES_URL', plugin_dir_url( __FILE__ ) );
|
||||||
|
|
||||||
|
if ( !defined( 'SP_LEAGUE_TABLES_DIR' ) )
|
||||||
|
define( 'SP_LEAGUE_TABLES_DIR', plugin_dir_path( __FILE__ ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add options to settings page.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function add_options( $settings ) {
|
||||||
|
return array_merge( $settings,
|
||||||
|
|
||||||
|
array(
|
||||||
|
array( 'title' => __( 'League Tables', 'sportspress' ), 'type' => 'title', 'id' => 'table_options' ),
|
||||||
|
),
|
||||||
|
|
||||||
|
apply_filters( 'sportspress_table_options', array(
|
||||||
|
array(
|
||||||
|
'title' => __( 'Teams', 'sportspress' ),
|
||||||
|
'desc' => __( 'Display logos', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_table_show_logos',
|
||||||
|
'default' => 'yes',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'title' => __( 'Pagination', 'sportspress' ),
|
||||||
|
'desc' => __( 'Paginate', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_table_paginated',
|
||||||
|
'default' => 'yes',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'title' => __( 'Limit', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_table_rows',
|
||||||
|
'class' => 'small-text',
|
||||||
|
'default' => '10',
|
||||||
|
'desc' => __( 'teams', 'sportspress' ),
|
||||||
|
'type' => 'number',
|
||||||
|
'custom_attributes' => array(
|
||||||
|
'min' => 1,
|
||||||
|
'step' => 1
|
||||||
|
),
|
||||||
|
),
|
||||||
|
) ),
|
||||||
|
|
||||||
|
array(
|
||||||
|
array( 'type' => 'sectionend', 'id' => 'table_options' ),
|
||||||
|
)
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if ( get_option( 'sportspress_load_league_tables_module', 'yes' ) == 'yes' ) {
|
||||||
|
new SportsPress_League_Tables();
|
||||||
|
}
|
||||||
@@ -122,6 +122,9 @@ final class SportsPress {
|
|||||||
add_action( 'init', array( 'SP_Shortcodes', 'init' ) );
|
add_action( 'init', array( 'SP_Shortcodes', 'init' ) );
|
||||||
add_action( 'after_setup_theme', array( $this, 'setup_environment' ) );
|
add_action( 'after_setup_theme', array( $this, 'setup_environment' ) );
|
||||||
|
|
||||||
|
// Include core modules
|
||||||
|
$this->include_modules();
|
||||||
|
|
||||||
// Loaded action
|
// Loaded action
|
||||||
do_action( 'sportspress_loaded' );
|
do_action( 'sportspress_loaded' );
|
||||||
}
|
}
|
||||||
@@ -249,15 +252,19 @@ final class SportsPress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include core widgets
|
* Include core modules.
|
||||||
|
*/
|
||||||
|
private function include_modules() {
|
||||||
|
foreach ( glob( $this->plugin_path() . '/modules/*.php' ) as $filename ) {
|
||||||
|
include $filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include core widgets.
|
||||||
*/
|
*/
|
||||||
public function include_widgets() {
|
public function include_widgets() {
|
||||||
include_once( 'includes/widgets/class-sp-widget-countdown.php' );
|
include_once( 'includes/widgets/class-sp-widget-countdown.php' );
|
||||||
if ( 'yes' == get_option( 'sportspress_load_calendars_module', 'yes' ) ) {
|
|
||||||
include_once( 'includes/widgets/class-sp-widget-event-calendar.php' );
|
|
||||||
include_once( 'includes/widgets/class-sp-widget-event-list.php' );
|
|
||||||
include_once( 'includes/widgets/class-sp-widget-event-blocks.php' );
|
|
||||||
}
|
|
||||||
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) {
|
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) {
|
||||||
include_once( 'includes/widgets/class-sp-widget-league-table.php' );
|
include_once( 'includes/widgets/class-sp-widget-league-table.php' );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,28 +46,26 @@ $common[ __( 'Position', 'sportspress' ) ] = implode( ', ', $position_names );
|
|||||||
|
|
||||||
$data = array_merge( $metrics_before, $common, $metrics_after );
|
$data = array_merge( $metrics_before, $common, $metrics_after );
|
||||||
|
|
||||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
if ( $current_teams ):
|
||||||
if ( $current_teams ):
|
$teams = array();
|
||||||
$teams = array();
|
foreach ( $current_teams as $team ):
|
||||||
foreach ( $current_teams as $team ):
|
$team_name = get_the_title( $team );
|
||||||
$team_name = get_the_title( $team );
|
if ( $link_teams ) $team_name = '<a href="' . get_post_permalink( $team ) . '">' . $team_name . '</a>';
|
||||||
if ( $link_teams ) $team_name = '<a href="' . get_post_permalink( $team ) . '">' . $team_name . '</a>';
|
$teams[] = $team_name;
|
||||||
$teams[] = $team_name;
|
endforeach;
|
||||||
endforeach;
|
$label = _n( 'Current Team', 'Current Teams', count( $teams ), 'sportspress' );
|
||||||
$label = _n( 'Current Team', 'Current Teams', count( $teams ), 'sportspress' );
|
$data[ $label ] = implode( ', ', $teams );
|
||||||
$data[ $label ] = implode( ', ', $teams );
|
endif;
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( $past_teams ):
|
if ( $past_teams ):
|
||||||
$teams = array();
|
$teams = array();
|
||||||
foreach ( $past_teams as $team ):
|
foreach ( $past_teams as $team ):
|
||||||
$team_name = get_the_title( $team );
|
$team_name = get_the_title( $team );
|
||||||
if ( $link_teams ) $team_name = '<a href="' . get_post_permalink( $team ) . '">' . $team_name . '</a>';
|
if ( $link_teams ) $team_name = '<a href="' . get_post_permalink( $team ) . '">' . $team_name . '</a>';
|
||||||
$teams[] = $team_name;
|
$teams[] = $team_name;
|
||||||
endforeach;
|
endforeach;
|
||||||
$data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams );
|
$data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams );
|
||||||
endif;
|
endif;
|
||||||
}
|
|
||||||
|
|
||||||
$data = apply_filters( 'sportspress_player_details', $data, $id );
|
$data = apply_filters( 'sportspress_player_details', $data, $id );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user