Modularize!

This commit is contained in:
Brian Miyaji
2015-01-28 14:02:35 +11:00
parent aa0eeae6cd
commit 87baaf7288
35 changed files with 1491 additions and 928 deletions

View File

@@ -6,30 +6,37 @@
}
#dashboard_right_now .sp-event-count a:before,
#dashboard_right_now .sp-event-count span:before,
#dashboard_right_now .sp-team-count a:before,
#dashboard_right_now .sp-team-count span:before,
#dashboard_right_now .sp-player-count a:before,
#dashboard_right_now .sp-player-count span:before {
#dashboard_right_now .sp_event-count a:before,
#dashboard_right_now .sp_event-count span:before,
#dashboard_right_now .sp_team-count a:before,
#dashboard_right_now .sp_team-count span:before,
#dashboard_right_now .sp_player-count a: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';
}
#dashboard_right_now .sp-event-count a:before,
#dashboard_right_now .sp-event-count span:before {
#dashboard_right_now .sp_event-count a:before,
#dashboard_right_now .sp_event-count span:before {
content: "\f145";
}
#dashboard_right_now .sp-team-count a:before,
#dashboard_right_now .sp-team-count span:before {
#dashboard_right_now .sp_team-count a:before,
#dashboard_right_now .sp_team-count span:before {
content: "\f334";
}
#dashboard_right_now .sp-player-count a:before,
#dashboard_right_now .sp-player-count span:before {
#dashboard_right_now .sp_player-count a:before,
#dashboard_right_now .sp_player-count span:before {
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 {
overflow: hidden;
margin: 0;

View File

@@ -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' ) ) {
$options['table'] = array( 'table' );
}

View File

