Plug meta boxes into admin cpm classes

This commit is contained in:
Brian Miyaji
2014-03-26 16:28:28 +11:00
parent 95a7fbb9c7
commit 690ba1463f
53 changed files with 3990 additions and 2386 deletions

View File

@@ -1,28 +0,0 @@
<?php
function sportspress_admin_enqueue_scripts( $hook ) {
wp_enqueue_style( 'jquery-chosen', plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/css/chosen.css', array(), null );
// Add ThemeBoy icon font, used in the admin stylesheet.
wp_enqueue_style( 'themeboy', plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/css/themeboy.css', array(), null );
// Load our admin stylesheet.
wp_enqueue_style( 'sportspress-admin', plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/css/admin.css', array(), time() );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-chosen', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
wp_enqueue_script( 'jquery-tiptip', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true );
wp_enqueue_script( 'jquery-caret', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/jquery.caret.min.js', array( 'jquery' ), '1.02', true );
wp_enqueue_script( 'jquery-countdown', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/jquery.countdown.min.js', array( 'jquery' ), '2.0.2', true );
if ( $hook == 'edit-tags.php' && isset( $_GET['taxonomy'] ) && $_GET['taxonomy'] == 'sp_venue' ):
wp_enqueue_script( 'google-maps', 'http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places' );
wp_enqueue_script( 'jquery-locationpicker', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/locationpicker.jquery.js', array( 'jquery' ), '0.1.6', true );
wp_enqueue_script( 'sportspress-admin-locationpicker', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/admin-locationpicker.js', array( 'jquery', 'google-maps', 'jquery-locationpicker' ), time(), true );
endif;
wp_enqueue_script( 'sportspress-admin', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/admin.js', array( 'jquery' ), time(), true );
// Localize scripts.
wp_localize_script( 'sportspress-admin', 'localized_strings', array( 'none' => __( 'None', 'sportspress' ), 'remove_text' => __( '&mdash; Remove &mdash;', 'sportspress' ), 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ) ) );
}
add_action( 'admin_enqueue_scripts', 'sportspress_admin_enqueue_scripts' );

View File

@@ -1,20 +0,0 @@
<?php
function sportspress_insert_post_data( $data, $postarr ) {
global $sportspress_options;
if( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ):
$teams = sportspress_array_value( $postarr, 'sp_team', array() );
$team_names = array();
foreach( $teams as $team ):
$team_names[] = get_the_title( $team );
endforeach;
$data['post_title'] = implode( ' ' . sportspress_array_value( $sportspress_options, 'event_teams_delimiter', 'vs' ) . ' ', $team_names );
endif;
return $data;
}
add_filter( 'wp_insert_post_data' , 'sportspress_insert_post_data' , '99', 2 );

View File

@@ -39,8 +39,8 @@ class SP_Admin_Assets {
if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
// Admin styles for SP pages only
wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . 'assets/css/admin.css', array(), SP_VERSION );
wp_enqueue_style( 'jquery-chosen', SP()->plugin_url() . 'assets/css/chosen.css', array(), '1.1.0' );
wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
wp_enqueue_style( 'jquery-chosen', SP()->plugin_url() . '/assets/css/chosen.css', array(), '1.1.0' );
wp_enqueue_style( 'wp-color-picker' );
}
@@ -60,21 +60,21 @@ class SP_Admin_Assets {
$screen = get_current_screen();
// Register scripts
wp_register_script( 'jquery-chosen', SP()->plugin_url() .'assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
wp_register_script( 'jquery-chosen', SP()->plugin_url() . '/assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
wp_register_script( 'jquery-tiptip', SP()->plugin_url() .'assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true );
wp_register_script( 'jquery-tiptip', SP()->plugin_url() . '/assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true );
wp_register_script( 'jquery-caret', SP()->plugin_url() .'assets/js/jquery.caret.min.js', array( 'jquery' ), '1.02', true );
wp_register_script( 'jquery-caret', SP()->plugin_url() . '/assets/js/jquery.caret.min.js', array( 'jquery' ), '1.02', true );
wp_register_script( 'jquery-countdown', SP()->plugin_url() .'assets/js/jquery.countdown.min.js', array( 'jquery' ), '2.0.2', true );
wp_register_script( 'jquery-countdown', SP()->plugin_url() . '/assets/js/jquery.countdown.min.js', array( 'jquery' ), '2.0.2', true );
wp_register_script( 'google-maps', 'http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places' );
wp_register_script( 'jquery-locationpicker', SP()->plugin_url() .'assets/js/locationpicker.jquery.js', array( 'jquery', 'google-maps' ), '0.1.6', true );
wp_register_script( 'jquery-locationpicker', SP()->plugin_url() . '/assets/js/locationpicker.jquery.js', array( 'jquery', 'google-maps' ), '0.1.6', true );
wp_register_script( 'sportspress-admin-locationpicker', SP()->plugin_url() .'assets/js/admin-locationpicker.js', array( 'jquery', 'google-maps', 'jquery-locationpicker' ), SP_VERSION, true );
wp_register_script( 'sportspress-admin-locationpicker', SP()->plugin_url() . '/assets/js/admin-locationpicker.js', array( 'jquery', 'google-maps', 'jquery-locationpicker' ), SP_VERSION, true );
wp_register_script( 'sportspress-admin', SP()->plugin_url() .'assets/js/admin.js', array( 'jquery', 'jquery-chosen', 'jquery-tiptip', 'jquery-caret', 'jquery-countdown' ), SP_VERSION, true );
wp_register_script( 'sportspress-admin', SP()->plugin_url() . '/assets/js/admin.js', array( 'jquery', 'jquery-chosen', 'jquery-tiptip', 'jquery-caret', 'jquery-countdown' ), SP_VERSION, true );
// SportsPress admin pages
if ( in_array( $screen->id, sp_get_screen_ids() ) ) {

View File

@@ -29,7 +29,7 @@ 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-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' );
@@ -52,52 +52,43 @@ class SP_Admin_Post_Types {
* @return array
*/
public function post_updated_messages( $messages ) {
global $post, $post_ID;
global $typenow, $post;
$messages['product'] = array(
0 => '', // Unused. Messages start at index 1.
1 => sprintf( __( 'Product updated. <a href="%s">View Product</a>', 'sportspress' ), esc_url( get_permalink($post_ID) ) ),
2 => __( 'Custom field updated.', 'sportspress' ),
3 => __( 'Custom field deleted.', 'sportspress' ),
4 => __( 'Product updated.', 'sportspress' ),
5 => isset($_GET['revision']) ? sprintf( __( 'Product restored to revision from %s', 'sportspress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf( __( 'Product published. <a href="%s">View Product</a>', 'sportspress' ), esc_url( get_permalink($post_ID) ) ),
7 => __( 'Product saved.', 'sportspress' ),
8 => sprintf( __( 'Product submitted. <a target="_blank" href="%s">Preview Product</a>', 'sportspress' ), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
9 => sprintf( __( 'Product scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview Product</a>', 'sportspress' ),
date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
10 => sprintf( __( 'Product draft updated. <a target="_blank" href="%s">Preview Product</a>', 'sportspress' ), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
);
if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_metric', 'sp_performance' ) ) ):
$obj = get_post_type_object( $typenow );
$messages['shop_order'] = array(
0 => '', // Unused. Messages start at index 1.
1 => __( 'Order updated.', 'sportspress' ),
2 => __( 'Custom field updated.', 'sportspress' ),
3 => __( 'Custom field deleted.', 'sportspress' ),
4 => __( 'Order updated.', 'sportspress' ),
5 => isset($_GET['revision']) ? sprintf( __( 'Order restored to revision from %s', 'sportspress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => __( 'Order updated.', 'sportspress' ),
7 => __( 'Order saved.', 'sportspress' ),
8 => __( 'Order submitted.', 'sportspress' ),
9 => sprintf( __( 'Order scheduled for: <strong>%1$s</strong>.', 'sportspress' ),
date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ) ),
10 => __( 'Order draft updated.', 'sportspress' )
);
for ( $i = 0; $i <= 10; $i++ ):
$messages['post'][ $i ] = __( 'Settings saved.', 'sportspress' ) .
' <a href="' . esc_url( admin_url( 'edit.php?post_type=' . $typenow ) ) . '">' .
__( 'View All', 'sportspress' ) . '</a>';
endfor;
elseif ( in_array( $typenow, array( 'sp_event', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ):
$obj = get_post_type_object( $typenow );
$messages['shop_coupon'] = array(
0 => '', // Unused. Messages start at index 1.
1 => __( 'Coupon updated.', 'sportspress' ),
2 => __( 'Custom field updated.', 'sportspress' ),
3 => __( 'Custom field deleted.', 'sportspress' ),
4 => __( 'Coupon updated.', 'sportspress' ),
5 => isset($_GET['revision']) ? sprintf( __( 'Coupon restored to revision from %s', 'sportspress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => __( 'Coupon updated.', 'sportspress' ),
7 => __( 'Coupon saved.', 'sportspress' ),
8 => __( 'Coupon submitted.', 'sportspress' ),
9 => sprintf( __( 'Coupon scheduled for: <strong>%1$s</strong>.', 'sportspress' ),
date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ) ),
10 => __( 'Coupon draft updated.', 'sportspress' )
);
$messages['post'][1] = __( 'Changes saved.', 'sportspress' ) .
' <a href="' . esc_url( get_permalink($post->ID) ) . '">' . $obj->labels->view_item . '</a>';
$messages['post'][4] = __( 'Changes saved.', 'sportspress' );
$messages['post'][6] = __( 'Success!', 'sportspress' ) .
' <a href="' . esc_url( get_permalink($post->ID) ) . '">' . $obj->labels->view_item . '</a>';
$messages['post'][7] = __( 'Changes saved.', 'sportspress' );
$messages['post'][8] = __( 'Success!', 'sportspress' ) .
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '">' .
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
$messages['post'][9] = sprintf(
__( 'Scheduled for: <b>%1$s</b>.', 'sportspress' ),
date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post->ID) ) ) .
' <a target="_blank" href="' . esc_url( get_permalink($post->ID) ) . '">' .
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
$messages['post'][10] = __( 'Success!', 'sportspress' ) .
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '">' .
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
endif;
return $messages;
}

View File

@@ -21,8 +21,6 @@ class SP_Admin {
add_action( 'init', array( $this, 'includes' ) );
add_action( 'current_screen', array( $this, 'conditonal_includes' ) );
add_action( 'admin_init', array( $this, 'prevent_admin_access' ) );
// add_action( 'admin_init', array( $this, 'preview_emails' ) );
// add_action( 'admin_footer', 'sp_print_js', 25 );
}
/**

View File

@@ -0,0 +1,192 @@
<?php
/**
* SportsPress Meta Boxes
*
* Sets up the write panels used by custom post types
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Admin_Meta_Boxes
*/
class SP_Admin_Meta_Boxes {
/**
* Constructor
*/
public function __construct() {
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 Performance Meta Boxes
add_action( 'sportspress_process_sp_performance_meta', 'SP_Meta_Box_Performance_Details::save', 10, 2 );
// Save Column Meta Boxes
add_action( 'sportspress_process_sp_column_meta', 'SP_Meta_Box_Column_Details::save', 10, 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 );
// Save Calendar Meta Boxes
add_action( 'sportspress_process_sp_calendar_meta', 'SP_Meta_Box_Calendar_Format::save', 10, 2 );
add_action( 'sportspress_process_sp_calendar_meta', 'SP_Meta_Box_Calendar_Details::save', 20, 2 );
add_action( 'sportspress_process_sp_calendar_meta', 'SP_Meta_Box_Calendar_Data::save', 30, 2 );
// Save Team Meta Boxes
add_action( 'sportspress_process_sp_team_meta', 'SP_Meta_Box_Team_Columns::save', 10, 2 );
// Save Table Meta Boxes
add_action( 'sportspress_process_sp_table_meta', 'SP_Meta_Box_Table_Details::save', 10, 2 );
add_action( 'sportspress_process_sp_table_meta', 'SP_Meta_Box_Table_Data::save', 20, 2 );
// Save Player Meta Boxes
add_action( 'sportspress_process_sp_player_meta', 'SP_Meta_Box_Player_Details::save', 10, 2 );
add_action( 'sportspress_process_sp_player_meta', 'SP_Meta_Box_Player_Metrics::save', 20, 2 );
add_action( 'sportspress_process_sp_player_meta', 'SP_Meta_Box_Player_Performance::save', 30, 2 );
// Save List Meta Boxes
add_action( 'sportspress_process_sp_list_meta', 'SP_Meta_Box_List_Format::save', 10, 2 );
add_action( 'sportspress_process_sp_list_meta', 'SP_Meta_Box_List_Details::save', 20, 2 );
add_action( 'sportspress_process_sp_list_meta', 'SP_Meta_Box_List_Data::save', 30, 2 );
}
/**
* Add SP Meta boxes
*/
public function add_meta_boxes() {
// 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' );
// Performance
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Performance_Details::output', 'sp_performance', 'normal', 'high' );
// Columns
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Column_Details::output', 'sp_column', 'normal', 'high' );
// Events
add_meta_box( 'submitdiv', __( 'Event', 'sportspress' ), 'post_submit_meta_box', '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' );
add_meta_box( 'sp_videodiv', __( 'Video', 'sportspress' ), 'SP_Meta_Box_Event_Video::output', 'sp_event', 'side', 'low' );
add_meta_box( 'sp_resultsdiv', __( 'Results', 'sportspress' ), 'SP_Meta_Box_Event_Results::output', 'sp_event', 'normal', 'high' );
add_meta_box( 'sp_performancediv', __( 'Performance', 'sportspress' ), 'SP_Meta_Box_Event_Performance::output', 'sp_event', 'normal', 'high' );
add_meta_box( 'sp_articlediv', __( 'Article', 'sportspress' ), 'SP_Meta_Box_Event_Article::output', 'sp_event', 'normal', 'high' );
// Calendars
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_Calendar_Shortcode::output', 'sp_calendar', 'side', 'default' );
add_meta_box( 'sp_formatdiv', __( 'Format', '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_descriptiondiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_Calendar_Description::output', 'sp_calendar', 'normal', 'high' );
// Teams
add_meta_box( 'sp_columnssdiv', __( 'Columns', 'sportspress' ), 'SP_Meta_Box_Team_Columns::output', 'sp_team', 'normal', 'high' );
// Tables
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_Table_Shortcode::output', 'sp_table', 'side', 'default' );
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Table_Details::output', 'sp_table', 'side', 'default' );
add_meta_box( 'sp_datadiv', __( 'League Table', 'sportspress' ), 'SP_Meta_Box_Table_Data::output', 'sp_table', 'normal', 'high' );
add_meta_box( 'sp_descriptiondiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_Table_Description::output', 'sp_table', 'normal', 'high' );
// Players
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Player_Details::output', 'sp_player', 'side', 'default' );
add_meta_box( 'sp_metricsdiv', __( 'Metrics', 'sportspress' ), 'SP_Meta_Box_Player_Metrics::output', 'sp_player', 'side', 'default' );
add_meta_box( 'sp_performancediv', __( 'Performance', 'sportspress' ), 'SP_Meta_Box_Player_Performance::output', 'sp_player', 'normal', 'high' );
// Lists
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_List_Shortcode::output', 'sp_list', 'side', 'default' );
add_meta_box( 'sp_formatdiv', __( 'Format', 'sportspress' ), 'SP_Meta_Box_List_Format::output', 'sp_list', 'side', 'default' );
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_List_Details::output', 'sp_list', 'side', 'default' );
add_meta_box( 'sp_datadiv', __( 'Player List', 'sportspress' ), 'SP_Meta_Box_List_Data::output', 'sp_list', 'normal', 'default' );
add_meta_box( 'sp_descriptiondiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_List_::output', 'sp_list', 'normal', 'high' );
}
/**
* Remove bloat
*/
public function remove_meta_boxes() {
// Events
remove_meta_box( 'submitdiv', 'sp_event', 'side' );
remove_meta_box( 'sp_venuediv', 'sp_event', 'side' );
remove_meta_box( 'sp_leaguediv', 'sp_event', 'side' );
remove_meta_box( 'sp_seasondiv', 'sp_event', 'side' );
// Calendars
remove_meta_box( 'sp_seasondiv', 'sp_calendar', 'side' );
remove_meta_box( 'sp_leaguediv', 'sp_calendar', 'side' );
remove_meta_box( 'sp_venuediv', 'sp_calendar', 'side' );
// Tables
remove_meta_box( 'sp_seasondiv', 'sp_table', 'side' );
remove_meta_box( 'sp_leaguediv', 'sp_table', 'side' );
// Players
remove_meta_box( 'sp_seasondiv', 'sp_player', 'side' );
remove_meta_box( 'sp_leaguediv', 'sp_player', 'side' );
remove_meta_box( 'sp_positiondiv', 'sp_player', 'side' );
// Lists
remove_meta_box( 'sp_seasondiv', 'sp_list', 'side' );
remove_meta_box( 'sp_leaguediv', 'sp_list', 'side' );
}
/**
* Rename core meta boxes
*/
public function rename_meta_boxes() {
global $post;
// Comments/Reviews
if ( isset( $post ) && ( 'publish' == $post->post_status || 'private' == $post->post_status ) ) {
remove_meta_box( 'commentsdiv', 'product', 'normal' );
add_meta_box( 'commentsdiv', __( 'Reviews', 'sportspress' ), 'post_comment_meta_box', 'product', 'normal' );
}
}
/**
* Check if we're saving, then trigger an action based on the post type
*
* @param int $post_id
* @param object $post
*/
public function save_meta_boxes( $post_id, $post ) {
if ( empty( $post_id ) || empty( $post ) ) return;
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
if ( is_int( wp_is_post_revision( $post ) ) ) return;
if ( is_int( wp_is_post_autosave( $post ) ) ) return;
if ( empty( $_POST['sportspress_meta_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_meta_nonce'], 'sportspress_save_data' ) ) return;
if ( ! current_user_can( 'edit_post', $post_id )) return;
if ( ! in_array( $post->post_type, array( 'sp_result', 'sp_outcome', 'sp_performance', 'sp_column', 'sp_metric', 'sp_statistic', 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ) return;
do_action( 'sportspress_process_' . $post->post_type . '_meta', $post_id, $post );
}
}
new SP_Admin_Meta_Boxes();

View File

@@ -0,0 +1,35 @@
<?php
/**
* Calendar Events
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Calendar_Data
*/
class SP_Meta_Box_Calendar_Data {
/**
* Output the metabox
*/
public static function output( $post ) {
list( $data, $usecolumns ) = sportspress_get_calendar_data( $post->ID, true );
sportspress_edit_calendar_table( $data, $usecolumns );
sportspress_nonce();
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
}
}

View File

@@ -0,0 +1,24 @@
<?php
/**
* Calendar Description
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Calendar_Description
*/
class SP_Meta_Box_Calendar_Description {
/**
* Output the metabox
*/
public static function output( $post ) {
wp_editor( $post->post_content, 'content' );
}
}

View File

@@ -0,0 +1,103 @@
<?php
/**
* Calendar Data
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Calendar_Details
*/
class SP_Meta_Box_Calendar_Details {
/**
* Output the metabox
*/
public static function output( $post ) {
global $sportspress_formats;
$league_id = sportspress_get_the_term_id( $post->ID, 'sp_league', 0 );
$season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
$venue_id = sportspress_get_the_term_id( $post->ID, 'sp_venue', 0 );
$team_id = get_post_meta( $post->ID, 'sp_team', true );
$formats = get_post_meta( $post->ID, 'sp_format' );
?>
<div>
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'show_option_all' => __( 'All', 'sportspress' ),
'taxonomy' => 'sp_league',
'name' => 'sp_league',
'selected' => $league_id,
'values' => 'term_id'
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
<p class="sp-tab-select">
<?php
$args = array(
'show_option_all' => __( 'All', 'sportspress' ),
'taxonomy' => 'sp_season',
'name' => 'sp_season',
'selected' => $season_id,
'values' => 'term_id'
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><strong><?php _e( 'Venue', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'show_option_all' => __( 'All', 'sportspress' ),
'taxonomy' => 'sp_venue',
'name' => 'sp_venue',
'selected' => $venue_id,
'values' => 'term_id'
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'show_option_all' => __( 'All', 'sportspress' ),
'post_type' => 'sp_team',
'name' => 'sp_team',
'selected' => $team_id,
'values' => 'ID'
);
if ( ! sportspress_dropdown_pages( $args ) ):
sportspress_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
</div>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_venue', 0 ), 'sp_venue' );
update_post_meta( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', 0 ) );
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* Calendar Format
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Calendar_Format
*/
class SP_Meta_Box_Calendar_Format {
/**
* Output the metabox
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$the_format = get_post_meta( $post->ID, 'sp_format', true );
?>
<div id="post-formats-select">
<?php foreach ( SP()->formats->calendar as $key => $format ): ?>
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( true, ( $key == 'calendar' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo $key; ?>" class="post-format-icon post-format-<?php echo $key; ?>"><?php echo $format; ?></label><br>
<?php endforeach; ?>
</div>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'calendar' ) );
}
}

View File

@@ -0,0 +1,30 @@
<?php
/**
* Calendar Shortcode
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Calendar_Shortcode
*/
class SP_Meta_Box_Calendar_Shortcode {
/**
* Output the metabox
*/
public static function output( $post ) {
$the_format = get_post_meta( $post->ID, 'sp_format', true );
?>
<p class="howto">
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
</p>
<p><input type="text" value="[event_<?php echo $the_format; ?> <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<?php
}
}

View File

@@ -0,0 +1,83 @@
<?php
/**
* Column Details
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Column_Details
*/
class SP_Meta_Box_Column_Details {
/**
* Output the metabox
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
$order = get_post_meta( $post->ID, 'sp_order', true );
$priority = get_post_meta( $post->ID, 'sp_priority', true );
$precision = get_post_meta( $post->ID, 'sp_precision', true );
// Defaults
if ( $precision == '' ) $precision = 0;
?>
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
</p>
<p><strong><?php _e( 'Equation', 'sportspress' ); ?></strong></p>
<p class="sp-equation-selector">
<?php
foreach ( $equation as $piece ):
sportspress_equation_selector( $post->ID, $piece, array( 'team_event', 'result', 'outcome' ) );
endforeach;
?>
</p>
<p><strong><?php _e( 'Rounding', 'sportspress' ); ?></strong></p>
<p class="sp-precision-selector">
<input name="sp_precision" type="text" size="4" id="sp_precision" value="<?php echo $precision; ?>" placeholder="0">
</p>
<p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p>
<p class="sp-order-selector">
<select name="sp_priority">
<?php
$options = array( '0' => __( 'Disable', 'sportspress' ) );
$count = wp_count_posts( 'sp_column' );
for( $i = 1; $i <= $count->publish; $i++ ):
$options[ $i ] = $i;
endfor;
foreach ( $options as $key => $value ):
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
endforeach;
?>
</select>
<select name="sp_order">
<?php
$options = array( 'DESC' => __( 'Descending', 'sportspress' ), 'ASC' => __( 'Ascending', 'sportspress' ) );
foreach ( $options as $key => $value ):
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $order, false ), $value );
endforeach;
?>
</select>
</p>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
sportspress_delete_duplicate_post( $_POST );
update_post_meta( $post_id, 'sp_equation', implode( ' ', sportspress_array_value( $_POST, 'sp_equation', array() ) ) );
update_post_meta( $post_id, 'sp_precision', (int) sportspress_array_value( $_POST, 'sp_precision', 1 ) );
update_post_meta( $post_id, 'sp_priority', sportspress_array_value( $_POST, 'sp_priority', '0' ) );
update_post_meta( $post_id, 'sp_order', sportspress_array_value( $_POST, 'sp_order', 'DESC' ) );
}
}

View File

@@ -0,0 +1,24 @@
<?php
/**
* Event Article
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Event_Article
*/
class SP_Meta_Box_Event_Article {
/**
* Output the metabox
*/
public static function output( $post ) {
wp_editor( $post->post_content, 'content' );
}
}

View File

@@ -0,0 +1,87 @@
<?php
/**
* Event Details
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Event_Details
*/
class SP_Meta_Box_Event_Details {
/**
* Output the metabox
*/
public static function output( $post ) {
$type = sportspress_get_the_term_id( $post->ID, 'sp_type', null );
$league_id = sportspress_get_the_term_id( $post->ID, 'sp_league', 0 );
$season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
$venue_id = sportspress_get_the_term_id( $post->ID, 'sp_venue', 0 );
?>
<div>
<fieldset class="sp-event-format-field sp-league-event-field sp-friendly-event-field">
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'taxonomy' => 'sp_league',
'name' => 'sp_league',
'selected' => $league_id,
'values' => 'term_id',
'show_option_none' => __( '-- Not set --', 'sportspress' ),
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'taxonomy' => 'sp_season',
'name' => 'sp_season',
'selected' => $season_id,
'values' => 'term_id',
'show_option_none' => __( '-- Not set --', 'sportspress' ),
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
</fieldset>
<p><strong><?php _e( 'Venue', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'taxonomy' => 'sp_venue',
'name' => 'sp_venue',
'selected' => $venue_id,
'values' => 'term_id',
'show_option_none' => __( '-- Not set --', 'sportspress' ),
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_venue', 'sp_event', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
</div>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_venue', 0 ), 'sp_venue' );
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* Event Format
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Event_Format
*/
class SP_Meta_Box_Event_Format {
/**
* Output the metabox
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$the_format = get_post_meta( $post->ID, 'sp_format', true );
?>
<div id="post-formats-select">
<?php foreach ( SP()->formats->event as $key => $format ): ?>
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( true, ( $key == 'league' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo $key; ?>" class="post-format-icon post-format-<?php echo $key; ?>"><?php echo $format; ?></label><br>
<?php endforeach; ?>
</div>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'league' ) );
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* Event Performance
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Event_Performance
*/
class SP_Meta_Box_Event_Performance {
/**
* Output the metabox
*/
public static function output( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false );
$stats = (array)get_post_meta( $post->ID, 'sp_players', true );
// Get columns from performance variables
$columns = sportspress_get_var_labels( 'sp_performance' );
foreach ( $teams as $key => $team_id ):
if ( ! $team_id ) continue;
// Get results for players in the team
$players = sportspress_array_between( (array)get_post_meta( $post->ID, 'sp_player', false ), 0, $key );
$data = sportspress_array_combine( $players, sportspress_array_value( $stats, $team_id, array() ) );
?>
<div>
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
<?php sportspress_edit_event_players_table( $columns, $data, $team_id ); ?>
</div>
<?php
endforeach;
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_players', sportspress_array_value( $_POST, 'sp_players', array() ) );
}
}

View File

@@ -0,0 +1,46 @@
<?php
/**
* Event Results
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Event_Results
*/
class SP_Meta_Box_Event_Results {
/**
* Output the metabox
*/
public static function output( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false );
$results = (array)get_post_meta( $post->ID, 'sp_results', true );
// Get columns from result variables
$columns = sportspress_get_var_labels( 'sp_result' );
// Get results for all teams
$data = sportspress_array_combine( $teams, $results );
?>
<div>
<?php sportspress_edit_event_results_table( $columns, $data ); ?>
</div>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
$results = (array)sportspress_array_value( $_POST, 'sp_results', array() );
update_post_meta( $post_id, 'sp_results', $results );
}
}

View File

@@ -0,0 +1,74 @@
<?php
/**
* Event Teams
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Event_Teams
*/
class SP_Meta_Box_Event_Teams {
/**
* Output the metabox
*/
public static function output( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false );
foreach ( $teams as $key => $value ):
?>
<div class="sp-clone">
<p class="sp-tab-select sp-title-generator">
<?php
$args = array(
'post_type' => 'sp_team',
'name' => 'sp_team[]',
'class' => 'sportspress-pages',
'show_option_none' => sprintf( __( 'Remove', 'sportspress' ), 'Team' ),
'option_none_value' => '0',
'selected' => $value
);
wp_dropdown_pages( $args );
?>
</p>
<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>
</ul>
<?php
sportspress_post_checklist( $post->ID, 'sp_player', 'block', 'sp_current_team', $key );
sportspress_post_checklist( $post->ID, 'sp_staff', 'none', 'sp_current_team', $key );
?>
</div>
<?php endforeach; ?>
<div class="sp-clone" data-clone-name="sp_team">
<p class="sp-tab-select sp-title-generator">
<?php
$args = array(
'post_type' => 'sp_team',
'name' => 'sp_team_selector',
'class' => 'sportspress-pages',
'show_option_none' => __( '&mdash; Add &mdash;', 'sportspress' ),
'option_none_value' => '0'
);
wp_dropdown_pages( $args );
?>
</p>
</div>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
sportspress_update_post_meta_recursive( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
sportspress_update_post_meta_recursive( $post_id, 'sp_player', sportspress_array_value( $_POST, 'sp_player', array() ) );
sportspress_update_post_meta_recursive( $post_id, 'sp_staff', sportspress_array_value( $_POST, 'sp_staff', array() ) );
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* Event Video
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Event_Video
*/
class SP_Meta_Box_Event_Video {
/**
* Output the metabox
*/
public static function output( $post ) {
$video = get_post_meta( $post->ID, 'sp_video', true );
if ( $video ):
?>
<fieldset class="sp-video-embed">
<?php echo apply_filters( 'the_content', '[embed width="254"]' . $video . '[/embed]' ); ?>
<p><a href="#" class="sp-remove-video"><?php _e( 'Remove video', 'sportspress' ); ?></a></p>
</fieldset>
<?php endif; ?>
<fieldset class="sp-video-field hidden">
<p><strong><?php _e( 'URL', 'sportspress' ); ?></strong></p>
<p><input class="widefat" type="text" name="sp_video" id="sp_video" value="<?php echo $video; ?>"></p>
<p><a href="#" class="sp-remove-video"><?php _e( 'Cancel', 'sportspress' ); ?></a></p>
</fieldset>
<fieldset class="sp-video-adder<?php if ( $video ): ?> hidden<?php endif; ?>">
<p><a href="#" class="sp-add-video"><?php _e( 'Add video', 'sportspress' ); ?></a></p>
</fieldset>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_video', sportspress_array_value( $_POST, 'sp_video', null ) );
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* List Data
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_List_Data
*/
class SP_Meta_Box_List_Data {
/**
* Output the metabox
*/
public static function output( $post ) {
list( $columns, $usecolumns, $data, $placeholders, $merged ) = sportspress_get_player_list_data( $post->ID, true );
sportspress_edit_player_list_table( $columns, $usecolumns, $data, $placeholders );
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
update_post_meta( $post_id, 'sp_players', sportspress_array_value( $_POST, 'sp_players', array() ) );
}
}

View File

@@ -0,0 +1,118 @@
<?php
/**
* List Details
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_List_Details
*/
class SP_Meta_Box_List_Details {
/**
* Output the metabox
*/
public static function output( $post ) {
$league_id = sportspress_get_the_term_id( $post->ID, 'sp_league', 0 );
$season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
$team_id = get_post_meta( $post->ID, 'sp_team', true );
$orderby = get_post_meta( $post->ID, 'sp_orderby', true );
$order = get_post_meta( $post->ID, 'sp_order', true );
?>
<div>
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'taxonomy' => 'sp_league',
'name' => 'sp_league',
'selected' => $league_id,
'values' => 'term_id',
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
<p class="sp-tab-select">
<?php
$args = array(
'taxonomy' => 'sp_season',
'name' => 'sp_season',
'selected' => $season_id,
'values' => 'term_id',
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
<p class="sp-tab-select">
<?php
$args = array(
'post_type' => 'sp_team',
'name' => 'sp_team',
'show_option_all' => __( 'All', 'sportspress' ),
'selected' => $team_id,
'values' => 'ID',
);
if ( ! sportspress_dropdown_pages( $args ) ):
sportspress_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><strong><?php _e( 'Sort by:', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'prepend_options' => array(
'number' => __( 'Number', 'sportspress' ),
'name' => __( 'Name', 'sportspress' ),
'eventsplayed' => __( 'Played', 'sportspress' )
),
'post_type' => 'sp_performance',
'name' => 'sp_orderby',
'selected' => $orderby,
'values' => 'slug',
);
if ( ! sportspress_dropdown_pages( $args ) ):
sportspress_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><strong><?php _e( 'Sort Order:', 'sportspress' ); ?></strong></p>
<p>
<select name="sp_order">
<option value="ASC" <?php selected( 'ASC', $order ); ?>><?php _e( 'Ascending', 'sportspress' ); ?></option>
<option value="DESC" <?php selected( 'DESC', $order ); ?>><?php _e( 'Descending', 'sportspress' ); ?></option>
</select>
</p>
<p><strong><?php _e( 'Players', 'sportspress' ); ?></strong></p>
<?php
sportspress_post_checklist( $post->ID, 'sp_player', 'block', 'sp_team' );
sportspress_post_adder( 'sp_player', __( 'Add New', 'sportspress' ) );
?>
</div>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
update_post_meta( $post_id, 'sp_orderby', sportspress_array_value( $_POST, 'sp_orderby', array() ) );
update_post_meta( $post_id, 'sp_order', sportspress_array_value( $_POST, 'sp_order', array() ) );
sportspress_update_post_meta_recursive( $post_id, 'sp_player', sportspress_array_value( $_POST, 'sp_player', array() ) );
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* List Format
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_List_Format
*/
class SP_Meta_Box_List_Format {
/**
* Output the metabox
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$the_format = get_post_meta( $post->ID, 'sp_format', true );
?>
<div id="post-formats-select">
<?php foreach ( SP()->formats->list as $key => $format ): ?>
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( true, ( $key == 'list' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo $key; ?>" class="post-format-icon post-format-<?php echo $key; ?>"><?php echo $format; ?></label><br>
<?php endforeach; ?>
</div>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'list' ) );
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Outcome Details
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Outcome_Details
*/
class SP_Meta_Box_Outcome_Details {
/**
* Output the metabox
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
?>
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
</p>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
sportspress_delete_duplicate_post( $_POST );
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* Performance Details
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Performance_Details
*/
class SP_Meta_Box_Performance_Details {
/**
* Output the metabox
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$calculate = get_post_meta( $post->ID, 'sp_calculate', true );
?>
<p><strong><?php _e( 'Calculate', 'sportspress' ); ?></strong></p>
<p class="sp-calculate-selector">
<?php sportspress_calculate_selector( $post->ID, $calculate ); ?>
</p>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
sportspress_delete_duplicate_post( $_POST );
update_post_meta( $post_id, 'sp_calculate', sportspress_array_value( $_POST, 'sp_calculate', 'DESC' ) );
}
}

View File

@@ -0,0 +1,158 @@
<?php
/**
* Player Details
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Player_Details
*/
class SP_Meta_Box_Player_Details {
/**
* Output the metabox
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$continents = SP()->countries->continents;
$number = get_post_meta( $post->ID, 'sp_number', true );
$nationality = get_post_meta( $post->ID, 'sp_nationality', true );
$leagues = get_the_terms( $post->ID, 'sp_league' );
$league_ids = array();
if ( $leagues ):
foreach ( $leagues as $league ):
$league_ids[] = $league->term_id;
endforeach;
endif;
$seasons = get_the_terms( $post->ID, 'sp_season' );
$season_ids = array();
if ( $seasons ):
foreach ( $seasons as $season ):
$season_ids[] = $season->term_id;
endforeach;
endif;
$positions = get_the_terms( $post->ID, 'sp_position' );
$position_ids = array();
if ( $positions ):
foreach ( $positions as $position ):
$position_ids[] = $position->term_id;
endforeach;
endif;
$teams = get_posts( array( 'post_type' => 'sp_team', 'posts_per_page' => -1 ) );
$past_teams = array_filter( get_post_meta( $post->ID, 'sp_past_team', false ) );
$current_team = get_post_meta( $post->ID, 'sp_current_team', true );
?>
<p><strong><?php _e( 'Number', 'sportspress' ); ?></strong></p>
<p><input type="text" size="4" id="sp_number" name="sp_number" value="<?php echo $number; ?>"></p>
<p><strong><?php _e( 'Nationality', 'sportspress' ); ?></strong></p>
<p><select id="sp_nationality" name="sp_nationality" data-placeholder="<?php printf( __( 'Select %s', 'sportspress' ), __( 'Nationality', 'sportspress' ) ); ?>" class="widefat chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?>">
<option value=""></option>
<?php foreach ( $continents as $continent => $countries ): ?>
<optgroup label="<?php echo $continent; ?>">
<?php foreach ( $countries as $code => $country ): ?>
<option value="<?php echo $code; ?>" <?php selected ( $nationality, $code ); ?>><?php echo $country; ?></option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select></p>
<p><strong><?php _e( 'Positions', 'sportspress' ); ?></strong></p>
<p><?php
$args = array(
'taxonomy' => 'sp_position',
'name' => 'tax_input[sp_position][]',
'selected' => $position_ids,
'values' => 'term_id',
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Positions', 'sportspress' ) ),
'class' => 'widefat',
'property' => 'multiple',
'chosen' => true,
);
sportspress_dropdown_taxonomies( $args );
?></p>
<p><strong><?php _e( 'Current Team', 'sportspress' ); ?></strong></p>
<p><?php
$args = array(
'post_type' => 'sp_team',
'name' => 'sp_current_team',
'show_option_blank' => true,
'selected' => $current_team,
'values' => 'ID',
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Team', 'sportspress' ) ),
'class' => 'sp-current-team widefat',
'chosen' => true,
);
sportspress_dropdown_pages( $args );
?></p>
<p><strong><?php _e( 'Past Teams', 'sportspress' ); ?></strong></p>
<p><?php
$args = array(
'post_type' => 'sp_team',
'name' => 'sp_past_team[]',
'selected' => $past_teams,
'values' => 'ID',
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
'class' => 'sp-past-teams widefat',
'property' => 'multiple',
'chosen' => true,
);
sportspress_dropdown_pages( $args );
?></p>
<p><strong><?php _e( 'Leagues', 'sportspress' ); ?></strong></p>
<p><?php
$args = array(
'taxonomy' => 'sp_league',
'name' => 'tax_input[sp_league][]',
'selected' => $league_ids,
'values' => 'term_id',
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ),
'class' => 'widefat',
'property' => 'multiple',
'chosen' => true,
);
sportspress_dropdown_taxonomies( $args );
?></p>
<p><strong><?php _e( 'Seasons', 'sportspress' ); ?></strong></p>
<p><?php
$args = array(
'taxonomy' => 'sp_season',
'name' => 'tax_input[sp_season][]',
'selected' => $season_ids,
'values' => 'term_id',
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ),
'class' => 'widefat',
'property' => 'multiple',
'chosen' => true,
);
sportspress_dropdown_taxonomies( $args );
?></p>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_number', sportspress_array_value( $_POST, 'sp_number', '' ) );
update_post_meta( $post_id, 'sp_nationality', sportspress_array_value( $_POST, 'sp_nationality', '' ) );
update_post_meta( $post_id, 'sp_current_team', sportspress_array_value( $_POST, 'sp_current_team', null ) );
sportspress_update_post_meta_recursive( $post_id, 'sp_past_team', sportspress_array_value( $_POST, 'sp_past_team', array() ) );
sportspress_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sportspress_array_value( $_POST, 'sp_current_team', null ) ), sportspress_array_value( $_POST, 'sp_past_team', array() ) ) );
}
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* Player Metrics
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Player_Metrics
*/
class SP_Meta_Box_Player_Metrics {
/**
* Output the metabox
*/
public static function output( $post ) {
$metrics = get_post_meta( $post->ID, 'sp_metrics', true );
$positions = get_the_terms( $post->ID, 'sp_position' );
$args = array(
'post_type' => 'sp_metric',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC',
);
if ( $positions ):
$position_ids = array();
foreach( $positions as $position ):
$position_ids[] = $position->term_id;
endforeach;
$args['tax_query'] = array(
array(
'taxonomy' => 'sp_position',
'field' => 'id',
'terms' => $position_ids,
),
);
endif;
$vars = get_posts( $args );
if ( $vars ):
foreach ( $vars as $var ):
?>
<p><strong><?php echo $var->post_title; ?></strong></p>
<p><input type="text" name="sp_metrics[<?php echo $var->post_name; ?>]" value="<?php echo sportspress_array_value( $metrics, $var->post_name, '' ); ?>" /></p>
<?php
endforeach;
else:
sportspress_post_adder( 'sp_metric', __( 'Add New', 'sportspress' ) );
endif;
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_metrics', sportspress_array_value( $_POST, 'sp_metrics', array() ) );
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* Player Performance
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Player_Performance
*/
class SP_Meta_Box_Player_Performance {
/**
* Output the metabox
*/
public static function output( $post ) {
$leagues = get_the_terms( $post->ID, 'sp_league' );
$league_num = sizeof( $leagues );
// Loop through performance for each league
foreach ( $leagues as $league ):
if ( $league_num > 1 ):
?>
<p><strong><?php echo $league->name; ?></strong></p>
<?php
endif;
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = sportspress_get_player_performance_data( $post->ID, $league->term_id, true );
sportspress_edit_player_performance_table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, ! current_user_can( 'edit_sp_teams' ) );
endforeach;
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_leagues', sportspress_array_value( $_POST, 'sp_leagues', array() ) );
if ( current_user_can( 'edit_sp_teams' ) )
update_post_meta( $post_id, 'sp_performance', sportspress_array_value( $_POST, 'sp_performance', array() ) );
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Result Details
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Result_Details
*/
class SP_Meta_Box_Result_Details {
/**
* Output the metabox
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
?>
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
</p>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
sportspress_delete_duplicate_post( $_POST );
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* Table Data
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Table_Data
*/
class SP_Meta_Box_Table_Data {
/**
* Output the metabox
*/
public static function output( $post ) {
list( $columns, $usecolumns, $data, $placeholders, $merged ) = sportspress_get_league_table_data( $post->ID, true );
sportspress_edit_league_table( $columns, $usecolumns, $data, $placeholders );
sportspress_nonce();
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
update_post_meta( $post_id, 'sp_teams', sportspress_array_value( $_POST, 'sp_teams', array() ) );
}
}

View File

@@ -0,0 +1,24 @@
<?php
/**
* Table Description
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Table_Description
*/
class SP_Meta_Box_Table_Description {
/**
* Output the metabox
*/
public static function output( $post ) {
wp_editor( $post->post_content, 'content' );
}
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* Table Details
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Table_Details
*/
class SP_Meta_Box_Table_Details {
/**
* Output the metabox
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$league_id = sportspress_get_the_term_id( $post->ID, 'sp_league', 0 );
$season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
?>
<div>
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'taxonomy' => 'sp_league',
'name' => 'sp_league',
'selected' => $league_id,
'values' => 'term_id'
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
<p class="sp-tab-select">
<?php
$args = array(
'taxonomy' => 'sp_season',
'name' => 'sp_season',
'selected' => $season_id,
'values' => 'term_id'
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><strong><?php _e( 'Teams', 'sportspress' ); ?></strong></p>
<?php
sportspress_post_checklist( $post->ID, 'sp_team', 'block', 'sp_season' );
sportspress_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
?>
</div>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
sportspress_update_post_meta_recursive( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Table Shortcode
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Table_Shortcode
*/
class SP_Meta_Box_Table_Shortcode {
/**
* Output the metabox
*/
public static function output( $post ) {
?>
<p class="howto">
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
</p>
<p><input type="text" value="[league_table <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<?php
}
}

View File

@@ -0,0 +1,52 @@
<?php
/**
* Team Columns
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Team_Columns
*/
class SP_Meta_Box_Team_Columns {
/**
* Output the metabox
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$leagues = (array)get_the_terms( $post->ID, 'sp_league' );
$league_num = sizeof( $leagues );
// Loop through columns for each league
foreach ( $leagues as $league ):
$league_id = $league->term_id;
if ( $league_num > 1 ):
?>
<p><strong><?php echo $league->name; ?></strong></p>
<?php
endif;
list( $columns, $data, $placeholders, $merged, $leagues_seasons ) = sportspress_get_team_columns_data( $post->ID, $league_id, true );
sportspress_edit_team_columns_table( $league_id, $columns, $data, $placeholders, $merged, $leagues_seasons, ! current_user_can( 'edit_sp_tables' ) );
endforeach;
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_leagues_seasons', sportspress_array_value( $_POST, 'sp_leagues_seasons', array() ) );
if ( current_user_can( 'edit_sp_tables' ) )
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
}
}

View File

@@ -30,7 +30,7 @@ class SportsPressGeneralSettingsPage {
}
function sport_callback() {
global $sportspress_options, $sportspress_sports;
global $sportspress_options;
$selected = sportspress_array_value( $sportspress_options, 'sport', null );
$custom_sport_name = sportspress_array_value( $sportspress_options, 'custom_sport_name', null );
@@ -38,7 +38,7 @@ class SportsPressGeneralSettingsPage {
<fieldset>
<select id="sportspress_sport" name="sportspress[sport]">
<option value><?php _e( '&mdash; Select &mdash;', 'sportspress' ); ?></option>
<?php foreach( $sportspress_sports as $slug => $sport ): ?>
<?php foreach( SP()->sports->options as $slug => $sport ): ?>
<option value="<?php echo $slug; ?>" <?php selected( $selected, $slug ); ?>><?php echo $sport['name']; ?></option>
<?php endforeach; ?>
<option value="custom" <?php selected( $selected, 'custom' ); ?>><?php _e( 'Custom', 'sportspress' ); ?></option>

View File

@@ -17,6 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
*/
function sp_get_screen_ids() {
return apply_filters( 'sportspress_screen_ids', array(
'settings_page_sportspress',
'edit-sp_result',
'sp_result',
'edit-sp_outcome',

View File

@@ -13,7 +13,7 @@
class SP_Formats {
/** @var array Array of formats */
public $formats;
private $data;
/**
* Constructor for the formats class - defines all preset formats.
@@ -22,7 +22,7 @@ class SP_Formats {
* @return void
*/
public function __construct() {
$this->formats = apply_filters( 'sportspress_formats', array(
$this->data = apply_filters( 'sportspress_formats', array(
'event' => array(
'league' => __( 'League', 'sportspress' ),
'friendly' => __( 'Friendly', 'sportspress' ),
@@ -37,4 +37,12 @@ class SP_Formats {
),
));
}
public function __get( $key ) {
return ( array_key_exists( $key, $this->data ) ? $this->data[ $key ] : null );
}
public function __set( $key, $value ){
$this->data[ $key ] = $value;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,170 +0,0 @@
<?php
global $sportspress_sports;
$sportspress_sports['baseball'] = array(
'name' => __( 'Baseball', 'sportspress' ),
'posts' => array(
// Columns
'sp_column' => array(
array(
'post_title' => 'W',
'post_name' => 'w',
'meta' => array(
'sp_equation' => '$w',
'sp_format' => 'integer',
'sp_precision' => 0,
'sp_priority' => 1,
'sp_order' => 'DESC',
),
),
array(
'post_title' => 'L',
'post_name' => 'l',
'meta' => array(
'sp_equation' => '$l',
'sp_format' => 'integer',
'sp_precision' => 0,
'sp_priority' => 2,
'sp_order' => 'ASC',
),
),
array(
'post_title' => 'Pct',
'post_name' => 'pct',
'meta' => array(
'sp_equation' => '$w / $eventsplayed',
'sp_format' => 'decimal',
'sp_precision' => 2,
),
),
array(
'post_title' => 'RS',
'post_name' => 'rs',
'meta' => array(
'sp_equation' => '$rfor',
'sp_format' => 'integer',
'sp_precision' => 0,
'sp_priority' => 3,
'sp_order' => 'DESC',
),
),
array(
'post_title' => 'RA',
'post_name' => 'ra',
'meta' => array(
'sp_equation' => '$ragainst',
'sp_format' => 'integer',
'sp_precision' => 0,
),
),
array(
'post_title' => 'Strk',
'post_name' => 'strk',
'meta' => array(
'sp_equation' => '$streak',
'sp_format' => 'integer',
'sp_precision' => 0,
),
),
),
// Statistics
'sp_performance' => array(
),
// Results
'sp_result' => array(
array(
'post_title' => '1',
'post_name' => 'first',
'meta' => array(
),
),
array(
'post_title' => '2',
'post_name' => 'second',
'meta' => array(
),
),
array(
'post_title' => '3',
'post_name' => 'third',
'meta' => array(
),
),
array(
'post_title' => '4',
'post_name' => 'fourth',
'meta' => array(
),
),
array(
'post_title' => '5',
'post_name' => 'fifth',
'meta' => array(
),
),
array(
'post_title' => '6',
'post_name' => 'sixth',
'meta' => array(
),
),
array(
'post_title' => '7',
'post_name' => 'seventh',
'meta' => array(
),
),
array(
'post_title' => '8',
'post_name' => 'eighth',
'meta' => array(
),
),
array(
'post_title' => '9',
'post_name' => 'ninth',
'meta' => array(
),
),
array(
'post_title' => '&nbsp;',
'post_name' => 'extra',
'meta' => array(
),
),
array(
'post_title' => 'R',
'post_name' => 'r',
'meta' => array(
),
),
array(
'post_title' => 'H',
'post_name' => 'h',
'meta' => array(
),
),
array(
'post_title' => 'E',
'post_name' => 'e',
'meta' => array(
),
),
),
// Outcomes
'sp_outcome' => array(
array(
'post_title' => 'Win',
'post_name' => 'w',
'meta' => array(
),
),
array(
'post_title' => 'Loss',
'post_name' => 'l',
'meta' => array(
),
),
),
),
);

View File

@@ -1,411 +0,0 @@
<?php
global $sportspress_sports;
$sportspress_sports['basketball'] = array(
'name' => __( 'Basketball', 'sportspress' ),
'terms' => array(
// Positions
'sp_position' => array(
array(
'name' => 'Point Guard',
'slug' => 'pointguard',
),
array(
'name' => 'Shooting Guard',
'slug' => 'shootingguard',
),
array(
'name' => 'Small Forward',
'slug' => 'smallforward',
),
array(
'name' => 'Power Forward',
'slug' => 'powerforward',
),
array(
'name' => 'Center',
'slug' => 'center',
),
),
),
'posts' => array(
// Results
'sp_result' => array(
array(
'post_title' => '1',
'post_name' => 'one',
),
array(
'post_title' => '2',
'post_name' => 'two',
),
array(
'post_title' => '3',
'post_name' => 'three',
),
array(
'post_title' => '4',
'post_name' => 'four',
),
array(
'post_title' => 'OT',
'post_name' => 'ot',
),
array(
'post_title' => 'T',
'post_name' => 't',
),
),
// Outcomes
'sp_outcome' => array(
array(
'post_title' => 'W',
'post_name' => 'w',
),
array(
'post_title' => 'L',
'post_name' => 'l',
),
),
// Table Columns
'sp_column' => array(
array(
'post_title' => 'W',
'post_name' => 'w',
'meta' => array(
'sp_equation' => '$w',
),
),
array(
'post_title' => 'L',
'post_name' => 'l',
'meta' => array(
'sp_equation' => '$l',
),
),
array(
'post_title' => 'Pct',
'post_name' => 'pct',
'meta' => array(
'sp_equation' => '$w / $eventsplayed * 100',
),
),
array(
'post_title' => 'GB',
'post_name' => 'gb',
'meta' => array(
'sp_equation' => '( $wmax + $l - $w - $lmax ) / 2',
),
),
array(
'post_title' => 'L10',
'post_name' => 'lten',
'meta' => array(
'sp_equation' => '$last10',
),
),
array(
'post_title' => 'Streak',
'post_name' => 'streak',
'meta' => array(
'sp_equation' => '$streak',
),
),
array(
'post_title' => 'PF',
'post_name' => 'pf',
'meta' => array(
'sp_equation' => '$tfor',
),
),
array(
'post_title' => 'PA',
'post_name' => 'pa',
'meta' => array(
'sp_equation' => '$tagainst',
),
),
array(
'post_title' => 'DIFF',
'post_name' => 'diff',
'meta' => array(
'sp_equation' => '$tfor - $tagainst',
),
),
),
// Player Metrics
'sp_metric' => array(
array(
'post_title' => 'Height',
'post_name' => 'height',
),
array(
'post_title' => 'Weight',
'post_name' => 'weight',
),
array(
'post_title' => 'Experience',
'post_name' => 'experience',
),
),
// Player Statistics
'sp_performance' => array(
array(
'post_title' => 'MIN',
'post_name' => 'min',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
array(
'post_title' => 'FGM',
'post_name' => 'fgm',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
array(
'post_title' => 'FGA',
'post_name' => 'fga',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
array(
'post_title' => '3PM',
'post_name' => '3pm',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
array(
'post_title' => '3PA',
'post_name' => '3pa',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
array(
'post_title' => 'FTM',
'post_name' => 'ftm',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
array(
'post_title' => 'FTA',
'post_name' => 'fta',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
array(
'post_title' => 'OFF',
'post_name' => 'off',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
array(
'post_title' => 'DEF',
'post_name' => 'def',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
array(
'post_title' => 'REB',
'post_name' => 'reb',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
array(
'post_title' => 'AST',
'post_name' => 'ast',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
array(
'post_title' => 'STL',
'post_name' => 'stl',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
array(
'post_title' => 'BLK',
'post_name' => 'blk',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
array(
'post_title' => 'TO',
'post_name' => 'to',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
array(
'post_title' => 'PF',
'post_name' => 'pf',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
array(
'post_title' => 'PTS',
'post_name' => 'pts',
'tax_input' => array(
'sp_position' => array(
'slug' => 'pointguard',
'slug' => 'shootingguard',
'slug' => 'smallforward',
'slug' => 'powerforward',
'slug' => 'center',
),
),
'meta' => array(
'sp_calculate' => 'average',
),
),
),
),
);

View File

@@ -1,71 +0,0 @@
<?php
global $sportspress_sports;
$sportspress_sports['cricket'] = array(
'name' => __( 'Cricket', 'sportspress' ),
'posts' => array(
// Table Columns
'sp_column' => array(
array(
'post_title' => 'M',
'post_name' => 'm',
'meta' => array(
'sp_equation' => '$eventsplayed',
),
),
array(
'post_title' => 'W',
'post_name' => 'w',
'meta' => array(
'sp_equation' => '$w',
),
),
array(
'post_title' => 'L',
'post_name' => 'l',
'meta' => array(
'sp_equation' => '$l',
),
),
array(
'post_title' => 'T',
'post_name' => 't',
'meta' => array(
'sp_equation' => '$t',
),
),
array(
'post_title' => 'N/R',
'post_name' => 'nr',
'meta' => array(
'sp_equation' => '$nr',
),
),
array(
'post_title' => 'Pts',
'post_name' => 'pts',
'meta' => array(
'sp_equation' => '$w * 2 + $nr',
'sp_priority' => '1',
'sp_order' => 'DESC',
),
),
array(
'post_title' => 'RR',
'post_name' => 'rr',
'meta' => array(
'sp_equation' => '( $rfor / $oagainst ) - ( $ragainst / $ofor )',
),
),
),
// Statistics
'sp_performance' => array(
),
// Results
'sp_result' => array(
),
// Outcomes
'sp_outcome' => array(
),
),
);

View File

@@ -1,891 +0,0 @@
<?php
global $sportspress_sports;
$sportspress_sports['football'] = array(
'name' => __( 'American Football', 'sportspress' ),
'terms' => array(
// Positions
'sp_position' => array(
array(
'name' => 'Quarterback',
'slug' => 'quarterback',
),
array(
'name' => 'Running Back',
'slug' => 'runningback',
),
array(
'name' => 'Wide Receiver',
'slug' => 'widereceiver',
),
array(
'name' => 'Tight End',
'slug' => 'tightend',
),
array(
'name' => 'Defensive Lineman',
'slug' => 'defensivelineman',
),
array(
'name' => 'Linebacker',
'slug' => 'linebacker',
),
array(
'name' => 'Defensive Back',
'slug' => 'defensiveback',
),
array(
'name' => 'Kickoff Kicker',
'slug' => 'kickoffkicker',
),
array(
'name' => 'Kick Returner',
'slug' => 'kickreturner',
),
array(
'name' => 'Punter',
'slug' => 'punter',
),
array(
'name' => 'Punt Returner',
'slug' => 'puntreturner',
),
array(
'name' => 'Field Goal Kicker',
'slug' => 'fieldgoalkicker',
),
),
),
'posts' => array(
// Results
'sp_result' => array(
array(
'post_title' => '1',
'post_name' => 'one',
),
array(
'post_title' => '2',
'post_name' => 'two',
),
array(
'post_title' => '3',
'post_name' => 'three',
),
array(
'post_title' => '4',
'post_name' => 'four',
),
array(
'post_title' => 'TD',
'post_name' => 'td',
),
array(
'post_title' => 'T',
'post_name' => 't',
),
),
// Outcomes
'sp_outcome' => array(
array(
'post_title' => 'Win',
'post_name' => 'w',
),
array(
'post_title' => 'Loss',
'post_name' => 'l',
),
array(
'post_title' => 'Tie',
'post_name' => 't',
),
),
// Table Columns
'sp_column' => array(
array(
'post_title' => 'W',
'post_name' => 'w',
'meta' => array(
'sp_equation' => '$w',
),
),
array(
'post_title' => 'L',
'post_name' => 'l',
'meta' => array(
'sp_equation' => '$l',
),
),
array(
'post_title' => 'T',
'post_name' => 't',
'meta' => array(
'sp_equation' => '$t',
),
),
array(
'post_title' => 'Pct',
'post_name' => 'pct',
'meta' => array(
'sp_equation' => '$w / $eventsplayed',
),
),
array(
'post_title' => 'PF',
'post_name' => 'pf',
'meta' => array(
'sp_equation' => '$tfor',
),
),
array(
'post_title' => 'PA',
'post_name' => 'pa',
'meta' => array(
'sp_equation' => '$tagainst',
),
),
array(
'post_title' => 'Net Pts',
'post_name' => 'netpts',
'meta' => array(
'sp_equation' => '$tfor - $tagainst',
),
),
array(
'post_title' => 'TD',
'post_name' => 'td',
'meta' => array(
'sp_equation' => '$td',
),
),
array(
'post_title' => 'Strk',
'post_name' => 'strk',
'meta' => array(
'sp_equation' => '$streak',
),
),
array(
'post_title' => 'Last 5',
'post_name' => 'last5',
'meta' => array(
'sp_equation' => '$last5',
),
),
),
// Player Metrics
'sp_metric' => array(
array(
'post_title' => 'Height',
'post_name' => 'height',
),
array(
'post_title' => 'Weight',
'post_name' => 'weight',
),
),
// Player Statistics
'sp_performance' => array(
array(
'post_title' => 'Comp',
'post_name' => 'comp',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
),
),
),
array(
'post_title' => 'Att',
'post_name' => 'att',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
'runningback',
),
),
),
array(
'post_title' => 'Pct',
'post_name' => 'pct',
'meta' => array(
'sp_calculate' => 'average',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
'kickoffkicker',
),
),
),
array(
'post_title' => 'Att/G',
'post_name' => 'attg',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
'runningback',
),
),
),
array(
'post_title' => 'Rec',
'post_name' => 'rec',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'widereceiver',
'tightend',
),
),
),
array(
'post_title' => 'Comb',
'post_name' => 'comb',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'defensivelineman',
'linebacker',
'defensiveback',
),
),
),
array(
'post_title' => 'Total',
'post_name' => 'total',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'defensivelineman',
'linebacker',
'defensiveback',
),
),
),
array(
'post_title' => 'Ast',
'post_name' => 'ast',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'defensivelineman',
'linebacker',
'defensiveback',
),
),
),
array(
'post_title' => 'Sck',
'post_name' => 'scktackles',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'defensivelineman',
'linebacker',
'defensiveback',
),
),
),
array(
'post_title' => 'SFTY',
'post_name' => 'sfty',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'defensivelineman',
'linebacker',
'defensiveback',
),
),
),
array(
'post_title' => 'PDef',
'post_name' => 'pdef',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'defensivelineman',
'linebacker',
'defensiveback',
),
),
),
array(
'post_title' => 'TDs',
'post_name' => 'tds',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'defensivelineman',
'linebacker',
'defensiveback',
),
),
),
array(
'post_title' => 'KO',
'post_name' => 'ko',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'kickoffkicker',
),
),
),
array(
'post_title' => 'Ret',
'post_name' => 'ret',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'kickreturner',
'puntreturner',
),
),
),
array(
'post_title' => 'Punts',
'post_name' => 'punts',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'punter',
),
),
),
array(
'post_title' => 'Yds',
'post_name' => 'yds',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
'runningback',
'widereceiver',
'tightend',
'defensivelineman',
'linebacker',
'defensiveback',
'kickoffkicker',
'kickreturner',
'punter',
'puntreturner',
),
),
),
array(
'post_title' => 'Net Yds',
'post_name' => 'netyds',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'punter',
),
),
),
array(
'post_title' => 'Avg',
'post_name' => 'avg',
'meta' => array(
'sp_calculate' => 'average',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
'runningback',
'widereceiver',
'tightend',
'kickoffkicker',
'kickreturner',
'punter',
'puntreturner',
),
),
),
array(
'post_title' => 'Net Avg',
'post_name' => 'netavg',
'meta' => array(
'sp_calculate' => 'average',
),
'tax_input' => array(
'sp_position' => array(
'punter',
),
),
),
array(
'post_title' => 'Blk',
'post_name' => 'blk',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'punter',
),
),
),
array(
'post_title' => 'OOB',
'post_name' => 'oob',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'kickoffkicker',
'punter',
),
),
),
array(
'post_title' => 'Dn',
'post_name' => 'dn',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'punter',
),
),
),
array(
'post_title' => 'IN 20',
'post_name' => 'in20',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'punter',
),
),
),
array(
'post_title' => 'TB',
'post_name' => 'tb',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'punter',
),
),
),
array(
'post_title' => 'FC',
'post_name' => 'fc',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'kickreturner',
'punter',
'puntreturner',
),
),
),
array(
'post_title' => 'Ret',
'post_name' => 'retpunt',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'kickoffkicker',
'kickreturner',
'punter',
'puntreturner',
),
),
),
array(
'post_title' => 'RetY',
'post_name' => 'rety',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'kickreturner',
'punter',
'puntreturner',
),
),
),
array(
'post_title' => 'Yds/G',
'post_name' => 'ydsg',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
'runningback',
'widereceiver',
'tightend',
),
),
),
array(
'post_title' => 'TD',
'post_name' => 'TD',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
'runningback',
'widereceiver',
'tightend',
'defensivelineman',
'linebacker',
'defensiveback',
'kickreturner',
'puntreturner',
),
),
),
array(
'post_title' => 'Int',
'post_name' => 'int',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
'defensivelineman',
'linebacker',
'defensiveback',
),
),
),
array(
'post_title' => '1st',
'post_name' => 'first',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
'runningback',
'widereceiver',
'tightend',
),
),
),
array(
'post_title' => '1st%',
'post_name' => 'firstpct',
'meta' => array(
'sp_calculate' => 'average',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
'runningback',
'widereceiver',
'tightend',
),
),
),
array(
'post_title' => 'Lng',
'post_name' => 'lng',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
'runningback',
'widereceiver',
'tightend',
'defensivelineman',
'linebacker',
'defensiveback',
'kickreturner',
'punter',
'puntreturner',
),
),
),
array(
'post_title' => '20+',
'post_name' => 'twentyplus',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
'runningback',
'widereceiver',
'tightend',
'kickreturner',
'puntreturner',
),
),
),
array(
'post_title' => '40+',
'post_name' => 'fourtyplus',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
'runningback',
'widereceiver',
'tightend',
'kickreturner',
'puntreturner',
),
),
),
array(
'post_title' => 'Sck',
'post_name' => 'sck',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
),
),
),
array(
'post_title' => 'Rate',
'post_name' => 'rate',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'quarterback',
),
),
),
array(
'post_title' => 'FUM',
'post_name' => 'fum',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'runningback',
'widereceiver',
'tightend',
'kickreturner',
'puntreturner',
),
),
),
array(
'post_title' => 'FF',
'post_name' => 'ff',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'defensivelineman',
'linebacker',
'defensiveback',
),
),
),
array(
'post_title' => 'Rec',
'post_name' => 'recfum',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'defensivelineman',
'linebacker',
'defensiveback',
),
),
),
array(
'post_title' => 'TD',
'post_name' => 'tdfum',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'kickoffkicker',
),
),
),
array(
'post_title' => 'Avg',
'post_name' => 'avgpunt',
'meta' => array(
'sp_calculate' => 'average',
),
'tax_input' => array(
'sp_position' => array(
'kickoffkicker',
'kickreturner',
'puntreturner',
),
),
),
array(
'post_title' => 'Lng',
'post_name' => 'lngpunt',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'kickreturner',
'puntreturner',
),
),
),
array(
'post_title' => 'TD',
'post_name' => 'tdpunt',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'kickoffkicker',
'kickreturner',
'punter',
'puntreturner',
),
),
),
array(
'post_title' => '20+',
'post_name' => 'twentypluspunt',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'kickreturner',
'puntreturner',
),
),
),
array(
'post_title' => '40+',
'post_name' => 'fourtypluspunt',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'kickreturner',
'puntreturner',
),
),
),
array(
'post_title' => 'FC',
'post_name' => 'fcpunt',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'kickreturner',
'puntreturner',
),
),
),
array(
'post_title' => 'FUM',
'post_name' => 'fumpunt',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'kickreturner',
'puntreturner',
),
),
),
array(
'post_title' => 'OSK',
'post_name' => 'osk',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'kickoffkicker',
),
),
),
array(
'post_title' => 'OSKR',
'post_name' => 'oskr',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'kickoffkicker',
),
),
),
),
),
);

