Plug meta boxes into admin cpm classes
This commit is contained in:
@@ -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() ) ) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
192
includes/admin/post-types/class-sp-admin-meta-boxes.php
Normal file
192
includes/admin/post-types/class-sp-admin-meta-boxes.php
Normal 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();
|
||||
@@ -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() ) );
|
||||
}
|
||||
}
|
||||
@@ -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' );
|
||||
}
|
||||
}
|
||||
@@ -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 ) );
|
||||
}
|
||||
}
|
||||
@@ -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' ) );
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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' ) );
|
||||
}
|
||||
}
|
||||
@@ -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' );
|
||||
}
|
||||
}
|
||||
@@ -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' );
|
||||
}
|
||||
}
|
||||
@@ -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' ) );
|
||||
}
|
||||
}
|
||||
@@ -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() ) );
|
||||
}
|
||||
}
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
@@ -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' => __( '— Add —', '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() ) );
|
||||
}
|
||||
}
|
||||
@@ -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 ) );
|
||||
}
|
||||
}
|
||||
@@ -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() ) );
|
||||
}
|
||||
}
|
||||
@@ -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() ) );
|
||||
}
|
||||
}
|
||||
@@ -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' ) );
|
||||
}
|
||||
}
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
@@ -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' ) );
|
||||
}
|
||||
}
|
||||
@@ -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() ) ) );
|
||||
}
|
||||
}
|
||||
@@ -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() ) );
|
||||
}
|
||||
}
|
||||
@@ -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() ) );
|
||||
}
|
||||
}
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
@@ -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() ) );
|
||||
}
|
||||
}
|
||||
@@ -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' );
|
||||
}
|
||||
}
|
||||
@@ -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() ) );
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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() ) );
|
||||
}
|
||||
}
|
||||
@@ -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( '— Select —', '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>
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user