@@ -39,7 +39,7 @@ class SP_Admin_Dashboard {
* Add links to At a Glance
*/
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 ):
if ( ! post_type_exists( $type ) ) continue;
$num_posts = wp_count_posts( $type );
@@ -50,11 +50,10 @@ class SP_Admin_Dashboard {
$text = sprintf( $text, number_format_i18n( $published ) );
if ( current_user_can( $post_type->cap->edit_posts ) ):
$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:
$output = '<span>' . $text . '</span>';
echo '<li class="post-count ' . str_replace( '_', '-', $post_type->name ) . '-count">' . $output . '</li>';
endif;
echo '<li class="post-count ' . $post_type->name . '-count">' . $output . '</li>';
endif;
endforeach;
return $items;

View File

@@ -28,12 +28,32 @@ class SP_Admin_Importers {
* Add menu items
*/
public function register_importers() {
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
register_importer( 'sp_event_csv', __( 'SportsPress Events (CSV)', 'sportspress' ), __( 'Import <strong>events</strong> from a csv file.', 'sportspress'), array( $this, 'events_importer' ) );
register_importer( 'sp_team_csv', __( 'SportsPress Teams (CSV)', 'sportspress' ), __( 'Import <strong>teams</strong> from a csv file.', 'sportspress'), array( $this, 'teams_importer' ) );
$importers = apply_filters( 'sportspress_importers', array(
'sp_event_csv' => array(
'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' ) );
}
/**

View File

@@ -85,17 +85,18 @@ class SP_Admin_Menus {
public function menu_highlight() {
global $typenow;
$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' );
elseif ( is_sp_config_type( $typenow ) )
} elseif ( is_sp_config_type( $typenow ) ) {
$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' );
elseif ( $typenow == 'sp_table' )
} elseif ( $typenow == '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' );
}
}
/**
* Renames admin menu items.

View File

@@ -30,23 +30,21 @@ class SP_Admin_Post_Types {
* Conditonally load classes and functions only needed when viewing a post type.
*/
public function include_post_type_handlers() {
include( 'post-types/class-sp-admin-meta-boxes.php' );
include( 'post-types/class-sp-admin-cpt-result.php' );
include( 'post-types/class-sp-admin-cpt-outcome.php' );
include( 'post-types/class-sp-admin-cpt-performance.php' );
include( 'post-types/class-sp-admin-cpt-column.php' );
include( 'post-types/class-sp-admin-cpt-metric.php' );
include( 'post-types/class-sp-admin-cpt-statistic.php' );
include( 'post-types/class-sp-admin-cpt-event.php' );
if ( 'yes' == get_option( 'sportspress_load_calendars_module', 'yes' ) )
include( 'post-types/class-sp-admin-cpt-calendar.php' );
include( 'post-types/class-sp-admin-cpt-team.php' );
include_once( 'post-types/class-sp-admin-meta-boxes.php' );
include_once( 'post-types/class-sp-admin-cpt-result.php' );
include_once( 'post-types/class-sp-admin-cpt-outcome.php' );
include_once( 'post-types/class-sp-admin-cpt-performance.php' );
include_once( 'post-types/class-sp-admin-cpt-column.php' );
include_once( 'post-types/class-sp-admin-cpt-metric.php' );
include_once( 'post-types/class-sp-admin-cpt-statistic.php' );
include_once( 'post-types/class-sp-admin-cpt-event.php' );
include_once( 'post-types/class-sp-admin-cpt-team.php' );
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) )
include( '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-table.php' );
include_once( 'post-types/class-sp-admin-cpt-player.php' );
if ( 'yes' == get_option( 'sportspress_load_player_lists_module', 'yes' ) )
include( '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-list.php' );
include_once( 'post-types/class-sp-admin-cpt-staff.php' );
do_action( 'sportspress_include_post_type_handlers' );
}

View File

@@ -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
$players = array(
'Mario Bellucci',
@@ -193,6 +159,38 @@ class SP_Admin_Sample_Data {
// Get 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
$columns = array( 'team' );
$args = array(
@@ -347,7 +345,6 @@ class SP_Admin_Sample_Data {
/*
* Insert events
*/
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
for ( $index = 0; $index < 6; $index ++ ) {
// Determine team index and post status
$i = $index % 3;
@@ -466,12 +463,10 @@ class SP_Admin_Sample_Data {
update_post_meta( $id, 'sp_format', 'league' );
update_post_meta( $id, 'sp_video', $event_videos[ $i ] );
}
}
/*
* Insert calendar
*/
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
$post = array(
'post_title' => _x( 'Fixtures & Results', 'example', 'sportspress' ),
'post_type' => 'sp_calendar',
@@ -498,12 +493,10 @@ class SP_Admin_Sample_Data {
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 ) );
@@ -545,12 +538,10 @@ class SP_Admin_Sample_Data {
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
*/
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' ),
@@ -593,7 +584,6 @@ class SP_Admin_Sample_Data {
update_post_meta( $id, 'sp_order', 'ASC' );
update_post_meta( $id, 'sp_team', $team_id );
}
}
/*
* Insert player list for player ranking
@@ -630,13 +620,11 @@ class SP_Admin_Sample_Data {
/*
* Update player list and league table per team
*/
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
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_table', sp_array_value( $inserted_ids['sp_table'], 0 ) );
}
}
}
/**
* Deletes sample SportsPress data

View File

@@ -34,10 +34,7 @@ class SP_Admin_Settings {
$settings[] = include( 'settings/class-sp-settings-modules.php' );
$settings[] = include( 'settings/class-sp-settings-general.php' );
$settings[] = include( 'settings/class-sp-settings-events.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-staff.php' );

View File

@@ -166,8 +166,8 @@ class SP_Admin_Welcome {
</div>
<?php
endif;
if ( isset( $_POST['sportspress_mode'] ) ):
update_option( 'sportspress_mode', $_POST['sportspress_mode'] );
if ( isset( $_POST['sportspress_load_individual_mode_module'] ) ):
update_option( 'sportspress_load_individual_mode_module', $_POST['sportspress_load_individual_mode_module'] );
endif;
if ( isset( $_POST['add_sample_data'] ) ):
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>
<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>
<h4><?php _e( 'Next Steps', 'sportspress' ); ?></h4>
<p><?php _e( 'We&#8217;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">
<ul>
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
<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>
<?php foreach ( $steps as $step ) { ?>
<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 } ?>
<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>
</div>
<?php } ?>
<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>
</div>
@@ -262,12 +281,12 @@ class SP_Admin_Welcome {
array(
'title' => __( 'Mode', 'sportspress' ),
'id' => 'sportspress_mode',
'default' => 'team',
'id' => 'sportspress_load_individual_mode_module',
'default' => 'no',
'type' => 'radio',
'options' => array(
'team' => __( 'Teams', 'sportspress' ),
'player' => __( 'Players', 'sportspress' ) . ' ' . __( '(Beta)', 'sportspress' ),
'no' => __( 'Team vs team', 'sportspress' ),
'yes' => __( 'Player vs player', 'sportspress' ),
),
'desc_tip' => _x( 'Who competes in events?', 'mode setting description', 'sportspress' ),
),

View File

@@ -17,40 +17,148 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
*/
class SP_Admin_Meta_Boxes {
/**
* @var array
*/
public $meta_boxes = null;
/**
* Constructor
*/
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, 'rename_meta_boxes' ), 20 );
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 30 );
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
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_Performance::save', 60, 2 );
@@ -95,61 +203,29 @@ class SP_Admin_Meta_Boxes {
public function add_meta_boxes() {
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
if ( isset( $post ) && isset( $post->ID ) )
$post_meta = get_post_meta( $post->ID );
else
$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
add_meta_box( 'sp_shortcodediv', __( 'Shortcodes', 'sportspress' ), 'SP_Meta_Box_Event_Shortcode::output', 'sp_event', 'side', 'default' );
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' ) );
$teams = array_filter( sp_array_value( $post_meta, 'sp_team', array() ), 'sp_filter_positive' );
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 ) ) {
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
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 );
}
/*
* Array filter removes values that are not positive.
*/
public function positive( $var = 0 ) {
return $var > 0;
}
}
new SP_Admin_Meta_Boxes();