View File

@@ -1,76 +0,0 @@
<?php
global $sportspress_sports;
$sportspress_sports['footy'] = array(
'name' => __( 'Australian Rules Football', 'sportspress' ),
'posts' => array(
// Table Columns
'sp_column' => array(
array(
'post_title' => 'P',
'post_name' => 'p',
'meta' => array(
'sp_equation' => '$eventsplayed',
)
),
array(
'post_title' => 'W',
'post_name' => 'w',
'meta' => array(
'sp_equation' => '$w',
)
),
array(
'post_title' => 'L',
'post_name' => 'l',
'meta' => array(
'sp_equation' => '$l',
)
),
array(
'post_title' => 'D',
'post_name' => 'd',
'meta' => array(
'sp_equation' => '$d',
)
),
array(
'post_title' => 'F',
'post_name' => 'f',
'meta' => array(
'sp_equation' => '$ptsfor',
)
),
array(
'post_title' => 'A',
'post_name' => 'a',
'meta' => array(
'sp_equation' => '$ptsagainst',
)
),
array(
'post_title' => 'Pct',
'post_name' => 'pct',
'meta' => array(
'sp_equation' => '( $w / $eventsplayed ) * 10 * 10',
)
),
array(
'post_title' => 'Pts',
'post_name' => 'pts',
'meta' => array(
'sp_equation' => '$pts',
)
)
),
// Statistics
'sp_performance' => array(
),
// Results
'sp_result' => array(
),
// Outcomes
'sp_outcome' => array(
),
),
);