View File

@@ -104,7 +104,6 @@ class SP_Meta_Box_Calendar_Details {
endif;
?>
</p>
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
<p>
<?php
@@ -120,7 +119,6 @@ class SP_Meta_Box_Calendar_Details {
endif;
?>
</p>
<?php } ?>
<p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p>
<p>
<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_to', sp_array_value( $_POST, 'sp_date_to', null ) );
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 ) );
}
}
}

View File

@@ -53,7 +53,6 @@ class SP_Meta_Box_Event_Teams {
sp_dropdown_taxonomies( $args );
?>
</p>
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
<p class="sp-tab-select sp-title-generator">
<?php
$args = array(
@@ -67,17 +66,19 @@ class SP_Meta_Box_Event_Teams {
sp_dropdown_pages( $args );
?>
</p>
<?php } else { ?>
<input type="hidden" name="sp_team[]" value="0">
<?php } ?>
<?php $tabs = apply_filters( 'sportspress_event_team_tabs', array( 'sp_player', 'sp_staff' ) ); ?>
<?php if ( $tabs ) { ?>
<ul id="sp_team-tabs" class="wp-tab-bar sp-tab-bar">
<li class="wp-tab-active"><a href="#sp_player-all"><?php _e( 'Players', 'sportspress' ); ?></a></li>
<li class="wp-tab"><a href="#sp_staff-all"><?php _e( 'Staff', 'sportspress' ); ?></a></li>
<?php foreach ( $tabs as $index => $post_type ) { $object = get_post_type_object( $post_type ); ?>
<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>
<?php
sp_post_checklist( $post->ID, 'sp_player', 'block', array( 'sp_league', 'sp_season', 'sp_current_team' ), $i );
sp_post_checklist( $post->ID, 'sp_staff', 'none', array( 'sp_league', 'sp_season', 'sp_current_team' ), $i );
foreach ( $tabs as $index => $post_type ) {
sp_post_checklist( $post->ID, $post_type, ( 0 == $index ? 'block' : 'none' ), array( 'sp_league', 'sp_season', 'sp_current_team' ), $i );
}
?>
<?php } ?>
</div>
<?php
endfor;
@@ -88,7 +89,11 @@ class SP_Meta_Box_Event_Teams {
*/
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_player', sp_array_value( $_POST, 'sp_player', array() ) );
sp_update_post_meta_recursive( $post_id, 'sp_staff', sp_array_value( $_POST, 'sp_staff', array() ) );
$tabs = apply_filters( 'sportspress_event_team_tabs', array( 'sp_player', 'sp_staff' ) );
if ( $tabs ) {
foreach ( $tabs as $post_type ) {
sp_update_post_meta_recursive( $post_id, $post_type, sp_array_value( $_POST, $post_type, array() ) );
}
}
}
}

View File

@@ -52,12 +52,10 @@ class SP_Meta_Box_List_Data {
<?php echo 'number' == $orderby ? '#' : __( 'Rank', 'sportspress' ); ?>
</label></th>
<th><?php _e( 'Player', 'sportspress' ); ?></th>
<?php if ( 'team' == get_option( 'sportspress_mode', '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 ) ); ?>>
<?php _e( 'Team', 'sportspress' ); ?>
</label></th>
<?php } ?>
<?php foreach ( $columns as $key => $label ): ?>
<?php if ( in_array( $key, array( 'number', 'team' ) ) ) continue; ?>
<th><label for="sp_columns_<?php echo $key; ?>">
@@ -102,7 +100,6 @@ class SP_Meta_Box_List_Data {
<a class="button button-primary sp-save"><?php _e( 'Save', 'sportspress' ); ?></a>
</span>
</td>
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
<td>
<?php
$selected = sp_array_value( $player_stats, 'team', get_post_meta( get_the_ID(), 'sp_team', true ) );
@@ -118,7 +115,6 @@ class SP_Meta_Box_List_Data {
wp_dropdown_pages( $args );
?>
</td>
<?php } ?>
<?php foreach( $columns as $column => $label ):
if ( in_array( $column, array( 'number', 'team' ) ) ) continue;
$value = sp_array_value( $player_stats, $column, '' );
@@ -134,7 +130,7 @@ class SP_Meta_Box_List_Data {
?>
<tr class="sp-row alternate">
<td colspan="<?php $colspan = sizeof( $columns ) + 3; echo $colspan; ?>">
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Players', 'sportspress' ) ); ?>
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Data', 'sportspress' ) ); ?>
</td>
</tr>
<?php
@@ -182,7 +178,7 @@ class SP_Meta_Box_List_Data {
?>
<tr class="sp-row alternate">
<td colspan="<?php $colspan = sizeof( $columns ) + 3; echo $colspan; ?>">
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Players', 'sportspress' ) ); ?>
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Details', 'sportspress' ) ); ?>
</td>
</tr>
<?php

View File

@@ -62,7 +62,7 @@ class SP_Meta_Box_List_Details {
endif;
?>
</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 class="sp-tab-select">
<?php
@@ -128,9 +128,7 @@ class SP_Meta_Box_List_Details {
* Save meta box data
*/
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() ) );
}
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' );
update_post_meta( $post_id, 'sp_grouping', sp_array_value( $_POST, 'sp_grouping', array() ) );

View File

@@ -83,7 +83,6 @@ class SP_Meta_Box_Player_Details {
sp_dropdown_taxonomies( $args );
?></p>
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
<p><strong><?php _e( 'Current Teams', 'sportspress' ); ?></strong></p>
<p><?php
$args = array(
@@ -113,7 +112,6 @@ class SP_Meta_Box_Player_Details {
);
sp_dropdown_pages( $args );
?></p>
<?php } ?>
<p><strong><?php _e( 'Competitions', 'sportspress' ); ?></strong></p>
<p><?php
@@ -153,10 +151,8 @@ class SP_Meta_Box_Player_Details {
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_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_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() ) ) );
}
}
}

View File

@@ -61,7 +61,6 @@ class SP_Meta_Box_Player_Statistics {
<thead>
<tr>
<th><?php _e( 'Season', 'sportspress' ); ?></th>
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ): ?>
<?php if ( $league_id ): ?>
<th>
<?php if ( $has_checkboxes ): ?>
@@ -74,7 +73,6 @@ class SP_Meta_Box_Player_Statistics {
<?php endif; ?>
</th>
<?php endif; ?>
<?php endif; ?>
<?php foreach ( $columns as $key => $label ): if ( $key == 'team' ) continue; ?>
<th><?php echo $label; ?></th>
<?php endforeach; ?>
@@ -89,7 +87,7 @@ class SP_Meta_Box_Player_Statistics {
?>
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td>
<?php if ( 'team' != get_option( 'sportspress_mode', 'team' ) && 0 !== $div_id ): ?>
<?php if ( 0 !== $div_id ): ?>
<label>
<?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 ); ?>>
@@ -105,7 +103,6 @@ class SP_Meta_Box_Player_Statistics {
?>
<?php endif; ?>
</td>
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ): ?>
<?php if ( $league_id ): ?>
<?php if ( $div_id == 0 ): ?>
<td>&nbsp;</td>
@@ -143,7 +140,6 @@ class SP_Meta_Box_Player_Statistics {
</td>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<?php foreach ( $columns as $column => $label ): if ( $column == 'team' ) continue;
?>
<td><?php

View File

@@ -81,7 +81,6 @@ class SP_Meta_Box_Staff_Details {
<?php endforeach; ?>
</select></p>
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
<p><strong><?php _e( 'Current Teams', 'sportspress' ); ?></strong></p>
<p><?php
$args = array(
@@ -111,7 +110,6 @@ class SP_Meta_Box_Staff_Details {
);
sp_dropdown_pages( $args );
?></p>
<?php } ?>
<p><strong><?php _e( 'Competitions', 'sportspress' ); ?></strong></p>
<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 );
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_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() ) ) );
}
}
}

View File

@@ -23,6 +23,7 @@ class SP_Meta_Box_Statistic_Equation extends SP_Meta_Box_Equation {
*/
public static function output( $post ) {
$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 );
}
}

View File

@@ -103,7 +103,7 @@ class SP_Meta_Box_Table_Data {
?>
<tr class="sp-row alternate">
<td colspan="<?php $colspan = sizeof( $columns ) + 2; echo $colspan; ?>">
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ); ?>
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Data', 'sportspress' ) ); ?>
</td>
</tr>
<?php
@@ -147,7 +147,7 @@ class SP_Meta_Box_Table_Data {
?>
<tr class="sp-row alternate">
<td colspan="<?php $colspan = sizeof( $columns ) + 1; echo $colspan; ?>">
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ); ?>
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Data', 'sportspress' ) ); ?>
</td>
</tr>
<?php

View File

@@ -59,7 +59,9 @@ class SP_Meta_Box_Table_Details {
endif;
?>
</p>
<p><strong><?php _e( 'Teams', 'sportspress' ); ?></strong></p>
<p><strong>
<?php _e( 'Teams', 'sportspress' ); ?>
</strong></p>
<p class="sp-select-setting">
<select name="sp_select">
<option value="auto" <?php selected( 'auto', $select ); ?>><?php _e( 'Auto', 'sportspress' ); ?></option>

View File

@@ -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 );
}