View File

@@ -1,69 +0,0 @@
<?php
global $sportspress_sports;
$sportspress_sports['gaming'] = array(
'name' => __( 'Competitive Gaming', 'sportspress' ),
'posts' => array(
// Table Columns
'sp_column' => array(
array(
'post_title' => 'W',
'post_name' => 'w',
'meta' => array(
'sp_equation' => '$w',
),
),
array(
'post_title' => 'L',
'post_name' => 'l',
'meta' => array(
'sp_equation' => '$l',
),
),
array(
'post_title' => 'Pct',
'post_name' => 'pct',
'meta' => array(
'sp_equation' => '$w / $eventsplayed',
),
),
array(
'post_title' => 'Strk',
'post_name' => 'strk',
'meta' => array(
'sp_equation' => '$strk',
),
),
array(
'post_title' => 'XP',
'post_name' => 'xp',
'meta' => array(
'sp_equation' => '$xp',
),
),
array(
'post_title' => 'Rep',
'post_name' => 'rep',
'meta' => array(
'sp_equation' => '$rep / $eventsplayed',
),
),
array(
'post_title' => 'Ping',
'post_name' => 'ping',
'meta' => array(
'sp_equation' => '$ping / $eventsplayed',
),
),
),
// Statistics
'sp_performance' => array(
),
// Results
'sp_result' => array(
),
// Outcomes
'sp_outcome' => array(
),
),
);