View File

@@ -60,12 +60,12 @@ class SP_Settings_General extends SP_Settings_Page {
array(
'title' => __( 'Mode', 'sportspress' ),
'id' => 'sportspress_mode',
'default' => 'team',
'id' => 'sportspress_load_individual_mode_module',
'default' => 'no',
'type' => 'radio',
'options' => array(
'team' => __( 'Teams', 'sportspress' ),
'player' => __( 'Players', 'sportspress' ) . ' ' . __( '(Beta)', 'sportspress' ),
'no' => __( 'Team vs team', 'sportspress' ),
'yes' => __( 'Player vs player', '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() {
?>
<input type="hidden" name="sportspress_current_mode" value="<?php echo get_option( 'sportspress_mode', 'team' ); ?>">
<?php if ( sp_array_value( $_POST, 'sportspress_mode', 'team' ) !== sp_array_value( $_POST, 'sportspress_current_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_load_individual_mode_module', 'no' ) !== sp_array_value( $_POST, 'sportspress_individual_mode_module_loaded', 'no' ) ) { ?>
<script type="text/javascript">
window.onload = function() {
window.location = window.location.href;

View File

@@ -195,7 +195,6 @@ class SP_Settings_Modules extends SP_Settings_Page {
<div class="sp-modules-main">
<?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">
<thead>
<tr><th>

View File

@@ -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 );
}
}

View File

@@ -106,13 +106,6 @@ class SP_Event extends SP_Custom_Post{
endif;
endforeach;
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;
return $performance;
endif;

View File

@@ -28,7 +28,7 @@ class SP_Modules {
'label' => __( 'Calendars', 'sportspress' ),
'icon' => 'sp-icon-calendar',
),
'videos' => array(
'event_videos' => array(
'label' => __( 'Videos', 'sportspress' ),
'icon' => 'dashicons dashicons-video-alt',
),

View File

@@ -450,7 +450,7 @@ class SP_Player_List extends SP_Custom_Post {
foreach( $this->columns as $key ):
if ( $key == 'number' ):
$labels[ $key ] = '#';
elseif ( $key == 'team' && 'team' == get_option( 'sportspress_mode', 'team' ) ):
elseif ( $key == 'team' ):
$labels[ $key ] = __( 'Team', 'sportspress' );
elseif ( array_key_exists( $key, $columns ) ):
$labels[ $key ] = $columns[ $key ];
@@ -469,7 +469,7 @@ class SP_Player_List extends SP_Custom_Post {
$labels = array();
if ( in_array( 'number', $this->columns ) ) $labels['number'] = '#';
$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 );
return $merged;

View File

@@ -188,7 +188,7 @@ class SP_Post_types {
apply_filters( 'sportspress_register_post_type_result',
array(
'labels' => array(
'name' => __( 'Team Results', 'sportspress' ),
'name' => __( 'Event Results', 'sportspress' ),
'singular_name' => __( 'Result', 'sportspress' ),
'add_new_item' => __( 'Add New Result', 'sportspress' ),
'edit_item' => __( 'Edit Result', 'sportspress' ),
@@ -396,40 +396,6 @@ class SP_Post_types {
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_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,
)
)
);
}
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
register_post_type( 'sp_team',
apply_filters( 'sportspress_register_post_type_team',
array(
@@ -492,7 +458,6 @@ class SP_Post_types {
)
);
}
}
register_post_type( 'sp_player',
apply_filters( 'sportspress_register_post_type_player',

View File

@@ -23,28 +23,13 @@ class SP_Shortcodes {
'player_details' => __CLASS__ . '::player_details',
'player_statistics' => __CLASS__ . '::player_statistics',
'staff' => __CLASS__ . '::staff',
);
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 ) {
add_shortcode( $shortcode, $function );

View 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();
}

View 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();
}

View 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();
}

View 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();
}

View File

@@ -122,6 +122,9 @@ final class SportsPress {
add_action( 'init', array( 'SP_Shortcodes', 'init' ) );
add_action( 'after_setup_theme', array( $this, 'setup_environment' ) );
// Include core modules
$this->include_modules();
// Loaded action
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() {
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' ) ) {
include_once( 'includes/widgets/class-sp-widget-league-table.php' );
}

View File

@@ -46,7 +46,6 @@ $common[ __( 'Position', 'sportspress' ) ] = implode( ', ', $position_names );
$data = array_merge( $metrics_before, $common, $metrics_after );
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
if ( $current_teams ):
$teams = array();
foreach ( $current_teams as $team ):
@@ -67,7 +66,6 @@ if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
endforeach;
$data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams );
endif;
}
$data = apply_filters( 'sportspress_player_details', $data, $id );