View File

@@ -1,55 +0,0 @@
<?php
global $sportspress_sports;
$sportspress_sports['golf'] = array(
'name' => __( 'Golf', 'sportspress' ),
'posts' => array(
// Table Columns
'sp_column' => array(
),
// Statistics
'sp_performance' => array(
array(
'post_title' => 'Events',
'post_name' => 'events',
'meta' => array(
'sp_equation' => '$eventsplayed',
),
),
array(
'post_title' => 'Avg',
'post_name' => 'avg',
'meta' => array(
'sp_equation' => '$ptsfor / $eventsplayed',
),
),
array(
'post_title' => 'Total',
'post_name' => 'total',
'meta' => array(
'sp_equation' => '$ptsfor',
),
),
array(
'post_title' => 'PL',
'post_name' => 'lost',
'meta' => array(
'sp_equation' => '$ptsagainst',
),
),
array(
'post_title' => 'PG',
'post_name' => 'gained',
'meta' => array(
'sp_equation' => '$ptsfor',
),
),
),
// Results
'sp_result' => array(
),
// Outcomes
'sp_outcome' => array(
),
),
);

View File

@@ -1,88 +0,0 @@
<?php
global $sportspress_sports;
$sportspress_sports['hockey'] = array(
'name' => __( 'Hockey', 'sportspress' ),
'posts' => array(
// Table Columns
'sp_column' => array(
array(
'post_title' => 'GP',
'post_name' => 'gp',
'meta' => array(
'sp_equation' => '$eventsplayed',
),
),
array(
'post_title' => 'W',
'post_name' => 'w',
'meta' => array(
'sp_equation' => '$w',
),
),
array(
'post_title' => 'L',
'post_name' => 'l',
'meta' => array(
'sp_equation' => '$l',
),
),
array(
'post_title' => 'OT',
'post_name' => 'ot',
'meta' => array(
'sp_equation' => '$ot',
),
),
array(
'post_title' => 'P',
'post_name' => 'p',
'meta' => array(
'sp_equation' => '$w * 2 + $ot',
),
),
array(
'post_title' => 'GF',
'post_name' => 'gf',
'meta' => array(
'sp_equation' => '$gfor',
),
),
array(
'post_title' => 'GA',
'post_name' => 'ga',
'meta' => array(
'sp_equation' => '$gagainst',
),
),
array(
'post_title' => 'Strk',
'post_name' => 'strk',
'meta' => array(
'sp_equation' => '$streak',
),
),
),
// Statistics
'sp_performance' => array(
),
// Results
'sp_result' => array(
),
// Outcomes
'sp_outcome' => array(
array(
'post_title' => 'Win',
'post_name' => 'w'
),
array(
'post_title' => 'Loss',
'post_name' => 'l'
),
array(
'post_title' => 'Overtime',
'post_name' => 'ot'
),
),
),
);

View File

@@ -1,57 +0,0 @@
<?php
global $sportspress_sports;
$sportspress_sports['racing'] = array(
'name' => __( 'Racing', 'sportspress' ),
'posts' => array(
// Table Columns
'sp_column' => array(
),
// Statistics
'sp_performance' => array(
array(
'post_title' => 'Pts',
'post_name' => 'pts',
'meta' => array(
'sp_equation' => '$ptsfor',
),
),
array(
'post_title' => 'B',
'post_name' => 'b',
'meta' => array(
'sp_equation' => '$ptsmax - $ptsfor',
),
),
array(
'post_title' => 'S',
'post_name' => 's',
'meta' => array(
'sp_equation' => '$eventsplayed',
),
),
array(
'post_title' => 'W',
'post_name' => 'w',
'meta' => array(
'sp_equation' => '$w',
'sp_priority' => '1',
'sp_order' => 'DESC',
),
),
array(
'post_title' => 'DNF',
'post_name' => 'dnf',
'meta' => array(
'sp_equation' => '$dnf',
),
),
),
// Results
'sp_result' => array(
),
// Outcomes
'sp_outcome' => array(
),
),
);

View File

@@ -1,160 +0,0 @@
<?php
global $sportspress_sports;
$sportspress_sports['rugby'] = array(
'name' => __( 'Rugby', 'sportspress' ),
'posts' => array(
// Results
'sp_result' => array(
array(
'post_title' => 'Points',
'post_name' => 'points',
),
array(
'post_title' => 'Bonus',
'post_name' => 'bonus',
),
),
// Outcomes
'sp_outcome' => array(
array(
'post_title' => 'Win',
'post_name' => 'w',
),
array(
'post_title' => 'Draw',
'post_name' => 'd',
),
array(
'post_title' => 'Loss',
'post_name' => 'l',
),
),
// Table Columns
'sp_column' => array(
array(
'post_title' => 'P',
'post_name' => 'p',
'meta' => array(
'sp_equation' => '$eventsplayed',
'sp_precision' => 0,
),
),
array(
'post_title' => 'W',
'post_name' => 'w',
'meta' => array(
'sp_equation' => '$w',
'sp_precision' => 0,
),
),
array(
'post_title' => 'D',
'post_name' => 'd',
'meta' => array(
'sp_equation' => '$d',
'sp_precision' => 0,
),
),
array(
'post_title' => 'L',
'post_name' => 'l',
'meta' => array(
'sp_equation' => '$l',
'sp_precision' => 0,
),
),
array(
'post_title' => 'B',
'post_name' => 'b',
'meta' => array(
'sp_equation' => '$bonus',
'sp_precision' => 0,
),
),
array(
'post_title' => 'F',
'post_name' => 'f',
'meta' => array(
'sp_equation' => '$pointsfor',
'sp_precision' => 0,
),
),
array(
'post_title' => 'A',
'post_name' => 'a',
'meta' => array(
'sp_equation' => '$pointsagainst',
'sp_precision' => 0,
),
),
array(
'post_title' => '+/-',
'post_name' => 'pd',
'meta' => array(
'sp_equation' => '$pointsfor - $pointsagainst',
'sp_precision' => 0,
),
),
array(
'post_title' => 'Pts',
'post_name' => 'pts',
'meta' => array(
'sp_equation' => '( $w + $bonus ) * 2 + $d',
'sp_precision' => 0,
'sp_priority' => '1',
'sp_order' => 'DESC',
),
),
),
// Player Metrics
'sp_metric' => array(
array(
'post_title' => 'Height',
'post_name' => 'height',
),
array(
'post_title' => 'Weight',
'post_name' => 'weight',
),
),
// Player Statistics
'sp_performance' => array(
array(
'post_title' => 'Points',
'post_name' => 'points',
'meta' => array(
'sp_calculate' => 'total',
),
),
array(
'post_title' => 'Tries',
'post_name' => 'tries',
'meta' => array(
'sp_calculate' => 'total',
),
),
array(
'post_title' => 'Conversions',
'post_name' => 'conversions',
'meta' => array(
'sp_calculate' => 'total',
),
),
array(
'post_title' => 'Penalty Goals',
'post_name' => 'penaltygoals',
'meta' => array(
'sp_calculate' => 'total',
),
),
array(
'post_title' => 'Drop Goals',
'post_name' => 'dropgoals',
'meta' => array(
'sp_calculate' => 'total',
),
),
),
),
);

View File

@@ -1,222 +0,0 @@
<?php
global $sportspress_sports;
$sportspress_sports['soccer'] = array(
'name' => __( 'Soccer (Association Football)', 'sportspress' ),
'terms' => array(
// Positions
'sp_position' => array(
array(
'name' => 'Goalkeeper',
'slug' => 'goalkeeper',
),
array(
'name' => 'Defender',
'slug' => 'defender',
),
array(
'name' => 'Midfielder',
'slug' => 'midfielder',
),
array(
'name' => 'Forward',
'slug' => 'forward',
),
),
),
'posts' => array(
// Results
'sp_result' => array(
array(
'post_title' => '1st Half',
'post_name' => 'firsthalf',
),
array(
'post_title' => '2nd Half',
'post_name' => 'secondhalf',
),
array(
'post_title' => 'Goals',
'post_name' => 'goals',
),
),
// Outcomes
'sp_outcome' => array(
array(
'post_title' => 'Win',
'post_name' => 'w',
),
array(
'post_title' => 'Draw',
'post_name' => 'd',
),
array(
'post_title' => 'Loss',
'post_name' => 'l',
),
),
// Table Columns
'sp_column' => array(
array(
'post_title' => 'P',
'post_name' => 'p',
'meta' => array(
'sp_equation' => '$eventsplayed',
'sp_precision' => 0,
),
),
array(
'post_title' => 'W',
'post_name' => 'w',
'meta' => array(
'sp_equation' => '$w',
'sp_precision' => 0,
),
),
array(
'post_title' => 'D',
'post_name' => 'd',
'meta' => array(
'sp_equation' => '$d',
'sp_precision' => 0,
),
),
array(
'post_title' => 'L',
'post_name' => 'l',
'meta' => array(
'sp_equation' => '$l',
'sp_precision' => 0,
),
),
array(
'post_title' => 'F',
'post_name' => 'f',
'meta' => array(
'sp_equation' => '$goalsfor',
'sp_precision' => 0,
'sp_priority' => '3',
'sp_order' => 'DESC',
),
),
array(
'post_title' => 'A',
'post_name' => 'a',
'meta' => array(
'sp_equation' => '$goalsagainst',
'sp_precision' => 0,
),
),
array(
'post_title' => 'GD',
'post_name' => 'gd',
'meta' => array(
'sp_equation' => '$goalsfor - $goalsagainst',
'sp_precision' => 0,
'sp_priority' => '2',
'sp_order' => 'DESC',
),
),
array(
'post_title' => 'Pts',
'post_name' => 'pts',
'meta' => array(
'sp_equation' => '$w * 3 + $d',
'sp_precision' => 0,
'sp_priority' => '1',
'sp_order' => 'DESC',
),
),
),
// Player Metrics
'sp_metric' => array(
array(
'post_title' => 'Height',
'post_name' => 'height',
'tax_input' => array(
'sp_position' => array(
'goalkeeper',
'defender',
'midfielder',
'forward',
),
),
),
array(
'post_title' => 'Weight',
'post_name' => 'weight',
'tax_input' => array(
'sp_position' => array(
'goalkeeper',
'defender',
'midfielder',
'forward',
),
),
),
),
// Player Statistics
'sp_performance' => array(
array(
'post_title' => 'Goals',
'post_name' => 'goals',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'goalkeeper',
'defender',
'midfielder',
'forward',
),
),
),
array(
'post_title' => 'Assists',
'post_name' => 'assists',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'goalkeeper',
'defender',
'midfielder',
'forward',
),
),
),
array(
'post_title' => 'Yellow Cards',
'post_name' => 'yellowcards',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'goalkeeper',
'defender',
'midfielder',
'forward',
),
),
),
array(
'post_title' => 'Red Cards',
'post_name' => 'redcards',
'meta' => array(
'sp_calculate' => 'total',
),
'tax_input' => array(
'sp_position' => array(
'goalkeeper',
'defender',
'midfielder',
'forward',
),
),
),
),
),
);

View File

@@ -46,6 +46,16 @@ final class SportsPress {
*/
public $countries = null;
/**
* @var SP_Sports $sports
*/
public $sports = null;
/**
* @var SP_Formats $formats
*/
public $formats = null;
/**
* @var SP_Text $text
*/
@@ -148,7 +158,7 @@ final class SportsPress {
return;
}
} elseif ( strpos( $class, 'sp_meta_box' ) === 0 ) {
} elseif ( strpos( $class, 'sp_meta_box_' ) === 0 ) {
$path = $this->plugin_path() . '/includes/admin/post-types/meta-boxes/';
$file = 'class-' . str_replace( '_', '-', $class ) . '.php';
@@ -196,7 +206,7 @@ final class SportsPress {
include_once( 'includes/sp-core-functions.php' );
// Globals
include_once( 'includes/admin/settings/globals.php' );
//include_once( 'includes/admin/settings/globals.php' );
// Options
include_once( 'includes/admin/settings/settings.php' );
@@ -220,6 +230,7 @@ final class SportsPress {
// Classes (used on all pages)
include_once( 'includes/class-sp-countries.php' ); // Defines continents and countries
include_once( 'includes/class-sp-formats.php' ); // Defines custom post type formats
include_once( 'includes/class-sp-text.php' ); // Defines editable strings
// Typical request actions (deprecating)
@@ -231,7 +242,7 @@ final class SportsPress {
// Admin request actions (deprecating)
include_once( 'admin/hooks/admin-init.php' );
include_once( 'admin/hooks/admin-menu.php' );
include_once( 'admin/hooks/admin-enqueue-scripts.php' );
//include_once( 'admin/hooks/admin-enqueue-scripts.php' );
include_once( 'admin/hooks/admin-print-styles.php' );
include_once( 'admin/hooks/admin-head.php' );
//include_once( 'admin/hooks/current-screen.php' );
@@ -241,7 +252,7 @@ final class SportsPress {
include_once( 'admin/hooks/post-thumbnail-html.php' );
//include_once( 'admin/hooks/restrict-manage-posts.php' );
//include_once( 'admin/hooks/parse-query.php' );
include_once( 'admin/hooks/save-post.php' );
//include_once( 'admin/hooks/save-post.php' );
// Filters (deprecating)
include_once( 'admin/hooks/admin-post-thumbnail-html.php' );
@@ -251,7 +262,7 @@ final class SportsPress {
include_once( 'admin/hooks/sanitize-title.php' );
include_once( 'admin/hooks/the-content.php' );
include_once( 'admin/hooks/widget-text.php' );
include_once( 'admin/hooks/wp-insert-post-data.php' );
//include_once( 'admin/hooks/wp-insert-post-data.php' );
include_once( 'admin/hooks/post-updated-messages.php' );
// Register activation hook (deprecating)
@@ -297,8 +308,8 @@ final class SportsPress {
// Load class instances
$this->countries = new SP_Countries(); // Countries class
// Load class instances
$this->sports = new SP_Sports(); // Sports class
$this->formats = new SP_Formats(); // Formats class
$this->text = new SP_Text(); // Text class
// Init action