';
if ( $event ) {
- $args = array_merge( $_REQUEST, array( 'import' => 'sp_event_performance_csv', 'step' => '1' ) );
- echo '
' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'
';
+ $args = array_merge(
+ $_REQUEST,
+ array(
+ 'import' => 'sp_event_performance_csv',
+ 'step' => '1',
+ )
+ );
+ echo '
' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '
' . sprintf( __( 'Box scores need to be defined with columns in a specific order. Click here to download a sample .', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/event-performance-sample.csv' ) . '
';
wp_import_upload_form( add_query_arg( $args, 'admin.php' ) );
} else {
@@ -167,10 +194,10 @@ if ( class_exists( 'WP_Importer' ) ) {
* @return void
*/
function options() {
- $event = sp_array_value( $_REQUEST, 'event', 0, 'key' );
- $teams = sp_array_value( $_REQUEST, 'teams', 0, 'key' );
- $index = sp_array_value( $_REQUEST, 'index', 0, 'key' );
- $team = sp_array_value( $_REQUEST, 'team', 0, 'key' );
+ $event = sp_array_value( $_REQUEST, 'event', 0, 'key' );
+ $teams = sp_array_value( $_REQUEST, 'teams', 0, 'key' );
+ $index = sp_array_value( $_REQUEST, 'index', 0, 'key' );
+ $team = sp_array_value( $_REQUEST, 'team', 0, 'key' );
$include = get_post_meta( $event, 'sp_team', false );
?>
+
+
+
+
+
plugin_url() . '/assets/js/admin/sportspress-admin.js', array( 'jquery', 'chosen', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-tiptip', 'jquery-caret' ), SP_VERSION, true );
+ wp_enqueue_script( 'sportspress-admin', SP()->plugin_url() . '/assets/js/admin/sportspress-admin.js', array( 'jquery', 'chosen', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-tiptip', 'jquery-caret' ), SP_VERSION, true );
}
/**
@@ -46,32 +48,36 @@ if ( class_exists( 'WP_Importer' ) ) {
function dispatch() {
$this->header();
- if ( ! empty( $_POST['delimiter'] ) )
+ if ( ! empty( $_POST['delimiter'] ) ) {
$this->delimiter = stripslashes( trim( sanitize_text_field( $_POST['delimiter'] ) ) );
+ }
- if ( ! $this->delimiter )
+ if ( ! $this->delimiter ) {
$this->delimiter = ',';
+ }
$step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step'];
- switch ( $step ):
+ switch ( $step ) :
case 0:
$this->greet();
break;
case 1:
check_admin_referer( 'import-upload' );
- if ( $this->handle_upload() ):
+ if ( $this->handle_upload() ) :
- if ( $this->id )
+ if ( $this->id ) {
$file = get_attached_file( $this->id );
- else
+ } else {
$file = ABSPATH . $this->file_url;
+ }
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
- if ( function_exists( 'gc_enable' ) )
+ if ( function_exists( 'gc_enable' ) ) {
gc_enable();
+ }
- @set_time_limit(0);
+ @set_time_limit( 0 );
@ob_flush();
@flush();
@@ -80,7 +86,7 @@ if ( class_exists( 'WP_Importer' ) ) {
break;
case 2:
check_admin_referer( 'import-upload' );
- if ( isset( $_POST['sp_import'] ) ):
+ if ( isset( $_POST['sp_import'] ) ) :
$columns = array_filter( sp_array_value( $_POST, 'sp_columns', array( 'post_title' ) ) );
$this->import( $_POST['sp_import'], array_values( $columns ) );
endif;
@@ -100,7 +106,7 @@ if ( class_exists( 'WP_Importer' ) ) {
?>
@@ -119,26 +125,26 @@ if ( class_exists( 'WP_Importer' ) ) {
$this->imported = $this->skipped = 0;
- if ( ! is_file($file) ):
+ if ( ! is_file( $file ) ) :
$this->footer();
die();
endif;
ini_set( 'auto_detect_line_endings', '1' );
- if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ):
+ if ( ( $handle = fopen( $file, 'r' ) ) !== false ) :
$header = fgetcsv( $handle, 0, $this->delimiter );
- if ( sizeof( $header ) >= 1 ):
+ if ( sizeof( $header ) >= 1 ) :
$action = 'admin.php?import=' . $this->import_page . '&step=2';
?>
-
';
_e( 'The CSV is invalid.', 'sportspress' ) . '';
@@ -191,7 +211,7 @@ if ( class_exists( 'WP_Importer' ) ) {
endif;
- fclose( $handle );
+ fclose( $handle );
endif;
}
@@ -199,7 +219,7 @@ if ( class_exists( 'WP_Importer' ) ) {
* format_data_from_csv function.
*
* @access public
- * @param mixed $data
+ * @param mixed $data
* @param string $enc
* @return string
*/
@@ -239,7 +259,6 @@ if ( class_exists( 'WP_Importer' ) ) {
return false;
}
-
}
return true;
@@ -276,6 +295,7 @@ if ( class_exists( 'WP_Importer' ) ) {
/**
* Added to http_request_timeout filter to force timeout at 60 seconds during import
+ *
* @param int $val
* @return int 60
*/
diff --git a/includes/admin/importers/class-sp-official-importer.php b/includes/admin/importers/class-sp-official-importer.php
index 200fd52b..2f3dcf59 100644
--- a/includes/admin/importers/class-sp-official-importer.php
+++ b/includes/admin/importers/class-sp-official-importer.php
@@ -2,13 +2,15 @@
/**
* Official importer - import officials into SportsPress.
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Importers
- * @version 2.5.1
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Importers
+ * @version 2.5.1
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
if ( class_exists( 'WP_Importer' ) ) {
class SP_Official_Importer extends SP_Importer {
@@ -20,9 +22,9 @@ if ( class_exists( 'WP_Importer' ) ) {
* @return void
*/
public function __construct() {
- $this->import_page = 'sp_official_csv';
+ $this->import_page = 'sp_official_csv';
$this->import_label = __( 'Import Officials', 'sportspress' );
- $this->columns = array(
+ $this->columns = array(
'post_title' => __( 'Name', 'sportspress' ),
);
parent::__construct();
@@ -39,33 +41,39 @@ if ( class_exists( 'WP_Importer' ) ) {
function import( $array = array(), $columns = array( 'post_title' ) ) {
$this->imported = $this->skipped = 0;
- if ( ! is_array( $array ) || ! sizeof( $array ) ):
+ if ( ! is_array( $array ) || ! sizeof( $array ) ) :
$this->footer();
die();
endif;
$rows = array_chunk( $array, sizeof( $columns ) );
- foreach ( $rows as $row ):
+ foreach ( $rows as $row ) :
$row = array_filter( $row );
- if ( empty( $row ) ) continue;
+ if ( empty( $row ) ) {
+ continue;
+ }
$meta = array();
- foreach ( $columns as $index => $key ):
+ foreach ( $columns as $index => $key ) :
$meta[ $key ] = sp_array_value( $row, $index );
endforeach;
$name = sp_array_value( $meta, 'post_title' );
- if ( ! $name ):
+ if ( ! $name ) :
$this->skipped++;
continue;
endif;
- $args = array( 'post_type' => 'sp_official', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $name ) );
+ $args = array(
+ 'post_type' => 'sp_official',
+ 'post_status' => 'publish',
+ 'post_title' => wp_strip_all_tags( $name ),
+ );
$id = wp_insert_post( $args );
@@ -75,7 +83,7 @@ if ( class_exists( 'WP_Importer' ) ) {
// Show Result
echo '
';
$this->import_end();
@@ -85,7 +93,7 @@ if ( class_exists( 'WP_Importer' ) ) {
* Performs post-import cleanup of files and the cache
*/
function import_end() {
- echo '
';
do_action( 'import_end' );
}
@@ -108,7 +116,7 @@ if ( class_exists( 'WP_Importer' ) ) {
*/
function greet() {
echo '
';
diff --git a/includes/admin/importers/class-sp-player-importer.php b/includes/admin/importers/class-sp-player-importer.php
index 84875868..9b0baac4 100644
--- a/includes/admin/importers/class-sp-player-importer.php
+++ b/includes/admin/importers/class-sp-player-importer.php
@@ -2,13 +2,15 @@
/**
* Player importer - import players into SportsPress.
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Importers
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Importers
* @version 2.7
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
if ( class_exists( 'WP_Importer' ) ) {
class SP_Player_Importer extends SP_Importer {
@@ -20,17 +22,17 @@ if ( class_exists( 'WP_Importer' ) ) {
* @return void
*/
public function __construct() {
- $this->import_page = 'sp_player_csv';
+ $this->import_page = 'sp_player_csv';
$this->import_label = __( 'Import Players', 'sportspress' );
- $this->columns = array(
- 'sp_number' => __( 'Squad Number', 'sportspress' ),
- 'post_title' => __( 'Name', 'sportspress' ),
- 'sp_position' => __( 'Positions', 'sportspress' ),
- 'sp_team' => __( 'Teams', 'sportspress' ),
- 'sp_league' => __( 'Leagues', 'sportspress' ),
- 'sp_season' => __( 'Seasons', 'sportspress' ),
+ $this->columns = array(
+ 'sp_number' => __( 'Squad Number', 'sportspress' ),
+ 'post_title' => __( 'Name', 'sportspress' ),
+ 'sp_position' => __( 'Positions', 'sportspress' ),
+ 'sp_team' => __( 'Teams', 'sportspress' ),
+ 'sp_league' => __( 'Leagues', 'sportspress' ),
+ 'sp_season' => __( 'Seasons', 'sportspress' ),
'sp_nationality' => __( 'Nationality', 'sportspress' ),
- 'post_date' => __( 'Date of Birth', 'sportspress' ),
+ 'post_date' => __( 'Date of Birth', 'sportspress' ),
);
parent::__construct();
}
@@ -46,21 +48,23 @@ if ( class_exists( 'WP_Importer' ) ) {
function import( $array = array(), $columns = array( 'post_title' ) ) {
$this->imported = $this->skipped = 0;
- if ( ! is_array( $array ) || ! sizeof( $array ) ):
+ if ( ! is_array( $array ) || ! sizeof( $array ) ) :
$this->footer();
die();
endif;
$rows = array_chunk( $array, sizeof( $columns ) );
-
+
// Get Date of Birth format from post vars
$date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : sanitize_text_field( $_POST['sp_date_format'] ) );
- foreach ( $rows as $row ):
+ foreach ( $rows as $row ) :
$row = array_filter( $row, 'strlen' );
- if ( empty( $row ) ) continue;
+ if ( empty( $row ) ) {
+ continue;
+ }
$meta = array();
@@ -76,17 +80,17 @@ if ( class_exists( 'WP_Importer' ) ) {
$meta[ $p ] = '';
}
- foreach ( $columns as $index => $key ):
+ foreach ( $columns as $index => $key ) :
$meta[ $key ] = sp_array_value( $row, $index );
endforeach;
$name = sp_array_value( $meta, 'post_title' );
$date = sp_array_value( $meta, 'post_date' );
-
+
// Format date of birth
- $date = str_replace( '/', '-', trim( $date ) );
+ $date = str_replace( '/', '-', trim( $date ) );
$date_array = explode( '-', $date );
- switch ( $date_format ):
+ switch ( $date_format ) :
case 'dd/mm/yyyy':
$date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' .
@@ -103,28 +107,37 @@ if ( class_exists( 'WP_Importer' ) ) {
substr( str_pad( sp_array_value( $date_array, 2, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 );
endswitch;
- if ( ! $name ):
+ if ( ! $name ) :
$this->skipped++;
continue;
endif;
// Get or insert player
$player_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_player' ) : false;
- if ( $player_object ):
- if ( $player_object->post_status != 'publish' ):
- wp_update_post( array( 'ID' => $player_object->ID, 'post_status' => 'publish' ) );
+ if ( $player_object ) :
+ if ( $player_object->post_status != 'publish' ) :
+ wp_update_post(
+ array(
+ 'ID' => $player_object->ID,
+ 'post_status' => 'publish',
+ )
+ );
endif;
$id = $player_object->ID;
// Handle preservable data.
foreach ( $preservable_metas_keys as $p ) {
- $terms = wp_get_object_terms( $id, $p, array( 'fields' => 'names' ) );
+ $terms = wp_get_object_terms( $id, $p, array( 'fields' => 'names' ) );
$meta[ $p ] .= '|' . implode( '|', $terms );
}
- else:
- $args = array( 'post_type' => 'sp_player', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $name ) );
+ else :
+ $args = array(
+ 'post_type' => 'sp_player',
+ 'post_status' => 'publish',
+ 'post_title' => wp_strip_all_tags( $name ),
+ );
// Check if a DoB was set
- if( '0000-00-00' !== $date ){
- $args['post_date'] = $date;
+ if ( '0000-00-00' !== $date ) {
+ $args['post_date'] = $date;
}
$id = wp_insert_post( $args );
@@ -148,18 +161,29 @@ if ( class_exists( 'WP_Importer' ) ) {
wp_set_object_terms( $id, $seasons, 'sp_season', false );
// Update teams
- $teams = (array)explode( '|', sp_array_value( $meta, 'sp_team' ) );
- $i = 0;
- foreach ( $teams as $team ):
+ $teams = (array) explode( '|', sp_array_value( $meta, 'sp_team' ) );
+ $i = 0;
+ foreach ( $teams as $team ) :
// Get or insert team
$team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
- if ( $team_object ):
- if ( $team_object->post_status != 'publish' ):
- wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );
+ if ( $team_object ) :
+ if ( $team_object->post_status != 'publish' ) :
+ wp_update_post(
+ array(
+ 'ID' => $team_object->ID,
+ 'post_status' => 'publish',
+ )
+ );
endif;
$team_id = $team_object->ID;
- else:
- $team_id = wp_insert_post( array( 'post_type' => 'sp_team', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $team ) ) );
+ else :
+ $team_id = wp_insert_post(
+ array(
+ 'post_type' => 'sp_team',
+ 'post_status' => 'publish',
+ 'post_title' => wp_strip_all_tags( $team ),
+ )
+ );
// Flag as import
update_post_meta( $team_id, '_sp_import', 1 );
wp_set_object_terms( $team_id, $leagues, 'sp_league', false );
@@ -170,7 +194,7 @@ if ( class_exists( 'WP_Importer' ) ) {
add_post_meta( $id, 'sp_team', $team_id );
// Update current team if first in array, otherwise use as past team
- if ( $i == 0 ):
+ if ( $i == 0 ) :
update_post_meta( $id, 'sp_current_team', $team_id );
else :
add_post_meta( $id, 'sp_past_team', $team_id );
@@ -181,7 +205,9 @@ if ( class_exists( 'WP_Importer' ) ) {
// Update nationality
$nationality = trim( strtolower( sp_array_value( $meta, 'sp_nationality' ) ) );
- if ( $nationality == '*' ) $nationality = '';
+ if ( $nationality == '*' ) {
+ $nationality = '';
+ }
update_post_meta( $id, 'sp_nationality', $nationality );
$this->imported++;
@@ -190,7 +216,7 @@ if ( class_exists( 'WP_Importer' ) ) {
// Show Result
echo '
';
$this->import_end();
@@ -200,7 +226,7 @@ if ( class_exists( 'WP_Importer' ) ) {
* Performs post-import cleanup of files and the cache
*/
function import_end() {
- echo '
';
do_action( 'import_end' );
}
@@ -223,7 +249,7 @@ if ( class_exists( 'WP_Importer' ) ) {
*/
function greet() {
echo '
diff --git a/includes/admin/importers/class-sp-staff-importer.php b/includes/admin/importers/class-sp-staff-importer.php
index 9f081143..81200f15 100644
--- a/includes/admin/importers/class-sp-staff-importer.php
+++ b/includes/admin/importers/class-sp-staff-importer.php
@@ -2,13 +2,15 @@
/**
* Staff importer - import staff into SportsPress.
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Importers
- * @version 2.5.5
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Importers
+ * @version 2.5.5
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
if ( class_exists( 'WP_Importer' ) ) {
class SP_Staff_Importer extends SP_Importer {
@@ -20,14 +22,14 @@ if ( class_exists( 'WP_Importer' ) ) {
* @return void
*/
public function __construct() {
- $this->import_page = 'sp_staff_csv';
+ $this->import_page = 'sp_staff_csv';
$this->import_label = __( 'Import Staff', 'sportspress' );
- $this->columns = array(
- 'post_title' => __( 'Name', 'sportspress' ),
- 'sp_role' => __( 'Jobs', 'sportspress' ),
- 'sp_team' => __( 'Teams', 'sportspress' ),
- 'sp_league' => __( 'Leagues', 'sportspress' ),
- 'sp_season' => __( 'Seasons', 'sportspress' ),
+ $this->columns = array(
+ 'post_title' => __( 'Name', 'sportspress' ),
+ 'sp_role' => __( 'Jobs', 'sportspress' ),
+ 'sp_team' => __( 'Teams', 'sportspress' ),
+ 'sp_league' => __( 'Leagues', 'sportspress' ),
+ 'sp_season' => __( 'Seasons', 'sportspress' ),
'sp_nationality' => __( 'Nationality', 'sportspress' ),
);
parent::__construct();
@@ -44,42 +46,53 @@ if ( class_exists( 'WP_Importer' ) ) {
function import( $array = array(), $columns = array( 'post_title' ) ) {
$this->imported = $this->skipped = 0;
- if ( ! is_array( $array ) || ! sizeof( $array ) ):
+ if ( ! is_array( $array ) || ! sizeof( $array ) ) :
$this->footer();
die();
endif;
$rows = array_chunk( $array, sizeof( $columns ) );
- foreach ( $rows as $row ):
+ foreach ( $rows as $row ) :
$row = array_filter( $row );
- if ( empty( $row ) ) continue;
+ if ( empty( $row ) ) {
+ continue;
+ }
$meta = array();
- foreach ( $columns as $index => $key ):
+ foreach ( $columns as $index => $key ) :
$meta[ $key ] = sp_array_value( $row, $index );
endforeach;
$name = sp_array_value( $meta, 'post_title' );
- if ( ! $name ):
+ if ( ! $name ) :
$this->skipped++;
continue;
endif;
// Get or insert staff
$staff_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_staff' ) : false;
- if ( $staff_object ):
- if ( $staff_object->post_status != 'publish' ):
- wp_update_post( array( 'ID' => $staff_object->ID, 'post_status' => 'publish' ) );
+ if ( $staff_object ) :
+ if ( $staff_object->post_status != 'publish' ) :
+ wp_update_post(
+ array(
+ 'ID' => $staff_object->ID,
+ 'post_status' => 'publish',
+ )
+ );
endif;
$id = $staff_object->ID;
- else:
- $args = array( 'post_type' => 'sp_staff', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $name ) );
- $id = wp_insert_post( $args );
+ else :
+ $args = array(
+ 'post_type' => 'sp_staff',
+ 'post_status' => 'publish',
+ 'post_title' => wp_strip_all_tags( $name ),
+ );
+ $id = wp_insert_post( $args );
// Flag as import
update_post_meta( $id, '_sp_import', 1 );
@@ -98,18 +111,29 @@ if ( class_exists( 'WP_Importer' ) ) {
wp_set_object_terms( $id, $seasons, 'sp_season', false );
// Update teams
- $teams = (array)explode( '|', sp_array_value( $meta, 'sp_team' ) );
- $i = 0;
- foreach ( $teams as $team ):
+ $teams = (array) explode( '|', sp_array_value( $meta, 'sp_team' ) );
+ $i = 0;
+ foreach ( $teams as $team ) :
// Get or insert team
$team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
- if ( $team_object ):
- if ( $team_object->post_status != 'publish' ):
- wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );
+ if ( $team_object ) :
+ if ( $team_object->post_status != 'publish' ) :
+ wp_update_post(
+ array(
+ 'ID' => $team_object->ID,
+ 'post_status' => 'publish',
+ )
+ );
endif;
$team_id = $team_object->ID;
- else:
- $team_id = wp_insert_post( array( 'post_type' => 'sp_team', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $team ) ) );
+ else :
+ $team_id = wp_insert_post(
+ array(
+ 'post_type' => 'sp_team',
+ 'post_status' => 'publish',
+ 'post_title' => wp_strip_all_tags( $team ),
+ )
+ );
// Flag as import
update_post_meta( $team_id, '_sp_import', 1 );
wp_set_object_terms( $team_id, $leagues, 'sp_league', false );
@@ -120,7 +144,7 @@ if ( class_exists( 'WP_Importer' ) ) {
add_post_meta( $id, 'sp_team', $team_id );
// Update current team if first in array
- if ( $i == 0 ):
+ if ( $i == 0 ) :
update_post_meta( $id, 'sp_current_team', $team_id );
endif;
@@ -129,7 +153,9 @@ if ( class_exists( 'WP_Importer' ) ) {
// Update nationality
$nationality = trim( strtolower( sp_array_value( $meta, 'sp_nationality' ) ) );
- if ( $nationality == '*' ) $nationality = '';
+ if ( $nationality == '*' ) {
+ $nationality = '';
+ }
update_post_meta( $id, 'sp_nationality', $nationality );
$this->imported++;
@@ -138,7 +164,7 @@ if ( class_exists( 'WP_Importer' ) ) {
// Show Result
echo '
- '.sprintf( __( 'Import complete - imported %s staff and skipped %s .', 'sportspress' ), $this->imported, $this->skipped ).'
+ ' . sprintf( __( 'Import complete - imported %1$s staff and skipped %2$s .', 'sportspress' ), $this->imported, $this->skipped ) . '
';
$this->import_end();
@@ -148,7 +174,7 @@ if ( class_exists( 'WP_Importer' ) ) {
* Performs post-import cleanup of files and the cache
*/
function import_end() {
- echo '' . __( 'All done!', 'sportspress' ) . ' ' . __( 'View Staff', 'sportspress' ) . ' ' . '
';
+ echo '' . __( 'All done!', 'sportspress' ) . ' ' . __( 'View Staff', 'sportspress' ) . ' ' . '
';
do_action( 'import_end' );
}
@@ -171,7 +197,7 @@ if ( class_exists( 'WP_Importer' ) ) {
*/
function greet() {
echo '';
- echo '
' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'
';
+ echo '
' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '
';
echo '
' . sprintf( __( 'Staff need to be defined with columns in a specific order (6 columns). Click here to download a sample .', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/staff-sample.csv' ) . '
';
wp_import_upload_form( 'admin.php?import=sp_staff_csv&step=1' );
echo '
';
diff --git a/includes/admin/importers/class-sp-team-importer.php b/includes/admin/importers/class-sp-team-importer.php
index b368a7fe..3c82a2da 100644
--- a/includes/admin/importers/class-sp-team-importer.php
+++ b/includes/admin/importers/class-sp-team-importer.php
@@ -2,13 +2,15 @@
/**
* Team importer - import teams into SportsPress.
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Importers
- * @version 2.5.5
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Importers
+ * @version 2.5.5
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
if ( class_exists( 'WP_Importer' ) ) {
class SP_Team_Importer extends SP_Importer {
@@ -20,15 +22,15 @@ if ( class_exists( 'WP_Importer' ) ) {
* @return void
*/
public function __construct() {
- $this->import_page = 'sp_team_csv';
+ $this->import_page = 'sp_team_csv';
$this->import_label = __( 'Import Teams', 'sportspress' );
- $this->columns = array(
- 'post_title' => __( 'Name', 'sportspress' ),
- 'sp_league' => __( 'Leagues', 'sportspress' ),
- 'sp_season' => __( 'Seasons', 'sportspress' ),
- 'sp_url' => __( 'Site URL', 'sportspress' ),
+ $this->columns = array(
+ 'post_title' => __( 'Name', 'sportspress' ),
+ 'sp_league' => __( 'Leagues', 'sportspress' ),
+ 'sp_season' => __( 'Seasons', 'sportspress' ),
+ 'sp_url' => __( 'Site URL', 'sportspress' ),
'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
- 'sp_venue' => __( 'Home', 'sportspress' ),
+ 'sp_venue' => __( 'Home', 'sportspress' ),
);
parent::__construct();
}
@@ -44,42 +46,53 @@ if ( class_exists( 'WP_Importer' ) ) {
function import( $array = array(), $columns = array( 'post_title' ) ) {
$this->imported = $this->skipped = 0;
- if ( ! is_array( $array ) || ! sizeof( $array ) ):
+ if ( ! is_array( $array ) || ! sizeof( $array ) ) :
$this->footer();
die();
endif;
$rows = array_chunk( $array, sizeof( $columns ) );
- foreach ( $rows as $row ):
+ foreach ( $rows as $row ) :
$row = array_filter( $row );
- if ( empty( $row ) ) continue;
+ if ( empty( $row ) ) {
+ continue;
+ }
$meta = array();
- foreach ( $columns as $index => $key ):
+ foreach ( $columns as $index => $key ) :
$meta[ $key ] = sp_array_value( $row, $index );
endforeach;
$name = sp_array_value( $meta, 'post_title' );
- if ( ! $name ):
+ if ( ! $name ) :
$this->skipped++;
continue;
endif;
// Get or insert team
$team_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_team' ) : false;
- if ( $team_object ):
- if ( $team_object->post_status != 'publish' ):
- wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );
+ if ( $team_object ) :
+ if ( $team_object->post_status != 'publish' ) :
+ wp_update_post(
+ array(
+ 'ID' => $team_object->ID,
+ 'post_status' => 'publish',
+ )
+ );
endif;
$id = $team_object->ID;
- else:
- $args = array( 'post_type' => 'sp_team', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $name ) );
- $id = wp_insert_post( $args );
+ else :
+ $args = array(
+ 'post_type' => 'sp_team',
+ 'post_status' => 'publish',
+ 'post_title' => wp_strip_all_tags( $name ),
+ );
+ $id = wp_insert_post( $args );
// Flag as import
update_post_meta( $id, '_sp_import', 1 );
@@ -107,7 +120,7 @@ if ( class_exists( 'WP_Importer' ) ) {
// Show Result
echo '
- '.sprintf( __( 'Import complete - imported %s teams and skipped %s .', 'sportspress' ), $this->imported, $this->skipped ).'
+ ' . sprintf( __( 'Import complete - imported %1$s teams and skipped %2$s .', 'sportspress' ), $this->imported, $this->skipped ) . '
';
$this->import_end();
@@ -117,7 +130,7 @@ if ( class_exists( 'WP_Importer' ) ) {
* Performs post-import cleanup of files and the cache
*/
function import_end() {
- echo '' . __( 'All done!', 'sportspress' ) . ' ' . __( 'View Teams', 'sportspress' ) . ' ' . '
';
+ echo '' . __( 'All done!', 'sportspress' ) . ' ' . __( 'View Teams', 'sportspress' ) . ' ' . '
';
do_action( 'import_end' );
}
@@ -130,7 +143,7 @@ if ( class_exists( 'WP_Importer' ) ) {
*/
function greet() {
echo '';
- echo '
' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'
';
+ echo '
' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '
';
echo '
' . sprintf( __( 'Teams need to be defined with columns in a specific order (3 columns). Click here to download a sample .', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/teams-sample.csv' ) . '
';
wp_import_upload_form( 'admin.php?import=sp_team_csv&step=1' );
echo '
';
diff --git a/includes/admin/post-types/class-sp-admin-cpt-calendar.php b/includes/admin/post-types/class-sp-admin-cpt-calendar.php
index 9e023e38..b3314b13 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-calendar.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-calendar.php
@@ -2,160 +2,170 @@
/**
* Admin functions for the calendars post type
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Admin_CPT' ) )
- include( 'class-sp-admin-cpt.php' );
+if ( ! class_exists( 'SP_Admin_CPT' ) ) {
+ require 'class-sp-admin-cpt.php';
+}
if ( ! class_exists( 'SP_Admin_CPT_Calendar' ) ) :
-/**
- * SP_Admin_CPT_Calendar Class
- */
-class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
-
/**
- * Constructor
+ * SP_Admin_CPT_Calendar Class
*/
- public function __construct() {
- $this->type = 'sp_calendar';
+ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
- // Admin Columns
- add_filter( 'manage_edit-sp_calendar_columns', array( $this, 'edit_columns' ) );
- add_action( 'manage_sp_calendar_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->type = 'sp_calendar';
- // Filtering
- add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
- add_filter( 'parse_query', array( $this, 'filters_query' ) );
-
- // Call SP_Admin_CPT constructor
- parent::__construct();
- }
+ // Admin Columns
+ add_filter( 'manage_edit-sp_calendar_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_calendar_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
- /**
- * Change the columns shown in admin.
- */
- public function edit_columns( $existing_columns ) {
- unset( $existing_columns['author'], $existing_columns['date'] );
- $columns = array_merge( array(
- 'cb' => ' ',
- 'title' => __( 'Title', 'sportspress' ),
- 'sp_league' => __( 'League', 'sportspress' ),
- 'sp_season' => __( 'Season', 'sportspress' ),
- 'sp_venue' => __( 'Venue', 'sportspress' ),
- 'sp_team' => __( 'Team', 'sportspress' ),
- 'sp_events' => __( 'Events', 'sportspress' ),
- 'sp_layout' => __( 'Layout', 'sportspress' ),
- ), $existing_columns );
- return apply_filters( 'sportspress_calendar_admin_columns', $columns );
- }
+ // Filtering
+ add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
+ add_filter( 'parse_query', array( $this, 'filters_query' ) );
- /**
- * Define our custom columns shown in admin.
- * @param string $column
- */
- public function custom_columns( $column, $post_id ) {
- switch ( $column ):
- case 'sp_league':
- echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : __( 'All', 'sportspress' );
- break;
- case 'sp_season':
- echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : __( 'All', 'sportspress' );
- break;
- case 'sp_venue':
- echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : __( 'All', 'sportspress' );
- break;
- case 'sp_team':
- $teams = (array)get_post_meta( $post_id, 'sp_team', false );
- $teams = array_filter( $teams );
- if ( empty( $teams ) ):
- echo __( 'All', 'sportspress' );
- else:
- $current_team = get_post_meta( $post_id, 'sp_current_team', true );
- foreach( $teams as $team_id ):
- if ( ! $team_id ) continue;
- $team = get_post( $team_id );
- if ( $team ):
- echo esc_html( $team->post_title );
- if ( $team_id == $current_team ):
- echo ' ';
+ // Call SP_Admin_CPT constructor
+ parent::__construct();
+ }
+
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ unset( $existing_columns['author'], $existing_columns['date'] );
+ $columns = array_merge(
+ array(
+ 'cb' => ' ',
+ 'title' => __( 'Title', 'sportspress' ),
+ 'sp_league' => __( 'League', 'sportspress' ),
+ 'sp_season' => __( 'Season', 'sportspress' ),
+ 'sp_venue' => __( 'Venue', 'sportspress' ),
+ 'sp_team' => __( 'Team', 'sportspress' ),
+ 'sp_events' => __( 'Events', 'sportspress' ),
+ 'sp_layout' => __( 'Layout', 'sportspress' ),
+ ),
+ $existing_columns
+ );
+ return apply_filters( 'sportspress_calendar_admin_columns', $columns );
+ }
+
+ /**
+ * Define our custom columns shown in admin.
+ *
+ * @param string $column
+ */
+ public function custom_columns( $column, $post_id ) {
+ switch ( $column ) :
+ case 'sp_league':
+ echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : __( 'All', 'sportspress' );
+ break;
+ case 'sp_season':
+ echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : __( 'All', 'sportspress' );
+ break;
+ case 'sp_venue':
+ echo get_the_terms( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : __( 'All', 'sportspress' );
+ break;
+ case 'sp_team':
+ $teams = (array) get_post_meta( $post_id, 'sp_team', false );
+ $teams = array_filter( $teams );
+ if ( empty( $teams ) ) :
+ echo __( 'All', 'sportspress' );
+ else :
+ $current_team = get_post_meta( $post_id, 'sp_current_team', true );
+ foreach ( $teams as $team_id ) :
+ if ( ! $team_id ) {
+ continue;
+ }
+ $team = get_post( $team_id );
+ if ( $team ) :
+ echo esc_html( $team->post_title );
+ if ( $team_id == $current_team ) :
+ echo ' ';
+ endif;
+ echo ' ';
endif;
- echo ' ';
- endif;
- endforeach;
- endif;
- break;
- case 'sp_events':
- $calendar = new SP_Calendar( $post_id );
- echo sizeof( $calendar->data() );
- break;
- case 'sp_layout':
- echo esc_html( sp_array_value( SP()->formats->calendar, get_post_meta( $post_id, 'sp_format', true ), '—' ) );
- break;
- endswitch;
- }
+ endforeach;
+ endif;
+ break;
+ case 'sp_events':
+ $calendar = new SP_Calendar( $post_id );
+ echo sizeof( $calendar->data() );
+ break;
+ case 'sp_layout':
+ echo esc_html( sp_array_value( SP()->formats->calendar, get_post_meta( $post_id, 'sp_format', true ), '—' ) );
+ break;
+ endswitch;
+ }
- /**
- * Show a category filter box
- */
- public function filters() {
- global $typenow, $wp_query;
+ /**
+ * Show a category filter box
+ */
+ public function filters() {
+ global $typenow, $wp_query;
- if ( $typenow != 'sp_calendar' )
- return;
+ if ( $typenow != 'sp_calendar' ) {
+ return;
+ }
- $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
- $args = array(
- 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
- 'taxonomy' => 'sp_league',
- 'name' => 'sp_league',
- 'selected' => $selected
- );
- sp_dropdown_taxonomies( $args );
+ $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
+ $args = array(
+ 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
+ 'taxonomy' => 'sp_league',
+ 'name' => 'sp_league',
+ 'selected' => $selected,
+ );
+ sp_dropdown_taxonomies( $args );
- $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
- $args = array(
- 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
- 'taxonomy' => 'sp_season',
- 'name' => 'sp_season',
- 'selected' => $selected
- );
- sp_dropdown_taxonomies( $args );
+ $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
+ $args = array(
+ 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
+ 'taxonomy' => 'sp_season',
+ 'name' => 'sp_season',
+ 'selected' => $selected,
+ );
+ sp_dropdown_taxonomies( $args );
- $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
- $args = array(
- 'post_type' => 'sp_team',
- 'name' => 'team',
- 'show_option_none' => __( 'Show all teams', 'sportspress' ),
- 'selected' => $selected,
- 'values' => 'ID',
- );
- wp_dropdown_pages( $args );
- }
+ $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
+ $args = array(
+ 'post_type' => 'sp_team',
+ 'name' => 'team',
+ 'show_option_none' => __( 'Show all teams', 'sportspress' ),
+ 'selected' => $selected,
+ 'values' => 'ID',
+ );
+ wp_dropdown_pages( $args );
+ }
- /**
- * Filter in admin based on options
- *
- * @param mixed $query
- */
- public function filters_query( $query ) {
- global $typenow, $wp_query;
+ /**
+ * Filter in admin based on options
+ *
+ * @param mixed $query
+ */
+ public function filters_query( $query ) {
+ global $typenow, $wp_query;
- if ( $typenow == 'sp_calendar' ) {
+ if ( $typenow == 'sp_calendar' ) {
- if ( ! empty( $_GET['team'] ) ) {
- $query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
- $query->query_vars['meta_key'] = 'sp_team';
- }
+ if ( ! empty( $_GET['team'] ) ) {
+ $query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
+ $query->query_vars['meta_key'] = 'sp_team';
+ }
+ }
}
}
-}
endif;
diff --git a/includes/admin/post-types/class-sp-admin-cpt-column.php b/includes/admin/post-types/class-sp-admin-cpt-column.php
index 0fb36a99..4ba91f88 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-column.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-column.php
@@ -2,80 +2,84 @@
/**
* Admin functions for the columns post type
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Admin_CPT' ) )
- include( 'class-sp-admin-cpt.php' );
+if ( ! class_exists( 'SP_Admin_CPT' ) ) {
+ require 'class-sp-admin-cpt.php';
+}
if ( ! class_exists( 'SP_Admin_CPT_Column' ) ) :
-/**
- * SP_Admin_CPT_Column Class
- */
-class SP_Admin_CPT_Column extends SP_Admin_CPT {
-
/**
- * Constructor
+ * SP_Admin_CPT_Column Class
*/
- public function __construct() {
- $this->type = 'sp_column';
+ class SP_Admin_CPT_Column extends SP_Admin_CPT {
- // Admin Columns
- add_filter( 'manage_edit-sp_column_columns', array( $this, 'edit_columns' ) );
- add_action( 'manage_sp_column_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
-
- // Call SP_Admin_CPT constructor
- parent::__construct();
- }
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->type = 'sp_column';
- /**
- * Change the columns shown in admin.
- */
- public function edit_columns( $existing_columns ) {
- $columns = array(
- 'cb' => ' ',
- 'title' => __( 'Label', 'sportspress' ),
- 'sp_key' => __( 'Key', 'sportspress' ),
- 'sp_equation' => __( 'Equation', 'sportspress' ),
- 'sp_precision' => __( 'Decimal Places', 'sportspress' ),
- 'sp_order' => __( 'Sort Order', 'sportspress' ),
- 'sp_description' => __( 'Description', 'sportspress' ),
- );
- return apply_filters( 'sportspress_column_admin_columns', $columns );
- }
+ // Admin Columns
+ add_filter( 'manage_edit-sp_column_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_column_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
- /**
- * Define our custom columns shown in admin.
- * @param string $column
- */
- public function custom_columns( $column, $post_id ) {
- switch ( $column ):
- case 'sp_key':
- global $post;
- echo esc_html( $post->post_name );
- break;
- case 'sp_equation':
- echo wp_kses_post( sp_get_post_equation( $post_id ) );
- break;
- case 'sp_precision':
- echo esc_html( sp_get_post_precision( $post_id ) );
- break;
- case 'sp_order':
- echo esc_html( sp_get_post_order( $post_id ) );
- break;
- case 'sp_description':
- global $post;
- echo '' . wp_kses_post( $post->post_excerpt ) . ' ';
- break;
- endswitch;
+ // Call SP_Admin_CPT constructor
+ parent::__construct();
+ }
+
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ $columns = array(
+ 'cb' => ' ',
+ 'title' => __( 'Label', 'sportspress' ),
+ 'sp_key' => __( 'Key', 'sportspress' ),
+ 'sp_equation' => __( 'Equation', 'sportspress' ),
+ 'sp_precision' => __( 'Decimal Places', 'sportspress' ),
+ 'sp_order' => __( 'Sort Order', 'sportspress' ),
+ 'sp_description' => __( 'Description', 'sportspress' ),
+ );
+ return apply_filters( 'sportspress_column_admin_columns', $columns );
+ }
+
+ /**
+ * Define our custom columns shown in admin.
+ *
+ * @param string $column
+ */
+ public function custom_columns( $column, $post_id ) {
+ switch ( $column ) :
+ case 'sp_key':
+ global $post;
+ echo esc_html( $post->post_name );
+ break;
+ case 'sp_equation':
+ echo wp_kses_post( sp_get_post_equation( $post_id ) );
+ break;
+ case 'sp_precision':
+ echo esc_html( sp_get_post_precision( $post_id ) );
+ break;
+ case 'sp_order':
+ echo esc_html( sp_get_post_order( $post_id ) );
+ break;
+ case 'sp_description':
+ global $post;
+ echo '' . wp_kses_post( $post->post_excerpt ) . ' ';
+ break;
+ endswitch;
+ }
}
-}
endif;
diff --git a/includes/admin/post-types/class-sp-admin-cpt-event.php b/includes/admin/post-types/class-sp-admin-cpt-event.php
index 1e0a2db4..4db3ca95 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-event.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-event.php
@@ -2,217 +2,235 @@
/**
* Admin functions for the events post type
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Admin_CPT' ) )
- include( 'class-sp-admin-cpt.php' );
+if ( ! class_exists( 'SP_Admin_CPT' ) ) {
+ require 'class-sp-admin-cpt.php';
+}
if ( ! class_exists( 'SP_Admin_CPT_Event' ) ) :
-/**
- * SP_Admin_CPT_Event Class
- */
-class SP_Admin_CPT_Event extends SP_Admin_CPT {
-
/**
- * Constructor
+ * SP_Admin_CPT_Event Class
*/
- public function __construct() {
- $this->type = 'sp_event';
+ class SP_Admin_CPT_Event extends SP_Admin_CPT {
- // Post title fields
- add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->type = 'sp_event';
- // Empty data filter
- add_filter( 'wp_insert_post_empty_content', array( $this, 'wp_insert_post_empty_content' ), 99, 2 );
+ // Post title fields
+ add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
- // Before data updates
- add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 99, 2 );
+ // Empty data filter
+ add_filter( 'wp_insert_post_empty_content', array( $this, 'wp_insert_post_empty_content' ), 99, 2 );
- // Admin Columns
- add_filter( 'manage_edit-sp_event_columns', array( $this, 'edit_columns' ) );
- add_filter( 'manage_edit-sp_event_sortable_columns', array( $this, 'sortable_columns' ) );
- add_action( 'pre_get_posts', array( $this, 'orderby_columns' ) );
- add_action( 'manage_sp_event_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
+ // Before data updates
+ add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 99, 2 );
- // Filtering
- add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
- add_filter( 'parse_query', array( $this, 'filters_query' ) );
+ // Admin Columns
+ add_filter( 'manage_edit-sp_event_columns', array( $this, 'edit_columns' ) );
+ add_filter( 'manage_edit-sp_event_sortable_columns', array( $this, 'sortable_columns' ) );
+ add_action( 'pre_get_posts', array( $this, 'orderby_columns' ) );
+ add_action( 'manage_sp_event_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
- // Post states
- add_filter( 'display_post_states', array( $this, 'post_states' ), 10, 2 );
-
- // Call SP_Admin_CPT constructor
- parent::__construct();
- }
+ // Filtering
+ add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
+ add_filter( 'parse_query', array( $this, 'filters_query' ) );
- /**
- * Change title boxes in admin.
- * @param string $text
- * @param object $post
- * @return string
- */
- public function enter_title_here( $text, $post ) {
- if ( $post->post_type == 'sp_event' )
- return __( '(Auto)', 'sportspress' );
+ // Post states
+ add_filter( 'display_post_states', array( $this, 'post_states' ), 10, 2 );
- return $text;
- }
+ // Call SP_Admin_CPT constructor
+ parent::__construct();
+ }
- /**
- * Mark as not empty when saving event if teams are selected for auto title.
- *
- * @param array $maybe_empty
- * @param array $postarr
- * @return bool
- */
- public function wp_insert_post_empty_content( $maybe_empty, $postarr ) {
- if ( $maybe_empty && 'sp_event' === sp_array_value( $postarr, 'post_type' ) ):
- $teams = sp_array_value( $postarr, 'sp_team', array() );
- $teams = array_filter( $teams );
- if ( sizeof( $teams ) ) return false;
- endif;
-
- return $maybe_empty;
- }
-
- /**
- * Auto-generate an event title based on the team playing if left blank.
- *
- * @param array $data
- * @param array $postarr
- * @return array
- */
- public function wp_insert_post_data( $data, $postarr ) {
- if ( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ):
-
- $teams = sp_array_value( $postarr, 'sp_team', array() );
- $teams = array_filter( $teams );
-
- $team_names = array();
- foreach ( $teams as $team ):
- while ( is_array( $team ) ) {
- $team = array_shift( array_filter( $team ) );
- }
- if ( $team > 0 ) $team_names[] = sp_team_short_name( $team );
- endforeach;
-
- $team_names = array_unique( $team_names );
-
- $reverse_teams = get_option( 'sportspress_event_reverse_teams', 'no' ) === 'yes' ? true : false;
- if ( $reverse_teams ) {
- $team_names = array_reverse( $team_names );
+ /**
+ * Change title boxes in admin.
+ *
+ * @param string $text
+ * @param object $post
+ * @return string
+ */
+ public function enter_title_here( $text, $post ) {
+ if ( $post->post_type == 'sp_event' ) {
+ return __( '(Auto)', 'sportspress' );
}
- $data['post_title'] = implode( ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ', $team_names );
-
- endif;
-
- return $data;
- }
-
- /**
- * Change the columns shown in admin.
- */
- public function edit_columns( $existing_columns ) {
- unset( $existing_columns['author'], $existing_columns['comments'] );
- $columns = array_merge( array(
- 'cb' => ' ',
- 'sp_format' => ' ',
- 'title' => null,
- 'date' => __( 'Date', 'sportspress' ),
- 'sp_time' => __( 'Time', 'sportspress' ),
- 'sp_team' => __( 'Teams', 'sportspress' ),
- 'sp_league' => __( 'League', 'sportspress' ),
- 'sp_season' => __( 'Season', 'sportspress' ),
- 'sp_venue' => __( 'Venue', 'sportspress' ),
- 'sp_day' => __( 'Match Day', 'sportspress' ),
- ), $existing_columns, array(
- 'title' => __( 'Event', 'sportspress' ),
- ) );
- return apply_filters( 'sportspress_event_admin_columns', $columns );
- }
-
- /**
- * Change the sortable columns in admin.
- */
- public function sortable_columns( $columns ) {
- $columns['sp_day'] = 'sp_day';
- return $columns;
- }
-
- /**
- * Define the sortable columns in admin.
- */
- public function orderby_columns( $query ) {
- if ( ! is_admin() ) return;
-
- $orderby = $query->get( 'orderby');
-
- if ( 'sp_day' == $orderby ) {
- $query->set( 'meta_key','sp_day' );
- $query->set( 'orderby','meta_value_num' );
+ return $text;
}
- }
- /**
- * Define our custom columns shown in admin.
- * @param string $column
- */
- public function custom_columns( $column, $post_id ) {
- switch ( $column ):
- case 'sp_format':
- $format = get_post_meta( $post_id, 'sp_format', true );
- $formats = new SP_Formats();
- $event_formats = $formats->event;
- if ( array_key_exists( $format, $event_formats ) ):
- echo ' ';
- endif;
- break;
- case 'sp_time':
- echo apply_filters( 'sportspress_event_time_admin', get_post_time( 'H:i', false, $post_id, true ) );
- break;
- case 'sp_team':
- $teams = (array)get_post_meta( $post_id, 'sp_team', false );
+ /**
+ * Mark as not empty when saving event if teams are selected for auto title.
+ *
+ * @param array $maybe_empty
+ * @param array $postarr
+ * @return bool
+ */
+ public function wp_insert_post_empty_content( $maybe_empty, $postarr ) {
+ if ( $maybe_empty && 'sp_event' === sp_array_value( $postarr, 'post_type' ) ) :
+ $teams = sp_array_value( $postarr, 'sp_team', array() );
$teams = array_filter( $teams );
- $teams = array_unique( $teams );
+ if ( sizeof( $teams ) ) {
+ return false;
+ }
+ endif;
+
+ return $maybe_empty;
+ }
+
+ /**
+ * Auto-generate an event title based on the team playing if left blank.
+ *
+ * @param array $data
+ * @param array $postarr
+ * @return array
+ */
+ public function wp_insert_post_data( $data, $postarr ) {
+ if ( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ) :
+
+ $teams = sp_array_value( $postarr, 'sp_team', array() );
+ $teams = array_filter( $teams );
+
+ $team_names = array();
+ foreach ( $teams as $team ) :
+ while ( is_array( $team ) ) {
+ $team = array_shift( array_filter( $team ) );
+ }
+ if ( $team > 0 ) {
+ $team_names[] = sp_team_short_name( $team );
+ }
+ endforeach;
+
+ $team_names = array_unique( $team_names );
+
$reverse_teams = get_option( 'sportspress_event_reverse_teams', 'no' ) === 'yes' ? true : false;
if ( $reverse_teams ) {
- $teams = array_reverse( $teams , true );
+ $team_names = array_reverse( $team_names );
}
- if ( empty( $teams ) ):
- echo '—';
- else:
- $results = get_post_meta( $post_id, 'sp_results', true );
- $main_result = get_option( 'sportspress_primary_result', null );
- echo ' ';
- echo '';
- foreach( $teams as $team_id ):
- if ( ! $team_id ) continue;
+
+ $data['post_title'] = implode( ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ', $team_names );
+
+ endif;
+
+ return $data;
+ }
+
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ unset( $existing_columns['author'], $existing_columns['comments'] );
+ $columns = array_merge(
+ array(
+ 'cb' => '
',
+ 'sp_format' => '
',
+ 'title' => null,
+ 'date' => __( 'Date', 'sportspress' ),
+ 'sp_time' => __( 'Time', 'sportspress' ),
+ 'sp_team' => __( 'Teams', 'sportspress' ),
+ 'sp_league' => __( 'League', 'sportspress' ),
+ 'sp_season' => __( 'Season', 'sportspress' ),
+ 'sp_venue' => __( 'Venue', 'sportspress' ),
+ 'sp_day' => __( 'Match Day', 'sportspress' ),
+ ),
+ $existing_columns,
+ array(
+ 'title' => __( 'Event', 'sportspress' ),
+ )
+ );
+ return apply_filters( 'sportspress_event_admin_columns', $columns );
+ }
+
+ /**
+ * Change the sortable columns in admin.
+ */
+ public function sortable_columns( $columns ) {
+ $columns['sp_day'] = 'sp_day';
+ return $columns;
+ }
+
+ /**
+ * Define the sortable columns in admin.
+ */
+ public function orderby_columns( $query ) {
+ if ( ! is_admin() ) {
+ return;
+ }
+
+ $orderby = $query->get( 'orderby' );
+
+ if ( 'sp_day' == $orderby ) {
+ $query->set( 'meta_key', 'sp_day' );
+ $query->set( 'orderby', 'meta_value_num' );
+ }
+ }
+
+ /**
+ * Define our custom columns shown in admin.
+ *
+ * @param string $column
+ */
+ public function custom_columns( $column, $post_id ) {
+ switch ( $column ) :
+ case 'sp_format':
+ $format = get_post_meta( $post_id, 'sp_format', true );
+ $formats = new SP_Formats();
+ $event_formats = $formats->event;
+ if ( array_key_exists( $format, $event_formats ) ) :
+ echo '
';
+ endif;
+ break;
+ case 'sp_time':
+ echo apply_filters( 'sportspress_event_time_admin', get_post_time( 'H:i', false, $post_id, true ) );
+ break;
+ case 'sp_team':
+ $teams = (array) get_post_meta( $post_id, 'sp_team', false );
+ $teams = array_filter( $teams );
+ $teams = array_unique( $teams );
+ $reverse_teams = get_option( 'sportspress_event_reverse_teams', 'no' ) === 'yes' ? true : false;
+ if ( $reverse_teams ) {
+ $teams = array_reverse( $teams, true );
+ }
+ if ( empty( $teams ) ) :
+ echo '—';
+ else :
+ $results = get_post_meta( $post_id, 'sp_results', true );
+ $main_result = get_option( 'sportspress_primary_result', null );
+ echo '
';
+ echo '
';
+ foreach ( $teams as $team_id ) :
+ if ( ! $team_id ) {
+ continue;
+ }
$team = get_post( $team_id );
- if ( $team ):
+ if ( $team ) :
$team_results = sportspress_array_value( $results, $team_id, null );
- if ( $main_result ):
+ if ( $main_result ) :
$team_result = sportspress_array_value( $team_results, $main_result, null );
- else:
- if ( is_array( $team_results ) ):
+ else :
+ if ( is_array( $team_results ) ) :
end( $team_results );
$team_result = prev( $team_results );
$main_result = key( $team_results );
- else:
+ else :
$team_result = null;
endif;
endif;
- if ( is_array( $team_results ) ):
+ if ( is_array( $team_results ) ) :
unset( $team_results['outcome'] );
$team_results = array_filter( $team_results, 'sp_filter_non_empty' );
$team_results = implode( ' | ', $team_results );
@@ -223,129 +241,134 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
echo esc_html( $team->post_title );
echo ' ';
endif;
- endforeach;
- echo '
';
- if ( current_user_can( 'edit_others_sp_events' ) ) {
- ?>
+ endforeach;
+ echo '
';
+ if ( current_user_can( 'edit_others_sp_events' ) ) {
+ ?>
- 'sp_team',
- 'name' => 'team',
- 'show_option_none' => __( 'Show all teams', 'sportspress' ),
- 'selected' => $selected,
- 'values' => 'ID',
- );
- wp_dropdown_pages( $args );
-
- $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
- $args = array(
- 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
- 'taxonomy' => 'sp_league',
- 'name' => 'sp_league',
- 'selected' => $selected
- );
- sp_dropdown_taxonomies( $args );
-
- $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
- $args = array(
- 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
- 'taxonomy' => 'sp_season',
- 'name' => 'sp_season',
- 'selected' => $selected
- );
- sp_dropdown_taxonomies( $args );
-
- $selected = isset( $_REQUEST['match_day'] ) ? sanitize_text_field( $_REQUEST['match_day'] ) : null;
- echo ' ';
-
- if ( current_user_can( 'edit_others_sp_events' ) )
- wp_nonce_field( 'sp-save-inline-results', 'sp-inline-nonce', false );
- }
-
- /**
- * Filter in admin based on options
- *
- * @param mixed $query
- */
- public function filters_query( $query ) {
- global $typenow, $wp_query;
-
- if ( $typenow == 'sp_event' ) {
- //Avoid overriding relation operator if already set
- if ( !isset( $query->query_vars['meta_query']['relation'] ) )
- $query->query_vars['meta_query']['relation'] = 'AND';
-
- if ( ! empty( $_GET['team'] ) ) {
- $query->query_vars['meta_query'][] = array(
- 'key' => 'sp_team',
- 'value' => $_GET['team'],
- );
+ echo esc_html( $day );
+ break;
+ endswitch;
}
-
- if ( ! empty( $_GET['match_day'] ) ) {
- $query->query_vars['meta_query'][] = array(
- 'key' => 'sp_day',
- 'value' => $_GET['match_day'],
- );
+
+ /**
+ * Show a category filter box
+ */
+ public function filters() {
+ global $typenow, $wp_query;
+
+ if ( $typenow != 'sp_event' ) {
+ return;
+ }
+
+ $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
+ $args = array(
+ 'post_type' => 'sp_team',
+ 'name' => 'team',
+ 'show_option_none' => __( 'Show all teams', 'sportspress' ),
+ 'selected' => $selected,
+ 'values' => 'ID',
+ );
+ wp_dropdown_pages( $args );
+
+ $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
+ $args = array(
+ 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
+ 'taxonomy' => 'sp_league',
+ 'name' => 'sp_league',
+ 'selected' => $selected,
+ );
+ sp_dropdown_taxonomies( $args );
+
+ $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
+ $args = array(
+ 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
+ 'taxonomy' => 'sp_season',
+ 'name' => 'sp_season',
+ 'selected' => $selected,
+ );
+ sp_dropdown_taxonomies( $args );
+
+ $selected = isset( $_REQUEST['match_day'] ) ? sanitize_text_field( $_REQUEST['match_day'] ) : null;
+ echo ' ';
+
+ if ( current_user_can( 'edit_others_sp_events' ) ) {
+ wp_nonce_field( 'sp-save-inline-results', 'sp-inline-nonce', false );
+ }
}
- }
- }
- /**
- * Replace displayed post state for events
- *
- * @param array $post_states
- * @param object $post
- */
- public function post_states( $post_states, $post ) {
- $status = get_post_meta( $post->ID, 'sp_status', true );
+ /**
+ * Filter in admin based on options
+ *
+ * @param mixed $query
+ */
+ public function filters_query( $query ) {
+ global $typenow, $wp_query;
- if ( 'postponed' == $status ) {
- $post_states = array( __( 'Postponed', 'sportspress' ) );
- } elseif ( 'cancelled' == $status ) {
- $post_states = array( __( 'Canceled', 'sportspress' ) );
- } elseif ( 'tbd' == $status ) {
- $post_states = array( __( 'TBD', 'sportspress' ) );
- }
+ if ( $typenow == 'sp_event' ) {
+ // Avoid overriding relation operator if already set
+ if ( ! isset( $query->query_vars['meta_query']['relation'] ) ) {
+ $query->query_vars['meta_query']['relation'] = 'AND';
+ }
- return $post_states;
- }
-}
+ if ( ! empty( $_GET['team'] ) ) {
+ $query->query_vars['meta_query'][] = array(
+ 'key' => 'sp_team',
+ 'value' => $_GET['team'],
+ );
+ }
+
+ if ( ! empty( $_GET['match_day'] ) ) {
+ $query->query_vars['meta_query'][] = array(
+ 'key' => 'sp_day',
+ 'value' => $_GET['match_day'],
+ );
+ }
+ }
+ }
+
+ /**
+ * Replace displayed post state for events
+ *
+ * @param array $post_states
+ * @param object $post
+ */
+ public function post_states( $post_states, $post ) {
+ $status = get_post_meta( $post->ID, 'sp_status', true );
+
+ if ( 'postponed' == $status ) {
+ $post_states = array( __( 'Postponed', 'sportspress' ) );
+ } elseif ( 'cancelled' == $status ) {
+ $post_states = array( __( 'Canceled', 'sportspress' ) );
+ } elseif ( 'tbd' == $status ) {
+ $post_states = array( __( 'TBD', 'sportspress' ) );
+ }
+
+ return $post_states;
+ }
+ }
endif;
diff --git a/includes/admin/post-types/class-sp-admin-cpt-list.php b/includes/admin/post-types/class-sp-admin-cpt-list.php
index dcc7f4bd..d1dc656c 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-list.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-list.php
@@ -2,154 +2,166 @@
/**
* Admin functions for the player lists post type
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Admin_CPT' ) )
- include( 'class-sp-admin-cpt.php' );
+if ( ! class_exists( 'SP_Admin_CPT' ) ) {
+ require 'class-sp-admin-cpt.php';
+}
if ( ! class_exists( 'SP_Admin_CPT_List' ) ) :
-/**
- * SP_Admin_CPT_List Class
- */
-class SP_Admin_CPT_List extends SP_Admin_CPT {
-
/**
- * Constructor
+ * SP_Admin_CPT_List Class
*/
- public function __construct() {
- $this->type = 'sp_list';
+ class SP_Admin_CPT_List extends SP_Admin_CPT {
- // Admin Columns
- add_filter( 'manage_edit-sp_list_columns', array( $this, 'edit_columns' ) );
- add_action( 'manage_sp_list_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->type = 'sp_list';
- // Filtering
- add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
- add_filter( 'parse_query', array( $this, 'filters_query' ) );
-
- // Call SP_Admin_CPT constructor
- parent::__construct();
- }
+ // Admin Columns
+ add_filter( 'manage_edit-sp_list_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_list_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
- /**
- * Change the columns shown in admin.
- */
- public function edit_columns( $existing_columns ) {
- unset( $existing_columns['author'], $existing_columns['date'] );
- $columns = array_merge( array(
- 'cb' => ' ',
- 'title' => __( 'Title', 'sportspress' ),
- 'sp_league' => __( 'League', 'sportspress' ),
- 'sp_season' => __( 'Season', 'sportspress' ),
- 'sp_team' => __( 'Team', 'sportspress' ),
- 'sp_player' => __( 'Players', 'sportspress' ),
- 'sp_layout' => __( 'Layout', 'sportspress' ),
- ), $existing_columns );
- return apply_filters( 'sportspress_list_admin_columns', $columns );
- }
+ // Filtering
+ add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
+ add_filter( 'parse_query', array( $this, 'filters_query' ) );
- /**
- * Define our custom columns shown in admin.
- * @param string $column
- */
- public function custom_columns( $column, $post_id ) {
- switch ( $column ):
- case 'sp_player':
- $select = get_post_meta( $post_id, 'sp_select', true );
- if ( 'manual' == $select ):
- $players = array_filter( get_post_meta( $post_id, 'sp_player' ) );
- echo sizeof( $players );
- else:
- _e( 'Auto', 'sportspress' );
- endif;
- break;
- case 'sp_league':
- echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : __( 'All', 'sportspress' );
- break;
- case 'sp_season':
- echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : __( 'All', 'sportspress' );
- break;
- case 'sp_team':
- $teams = (array)get_post_meta( $post_id, 'sp_team', false );
- $teams = array_filter( $teams );
- if ( empty( $teams ) ):
- echo __( 'All', 'sportspress' );
- else:
- foreach( $teams as $team_id ):
- if ( ! $team_id ) continue;
- $team = get_post( $team_id );
- if ( $team ) echo esc_html( $team->post_title ) . ' ';
- endforeach;
- endif;
- break;
- case 'sp_layout':
- echo esc_html( sp_array_value( SP()->formats->list, get_post_meta( $post_id, 'sp_format', true ), '—' ) );
- break;
- endswitch;
- }
+ // Call SP_Admin_CPT constructor
+ parent::__construct();
+ }
- /**
- * Show a category filter box
- */
- public function filters() {
- global $typenow, $wp_query;
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ unset( $existing_columns['author'], $existing_columns['date'] );
+ $columns = array_merge(
+ array(
+ 'cb' => ' ',
+ 'title' => __( 'Title', 'sportspress' ),
+ 'sp_league' => __( 'League', 'sportspress' ),
+ 'sp_season' => __( 'Season', 'sportspress' ),
+ 'sp_team' => __( 'Team', 'sportspress' ),
+ 'sp_player' => __( 'Players', 'sportspress' ),
+ 'sp_layout' => __( 'Layout', 'sportspress' ),
+ ),
+ $existing_columns
+ );
+ return apply_filters( 'sportspress_list_admin_columns', $columns );
+ }
- if ( $typenow != 'sp_list' )
- return;
+ /**
+ * Define our custom columns shown in admin.
+ *
+ * @param string $column
+ */
+ public function custom_columns( $column, $post_id ) {
+ switch ( $column ) :
+ case 'sp_player':
+ $select = get_post_meta( $post_id, 'sp_select', true );
+ if ( 'manual' == $select ) :
+ $players = array_filter( get_post_meta( $post_id, 'sp_player' ) );
+ echo sizeof( $players );
+ else :
+ _e( 'Auto', 'sportspress' );
+ endif;
+ break;
+ case 'sp_league':
+ echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : __( 'All', 'sportspress' );
+ break;
+ case 'sp_season':
+ echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : __( 'All', 'sportspress' );
+ break;
+ case 'sp_team':
+ $teams = (array) get_post_meta( $post_id, 'sp_team', false );
+ $teams = array_filter( $teams );
+ if ( empty( $teams ) ) :
+ echo __( 'All', 'sportspress' );
+ else :
+ foreach ( $teams as $team_id ) :
+ if ( ! $team_id ) {
+ continue;
+ }
+ $team = get_post( $team_id );
+ if ( $team ) {
+ echo esc_html( $team->post_title ) . ' ';
+ }
+ endforeach;
+ endif;
+ break;
+ case 'sp_layout':
+ echo esc_html( sp_array_value( SP()->formats->list, get_post_meta( $post_id, 'sp_format', true ), '—' ) );
+ break;
+ endswitch;
+ }
- $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
- $args = array(
- 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
- 'taxonomy' => 'sp_league',
- 'name' => 'sp_league',
- 'selected' => $selected
- );
- sp_dropdown_taxonomies( $args );
+ /**
+ * Show a category filter box
+ */
+ public function filters() {
+ global $typenow, $wp_query;
- $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
- $args = array(
- 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
- 'taxonomy' => 'sp_season',
- 'name' => 'sp_season',
- 'selected' => $selected
- );
- sp_dropdown_taxonomies( $args );
+ if ( $typenow != 'sp_list' ) {
+ return;
+ }
- $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
- $args = array(
- 'post_type' => 'sp_team',
- 'name' => 'team',
- 'show_option_none' => __( 'Show all teams', 'sportspress' ),
- 'selected' => $selected,
- 'values' => 'ID',
- );
- wp_dropdown_pages( $args );
- }
+ $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
+ $args = array(
+ 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
+ 'taxonomy' => 'sp_league',
+ 'name' => 'sp_league',
+ 'selected' => $selected,
+ );
+ sp_dropdown_taxonomies( $args );
- /**
- * Filter in admin based on options
- *
- * @param mixed $query
- */
- public function filters_query( $query ) {
- global $typenow, $wp_query;
+ $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
+ $args = array(
+ 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
+ 'taxonomy' => 'sp_season',
+ 'name' => 'sp_season',
+ 'selected' => $selected,
+ );
+ sp_dropdown_taxonomies( $args );
- if ( $typenow == 'sp_list' ) {
+ $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
+ $args = array(
+ 'post_type' => 'sp_team',
+ 'name' => 'team',
+ 'show_option_none' => __( 'Show all teams', 'sportspress' ),
+ 'selected' => $selected,
+ 'values' => 'ID',
+ );
+ wp_dropdown_pages( $args );
+ }
- if ( ! empty( $_GET['team'] ) ) {
- $query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
- $query->query_vars['meta_key'] = 'sp_team';
- }
+ /**
+ * Filter in admin based on options
+ *
+ * @param mixed $query
+ */
+ public function filters_query( $query ) {
+ global $typenow, $wp_query;
+
+ if ( $typenow == 'sp_list' ) {
+
+ if ( ! empty( $_GET['team'] ) ) {
+ $query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
+ $query->query_vars['meta_key'] = 'sp_team';
+ }
+ }
}
}
-}
endif;
diff --git a/includes/admin/post-types/class-sp-admin-cpt-metric.php b/includes/admin/post-types/class-sp-admin-cpt-metric.php
index c6b8e93f..12397466 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-metric.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-metric.php
@@ -2,68 +2,72 @@
/**
* Admin functions for the columns post type
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Admin_CPT' ) )
- include( 'class-sp-admin-cpt.php' );
+if ( ! class_exists( 'SP_Admin_CPT' ) ) {
+ require 'class-sp-admin-cpt.php';
+}
if ( ! class_exists( 'SP_Admin_CPT_Metric' ) ) :
-/**
- * SP_Admin_CPT_Metric Class
- */
-class SP_Admin_CPT_Metric extends SP_Admin_CPT {
-
/**
- * Constructor
+ * SP_Admin_CPT_Metric Class
*/
- public function __construct() {
- $this->type = 'sp_metric';
+ class SP_Admin_CPT_Metric extends SP_Admin_CPT {
- // Admin Columns
- add_filter( 'manage_edit-sp_metric_columns', array( $this, 'edit_columns' ) );
- add_action( 'manage_sp_metric_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
-
- // Call SP_Admin_CPT constructor
- parent::__construct();
- }
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->type = 'sp_metric';
- /**
- * Change the columns shown in admin.
- */
- public function edit_columns( $existing_columns ) {
- $columns = array(
- 'cb' => ' ',
- 'title' => __( 'Label', 'sportspress' ),
- 'sp_key' => __( 'Variable', 'sportspress' ),
- 'sp_description' => __( 'Description', 'sportspress' ),
- );
- return apply_filters( 'sportspress_metric_admin_columns', $columns );
- }
+ // Admin Columns
+ add_filter( 'manage_edit-sp_metric_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_metric_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
- /**
- * Define our custom columns shown in admin.
- * @param string $column
- */
- public function custom_columns( $column, $post_id ) {
- switch ( $column ):
- case 'sp_key':
- global $post;
- echo esc_html( $post->post_name );
- break;
- case 'sp_description':
- global $post;
- echo '' . wp_kses_post( $post->post_excerpt ) . ' ';
- break;
- endswitch;
+ // Call SP_Admin_CPT constructor
+ parent::__construct();
+ }
+
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ $columns = array(
+ 'cb' => ' ',
+ 'title' => __( 'Label', 'sportspress' ),
+ 'sp_key' => __( 'Variable', 'sportspress' ),
+ 'sp_description' => __( 'Description', 'sportspress' ),
+ );
+ return apply_filters( 'sportspress_metric_admin_columns', $columns );
+ }
+
+ /**
+ * Define our custom columns shown in admin.
+ *
+ * @param string $column
+ */
+ public function custom_columns( $column, $post_id ) {
+ switch ( $column ) :
+ case 'sp_key':
+ global $post;
+ echo esc_html( $post->post_name );
+ break;
+ case 'sp_description':
+ global $post;
+ echo '' . wp_kses_post( $post->post_excerpt ) . ' ';
+ break;
+ endswitch;
+ }
}
-}
endif;
diff --git a/includes/admin/post-types/class-sp-admin-cpt-official.php b/includes/admin/post-types/class-sp-admin-cpt-official.php
index d689885f..7e0ca0f9 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-official.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-official.php
@@ -2,51 +2,56 @@
/**
* Admin functions for the officials post type
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
- * @version 2.5.1
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
+ * @version 2.5.1
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Admin_CPT' ) )
- include( 'class-sp-admin-cpt.php' );
+if ( ! class_exists( 'SP_Admin_CPT' ) ) {
+ require 'class-sp-admin-cpt.php';
+}
if ( ! class_exists( 'SP_Admin_CPT_Official' ) ) :
-/**
- * SP_Admin_CPT_Official Class
- */
-class SP_Admin_CPT_Official extends SP_Admin_CPT {
-
/**
- * Constructor
+ * SP_Admin_CPT_Official Class
*/
- public function __construct() {
- $this->type = 'sp_official';
+ class SP_Admin_CPT_Official extends SP_Admin_CPT {
- // Post title fields
- add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->type = 'sp_official';
- // Call SP_Admin_CPT constructor
- parent::__construct();
+ // Post title fields
+ add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
+
+ // Call SP_Admin_CPT constructor
+ parent::__construct();
+ }
+
+ /**
+ * Change title boxes in admin.
+ *
+ * @param string $text
+ * @param object $post
+ * @return string
+ */
+ public function enter_title_here( $text, $post ) {
+ if ( $post->post_type == 'sp_official' ) {
+ return __( 'Name', 'sportspress' );
+ }
+
+ return $text;
+ }
}
- /**
- * Change title boxes in admin.
- * @param string $text
- * @param object $post
- * @return string
- */
- public function enter_title_here( $text, $post ) {
- if ( $post->post_type == 'sp_official' )
- return __( 'Name', 'sportspress' );
-
- return $text;
- }
-}
-
endif;
return new SP_Admin_CPT_Official();
diff --git a/includes/admin/post-types/class-sp-admin-cpt-outcome.php b/includes/admin/post-types/class-sp-admin-cpt-outcome.php
index 188933a4..0b7e881d 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-outcome.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-outcome.php
@@ -2,73 +2,77 @@
/**
* Admin functions for the outcomes post type
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Admin_CPT' ) )
- include( 'class-sp-admin-cpt.php' );
+if ( ! class_exists( 'SP_Admin_CPT' ) ) {
+ require 'class-sp-admin-cpt.php';
+}
if ( ! class_exists( 'SP_Admin_CPT_Outcome' ) ) :
-/**
- * SP_Admin_CPT_Outcome Class
- */
-class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
-
/**
- * Constructor
+ * SP_Admin_CPT_Outcome Class
*/
- public function __construct() {
- $this->type = 'sp_outcome';
+ class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
- // Admin Columns
- add_filter( 'manage_edit-sp_outcome_columns', array( $this, 'edit_columns' ) );
- add_action( 'manage_sp_outcome_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
-
- // Call SP_Admin_CPT constructor
- parent::__construct();
- }
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->type = 'sp_outcome';
- /**
- * Change the columns shown in admin.
- */
- public function edit_columns( $existing_columns ) {
- $columns = array(
- 'cb' => ' ',
- 'title' => __( 'Label', 'sportspress' ),
- 'sp_key' => __( 'Variable', 'sportspress' ),
- 'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
- 'sp_description' => __( 'Description', 'sportspress' ),
- );
- return apply_filters( 'sportspress_outcome_admin_columns', $columns );
- }
+ // Admin Columns
+ add_filter( 'manage_edit-sp_outcome_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_outcome_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
- /**
- * Define our custom columns shown in admin.
- * @param string $column
- */
- public function custom_columns( $column, $post_id ) {
- switch ( $column ):
- case 'sp_key':
- global $post;
- echo esc_html( $post->post_name );
- break;
- case 'sp_abbreviation':
- global $post;
- echo esc_html( sp_get_post_abbreviation( $post->ID ) );
- break;
- case 'sp_description':
- global $post;
- echo '' . wp_kses_post( $post->post_excerpt ) . ' ';
- break;
- endswitch;
+ // Call SP_Admin_CPT constructor
+ parent::__construct();
+ }
+
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ $columns = array(
+ 'cb' => ' ',
+ 'title' => __( 'Label', 'sportspress' ),
+ 'sp_key' => __( 'Variable', 'sportspress' ),
+ 'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
+ 'sp_description' => __( 'Description', 'sportspress' ),
+ );
+ return apply_filters( 'sportspress_outcome_admin_columns', $columns );
+ }
+
+ /**
+ * Define our custom columns shown in admin.
+ *
+ * @param string $column
+ */
+ public function custom_columns( $column, $post_id ) {
+ switch ( $column ) :
+ case 'sp_key':
+ global $post;
+ echo esc_html( $post->post_name );
+ break;
+ case 'sp_abbreviation':
+ global $post;
+ echo esc_html( sp_get_post_abbreviation( $post->ID ) );
+ break;
+ case 'sp_description':
+ global $post;
+ echo '' . wp_kses_post( $post->post_excerpt ) . ' ';
+ break;
+ endswitch;
+ }
}
-}
endif;
diff --git a/includes/admin/post-types/class-sp-admin-cpt-performance.php b/includes/admin/post-types/class-sp-admin-cpt-performance.php
index eaa7d6c6..4f66d031 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-performance.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-performance.php
@@ -2,82 +2,86 @@
/**
* Admin functions for the performance post type
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Admin_CPT' ) )
- include( 'class-sp-admin-cpt.php' );
+if ( ! class_exists( 'SP_Admin_CPT' ) ) {
+ require 'class-sp-admin-cpt.php';
+}
if ( ! class_exists( 'SP_Admin_CPT_Performance' ) ) :
-/**
- * SP_Admin_CPT_Performance Class
- */
-class SP_Admin_CPT_Performance extends SP_Admin_CPT {
-
/**
- * Constructor
+ * SP_Admin_CPT_Performance Class
*/
- public function __construct() {
- $this->type = 'sp_performance';
+ class SP_Admin_CPT_Performance extends SP_Admin_CPT {
- // Admin Columns
- add_filter( 'manage_edit-sp_performance_columns', array( $this, 'edit_columns' ) );
- add_action( 'manage_sp_performance_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
-
- // Call SP_Admin_CPT constructor
- parent::__construct();
- }
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->type = 'sp_performance';
- /**
- * Change the columns shown in admin.
- */
- public function edit_columns( $existing_columns ) {
- $columns = array(
- 'cb' => ' ',
- 'sp_icon' => __( 'Icon', 'sportspress' ),
- 'title' => __( 'Label', 'sportspress' ),
- 'sp_key' => __( 'Variable', 'sportspress' ),
- 'sp_section' => __( 'Category', 'sportspress' ),
- 'sp_config_format' => __( 'Format', 'sportspress' ),
- 'sp_description' => __( 'Description', 'sportspress' ),
- );
- return apply_filters( 'sportspress_performance_admin_columns', $columns );
- }
+ // Admin Columns
+ add_filter( 'manage_edit-sp_performance_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_performance_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
- /**
- * Define our custom columns shown in admin.
- * @param string $column
- */
- public function custom_columns( $column, $post_id ) {
- switch ( $column ):
- case 'sp_icon':
- echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
- break;
- case 'sp_key':
- global $post;
- echo esc_html( $post->post_name );
- break;
- case 'sp_section':
- global $post;
- echo esc_html( sp_get_post_section( $post->ID ) );
- break;
- case 'sp_config_format':
- global $post;
- echo esc_html( sp_get_post_format( $post->ID ) );
- break;
- case 'sp_description':
- global $post;
- echo '' . wp_kses_post( $post->post_excerpt ) . ' ';
- break;
- endswitch;
+ // Call SP_Admin_CPT constructor
+ parent::__construct();
+ }
+
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ $columns = array(
+ 'cb' => ' ',
+ 'sp_icon' => __( 'Icon', 'sportspress' ),
+ 'title' => __( 'Label', 'sportspress' ),
+ 'sp_key' => __( 'Variable', 'sportspress' ),
+ 'sp_section' => __( 'Category', 'sportspress' ),
+ 'sp_config_format' => __( 'Format', 'sportspress' ),
+ 'sp_description' => __( 'Description', 'sportspress' ),
+ );
+ return apply_filters( 'sportspress_performance_admin_columns', $columns );
+ }
+
+ /**
+ * Define our custom columns shown in admin.
+ *
+ * @param string $column
+ */
+ public function custom_columns( $column, $post_id ) {
+ switch ( $column ) :
+ case 'sp_icon':
+ echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
+ break;
+ case 'sp_key':
+ global $post;
+ echo esc_html( $post->post_name );
+ break;
+ case 'sp_section':
+ global $post;
+ echo esc_html( sp_get_post_section( $post->ID ) );
+ break;
+ case 'sp_config_format':
+ global $post;
+ echo esc_html( sp_get_post_format( $post->ID ) );
+ break;
+ case 'sp_description':
+ global $post;
+ echo '' . wp_kses_post( $post->post_excerpt ) . ' ';
+ break;
+ endswitch;
+ }
}
-}
endif;
diff --git a/includes/admin/post-types/class-sp-admin-cpt-player.php b/includes/admin/post-types/class-sp-admin-cpt-player.php
index b77f4b71..acaede58 100755
--- a/includes/admin/post-types/class-sp-admin-cpt-player.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-player.php
@@ -2,226 +2,245 @@
/**
* Admin functions for the players post type
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Admin_CPT' ) )
- include( 'class-sp-admin-cpt.php' );
+if ( ! class_exists( 'SP_Admin_CPT' ) ) {
+ require 'class-sp-admin-cpt.php';
+}
if ( ! class_exists( 'SP_Admin_CPT_Player' ) ) :
-/**
- * SP_Admin_CPT_Player Class
- */
-class SP_Admin_CPT_Player extends SP_Admin_CPT {
-
/**
- * Constructor
+ * SP_Admin_CPT_Player Class
*/
- public function __construct() {
- $this->type = 'sp_player';
+ class SP_Admin_CPT_Player extends SP_Admin_CPT {
- // Post title fields
- add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->type = 'sp_player';
- // Admin columns
- add_filter( 'manage_edit-sp_player_columns', array( $this, 'edit_columns' ) );
- add_action( 'manage_sp_player_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
+ // Post title fields
+ add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
- // Filtering
- add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
- add_filter( 'parse_query', array( $this, 'filters_query' ) );
+ // Admin columns
+ add_filter( 'manage_edit-sp_player_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_player_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
- // Quick edit
- add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_number' ), 10, 2 );
- add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_teams' ), 10, 2 );
- add_action( 'save_post', array( $this, 'quick_save' ) );
-
- // Bulk edit
- add_action( 'bulk_edit_custom_box', array( $this, 'bulk_edit_teams' ), 10, 2 );
- add_action( 'wp_ajax_save_bulk_edit_sp_player', array( $this, 'bulk_save' ) );
-
- // Call SP_Admin_CPT constructor
- parent::__construct();
- }
+ // Filtering
+ add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
+ add_filter( 'parse_query', array( $this, 'filters_query' ) );
- /**
- * Change title boxes in admin.
- * @param string $text
- * @param object $post
- * @return string
- */
- public function enter_title_here( $text, $post ) {
- if ( $post->post_type == 'sp_player' )
- return __( 'Name', 'sportspress' );
+ // Quick edit
+ add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_number' ), 10, 2 );
+ add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_teams' ), 10, 2 );
+ add_action( 'save_post', array( $this, 'quick_save' ) );
- return $text;
- }
+ // Bulk edit
+ add_action( 'bulk_edit_custom_box', array( $this, 'bulk_edit_teams' ), 10, 2 );
+ add_action( 'wp_ajax_save_bulk_edit_sp_player', array( $this, 'bulk_save' ) );
- /**
- * Change the columns shown in admin.
- */
- public function edit_columns( $existing_columns ) {
- unset( $existing_columns['author'], $existing_columns['date'] );
- $columns = array_merge( array(
- 'cb' => ' ',
- 'sp_number' => ' ',
- 'title' => null,
- 'sp_position' => __( 'Positions', 'sportspress' ),
- 'sp_team' => __( 'Teams', 'sportspress' ),
- 'sp_league' => __( 'Leagues', 'sportspress' ),
- 'sp_season' => __( 'Seasons', 'sportspress' ),
- ), $existing_columns, array(
- 'title' => __( 'Name', 'sportspress' )
- ) );
- return apply_filters( 'sportspress_player_admin_columns', $columns );
- }
+ // Call SP_Admin_CPT constructor
+ parent::__construct();
+ }
- /**
- * Define our custom columns shown in admin.
- * @param string $column
- */
- public function custom_columns( $column, $post_id ) {
- switch ( $column ):
- case 'sp_number':
- echo esc_html( get_post_meta ( $post_id, 'sp_number', true ) );
- break;
- case 'sp_position':
- echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
- break;
- case 'sp_team':
- $current_teams = get_post_meta( $post_id, 'sp_current_team', false );
- $past_teams = get_post_meta( $post_id, 'sp_past_team', false );
- $current_teams = array_filter( $current_teams );
- $past_teams = array_filter( $past_teams );
- echo ' ';
- $teams = (array)get_post_meta( $post_id, 'sp_team', false );
- $teams = array_filter( $teams );
- $teams = array_unique( $teams );
- if ( empty( $teams ) ):
- echo '—';
- else:
- foreach( $teams as $team_id ):
- if ( ! $team_id ) continue;
- $team = get_post( $team_id );
- if ( $team ):
- echo esc_html( $team->post_title );
- if ( in_array( $team_id, $current_teams ) ):
- echo ' ';
- endif;
- echo ' ';
- endif;
- endforeach;
- endif;
- break;
- case 'sp_league':
- echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
- break;
- case 'sp_season':
- echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
- break;
- case 'sp_venue':
- echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—';
- break;
- endswitch;
- }
-
- /**
- * Show a category filter box
- */
- public function filters() {
- global $typenow, $wp_query;
-
- if ( $typenow != 'sp_player' )
- return;
-
- if ( taxonomy_exists( 'sp_position' ) ):
- $selected = isset( $_REQUEST['sp_position'] ) ? sanitize_key( $_REQUEST['sp_position'] ) : null;
- $args = array(
- 'show_option_all' => __( 'Show all positions', 'sportspress' ),
- 'taxonomy' => 'sp_position',
- 'name' => 'sp_position',
- 'selected' => $selected
- );
- sp_dropdown_taxonomies( $args );
- endif;
-
- $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
- $args = array(
- 'post_type' => 'sp_team',
- 'name' => 'team',
- 'show_option_none' => __( 'Show all teams', 'sportspress' ),
- 'selected' => $selected,
- 'values' => 'ID',
- );
- wp_dropdown_pages( $args );
-
- if ( taxonomy_exists( 'sp_league' ) ):
- $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
- $args = array(
- 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
- 'taxonomy' => 'sp_league',
- 'name' => 'sp_league',
- 'selected' => $selected
- );
- sp_dropdown_taxonomies( $args );
- endif;
-
- if ( taxonomy_exists( 'sp_season' ) ):
- $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
- $args = array(
- 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
- 'taxonomy' => 'sp_season',
- 'name' => 'sp_season',
- 'selected' => $selected
- );
- sp_dropdown_taxonomies( $args );
- endif;
- }
-
- /**
- * Filter in admin based on options
- *
- * @param mixed $query
- */
- public function filters_query( $query ) {
-
- if ( empty ( $query->query_vars['post_type'] ) || $query->query_vars['post_type'] !== 'sp_player' ) return $query;
-
- global $typenow, $wp_query;
-
- if ( $typenow == 'sp_player' ) {
-
- if ( ! empty( $_GET['team'] ) ) {
- $query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
- $query->query_vars['meta_key'] = 'sp_team';
+ /**
+ * Change title boxes in admin.
+ *
+ * @param string $text
+ * @param object $post
+ * @return string
+ */
+ public function enter_title_here( $text, $post ) {
+ if ( $post->post_type == 'sp_player' ) {
+ return __( 'Name', 'sportspress' );
}
+
+ return $text;
}
- return $query;
- }
-
- /**
- * Quick edit squad number
- *
- * @param string $column_name
- * @param string $post_type
- */
- public function quick_edit_number( $column_name, $post_type ) {
- if ( $this->type !== $post_type ) return;
- if ( 'sp_number' !== $column_name ) return;
-
- static $print_nonce = true;
- if ( $print_nonce ) {
- $print_nonce = false;
- wp_nonce_field( plugin_basename( __FILE__ ), 'sp_player_edit_nonce' );
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ unset( $existing_columns['author'], $existing_columns['date'] );
+ $columns = array_merge(
+ array(
+ 'cb' => ' ',
+ 'sp_number' => ' ',
+ 'title' => null,
+ 'sp_position' => __( 'Positions', 'sportspress' ),
+ 'sp_team' => __( 'Teams', 'sportspress' ),
+ 'sp_league' => __( 'Leagues', 'sportspress' ),
+ 'sp_season' => __( 'Seasons', 'sportspress' ),
+ ),
+ $existing_columns,
+ array(
+ 'title' => __( 'Name', 'sportspress' ),
+ )
+ );
+ return apply_filters( 'sportspress_player_admin_columns', $columns );
}
- ?>
+
+ /**
+ * Define our custom columns shown in admin.
+ *
+ * @param string $column
+ */
+ public function custom_columns( $column, $post_id ) {
+ switch ( $column ) :
+ case 'sp_number':
+ echo esc_html( get_post_meta( $post_id, 'sp_number', true ) );
+ break;
+ case 'sp_position':
+ echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
+ break;
+ case 'sp_team':
+ $current_teams = get_post_meta( $post_id, 'sp_current_team', false );
+ $past_teams = get_post_meta( $post_id, 'sp_past_team', false );
+ $current_teams = array_filter( $current_teams );
+ $past_teams = array_filter( $past_teams );
+ echo ' ';
+ $teams = (array) get_post_meta( $post_id, 'sp_team', false );
+ $teams = array_filter( $teams );
+ $teams = array_unique( $teams );
+ if ( empty( $teams ) ) :
+ echo '—';
+ else :
+ foreach ( $teams as $team_id ) :
+ if ( ! $team_id ) {
+ continue;
+ }
+ $team = get_post( $team_id );
+ if ( $team ) :
+ echo esc_html( $team->post_title );
+ if ( in_array( $team_id, $current_teams ) ) :
+ echo ' ';
+ endif;
+ echo ' ';
+ endif;
+ endforeach;
+ endif;
+ break;
+ case 'sp_league':
+ echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
+ break;
+ case 'sp_season':
+ echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
+ break;
+ case 'sp_venue':
+ echo get_the_terms( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—';
+ break;
+ endswitch;
+ }
+
+ /**
+ * Show a category filter box
+ */
+ public function filters() {
+ global $typenow, $wp_query;
+
+ if ( $typenow != 'sp_player' ) {
+ return;
+ }
+
+ if ( taxonomy_exists( 'sp_position' ) ) :
+ $selected = isset( $_REQUEST['sp_position'] ) ? sanitize_key( $_REQUEST['sp_position'] ) : null;
+ $args = array(
+ 'show_option_all' => __( 'Show all positions', 'sportspress' ),
+ 'taxonomy' => 'sp_position',
+ 'name' => 'sp_position',
+ 'selected' => $selected,
+ );
+ sp_dropdown_taxonomies( $args );
+ endif;
+
+ $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
+ $args = array(
+ 'post_type' => 'sp_team',
+ 'name' => 'team',
+ 'show_option_none' => __( 'Show all teams', 'sportspress' ),
+ 'selected' => $selected,
+ 'values' => 'ID',
+ );
+ wp_dropdown_pages( $args );
+
+ if ( taxonomy_exists( 'sp_league' ) ) :
+ $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
+ $args = array(
+ 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
+ 'taxonomy' => 'sp_league',
+ 'name' => 'sp_league',
+ 'selected' => $selected,
+ );
+ sp_dropdown_taxonomies( $args );
+ endif;
+
+ if ( taxonomy_exists( 'sp_season' ) ) :
+ $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
+ $args = array(
+ 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
+ 'taxonomy' => 'sp_season',
+ 'name' => 'sp_season',
+ 'selected' => $selected,
+ );
+ sp_dropdown_taxonomies( $args );
+ endif;
+ }
+
+ /**
+ * Filter in admin based on options
+ *
+ * @param mixed $query
+ */
+ public function filters_query( $query ) {
+
+ if ( empty( $query->query_vars['post_type'] ) || $query->query_vars['post_type'] !== 'sp_player' ) {
+ return $query;
+ }
+
+ global $typenow, $wp_query;
+
+ if ( $typenow == 'sp_player' ) {
+
+ if ( ! empty( $_GET['team'] ) ) {
+ $query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
+ $query->query_vars['meta_key'] = 'sp_team';
+ }
+ }
+
+ return $query;
+ }
+
+ /**
+ * Quick edit squad number
+ *
+ * @param string $column_name
+ * @param string $post_type
+ */
+ public function quick_edit_number( $column_name, $post_type ) {
+ if ( $this->type !== $post_type ) {
+ return;
+ }
+ if ( 'sp_number' !== $column_name ) {
+ return;
+ }
+
+ static $print_nonce = true;
+ if ( $print_nonce ) {
+ $print_nonce = false;
+ wp_nonce_field( plugin_basename( __FILE__ ), 'sp_player_edit_nonce' );
+ }
+ ?>
@@ -230,27 +249,35 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
- type !== $post_type ) return;
- if ( 'sp_team' !== $column_name ) return;
+ /**
+ * Quick edit teams
+ *
+ * @param string $column_name
+ * @param string $post_type
+ */
+ public function quick_edit_teams( $column_name, $post_type ) {
+ if ( $this->type !== $post_type ) {
+ return;
+ }
+ if ( 'sp_team' !== $column_name ) {
+ return;
+ }
- $teams = get_posts( array(
- 'post_type' => 'sp_team',
- 'numberposts' => -1,
- 'post_status' => 'publish',
- ) );
-
- if ( ! $teams ) return;
- ?>
+ $teams = get_posts(
+ array(
+ 'post_type' => 'sp_team',
+ 'numberposts' => -1,
+ 'post_status' => 'publish',
+ )
+ );
+
+ if ( ! $teams ) {
+ return;
+ }
+ ?>
@@ -269,57 +296,75 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
- type}_edit_nonce" => '' );
- if ( ! wp_verify_nonce( $_POST["{$this->type}_edit_nonce"], plugin_basename( __FILE__ ) ) ) return $post_id;;
-
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $post_id;
- if ( isset( $post->post_type ) && $post->post_type == 'revision' ) return $post_id;
-
- if ( isset( $_POST[ 'sp_number' ] ) ) {
- update_post_meta( $post_id, 'sp_number', $_POST[ 'sp_number' ] );
+ type !== $post_type ) return;
- if ( 'sp_team' !== $column_name ) return;
+ $_POST += array( "{$this->type}_edit_nonce" => '' );
+ if ( ! wp_verify_nonce( $_POST[ "{$this->type}_edit_nonce" ], plugin_basename( __FILE__ ) ) ) {
+ return $post_id;
+ }
- static $print_nonce = true;
- if ( $print_nonce ) {
- $print_nonce = false;
- wp_nonce_field( plugin_basename( __FILE__ ), 'sp_player_edit_nonce' );
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
+ return $post_id;
+ }
+ if ( isset( $post->post_type ) && $post->post_type == 'revision' ) {
+ return $post_id;
+ }
+
+ if ( isset( $_POST['sp_number'] ) ) {
+ update_post_meta( $post_id, 'sp_number', $_POST['sp_number'] );
+ }
+
+ sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array() ) );
+ sp_update_post_meta_recursive( $post_id, 'sp_past_team', sp_array_value( $_POST, 'sp_past_team', array() ) );
+ sp_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sp_array_value( $_POST, 'sp_current_team', array() ) ), sp_array_value( $_POST, 'sp_past_team', array() ) ) );
}
- $teams = get_posts( array(
- 'post_type' => 'sp_team',
- 'numberposts' => -1,
- 'post_status' => 'publish',
- ) );
-
- if ( ! $teams ) return;
- ?>
+ /**
+ * Bulk edit teams
+ *
+ * @param string $column_name
+ * @param string $post_type
+ */
+ public function bulk_edit_teams( $column_name, $post_type ) {
+ if ( $this->type !== $post_type ) {
+ return;
+ }
+ if ( 'sp_team' !== $column_name ) {
+ return;
+ }
+
+ static $print_nonce = true;
+ if ( $print_nonce ) {
+ $print_nonce = false;
+ wp_nonce_field( plugin_basename( __FILE__ ), 'sp_player_edit_nonce' );
+ }
+
+ $teams = get_posts(
+ array(
+ 'post_type' => 'sp_team',
+ 'numberposts' => -1,
+ 'post_status' => 'publish',
+ )
+ );
+
+ if ( ! $teams ) {
+ return;
+ }
+ ?>
@@ -338,35 +383,39 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
- '' );
- if ( ! wp_verify_nonce( $_POST["nonce"], plugin_basename( __FILE__ ) ) ) return;
-
- $post_ids = ( ! empty( $_POST[ 'post_ids' ] ) ) ? $_POST[ 'post_ids' ] : array();
-
- $current_teams = sp_array_value( $_POST, 'current_teams', array() );
- $past_teams = sp_array_value( $_POST, 'past_teams', array() );
- $teams = array_merge( $current_teams, $past_teams );
-
- if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
- foreach ( $post_ids as $post_id ) {
- if ( ! current_user_can( 'edit_post', $post_id ) ) continue;
-
- sp_add_post_meta_recursive( $post_id, 'sp_current_team', $current_teams );
- sp_add_post_meta_recursive( $post_id, 'sp_past_team', $past_teams );
- sp_add_post_meta_recursive( $post_id, 'sp_team', $teams );
- }
+ '' );
+ if ( ! wp_verify_nonce( $_POST['nonce'], plugin_basename( __FILE__ ) ) ) {
+ return;
+ }
+
+ $post_ids = ( ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array();
+
+ $current_teams = sp_array_value( $_POST, 'current_teams', array() );
+ $past_teams = sp_array_value( $_POST, 'past_teams', array() );
+ $teams = array_merge( $current_teams, $past_teams );
+
+ if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
+ foreach ( $post_ids as $post_id ) {
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
+ continue;
+ }
+
+ sp_add_post_meta_recursive( $post_id, 'sp_current_team', $current_teams );
+ sp_add_post_meta_recursive( $post_id, 'sp_past_team', $past_teams );
+ sp_add_post_meta_recursive( $post_id, 'sp_team', $teams );
+ }
+ }
+
+ die();
+ }
}
-}
endif;
diff --git a/includes/admin/post-types/class-sp-admin-cpt-result.php b/includes/admin/post-types/class-sp-admin-cpt-result.php
index 4cad15a4..2f6dc560 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-result.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-result.php
@@ -2,68 +2,72 @@
/**
* Admin functions for the results post type
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Admin_CPT' ) )
- include( 'class-sp-admin-cpt.php' );
+if ( ! class_exists( 'SP_Admin_CPT' ) ) {
+ require 'class-sp-admin-cpt.php';
+}
if ( ! class_exists( 'SP_Admin_CPT_Result' ) ) :
-/**
- * SP_Admin_CPT_Result Class
- */
-class SP_Admin_CPT_Result extends SP_Admin_CPT {
-
/**
- * Constructor
+ * SP_Admin_CPT_Result Class
*/
- public function __construct() {
- $this->type = 'sp_result';
+ class SP_Admin_CPT_Result extends SP_Admin_CPT {
- // Admin Columns
- add_filter( 'manage_edit-sp_result_columns', array( $this, 'edit_columns' ) );
- add_action( 'manage_sp_result_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
-
- // Call SP_Admin_CPT constructor
- parent::__construct();
- }
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->type = 'sp_result';
- /**
- * Change the columns shown in admin.
- */
- public function edit_columns( $existing_columns ) {
- $columns = array(
- 'cb' => ' ',
- 'title' => __( 'Label', 'sportspress' ),
- 'sp_key' => __( 'Variable', 'sportspress' ),
- 'sp_description' => __( 'Description', 'sportspress' ),
- );
- return apply_filters( 'sportspress_result_admin_columns', $columns );
- }
+ // Admin Columns
+ add_filter( 'manage_edit-sp_result_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_result_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
- /**
- * Define our custom columns shown in admin.
- * @param string $column
- */
- public function custom_columns( $column, $post_id ) {
- switch ( $column ):
- case 'sp_key':
- global $post;
- echo esc_html( $post->post_name ) . 'for, ' . esc_html( $post->post_name ) . 'against';
- break;
- case 'sp_description':
- global $post;
- echo '' . wp_kses_post( $post->post_excerpt ) . ' ';
- break;
- endswitch;
+ // Call SP_Admin_CPT constructor
+ parent::__construct();
+ }
+
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ $columns = array(
+ 'cb' => ' ',
+ 'title' => __( 'Label', 'sportspress' ),
+ 'sp_key' => __( 'Variable', 'sportspress' ),
+ 'sp_description' => __( 'Description', 'sportspress' ),
+ );
+ return apply_filters( 'sportspress_result_admin_columns', $columns );
+ }
+
+ /**
+ * Define our custom columns shown in admin.
+ *
+ * @param string $column
+ */
+ public function custom_columns( $column, $post_id ) {
+ switch ( $column ) :
+ case 'sp_key':
+ global $post;
+ echo esc_html( $post->post_name ) . 'for, ' . esc_html( $post->post_name ) . 'against';
+ break;
+ case 'sp_description':
+ global $post;
+ echo '' . wp_kses_post( $post->post_excerpt ) . ' ';
+ break;
+ endswitch;
+ }
}
-}
endif;
diff --git a/includes/admin/post-types/class-sp-admin-cpt-spec.php b/includes/admin/post-types/class-sp-admin-cpt-spec.php
index 361db988..2ddaa9fc 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-spec.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-spec.php
@@ -2,68 +2,72 @@
/**
* Admin functions for the columns post type
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Admin_CPT' ) )
- include( 'class-sp-admin-cpt.php' );
+if ( ! class_exists( 'SP_Admin_CPT' ) ) {
+ require 'class-sp-admin-cpt.php';
+}
if ( ! class_exists( 'SP_Admin_CPT_Spec' ) ) :
-/**
- * SP_Admin_CPT_Spec Class
- */
-class SP_Admin_CPT_Spec extends SP_Admin_CPT {
-
/**
- * Constructor
+ * SP_Admin_CPT_Spec Class
*/
- public function __construct() {
- $this->type = 'sp_spec';
+ class SP_Admin_CPT_Spec extends SP_Admin_CPT {
- // Admin Columns
- add_filter( 'manage_edit-sp_spec_columns', array( $this, 'edit_columns' ) );
- add_action( 'manage_sp_spec_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
-
- // Call SP_Admin_CPT constructor
- parent::__construct();
- }
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->type = 'sp_spec';
- /**
- * Change the columns shown in admin.
- */
- public function edit_columns( $existing_columns ) {
- $columns = array(
- 'cb' => ' ',
- 'title' => __( 'Label', 'sportspress' ),
- 'sp_key' => __( 'Variable', 'sportspress' ),
- 'sp_description' => __( 'Description', 'sportspress' ),
- );
- return apply_filters( 'sportspress_spec_admin_columns', $columns );
- }
+ // Admin Columns
+ add_filter( 'manage_edit-sp_spec_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_spec_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
- /**
- * Define our custom columns shown in admin.
- * @param string $column
- */
- public function custom_columns( $column, $post_id ) {
- switch ( $column ):
- case 'sp_key':
- global $post;
- echo esc_html( $post->post_name );
- break;
- case 'sp_description':
- global $post;
- echo '' . wp_kses_post( $post->post_excerpt ) . ' ';
- break;
- endswitch;
+ // Call SP_Admin_CPT constructor
+ parent::__construct();
+ }
+
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ $columns = array(
+ 'cb' => ' ',
+ 'title' => __( 'Label', 'sportspress' ),
+ 'sp_key' => __( 'Variable', 'sportspress' ),
+ 'sp_description' => __( 'Description', 'sportspress' ),
+ );
+ return apply_filters( 'sportspress_spec_admin_columns', $columns );
+ }
+
+ /**
+ * Define our custom columns shown in admin.
+ *
+ * @param string $column
+ */
+ public function custom_columns( $column, $post_id ) {
+ switch ( $column ) :
+ case 'sp_key':
+ global $post;
+ echo esc_html( $post->post_name );
+ break;
+ case 'sp_description':
+ global $post;
+ echo '' . wp_kses_post( $post->post_excerpt ) . ' ';
+ break;
+ endswitch;
+ }
}
-}
endif;
diff --git a/includes/admin/post-types/class-sp-admin-cpt-staff.php b/includes/admin/post-types/class-sp-admin-cpt-staff.php
index 0a9ae880..7c69e239 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-staff.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-staff.php
@@ -2,169 +2,182 @@
/**
* Admin functions for the staff post type
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Admin_CPT' ) )
- include( 'class-sp-admin-cpt.php' );
+if ( ! class_exists( 'SP_Admin_CPT' ) ) {
+ require 'class-sp-admin-cpt.php';
+}
if ( ! class_exists( 'SP_Admin_CPT_Staff' ) ) :
-/**
- * SP_Admin_CPT_Staff Class
- */
-class SP_Admin_CPT_Staff extends SP_Admin_CPT {
-
/**
- * Constructor
+ * SP_Admin_CPT_Staff Class
*/
- public function __construct() {
- $this->type = 'sp_staff';
+ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
- // Post title fields
- add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->type = 'sp_staff';
- // Admin Columns
- add_filter( 'manage_edit-sp_staff_columns', array( $this, 'edit_columns' ) );
- add_action( 'manage_sp_staff_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
+ // Post title fields
+ add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
- // Filtering
- add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
- add_filter( 'parse_query', array( $this, 'filters_query' ) );
-
- // Call SP_Admin_CPT constructor
- parent::__construct();
- }
+ // Admin Columns
+ add_filter( 'manage_edit-sp_staff_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_staff_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
- /**
- * Change title boxes in admin.
- * @param string $text
- * @param object $post
- * @return string
- */
- public function enter_title_here( $text, $post ) {
- if ( $post->post_type == 'sp_staff' )
- return __( 'Name', 'sportspress' );
+ // Filtering
+ add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
+ add_filter( 'parse_query', array( $this, 'filters_query' ) );
- return $text;
- }
+ // Call SP_Admin_CPT constructor
+ parent::__construct();
+ }
- /**
- * Change the columns shown in admin.
- */
- public function edit_columns( $existing_columns ) {
- unset( $existing_columns['author'], $existing_columns['date'] );
- $columns = array_merge( array(
- 'cb' => ' ',
- 'title' => null,
- 'sp_role' => __( 'Job', 'sportspress' ),
- 'sp_team' => __( 'Teams', 'sportspress' ),
- 'sp_league' => __( 'Leagues', 'sportspress' ),
- 'sp_season' => __( 'Seasons', 'sportspress' ),
- ), $existing_columns, array(
- 'title' => __( 'Name', 'sportspress' )
- ) );
- return apply_filters( 'sportspress_staff_admin_columns', $columns );
- }
+ /**
+ * Change title boxes in admin.
+ *
+ * @param string $text
+ * @param object $post
+ * @return string
+ */
+ public function enter_title_here( $text, $post ) {
+ if ( $post->post_type == 'sp_staff' ) {
+ return __( 'Name', 'sportspress' );
+ }
- /**
- * Define our custom columns shown in admin.
- * @param string $column
- */
- public function custom_columns( $column, $post_id ) {
- switch ( $column ):
- case 'sp_role':
- echo get_the_terms( $post_id, 'sp_role' ) ? the_terms( $post_id, 'sp_role' ) : '—';
- break;
- case 'sp_team':
- $teams = (array)get_post_meta( $post_id, 'sp_team', false );
- $teams = array_filter( $teams );
- if ( empty( $teams ) ):
- echo '—';
- else:
- $current_teams = get_post_meta( $post_id, 'sp_current_team', false );
- foreach( $teams as $team_id ):
- if ( ! $team_id ) continue;
- $team = get_post( $team_id );
- if ( $team ):
- echo esc_html( $team->post_title );
- if ( in_array( $team_id, $current_teams ) ):
- echo ' ';
+ return $text;
+ }
+
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ unset( $existing_columns['author'], $existing_columns['date'] );
+ $columns = array_merge(
+ array(
+ 'cb' => ' ',
+ 'title' => null,
+ 'sp_role' => __( 'Job', 'sportspress' ),
+ 'sp_team' => __( 'Teams', 'sportspress' ),
+ 'sp_league' => __( 'Leagues', 'sportspress' ),
+ 'sp_season' => __( 'Seasons', 'sportspress' ),
+ ),
+ $existing_columns,
+ array(
+ 'title' => __( 'Name', 'sportspress' ),
+ )
+ );
+ return apply_filters( 'sportspress_staff_admin_columns', $columns );
+ }
+
+ /**
+ * Define our custom columns shown in admin.
+ *
+ * @param string $column
+ */
+ public function custom_columns( $column, $post_id ) {
+ switch ( $column ) :
+ case 'sp_role':
+ echo get_the_terms( $post_id, 'sp_role' ) ? the_terms( $post_id, 'sp_role' ) : '—';
+ break;
+ case 'sp_team':
+ $teams = (array) get_post_meta( $post_id, 'sp_team', false );
+ $teams = array_filter( $teams );
+ if ( empty( $teams ) ) :
+ echo '—';
+ else :
+ $current_teams = get_post_meta( $post_id, 'sp_current_team', false );
+ foreach ( $teams as $team_id ) :
+ if ( ! $team_id ) {
+ continue;
+ }
+ $team = get_post( $team_id );
+ if ( $team ) :
+ echo esc_html( $team->post_title );
+ if ( in_array( $team_id, $current_teams ) ) :
+ echo ' ';
+ endif;
+ echo ' ';
endif;
- echo ' ';
- endif;
- endforeach;
- endif;
- break;
- case 'sp_league':
- echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
- break;
- case 'sp_season':
- echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
- break;
- endswitch;
- }
+ endforeach;
+ endif;
+ break;
+ case 'sp_league':
+ echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
+ break;
+ case 'sp_season':
+ echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
+ break;
+ endswitch;
+ }
- /**
- * Show a category filter box
- */
- public function filters() {
- global $typenow, $wp_query;
+ /**
+ * Show a category filter box
+ */
+ public function filters() {
+ global $typenow, $wp_query;
- if ( $typenow != 'sp_staff' )
- return;
+ if ( $typenow != 'sp_staff' ) {
+ return;
+ }
- $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
- $args = array(
- 'post_type' => 'sp_team',
- 'name' => 'team',
- 'show_option_none' => __( 'Show all teams', 'sportspress' ),
- 'selected' => $selected,
- 'values' => 'ID',
- );
- wp_dropdown_pages( $args );
+ $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
+ $args = array(
+ 'post_type' => 'sp_team',
+ 'name' => 'team',
+ 'show_option_none' => __( 'Show all teams', 'sportspress' ),
+ 'selected' => $selected,
+ 'values' => 'ID',
+ );
+ wp_dropdown_pages( $args );
- $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
- $args = array(
- 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
- 'taxonomy' => 'sp_league',
- 'name' => 'sp_league',
- 'selected' => $selected
- );
- sp_dropdown_taxonomies( $args );
+ $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
+ $args = array(
+ 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
+ 'taxonomy' => 'sp_league',
+ 'name' => 'sp_league',
+ 'selected' => $selected,
+ );
+ sp_dropdown_taxonomies( $args );
- $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
- $args = array(
- 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
- 'taxonomy' => 'sp_season',
- 'name' => 'sp_season',
- 'selected' => $selected
- );
- sp_dropdown_taxonomies( $args );
- }
+ $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
+ $args = array(
+ 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
+ 'taxonomy' => 'sp_season',
+ 'name' => 'sp_season',
+ 'selected' => $selected,
+ );
+ sp_dropdown_taxonomies( $args );
+ }
- /**
- * Filter in admin based on options
- *
- * @param mixed $query
- */
- public function filters_query( $query ) {
- global $typenow, $wp_query;
+ /**
+ * Filter in admin based on options
+ *
+ * @param mixed $query
+ */
+ public function filters_query( $query ) {
+ global $typenow, $wp_query;
- if ( $typenow == 'sp_staff' ) {
+ if ( $typenow == 'sp_staff' ) {
- if ( ! empty( $_GET['team'] ) ) {
- $query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
- $query->query_vars['meta_key'] = 'sp_team';
- }
+ if ( ! empty( $_GET['team'] ) ) {
+ $query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
+ $query->query_vars['meta_key'] = 'sp_team';
+ }
+ }
}
}
-}
endif;
diff --git a/includes/admin/post-types/class-sp-admin-cpt-statistic.php b/includes/admin/post-types/class-sp-admin-cpt-statistic.php
index 70ff2e19..9e19f109 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-statistic.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-statistic.php
@@ -2,80 +2,84 @@
/**
* Admin functions for the statistics post type
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Admin_CPT' ) )
- include( 'class-sp-admin-cpt.php' );
+if ( ! class_exists( 'SP_Admin_CPT' ) ) {
+ require 'class-sp-admin-cpt.php';
+}
if ( ! class_exists( 'SP_Admin_CPT_Statistic' ) ) :
-/**
- * SP_Admin_CPT_Statistic Class
- */
-class SP_Admin_CPT_Statistic extends SP_Admin_CPT {
-
/**
- * Constructor
+ * SP_Admin_CPT_Statistic Class
*/
- public function __construct() {
- $this->type = 'sp_statistic';
+ class SP_Admin_CPT_Statistic extends SP_Admin_CPT {
- // Admin Columns
- add_filter( 'manage_edit-sp_statistic_columns', array( $this, 'edit_columns' ) );
- add_action( 'manage_sp_statistic_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
-
- // Call SP_Admin_CPT constructor
- parent::__construct();
- }
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->type = 'sp_statistic';
- /**
- * Change the columns shown in admin.
- */
- public function edit_columns( $existing_columns ) {
- $columns = array(
- 'cb' => ' ',
- 'sp_icon' => __( 'Icon', 'sportspress' ),
- 'title' => __( 'Label', 'sportspress' ),
- 'sp_key' => __( 'Key', 'sportspress' ),
- 'sp_equation' => __( 'Equation', 'sportspress' ),
- 'sp_precision' => __( 'Decimal Places', 'sportspress' ),
- 'sp_description' => __( 'Description', 'sportspress' ),
- );
- return apply_filters( 'sportspress_statistic_admin_columns', $columns );
- }
+ // Admin Columns
+ add_filter( 'manage_edit-sp_statistic_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_statistic_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
- /**
- * Define our custom columns shown in admin.
- * @param string $column
- */
- public function custom_columns( $column, $post_id ) {
- switch ( $column ):
- case 'sp_icon':
- echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
- break;
- case 'sp_key':
- global $post;
- echo esc_html( $post->post_name );
- break;
- case 'sp_equation':
- echo esc_html( sp_get_post_equation( $post_id ) );
- break;
- case 'sp_precision':
- echo esc_html( sp_get_post_precision( $post_id ) );
- break;
- case 'sp_description':
- global $post;
- echo '' . wp_kses_post( $post->post_excerpt ) . ' ';
- break;
- endswitch;
+ // Call SP_Admin_CPT constructor
+ parent::__construct();
+ }
+
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ $columns = array(
+ 'cb' => ' ',
+ 'sp_icon' => __( 'Icon', 'sportspress' ),
+ 'title' => __( 'Label', 'sportspress' ),
+ 'sp_key' => __( 'Key', 'sportspress' ),
+ 'sp_equation' => __( 'Equation', 'sportspress' ),
+ 'sp_precision' => __( 'Decimal Places', 'sportspress' ),
+ 'sp_description' => __( 'Description', 'sportspress' ),
+ );
+ return apply_filters( 'sportspress_statistic_admin_columns', $columns );
+ }
+
+ /**
+ * Define our custom columns shown in admin.
+ *
+ * @param string $column
+ */
+ public function custom_columns( $column, $post_id ) {
+ switch ( $column ) :
+ case 'sp_icon':
+ echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
+ break;
+ case 'sp_key':
+ global $post;
+ echo esc_html( $post->post_name );
+ break;
+ case 'sp_equation':
+ echo esc_html( sp_get_post_equation( $post_id ) );
+ break;
+ case 'sp_precision':
+ echo esc_html( sp_get_post_precision( $post_id ) );
+ break;
+ case 'sp_description':
+ global $post;
+ echo '' . wp_kses_post( $post->post_excerpt ) . ' ';
+ break;
+ endswitch;
+ }
}
-}
endif;
diff --git a/includes/admin/post-types/class-sp-admin-cpt-table.php b/includes/admin/post-types/class-sp-admin-cpt-table.php
index 2e9cf855..5b19ca83 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-table.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-table.php
@@ -2,136 +2,144 @@
/**
* Admin functions for the league tables post type
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
- * @version 2.5
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
+ * @version 2.5
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Admin_CPT' ) )
- include( 'class-sp-admin-cpt.php' );
+if ( ! class_exists( 'SP_Admin_CPT' ) ) {
+ require 'class-sp-admin-cpt.php';
+}
if ( ! class_exists( 'SP_Admin_CPT_Table' ) ) :
-/**
- * SP_Admin_CPT_Table Class
- */
-class SP_Admin_CPT_Table extends SP_Admin_CPT {
-
/**
- * Constructor
+ * SP_Admin_CPT_Table Class
*/
- public function __construct() {
- $this->type = 'sp_table';
+ class SP_Admin_CPT_Table extends SP_Admin_CPT {
- // Admin Columns
- add_filter( 'manage_edit-sp_table_columns', array( $this, 'edit_columns' ) );
- add_action( 'manage_sp_table_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->type = 'sp_table';
- // Filtering
- add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
- add_filter( 'parse_query', array( $this, 'filters_query' ) );
-
- // Call SP_Admin_CPT constructor
- parent::__construct();
- }
+ // Admin Columns
+ add_filter( 'manage_edit-sp_table_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_table_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
- /**
- * Change the columns shown in admin.
- */
- public function edit_columns( $existing_columns ) {
- unset( $existing_columns['date'] );
- $columns = array_merge( array(
- 'cb' => ' ',
- 'title' => __( 'Title', 'sportspress' ),
- 'sp_league' => __( 'League', 'sportspress' ),
- 'sp_season' => __( 'Season', 'sportspress' ),
- 'sp_team' => __( 'Teams', 'sportspress' ),
- ), $existing_columns );
- return apply_filters( 'sportspress_table_admin_columns', $columns );
- }
+ // Filtering
+ add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
+ add_filter( 'parse_query', array( $this, 'filters_query' ) );
- /**
- * Define our custom columns shown in admin.
- * @param string $column
- */
- public function custom_columns( $column, $post_id ) {
- switch ( $column ):
- case 'sp_league':
- echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
- break;
- case 'sp_season':
- echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
- break;
- case 'sp_team':
- $select = get_post_meta( $post_id, 'sp_select', true );
- if ( 'manual' == $select ):
- $teams = array_filter( get_post_meta( $post_id, 'sp_team' ) );
- echo sizeof( $teams );
- else:
- _e( 'Auto', 'sportspress' );
- endif;
- break;
- endswitch;
- }
+ // Call SP_Admin_CPT constructor
+ parent::__construct();
+ }
- /**
- * Show a category filter box
- */
- public function filters() {
- global $typenow, $wp_query;
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ unset( $existing_columns['date'] );
+ $columns = array_merge(
+ array(
+ 'cb' => ' ',
+ 'title' => __( 'Title', 'sportspress' ),
+ 'sp_league' => __( 'League', 'sportspress' ),
+ 'sp_season' => __( 'Season', 'sportspress' ),
+ 'sp_team' => __( 'Teams', 'sportspress' ),
+ ),
+ $existing_columns
+ );
+ return apply_filters( 'sportspress_table_admin_columns', $columns );
+ }
- if ( $typenow != 'sp_table' )
- return;
+ /**
+ * Define our custom columns shown in admin.
+ *
+ * @param string $column
+ */
+ public function custom_columns( $column, $post_id ) {
+ switch ( $column ) :
+ case 'sp_league':
+ echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
+ break;
+ case 'sp_season':
+ echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
+ break;
+ case 'sp_team':
+ $select = get_post_meta( $post_id, 'sp_select', true );
+ if ( 'manual' == $select ) :
+ $teams = array_filter( get_post_meta( $post_id, 'sp_team' ) );
+ echo sizeof( $teams );
+ else :
+ _e( 'Auto', 'sportspress' );
+ endif;
+ break;
+ endswitch;
+ }
- $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
- $args = array(
- 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
- 'taxonomy' => 'sp_league',
- 'name' => 'sp_league',
- 'selected' => $selected
- );
- sp_dropdown_taxonomies( $args );
+ /**
+ * Show a category filter box
+ */
+ public function filters() {
+ global $typenow, $wp_query;
- $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
- $args = array(
- 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
- 'taxonomy' => 'sp_season',
- 'name' => 'sp_season',
- 'selected' => $selected
- );
- sp_dropdown_taxonomies( $args );
+ if ( $typenow != 'sp_table' ) {
+ return;
+ }
- $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
- $args = array(
- 'post_type' => 'sp_team',
- 'name' => 'team',
- 'show_option_none' => __( 'Show all teams', 'sportspress' ),
- 'selected' => $selected,
- 'values' => 'ID',
- );
- wp_dropdown_pages( $args );
- }
+ $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
+ $args = array(
+ 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
+ 'taxonomy' => 'sp_league',
+ 'name' => 'sp_league',
+ 'selected' => $selected,
+ );
+ sp_dropdown_taxonomies( $args );
- /**
- * Filter in admin based on options
- *
- * @param mixed $query
- */
- public function filters_query( $query ) {
- global $typenow, $wp_query;
+ $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
+ $args = array(
+ 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
+ 'taxonomy' => 'sp_season',
+ 'name' => 'sp_season',
+ 'selected' => $selected,
+ );
+ sp_dropdown_taxonomies( $args );
- if ( $typenow == 'sp_table' ) {
+ $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
+ $args = array(
+ 'post_type' => 'sp_team',
+ 'name' => 'team',
+ 'show_option_none' => __( 'Show all teams', 'sportspress' ),
+ 'selected' => $selected,
+ 'values' => 'ID',
+ );
+ wp_dropdown_pages( $args );
+ }
- if ( ! empty( $_GET['team'] ) ) {
- $query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
- $query->query_vars['meta_key'] = 'sp_team';
- }
+ /**
+ * Filter in admin based on options
+ *
+ * @param mixed $query
+ */
+ public function filters_query( $query ) {
+ global $typenow, $wp_query;
+
+ if ( $typenow == 'sp_table' ) {
+
+ if ( ! empty( $_GET['team'] ) ) {
+ $query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
+ $query->query_vars['meta_key'] = 'sp_team';
+ }
+ }
}
}
-}
endif;
diff --git a/includes/admin/post-types/class-sp-admin-cpt-team.php b/includes/admin/post-types/class-sp-admin-cpt-team.php
index 8163ec61..3ab56d69 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-team.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-team.php
@@ -2,131 +2,142 @@
/**
* Admin functions for the teams post type
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
- * @version 2.6
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
+ * @version 2.6
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Admin_CPT' ) )
- include( 'class-sp-admin-cpt.php' );
+if ( ! class_exists( 'SP_Admin_CPT' ) ) {
+ require 'class-sp-admin-cpt.php';
+}
if ( ! class_exists( 'SP_Admin_CPT_Team' ) ) :
-/**
- * SP_Admin_CPT_Team Class
- */
-class SP_Admin_CPT_Team extends SP_Admin_CPT {
-
/**
- * Constructor
+ * SP_Admin_CPT_Team Class
*/
- public function __construct() {
- $this->type = 'sp_team';
+ class SP_Admin_CPT_Team extends SP_Admin_CPT {
- // Post title fields
- add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->type = 'sp_team';
- // Admin Columns
- add_filter( 'manage_edit-sp_team_columns', array( $this, 'edit_columns' ) );
- add_action( 'manage_sp_team_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
+ // Post title fields
+ add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
- // Filtering
- add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
-
- // Call SP_Admin_CPT constructor
- parent::__construct();
+ // Admin Columns
+ add_filter( 'manage_edit-sp_team_columns', array( $this, 'edit_columns' ) );
+ add_action( 'manage_sp_team_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
+
+ // Filtering
+ add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
+
+ // Call SP_Admin_CPT constructor
+ parent::__construct();
+ }
+
+ /**
+ * Change title boxes in admin.
+ *
+ * @param string $text
+ * @param object $post
+ * @return string
+ */
+ public function enter_title_here( $text, $post ) {
+ if ( $post->post_type == 'sp_team' ) {
+ return __( 'Name', 'sportspress' );
+ }
+
+ return $text;
+ }
+
+ /**
+ * Change the columns shown in admin.
+ */
+ public function edit_columns( $existing_columns ) {
+ unset( $existing_columns['author'], $existing_columns['date'] );
+ $columns = array_merge(
+ array(
+ 'cb' => ' ',
+ 'sp_icon' => ' ',
+ 'title' => null,
+ 'sp_short_name' => __( 'Short Name', 'sportspress' ),
+ 'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
+ 'sp_league' => __( 'Leagues', 'sportspress' ),
+ 'sp_season' => __( 'Seasons', 'sportspress' ),
+ ),
+ $existing_columns,
+ array(
+ 'title' => __( 'Team', 'sportspress' ),
+ )
+ );
+ return apply_filters( 'sportspress_team_admin_columns', $columns );
+ }
+
+ /**
+ * Define our custom columns shown in admin.
+ *
+ * @param string $column
+ */
+ public function custom_columns( $column, $post_id ) {
+ switch ( $column ) :
+ case 'sp_icon':
+ echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
+ break;
+ case 'sp_short_name':
+ $short_name = get_post_meta( $post_id, 'sp_short_name', true );
+ echo $short_name ? esc_html( $short_name ) : '—';
+ break;
+ case 'sp_abbreviation':
+ $abbreviation = get_post_meta( $post_id, 'sp_abbreviation', true );
+ echo $abbreviation ? esc_html( $abbreviation ) : '—';
+ break;
+ case 'sp_league':
+ echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
+ break;
+ case 'sp_season':
+ echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
+ break;
+ endswitch;
+ }
+
+ /**
+ * Show a category filter box
+ */
+ public function filters() {
+ global $typenow, $wp_query;
+
+ if ( $typenow != 'sp_team' ) {
+ return;
+ }
+
+ $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
+ $args = array(
+ 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
+ 'taxonomy' => 'sp_league',
+ 'name' => 'sp_league',
+ 'selected' => $selected,
+ );
+ sp_dropdown_taxonomies( $args );
+
+ $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
+ $args = array(
+ 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
+ 'taxonomy' => 'sp_season',
+ 'name' => 'sp_season',
+ 'selected' => $selected,
+ );
+ sp_dropdown_taxonomies( $args );
+ }
}
- /**
- * Change title boxes in admin.
- * @param string $text
- * @param object $post
- * @return string
- */
- public function enter_title_here( $text, $post ) {
- if ( $post->post_type == 'sp_team' )
- return __( 'Name', 'sportspress' );
-
- return $text;
- }
-
- /**
- * Change the columns shown in admin.
- */
- public function edit_columns( $existing_columns ) {
- unset( $existing_columns['author'], $existing_columns['date'] );
- $columns = array_merge( array(
- 'cb' => ' ',
- 'sp_icon' => ' ',
- 'title' => null,
- 'sp_short_name' => __( 'Short Name', 'sportspress' ),
- 'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
- 'sp_league' => __( 'Leagues', 'sportspress' ),
- 'sp_season' => __( 'Seasons', 'sportspress' ),
- ), $existing_columns, array(
- 'title' => __( 'Team', 'sportspress' ),
- ) );
- return apply_filters( 'sportspress_team_admin_columns', $columns );
- }
-
- /**
- * Define our custom columns shown in admin.
- * @param string $column
- */
- public function custom_columns( $column, $post_id ) {
- switch ( $column ):
- case 'sp_icon':
- echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
- break;
- case 'sp_short_name':
- $short_name = get_post_meta ( $post_id, 'sp_short_name', true );
- echo $short_name ? esc_html( $short_name ) : '—';
- break;
- case 'sp_abbreviation':
- $abbreviation = get_post_meta ( $post_id, 'sp_abbreviation', true );
- echo $abbreviation ? esc_html( $abbreviation ) : '—';
- break;
- case 'sp_league':
- echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
- break;
- case 'sp_season':
- echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
- break;
- endswitch;
- }
-
- /**
- * Show a category filter box
- */
- public function filters() {
- global $typenow, $wp_query;
-
- if ( $typenow != 'sp_team' )
- return;
-
- $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
- $args = array(
- 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
- 'taxonomy' => 'sp_league',
- 'name' => 'sp_league',
- 'selected' => $selected
- );
- sp_dropdown_taxonomies( $args );
-
- $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
- $args = array(
- 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
- 'taxonomy' => 'sp_season',
- 'name' => 'sp_season',
- 'selected' => $selected
- );
- sp_dropdown_taxonomies( $args );
- }
-}
-
endif;
return new SP_Admin_CPT_Team();
diff --git a/includes/admin/post-types/class-sp-admin-cpt.php b/includes/admin/post-types/class-sp-admin-cpt.php
index d0daa1ac..fd1e9fbd 100644
--- a/includes/admin/post-types/class-sp-admin-cpt.php
+++ b/includes/admin/post-types/class-sp-admin-cpt.php
@@ -2,66 +2,70 @@
/**
* Admin functions for post types
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Post_Types
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Post_Types
* @version 0.7
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
if ( ! class_exists( 'SP_Admin_CPT' ) ) :
-/**
- * SP_Admin_CPT Class
- */
-class SP_Admin_CPT {
-
- protected $type = '';
-
/**
- * Constructor
+ * SP_Admin_CPT Class
*/
- public function __construct() {
- // Insert into X media browser
- add_filter( 'media_view_strings', array( $this, 'change_insert_into_post' ) );
+ class SP_Admin_CPT {
+
+ protected $type = '';
+
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ // Insert into X media browser
+ add_filter( 'media_view_strings', array( $this, 'change_insert_into_post' ) );
+ }
+
+ /**
+ * Change label for insert buttons.
+ *
+ * @access public
+ * @param array $strings
+ * @return array
+ */
+ function change_insert_into_post( $strings ) {
+ global $post_type;
+
+ if ( $post_type == $this->type ) {
+ $obj = get_post_type_object( $this->type );
+
+ $strings['insertIntoPost'] = sprintf( __( 'Insert into %s', 'sportspress' ), $obj->labels->singular_name );
+ $strings['uploadedToThisPost'] = sprintf( __( 'Uploaded to this %s', 'sportspress' ), $obj->labels->singular_name );
+ }
+
+ return $strings;
+ }
+
+ /**
+ * Check if we're editing or adding an event
+ *
+ * @return boolean
+ */
+ private function is_editing() {
+ if ( ! empty( $_GET['post_type'] ) && $this->type == $_GET['post_type'] ) {
+ return true;
+ }
+ if ( ! empty( $_GET['post'] ) && $this->type == get_post_type( $_GET['post'] ) ) {
+ return true;
+ }
+ if ( ! empty( $_REQUEST['post_id'] ) && $this->type == get_post_type( $_REQUEST['post_id'] ) ) {
+ return true;
+ }
+ return false;
+ }
}
- /**
- * Change label for insert buttons.
- * @access public
- * @param array $strings
- * @return array
- */
- function change_insert_into_post( $strings ) {
- global $post_type;
-
- if ( $post_type == $this->type ) {
- $obj = get_post_type_object( $this->type );
-
- $strings['insertIntoPost'] = sprintf( __( 'Insert into %s', 'sportspress' ), $obj->labels->singular_name );
- $strings['uploadedToThisPost'] = sprintf( __( 'Uploaded to this %s', 'sportspress' ), $obj->labels->singular_name );
- }
-
- return $strings;
- }
-
- /**
- * Check if we're editing or adding an event
- * @return boolean
- */
- private function is_editing() {
- if ( ! empty( $_GET['post_type'] ) && $this->type == $_GET['post_type'] ) {
- return true;
- }
- if ( ! empty( $_GET['post'] ) && $this->type == get_post_type( $_GET['post'] ) ) {
- return true;
- }
- if ( ! empty( $_REQUEST['post_id'] ) && $this->type == get_post_type( $_REQUEST['post_id'] ) ) {
- return true;
- }
- return false;
- }
-}
-
-endif;
\ No newline at end of file
+endif;
diff --git a/includes/admin/post-types/class-sp-admin-meta-boxes.php b/includes/admin/post-types/class-sp-admin-meta-boxes.php
index 07257144..993bcc94 100644
--- a/includes/admin/post-types/class-sp-admin-meta-boxes.php
+++ b/includes/admin/post-types/class-sp-admin-meta-boxes.php
@@ -4,13 +4,15 @@
*
* Sets up the write panels used by custom post types
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.6.8
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.6.8
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Admin_Meta_Boxes
@@ -27,202 +29,202 @@ class SP_Admin_Meta_Boxes {
*/
public function __construct() {
$meta_boxes = array(
- 'sp_outcome' => array(
+ 'sp_outcome' => array(
'details' => array(
- 'title' => __( 'Details', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Outcome_Details::save',
- 'output' => 'SP_Meta_Box_Outcome_Details::output',
- 'context' => 'normal',
+ 'title' => __( 'Details', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Outcome_Details::save',
+ 'output' => 'SP_Meta_Box_Outcome_Details::output',
+ 'context' => 'normal',
'priority' => 'high',
),
),
- 'sp_result' => array(
- 'details' => array(
- 'title' => __( 'Details', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Result_Details::save',
- 'output' => 'SP_Meta_Box_Result_Details::output',
- 'context' => 'side',
+ 'sp_result' => array(
+ 'details' => array(
+ 'title' => __( 'Details', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Result_Details::save',
+ 'output' => 'SP_Meta_Box_Result_Details::output',
+ 'context' => 'side',
'priority' => 'default',
),
'equation' => array(
- 'title' => __( 'Equation', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Result_Equation::save',
- 'output' => 'SP_Meta_Box_Result_Equation::output',
- 'context' => 'normal',
+ 'title' => __( 'Equation', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Result_Equation::save',
+ 'output' => 'SP_Meta_Box_Result_Equation::output',
+ 'context' => 'normal',
'priority' => 'high',
),
),
'sp_performance' => array(
- 'details' => array(
- 'title' => __( 'Details', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Performance_Details::save',
- 'output' => 'SP_Meta_Box_Performance_Details::output',
- 'context' => 'normal',
+ 'details' => array(
+ 'title' => __( 'Details', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Performance_Details::save',
+ 'output' => 'SP_Meta_Box_Performance_Details::output',
+ 'context' => 'normal',
'priority' => 'high',
),
'equation' => array(
- 'title' => __( 'Equation', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Performance_Equation::save',
- 'output' => 'SP_Meta_Box_Performance_Equation::output',
- 'context' => 'normal',
+ 'title' => __( 'Equation', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Performance_Equation::save',
+ 'output' => 'SP_Meta_Box_Performance_Equation::output',
+ 'context' => 'normal',
'priority' => 'high',
),
),
- 'sp_column' => array(
- 'details' => array(
- 'title' => __( 'Details', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Column_Details::save',
- 'output' => 'SP_Meta_Box_Column_Details::output',
- 'context' => 'side',
+ 'sp_column' => array(
+ 'details' => array(
+ 'title' => __( 'Details', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Column_Details::save',
+ 'output' => 'SP_Meta_Box_Column_Details::output',
+ 'context' => 'side',
'priority' => 'default',
),
'equation' => array(
- 'title' => __( 'Equation', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Column_Equation::save',
- 'output' => 'SP_Meta_Box_Column_Equation::output',
- 'context' => 'normal',
+ 'title' => __( 'Equation', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Column_Equation::save',
+ 'output' => 'SP_Meta_Box_Column_Equation::output',
+ 'context' => 'normal',
'priority' => 'high',
),
),
- 'sp_metric' => array(
+ 'sp_metric' => array(
'details' => array(
- 'title' => __( 'Details', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Metric_Details::save',
- 'output' => 'SP_Meta_Box_Metric_Details::output',
- 'context' => 'normal',
+ 'title' => __( 'Details', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Metric_Details::save',
+ 'output' => 'SP_Meta_Box_Metric_Details::output',
+ 'context' => 'normal',
'priority' => 'high',
),
),
- 'sp_statistic' => array(
- 'details' => array(
- 'title' => __( 'Details', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Statistic_Details::save',
- 'output' => 'SP_Meta_Box_Statistic_Details::output',
- 'context' => 'side',
+ 'sp_statistic' => array(
+ 'details' => array(
+ 'title' => __( 'Details', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Statistic_Details::save',
+ 'output' => 'SP_Meta_Box_Statistic_Details::output',
+ 'context' => 'side',
'priority' => 'default',
),
'equation' => array(
- 'title' => __( 'Equation', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Statistic_Equation::save',
- 'output' => 'SP_Meta_Box_Statistic_Equation::output',
- 'context' => 'normal',
+ 'title' => __( 'Equation', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Statistic_Equation::save',
+ 'output' => 'SP_Meta_Box_Statistic_Equation::output',
+ 'context' => 'normal',
'priority' => 'high',
),
),
- 'sp_event' => array(
- 'shortcode' => array(
- 'title' => __( 'Shortcodes', 'sportspress' ),
- 'output' => 'SP_Meta_Box_Event_Shortcode::output',
- 'context' => 'side',
+ 'sp_event' => array(
+ 'shortcode' => array(
+ 'title' => __( 'Shortcodes', 'sportspress' ),
+ 'output' => 'SP_Meta_Box_Event_Shortcode::output',
+ 'context' => 'side',
'priority' => 'default',
),
- 'format' => array(
- 'title' => __( 'Format', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Event_Format::save',
- 'output' => 'SP_Meta_Box_Event_Format::output',
- 'context' => 'side',
+ 'format' => array(
+ 'title' => __( 'Format', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Event_Format::save',
+ 'output' => 'SP_Meta_Box_Event_Format::output',
+ 'context' => 'side',
'priority' => 'default',
),
- 'mode' => array(
- 'title' => __( 'Mode', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Event_Mode::save',
- 'output' => 'SP_Meta_Box_Event_Mode::output',
- 'context' => 'side',
+ 'mode' => array(
+ 'title' => __( 'Mode', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Event_Mode::save',
+ 'output' => 'SP_Meta_Box_Event_Mode::output',
+ 'context' => 'side',
'priority' => 'default',
),
- 'details' => array(
- 'title' => __( 'Details', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Event_Details::save',
- 'output' => 'SP_Meta_Box_Event_Details::output',
- 'context' => 'side',
+ 'details' => array(
+ 'title' => __( 'Details', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Event_Details::save',
+ 'output' => 'SP_Meta_Box_Event_Details::output',
+ 'context' => 'side',
'priority' => 'default',
),
- 'team' => array(
- 'title' => __( 'Teams', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Event_Teams::save',
- 'output' => 'SP_Meta_Box_Event_Teams::output',
- 'context' => 'side',
+ 'team' => array(
+ 'title' => __( 'Teams', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Event_Teams::save',
+ 'output' => 'SP_Meta_Box_Event_Teams::output',
+ 'context' => 'side',
'priority' => 'default',
),
- 'results' => array(
- 'title' => __( 'Results', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Event_Results::save',
- 'output' => 'SP_Meta_Box_Event_Results::output',
- 'context' => 'normal',
+ 'results' => array(
+ 'title' => __( 'Results', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Event_Results::save',
+ 'output' => 'SP_Meta_Box_Event_Results::output',
+ 'context' => 'normal',
'priority' => 'high',
),
'performance' => array(
- 'title' => __( 'Box Score', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Event_Performance::save',
- 'output' => 'SP_Meta_Box_Event_Performance::output',
- 'context' => 'normal',
+ 'title' => __( 'Box Score', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Event_Performance::save',
+ 'output' => 'SP_Meta_Box_Event_Performance::output',
+ 'context' => 'normal',
'priority' => 'high',
),
),
- 'sp_team' => array(
+ 'sp_team' => array(
'details' => array(
- 'title' => __( 'Details', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Team_Details::save',
- 'output' => 'SP_Meta_Box_Team_Details::output',
- 'context' => 'side',
+ 'title' => __( 'Details', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Team_Details::save',
+ 'output' => 'SP_Meta_Box_Team_Details::output',
+ 'context' => 'side',
'priority' => 'default',
),
- 'staff' => array(
- 'title' => __( 'Staff', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Team_Staff::save',
- 'output' => 'SP_Meta_Box_Team_Staff::output',
- 'context' => 'normal',
+ 'staff' => array(
+ 'title' => __( 'Staff', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Team_Staff::save',
+ 'output' => 'SP_Meta_Box_Team_Staff::output',
+ 'context' => 'normal',
'priority' => 'high',
),
),
- 'sp_player' => array(
- 'shortcode' => array(
- 'title' => __( 'Shortcodes', 'sportspress' ),
- 'output' => 'SP_Meta_Box_Player_Shortcode::output',
- 'context' => 'side',
+ 'sp_player' => array(
+ 'shortcode' => array(
+ 'title' => __( 'Shortcodes', 'sportspress' ),
+ 'output' => 'SP_Meta_Box_Player_Shortcode::output',
+ 'context' => 'side',
'priority' => 'default',
),
- 'columns' => array(
- 'title' => __( 'Columns', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Player_Columns::save',
- 'output' => 'SP_Meta_Box_Player_Columns::output',
- 'context' => 'side',
+ 'columns' => array(
+ 'title' => __( 'Columns', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Player_Columns::save',
+ 'output' => 'SP_Meta_Box_Player_Columns::output',
+ 'context' => 'side',
'priority' => 'default',
),
- 'details' => array(
- 'title' => __( 'Details', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Player_Details::save',
- 'output' => 'SP_Meta_Box_Player_Details::output',
- 'context' => 'side',
+ 'details' => array(
+ 'title' => __( 'Details', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Player_Details::save',
+ 'output' => 'SP_Meta_Box_Player_Details::output',
+ 'context' => 'side',
'priority' => 'default',
),
- 'metrics' => array(
- 'title' => __( 'Metrics', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Player_Metrics::save',
- 'output' => 'SP_Meta_Box_Player_Metrics::output',
- 'context' => 'side',
+ 'metrics' => array(
+ 'title' => __( 'Metrics', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Player_Metrics::save',
+ 'output' => 'SP_Meta_Box_Player_Metrics::output',
+ 'context' => 'side',
'priority' => 'default',
),
'statistics' => array(
- 'title' => __( 'Statistics', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Player_Statistics::save',
- 'output' => 'SP_Meta_Box_Player_Statistics::output',
- 'context' => 'normal',
+ 'title' => __( 'Statistics', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Player_Statistics::save',
+ 'output' => 'SP_Meta_Box_Player_Statistics::output',
+ 'context' => 'normal',
'priority' => 'high',
),
),
- 'sp_staff' => array(
+ 'sp_staff' => array(
'shortcode' => array(
- 'title' => __( 'Shortcode', 'sportspress' ),
- 'output' => 'SP_Meta_Box_Staff_Shortcode::output',
- 'context' => 'side',
+ 'title' => __( 'Shortcode', 'sportspress' ),
+ 'output' => 'SP_Meta_Box_Staff_Shortcode::output',
+ 'context' => 'side',
'priority' => 'default',
),
- 'details' => array(
- 'title' => __( 'Details', 'sportspress' ),
- 'save' => 'SP_Meta_Box_Staff_Details::save',
- 'output' => 'SP_Meta_Box_Staff_Details::output',
- 'context' => 'side',
+ 'details' => array(
+ 'title' => __( 'Details', 'sportspress' ),
+ 'save' => 'SP_Meta_Box_Staff_Details::save',
+ 'output' => 'SP_Meta_Box_Staff_Details::output',
+ 'context' => 'side',
'priority' => 'default',
),
),
@@ -303,7 +305,7 @@ class SP_Admin_Meta_Boxes {
remove_meta_box( 'postimagediv', 'sp_performance', 'side' );
add_meta_box( 'postimagediv', __( 'Icon', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_performance', 'side', 'low' );
-
+
remove_meta_box( 'postimagediv', 'sp_statistic', 'side' );
add_meta_box( 'postimagediv', __( 'Icon', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_statistic', 'side', 'low' );
}
@@ -311,17 +313,31 @@ class SP_Admin_Meta_Boxes {
/**
* Check if we're saving, then trigger an action based on the post type
*
- * @param int $post_id
+ * @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 ( ! apply_filters( 'sportspress_user_can', current_user_can( 'edit_post', $post_id ), $post_id ) ) return;
- if ( ! is_sp_post_type( $post->post_type ) && ! is_sp_config_type( $post->post_type ) ) return;
+ 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 ( ! apply_filters( 'sportspress_user_can', current_user_can( 'edit_post', $post_id ), $post_id ) ) {
+ return;
+ }
+ if ( ! is_sp_post_type( $post->post_type ) && ! is_sp_config_type( $post->post_type ) ) {
+ return;
+ }
do_action( 'sportspress_process_' . $post->post_type . '_meta', $post_id, $post );
}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-columns.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-columns.php
index a7abf289..d6350576 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-columns.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-columns.php
@@ -2,13 +2,15 @@
/**
* Calendar Columns
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Calendar_Columns
@@ -19,9 +21,9 @@ class SP_Meta_Box_Calendar_Columns {
* Output the metabox
*/
public static function output( $post ) {
- $selected = (array) get_post_meta( $post->ID, 'sp_columns', true );
+ $selected = (array) get_post_meta( $post->ID, 'sp_columns', true );
$title_format = get_option( 'sportspress_event_list_title_format', 'title' );
- $time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
+ $time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
if ( is_array( $selected ) ) {
$selected = array_filter( $selected );
@@ -30,11 +32,11 @@ class SP_Meta_Box_Calendar_Columns {
$columns = array();
if ( 'teams' === $title_format ) {
- $columns[ 'event' ] = __( 'Home', 'sportspress' ) . ' | ' . __( 'Away', 'sportspress' );
+ $columns['event'] = __( 'Home', 'sportspress' ) . ' | ' . __( 'Away', 'sportspress' );
} elseif ( 'homeaway' === $title_format ) {
- $columns[ 'event' ] = __( 'Teams', 'sportspress' );
+ $columns['event'] = __( 'Teams', 'sportspress' );
} else {
- $columns[ 'event' ] = __( 'Title', 'sportspress' );
+ $columns['event'] = __( 'Title', 'sportspress' );
}
if ( 'time' === $time_format || 'separate' === $time_format ) {
@@ -47,27 +49,27 @@ class SP_Meta_Box_Calendar_Columns {
$columns['results'] = __( 'Results', 'sportspress' );
}
- $columns['league'] = __( 'League', 'sportspress' );
- $columns['season'] = __( 'Season', 'sportspress' );
- $columns['venue'] = __( 'Venue', 'sportspress' );
+ $columns['league'] = __( 'League', 'sportspress' );
+ $columns['season'] = __( 'Season', 'sportspress' );
+ $columns['venue'] = __( 'Venue', 'sportspress' );
$columns['article'] = __( 'Article', 'sportspress' );
- $columns['day'] = __( 'Match Day', 'sportspress' );
+ $columns['day'] = __( 'Match Day', 'sportspress' );
$columns = apply_filters( 'sportspress_calendar_columns', $columns );
?>
data();
+ $calendar = new SP_Calendar( $post );
+ $data = $calendar->data();
$usecolumns = $calendar->columns;
self::table( $data, $usecolumns );
}
@@ -37,11 +39,11 @@ class SP_Meta_Box_Calendar_Data {
*/
public static function table( $data = array(), $usecolumns = null ) {
$title_format = get_option( 'sportspress_event_list_title_format', 'title' );
- $time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
+ $time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
if ( is_array( $usecolumns ) ) {
$usecolumns = array_filter( $usecolumns );
- }else{
+ } else {
$usecolumns = array();
}
?>
@@ -57,7 +59,11 @@ class SP_Meta_Box_Calendar_Data {
|
+ |
+
0 ):
+ if ( is_array( $data ) ) :
+ if ( sizeof( $data ) > 0 ) :
$main_result = get_option( 'sportspress_primary_result', null );
- $i = 0;
- foreach ( $data as $event ):
- $teams = get_post_meta( $event->ID, 'sp_team' );
- $results = get_post_meta( $event->ID, 'sp_results', true );
- $video = get_post_meta( $event->ID, 'sp_video', true );
+ $i = 0;
+ foreach ( $data as $event ) :
+ $teams = get_post_meta( $event->ID, 'sp_team' );
+ $results = get_post_meta( $event->ID, 'sp_results', true );
+ $video = get_post_meta( $event->ID, 'sp_video', true );
$main_results = array();
?>
-
+
- post_title ); ?>
-
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php
index 5b6a1f4f..f7daa3d5 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php
@@ -2,13 +2,15 @@
/**
* Calendar Details
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Calendar_Details
@@ -19,22 +21,22 @@ class SP_Meta_Box_Calendar_Details {
* Output the metabox
*/
public static function output( $post ) {
- $taxonomies = get_object_taxonomies( 'sp_calendar' );
- $caption = get_post_meta( $post->ID, 'sp_caption', true );
- $status = get_post_meta( $post->ID, 'sp_status', true );
- $date = get_post_meta( $post->ID, 'sp_date', true );
- $date_from = get_post_meta( $post->ID, 'sp_date_from', true );
- $date_to = get_post_meta( $post->ID, 'sp_date_to', true );
- $date_past = get_post_meta( $post->ID, 'sp_date_past', true );
- $date_future = get_post_meta( $post->ID, 'sp_date_future', true );
+ $taxonomies = get_object_taxonomies( 'sp_calendar' );
+ $caption = get_post_meta( $post->ID, 'sp_caption', true );
+ $status = get_post_meta( $post->ID, 'sp_status', true );
+ $date = get_post_meta( $post->ID, 'sp_date', true );
+ $date_from = get_post_meta( $post->ID, 'sp_date_from', true );
+ $date_to = get_post_meta( $post->ID, 'sp_date_to', true );
+ $date_past = get_post_meta( $post->ID, 'sp_date_past', true );
+ $date_future = get_post_meta( $post->ID, 'sp_date_future', true );
$date_relative = get_post_meta( $post->ID, 'sp_date_relative', true );
- $event_format = get_post_meta( $post->ID, 'sp_event_format', true );
- $day = get_post_meta( $post->ID, 'sp_day', true );
- $teams = get_post_meta( $post->ID, 'sp_team', false );
- $players = get_post_meta( $post->ID, 'sp_player', false );
- $table_id = get_post_meta( $post->ID, 'sp_table', true );
- $orderby = get_post_meta( $post->ID, 'sp_orderby', true );
- $order = get_post_meta( $post->ID, 'sp_order', true );
+ $event_format = get_post_meta( $post->ID, 'sp_event_format', true );
+ $day = get_post_meta( $post->ID, 'sp_day', true );
+ $teams = get_post_meta( $post->ID, 'sp_team', false );
+ $players = get_post_meta( $post->ID, 'sp_player', false );
+ $table_id = get_post_meta( $post->ID, 'sp_table', true );
+ $orderby = get_post_meta( $post->ID, 'sp_orderby', true );
+ $order = get_post_meta( $post->ID, 'sp_order', true );
?>
@@ -44,8 +46,8 @@ class SP_Meta_Box_Calendar_Details {
'sp_status',
- 'id' => 'sp_status',
+ 'name' => 'sp_status',
+ 'id' => 'sp_status',
'selected' => $status,
);
sp_dropdown_statuses( $args );
@@ -55,7 +57,7 @@ class SP_Meta_Box_Calendar_Details {
All
- formats->event as $key => $format ): ?>
+ formats->event as $key => $format ) : ?>
>
@@ -65,8 +67,8 @@ class SP_Meta_Box_Calendar_Details {
'sp_date',
- 'id' => 'sp_date',
+ 'name' => 'sp_date',
+ 'id' => 'sp_date',
'selected' => $date,
);
sp_dropdown_dates( $args );
@@ -112,17 +114,17 @@ class SP_Meta_Box_Calendar_Details {
'sp_team',
- 'name' => 'sp_team[]',
- 'selected' => $teams,
- 'values' => 'ID',
- 'class' => 'widefat',
- 'property' => 'multiple',
- 'chosen' => true,
+ 'post_type' => 'sp_team',
+ 'name' => 'sp_team[]',
+ 'selected' => $teams,
+ 'values' => 'ID',
+ 'class' => 'widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
'placeholder' => __( 'All', 'sportspress' ),
);
- if ( ! sp_dropdown_pages( $args ) ):
- sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
+ if ( ! sp_dropdown_pages( $args ) ) :
+ sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
@@ -130,17 +132,17 @@ class SP_Meta_Box_Calendar_Details {
'sp_player',
- 'name' => 'sp_player[]',
- 'selected' => $players,
- 'values' => 'ID',
- 'class' => 'widefat',
- 'property' => 'multiple',
- 'chosen' => true,
+ 'post_type' => 'sp_player',
+ 'name' => 'sp_player[]',
+ 'selected' => $players,
+ 'values' => 'ID',
+ 'class' => 'widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
'placeholder' => __( 'All', 'sportspress' ),
);
- if ( ! sp_dropdown_pages( $args ) ):
- sp_post_adder( 'sp_player', __( 'Add New', 'sportspress' ) );
+ if ( ! sp_dropdown_pages( $args ) ) :
+ sp_post_adder( 'sp_player', __( 'Add New', 'sportspress' ) );
endif;
?>
@@ -184,4 +186,4 @@ class SP_Meta_Box_Calendar_Details {
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array(), 'int' ) );
sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array(), 'int' ) );
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-feeds.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-feeds.php
index 6a41f958..0c8b31b4 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-feeds.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-feeds.php
@@ -4,13 +4,15 @@
*
* Based on a tutorial by Steve Thomas.
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Calendar_Feeds
@@ -21,7 +23,7 @@ class SP_Meta_Box_Calendar_Feeds {
* Output the metabox
*/
public static function output( $post ) {
- $feeds = new SP_Feeds();
+ $feeds = new SP_Feeds();
$calendar_feeds = $feeds->calendar;
?>
@@ -52,4 +54,4 @@ class SP_Meta_Box_Calendar_Feeds {
ID, 'sp_format', true );
?>
- formats->calendar as $key => $format ): ?>
+ formats->calendar as $key => $format ) : ?>
>
@@ -36,4 +38,4 @@ class SP_Meta_Box_Calendar_Format {
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'calendar', 'text' ) );
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-shortcode.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-shortcode.php
index d65c8a5e..baef3e8a 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-shortcode.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-shortcode.php
@@ -2,13 +2,15 @@
/**
* Calendar Shortcode
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
* @version 1.6.1
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Calendar_Shortcode
@@ -20,7 +22,9 @@ class SP_Meta_Box_Calendar_Shortcode {
*/
public static function output( $post ) {
$the_format = get_post_meta( $post->ID, 'sp_format', true );
- if ( ! $the_format ) $the_format = 'calendar';
+ if ( ! $the_format ) {
+ $the_format = 'calendar';
+ }
?>
@@ -28,4 +32,4 @@ class SP_Meta_Box_Calendar_Shortcode {
ID, 'sp_equation', true ) );
- $order = get_post_meta( $post->ID, 'sp_order', true );
- $priority = get_post_meta( $post->ID, 'sp_priority', true );
+ $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;
+ if ( $precision == '' ) {
+ $precision = 0;
+ }
?>
@@ -45,19 +50,22 @@ class SP_Meta_Box_Column_Details extends SP_Meta_Box_Config {
__( 'Disable', 'sportspress' ) );
- $count = wp_count_posts( 'sp_column' );
- for( $i = 1; $i <= $count->publish; $i++ ):
+ $count = wp_count_posts( 'sp_column' );
+ for ( $i = 1; $i <= $count->publish; $i++ ) :
$options[ $i ] = $i;
endfor;
- foreach ( $options as $key => $value ):
+ foreach ( $options as $key => $value ) :
printf( '%s ', $key, selected( true, $key == $priority, false ), $value );
endforeach;
?>
__( 'Descending', 'sportspress' ), 'ASC' => __( 'Ascending', 'sportspress' ) );
- foreach ( $options as $key => $value ):
+ $options = array(
+ 'DESC' => __( 'Descending', 'sportspress' ),
+ 'ASC' => __( 'Ascending', 'sportspress' ),
+ );
+ foreach ( $options as $key => $value ) :
printf( '%s ', $key, selected( true, $key == $order, false ), $value );
endforeach;
?>
@@ -75,4 +83,4 @@ class SP_Meta_Box_Column_Details extends SP_Meta_Box_Config {
update_post_meta( $post_id, 'sp_priority', sp_array_value( $_POST, 'sp_priority', '0', 'int' ) );
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', 'DESC', 'text' ) );
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-column-equation.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-column-equation.php
index c633e281..332d1632 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-column-equation.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-column-equation.php
@@ -2,16 +2,19 @@
/**
* Column Equation
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
* @version 1.9.4
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Meta_Box_Equation' ) )
- include( 'class-sp-meta-box-equation.php' );
+if ( ! class_exists( 'SP_Meta_Box_Equation' ) ) {
+ require 'class-sp-meta-box-equation.php';
+}
/**
* SP_Meta_Box_Column_Equation
@@ -25,4 +28,4 @@ class SP_Meta_Box_Column_Equation extends SP_Meta_Box_Equation {
$equation = get_post_meta( $post->ID, 'sp_equation', true );
self::builder( $post->post_title, $equation, array( 'team_event', 'outcome', 'result', 'subset', 'preset' ) );
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-config.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-config.php
index fe0e682a..98e13795 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-config.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-config.php
@@ -2,13 +2,15 @@
/**
* Config type meta box functions
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
* @version 1.0
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Config
@@ -26,14 +28,16 @@ class SP_Meta_Box_Config {
global $wpdb;
$key = isset( $post['sp_key'] ) ? $post['sp_key'] : null;
- if ( ! $key ) $key = $post['post_title'];
- $id = sp_array_value( $post, 'post_ID', 'var' );
+ if ( ! $key ) {
+ $key = $post['post_title'];
+ }
+ $id = sp_array_value( $post, 'post_ID', 'var' );
$title = sp_get_eos_safe_slug( $key, $id );
- $check_sql = "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
+ $check_sql = "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $title, $post['post_type'], $id ) );
- if ( $post_name_check ):
+ if ( $post_name_check ) :
wp_delete_post( $post_name_check, true );
$post['post_status'] = 'draft';
endif;
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php
index 6d1242cb..3e188bec 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php
@@ -2,13 +2,15 @@
/**
* Equation meta box functions
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Equation
@@ -23,88 +25,146 @@ class SP_Meta_Box_Equation {
}
public static function builder( $title = 'f(x)', $equation = '', $groups = array() ) {
- if ( $title == '' ) $title = 'f(x)';
+ if ( $title == '' ) {
+ $title = 'f(x)';
+ }
$options = array(); // Multidimensional equation part options
- $parts = array(); // Flattened equation part options
+ $parts = array(); // Flattened equation part options
// Add groups to options
- foreach ( $groups as $group ):
- switch ( $group ):
+ foreach ( $groups as $group ) :
+ switch ( $group ) :
case 'player_event':
- $options[ 'Events' ] = array( '$eventsattended' => __( 'Attended', 'sportspress' ), '$eventsplayed' => __( 'Played', 'sportspress' ), '$eventsstarted' => __( 'Started', 'sportspress' ), '$eventssubbed' => __( 'Substituted', 'sportspress' ), '$eventminutes' => __( 'Minutes', 'sportspress' ) );
+ $options['Events'] = array(
+ '$eventsattended' => __( 'Attended', 'sportspress' ),
+ '$eventsplayed' => __( 'Played', 'sportspress' ),
+ '$eventsstarted' => __( 'Started', 'sportspress' ),
+ '$eventssubbed' => __( 'Substituted', 'sportspress' ),
+ '$eventminutes' => __( 'Minutes', 'sportspress' ),
+ );
break;
case 'team_event':
- $options[ 'Events' ] = array( '$eventsplayed' => __( 'Played', 'sportspress' ), '$eventminutes' => __( 'Minutes', 'sportspress' ) );
+ $options['Events'] = array(
+ '$eventsplayed' => __( 'Played', 'sportspress' ),
+ '$eventminutes' => __( 'Minutes', 'sportspress' ),
+ );
break;
case 'result':
- $options[ 'Results' ] = self::optgroup( 'sp_result', array( 'for' => '(' . __( 'for', 'sportspress' ) . ')', 'against' => '(' . __( 'against', 'sportspress' ) . ')' ), null, false );
+ $options['Results'] = self::optgroup(
+ 'sp_result',
+ array(
+ 'for' => '(' . __( 'for', 'sportspress' ) . ')',
+ 'against' => '(' . __(
+ 'against',
+ 'sportspress'
+ ) . ')',
+ ),
+ null,
+ false
+ );
break;
case 'outcome':
- $options[ 'Outcomes' ] = self::optgroup( 'sp_outcome' );
+ $options['Outcomes'] = self::optgroup( 'sp_outcome' );
break;
case 'preset':
- $options[ 'Presets' ] = array( '$gamesback' => __( 'Games Back', 'sportspress' ), '$homerecord' => __( 'Home Record', 'sportspress' ), '$awayrecord' => __( 'Away Record', 'sportspress' ), '$streak' => __( 'Streak', 'sportspress' ), '$form' => __( 'Form', 'sportspress' ), '$last5' => __( 'Last 5', 'sportspress' ), '$last10' => __( 'Last 10', 'sportspress' ) );
+ $options['Presets'] = array(
+ '$gamesback' => __( 'Games Back', 'sportspress' ),
+ '$homerecord' => __( 'Home Record', 'sportspress' ),
+ '$awayrecord' => __( 'Away Record', 'sportspress' ),
+ '$streak' => __( 'Streak', 'sportspress' ),
+ '$form' => __( 'Form', 'sportspress' ),
+ '$last5' => __( 'Last 5', 'sportspress' ),
+ '$last10' => __( 'Last 10', 'sportspress' ),
+ );
break;
case 'subset':
- $options[ 'Subsets' ] = array( '_home' => '@' . __( 'Home', 'sportspress' ), '_away' => '@' . __( 'Away', 'sportspress' ), '_venue' => '@' . __( 'Venue', 'sportspress' ) );
+ $options['Subsets'] = array(
+ '_home' => '@' . __( 'Home', 'sportspress' ),
+ '_away' => '@' . __( 'Away', 'sportspress' ),
+ '_venue' => '@' . __( 'Venue', 'sportspress' ),
+ );
break;
case 'performance':
- $options[ 'Performance' ] = self::optgroup( 'sp_performance' );
+ $options['Performance'] = self::optgroup( 'sp_performance' );
break;
case 'metric':
- $options[ 'Metrics' ] = self::optgroup( 'sp_metric' );
+ $options['Metrics'] = self::optgroup( 'sp_metric' );
break;
endswitch;
endforeach;
// Add operators to options
- $options[ 'Operators' ] = array( '+' => '+', '-' => '−', '*' => '×', '/' => '÷', '(' => '(', ')' => ')' );
+ $options['Operators'] = array(
+ '+' => '+',
+ '-' => '−',
+ '*' => '×',
+ '/' => '÷',
+ '(' => '(',
+ ')' => ')',
+ );
// Create array of constants
- $max = 10;
+ $max = 10;
$constants = array();
- for ( $i = 0; $i <= $max; $i ++ ):
- $constants[$i] = $i;
+ for ( $i = 0; $i <= $max; $i ++ ) :
+ $constants[ $i ] = $i;
endfor;
// Add 100 to constants
$constants[100] = 100;
// Add constants to options
- $options[ 'Constants' ] = (array) $constants;
+ $options['Constants'] = (array) $constants;
$options = apply_filters( 'sportspress_equation_options', $options );
?>
- $option ): ?>
- class="alternate">
+ $option ) : ?>
+
+ class="alternate">
- $value ): $parts[ $key ] = $value;
- ?>
+ $value ) :
+ $parts[ $key ] = $value;
+ ?>
+
+
-
+
=
-
+ ×
+ ×
+
+ ?>
+
$type,
- 'numberposts' => -1,
+ 'post_type' => $type,
+ 'numberposts' => -1,
'posts_per_page' => -1,
- 'orderby' => 'menu_order',
- 'order' => 'ASC',
- 'meta_query' => array(
- 'relation' => 'OR',
+ 'orderby' => 'menu_order',
+ 'order' => 'ASC',
+ 'meta_query' => array(
+ 'relation' => 'OR',
array(
- 'key' => 'sp_format',
- 'value' => 'number',
+ 'key' => 'sp_format',
+ 'value' => 'number',
'compare' => 'NOT EXISTS',
),
array(
- 'key' => 'sp_format',
- 'value' => array( 'equation', 'text' ),
+ 'key' => 'sp_format',
+ 'value' => array( 'equation', 'text' ),
'compare' => 'NOT IN',
),
),
@@ -137,22 +197,24 @@ class SP_Meta_Box_Equation {
$vars = get_posts( $args );
// Add extra vars to the array
- if ( isset( $defaults ) && is_array( $defaults ) ):
- foreach ( $defaults as $key => $value ):
+ if ( isset( $defaults ) && is_array( $defaults ) ) :
+ foreach ( $defaults as $key => $value ) :
$arr[ $key ] = $value;
endforeach;
endif;
// Add vars to the array
- if ( isset( $variations ) && is_array( $variations ) ):
- foreach ( $vars as $var ):
- if ( $totals ) $arr[ '$' . $var->post_name ] = $var->post_title;
- foreach ( $variations as $key => $value ):
+ if ( isset( $variations ) && is_array( $variations ) ) :
+ foreach ( $vars as $var ) :
+ if ( $totals ) {
+ $arr[ '$' . $var->post_name ] = $var->post_title;
+ }
+ foreach ( $variations as $key => $value ) :
$arr[ '$' . $var->post_name . $key ] = $var->post_title . ' ' . $value;
endforeach;
endforeach;
- else:
- foreach ( $vars as $var ):
+ else :
+ foreach ( $vars as $var ) :
$arr[ '$' . $var->post_name ] = $var->post_title;
endforeach;
endif;
@@ -162,6 +224,7 @@ class SP_Meta_Box_Equation {
/**
* Equation part labels for localization
+ *
* @return null
*/
public static function equation_part_labels() {
@@ -170,4 +233,4 @@ class SP_Meta_Box_Equation {
__( 'Subsets', 'sportspress' );
__( 'Constants', 'sportspress' );
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-details.php
index 6338c8b6..0e5d9bda 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-details.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-details.php
@@ -2,13 +2,15 @@
/**
* Event Details
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Event_Details
@@ -19,9 +21,9 @@ class SP_Meta_Box_Event_Details {
* Output the metabox
*/
public static function output( $post ) {
- $day = get_post_meta( $post->ID, 'sp_day', true );
+ $day = get_post_meta( $post->ID, 'sp_day', true );
$taxonomies = get_object_taxonomies( 'sp_event' );
- $minutes = get_post_meta( $post->ID, 'sp_minutes', true );
+ $minutes = get_post_meta( $post->ID, 'sp_minutes', true );
?>
@@ -39,7 +41,9 @@ class SP_Meta_Box_Event_Details {
@@ -48,14 +52,14 @@ class SP_Meta_Box_Event_Details {
ID, 'sp_venue' );
- $args = array(
- 'taxonomy' => 'sp_venue',
- 'name' => 'tax_input[sp_venue][]',
- 'class' => 'sp-has-dummy',
- 'selected' => sp_get_the_term_id_or_meta( $post->ID, 'sp_venue' ),
- 'values' => 'term_id',
+ $args = array(
+ 'taxonomy' => 'sp_venue',
+ 'name' => 'tax_input[sp_venue][]',
+ 'class' => 'sp-has-dummy',
+ 'selected' => sp_get_the_term_id_or_meta( $post->ID, 'sp_venue' ),
+ 'values' => 'term_id',
'show_option_none' => __( '— Not set —', 'sportspress' ),
- 'chosen' => true,
+ 'chosen' => true,
);
if ( in_array( 'sp_venue', apply_filters( 'sportspress_event_auto_taxonomies', array( 'sp_venue' ) ) ) ) {
$args['show_option_all'] = __( '(Auto)', 'sportspress' );
@@ -75,10 +79,10 @@ class SP_Meta_Box_Event_Details {
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_day', sp_array_value( $_POST, 'sp_day', null, 'text' ) );
update_post_meta( $post_id, 'sp_minutes', sp_array_value( $_POST, 'sp_minutes', get_option( 'sportspress_event_minutes', 90 ), 'int' ) );
- $venues = array_filter( sp_array_value( sp_array_value( $_POST, 'tax_input', array() ), 'sp_venue', array() ) );
+ $venues = array_filter( sp_array_value( sp_array_value( $_POST, 'tax_input', array() ), 'sp_venue', array() ) );
if ( empty( $venues ) ) {
$teams = sp_array_value( $_POST, 'sp_team', array(), 'int' );
- $team = reset( $teams );
+ $team = reset( $teams );
$venue = sp_get_the_term_id( $team, 'sp_venue' );
wp_set_post_terms( $post_id, $venue, 'sp_venue' );
}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-format.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-format.php
index 3866fa63..b4a54c96 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-format.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-format.php
@@ -2,13 +2,15 @@
/**
* Event Format
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Event_Format
@@ -23,7 +25,7 @@ class SP_Meta_Box_Event_Format {
$the_format = get_post_meta( $post->ID, 'sp_format', true );
?>
- formats->event as $key => $format ): ?>
+ formats->event as $key => $format ) : ?>
>
@@ -36,4 +38,4 @@ class SP_Meta_Box_Event_Format {
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'league', 'text' ) );
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-mode.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-mode.php
index 7918dba8..d39e43c8 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-mode.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-mode.php
@@ -5,34 +5,41 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Event_Mode
*/
class SP_Meta_Box_Event_Mode {
- /**
- * Output the metabox
- */
- public static function output( $post ) {
- $the_mode = sp_get_post_mode( $post->ID );
- ?>
-
- __( 'Team vs team', 'sportspress' ), 'player' => __( 'Player vs player', 'sportspress' ) ) as $key => $mode ): ?>
- >
-
-
- ID );
+ ?>
+
+ __( 'Team vs team', 'sportspress' ),
+ 'player' => __( 'Player vs player', 'sportspress' ),
+ ) as $key => $mode ) :
+ ?>
+ >
+
+
+ 'sp_duty',
- 'hide_empty' => false,
- 'orderby' => 'meta_value_num',
- 'meta_query' => array(
- 'relation' => 'OR',
- array(
- 'key' => 'sp_order',
- 'compare' => 'NOT EXISTS'
- ),
- array(
- 'key' => 'sp_order',
- 'compare' => 'EXISTS'
- ),
- ),
- ) );
+ /**
+ * Output the metabox
+ */
+ public static function output( $post ) {
+ $duties = get_terms(
+ array(
+ 'taxonomy' => 'sp_duty',
+ 'hide_empty' => false,
+ 'orderby' => 'meta_value_num',
+ 'meta_query' => array(
+ 'relation' => 'OR',
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'NOT EXISTS',
+ ),
+ array(
+ 'key' => 'sp_order',
+ 'compare' => 'EXISTS',
+ ),
+ ),
+ )
+ );
- $officials = (array) get_post_meta( $post->ID, 'sp_officials', true );
+ $officials = (array) get_post_meta( $post->ID, 'sp_officials', true );
- if ( is_array( $duties ) && sizeof( $duties ) ) {
- foreach ( $duties as $duty ) {
- ?>
- name ); ?>
- 'sp_official',
- 'name' => 'sp_officials[' . $duty->term_id . '][]',
- 'selected' => sp_array_value( $officials, $duty->term_id, array() ),
- 'values' => 'ID',
- 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Officials', 'sportspress' ) ),
- 'class' => 'widefat',
- 'property' => 'multiple',
- 'chosen' => true,
- );
+ if ( is_array( $duties ) && sizeof( $duties ) ) {
+ foreach ( $duties as $duty ) {
+ ?>
+
name ); ?>
+
+ 'sp_official',
+ 'name' => 'sp_officials[' . $duty->term_id . '][]',
+ 'selected' => sp_array_value( $officials, $duty->term_id, array() ),
+ 'values' => 'ID',
+ 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Officials', 'sportspress' ) ),
+ 'class' => 'widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
+ );
- if ( ! sp_dropdown_pages( $args ) ) {
- sp_post_adder( 'sp_official', __( 'Add New', 'sportspress' ) );
- }
- ?>
-
+
+ performance( true );
- if ( 'yes' == get_option( 'sportspress_event_performance_show_minutes', 'no' ) )
+ if ( 'yes' == get_option( 'sportspress_event_performance_show_minutes', 'no' ) ) {
$timeline = $event->timeline( true );
- else
+ } else {
$timeline = false;
+ }
// Determine if columns are auto or manual
- if ( 'manual' == get_option( 'sportspress_event_performance_columns', 'auto' ) )
+ if ( 'manual' == get_option( 'sportspress_event_performance_columns', 'auto' ) ) {
$manual = true;
- else
+ } else {
$manual = false;
+ }
// Determine if we need checkboxes
- if ( $manual )
+ if ( $manual ) {
$has_checkboxes = true;
- else
+ } else {
$has_checkboxes = false;
-
+ }
+
// Get player number option
$numbers = 'yes' == get_option( 'sportspress_event_show_player_numbers', 'yes' ) ? true : false;
// Get positions
$positions = array();
- if ( 'yes' == get_option( 'sportspress_event_show_position', 'yes' ) && taxonomy_exists( 'sp_position' ) ):
- $args = array(
- 'hide_empty' => false,
- 'parent' => 0,
+ if ( 'yes' == get_option( 'sportspress_event_show_position', 'yes' ) && taxonomy_exists( 'sp_position' ) ) :
+ $args = array(
+ 'hide_empty' => false,
+ 'parent' => 0,
'include_children' => true,
);
$positions = get_terms( 'sp_position', $args );
@@ -55,7 +60,7 @@ class SP_Meta_Box_Event_Performance {
// Apply filters to labels
$labels = apply_filters( 'sportspress_event_performance_labels_admin', $labels );
-
+
// Check if individual mode
$is_individual = 'player' === sp_get_post_mode( $post->ID );
@@ -95,27 +100,29 @@ class SP_Meta_Box_Event_Performance {
$team_id ):
- if ( -1 == $team_id ) continue;
+ foreach ( $teams as $key => $team_id ) :
+ if ( -1 == $team_id ) {
+ continue;
+ }
// Get results for players in the team
- $players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key );
+ $players = sp_array_between( (array) get_post_meta( $post_id, 'sp_player', false ), 0, $key );
$players[] = -1;
- $data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
+ $data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
// Get team timeline
- if ( is_array( $timeline ) ):
+ if ( is_array( $timeline ) ) :
$team_timeline = (array) sp_array_value( $timeline, $team_id, array() );
- else:
+ else :
$team_timeline = false;
endif;
- foreach ( $data as $player_id => $player_performance ):
+ foreach ( $data as $player_id => $player_performance ) :
// Get player timeline
- if ( is_array( $team_timeline ) ):
+ if ( is_array( $team_timeline ) ) :
$player_timeline = (array) sp_array_value( $team_timeline, $player_id, array() );
- else:
+ else :
$player_timeline = false;
endif;
@@ -129,27 +136,46 @@ class SP_Meta_Box_Event_Performance {
$team_id ):
- if ( -1 == $team_id ) continue;
-
+
+ foreach ( $teams as $key => $team_id ) :
+ if ( -1 == $team_id ) {
+ continue;
+ }
+
if ( -1 == $sections ) {
// Get results for players in the team
- $players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key );
+ $players = sp_array_between( (array) get_post_meta( $post_id, 'sp_player', false ), 0, $key );
$players[] = -1;
- $data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
+ $data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
// Get team timeline
- if ( is_array( $timeline ) ):
+ if ( is_array( $timeline ) ) :
$team_timeline = (array) sp_array_value( $timeline, $team_id, array() );
- else:
+ else :
$team_timeline = false;
endif;
?>
-
+
@@ -158,21 +184,21 @@ class SP_Meta_Box_Event_Performance {
'sp_performance',
- 'numberposts' => 100,
+ 'post_type' => 'sp_performance',
+ 'numberposts' => 100,
'posts_per_page' => 100,
- 'orderby' => 'menu_order',
- 'order' => 'ASC',
- 'meta_query' => array(
- 'relation' => 'OR',
+ 'orderby' => 'menu_order',
+ 'order' => 'ASC',
+ 'meta_query' => array(
+ 'relation' => 'OR',
array(
- 'key' => 'sp_format',
- 'value' => 'number',
+ 'key' => 'sp_format',
+ 'value' => 'number',
'compare' => 'NOT EXISTS',
),
array(
- 'key' => 'sp_format',
- 'value' => 'equation',
+ 'key' => 'sp_format',
+ 'value' => 'equation',
'compare' => '!=',
),
),
@@ -181,12 +207,12 @@ class SP_Meta_Box_Event_Performance {
$performances = get_posts( $args );
$labels = array( array(), array() );
- foreach ( $performances as $performance ):
+ foreach ( $performances as $performance ) :
$section = get_post_meta( $performance->ID, 'sp_section', true );
if ( '' === $section ) {
$section = -1;
}
- switch ( $section ):
+ switch ( $section ) :
case 1:
$labels[1][ $performance->post_name ] = $performance->post_title;
break;
@@ -194,47 +220,65 @@ class SP_Meta_Box_Event_Performance {
$labels[0][ $performance->post_name ] = $performance->post_title;
endswitch;
endforeach;
-
- $offense = (array)get_post_meta( $post_id, 'sp_offense', false );
- $defense = (array)get_post_meta( $post_id, 'sp_defense', false );
- $data = array();
+
+ $offense = (array) get_post_meta( $post_id, 'sp_offense', false );
+ $defense = (array) get_post_meta( $post_id, 'sp_defense', false );
+ $data = array();
if ( sizeof( $offense ) || sizeof( $defense ) ) {
// Get results for offensive players in the team
- $offense = sp_array_between( $offense, 0, $key );
+ $offense = sp_array_between( $offense, 0, $key );
$offense[] = -1;
- $data[0] = sp_array_combine( $offense, sp_array_value( $stats, $team_id, array() ) );
-
+ $data[0] = sp_array_combine( $offense, sp_array_value( $stats, $team_id, array() ) );
+
// Get results for defensive players in the team
- $defense = sp_array_between( $defense, 0, $key );
+ $defense = sp_array_between( $defense, 0, $key );
$defense[] = -1;
- $data[1] = sp_array_combine( $defense, sp_array_value( $stats, $team_id, array() ) );
+ $data[1] = sp_array_combine( $defense, sp_array_value( $stats, $team_id, array() ) );
} else {
// Get results for all players in the team
- $players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key );
+ $players = sp_array_between( (array) get_post_meta( $post_id, 'sp_player', false ), 0, $key );
$players[] = -1;
- $data[0] = $data[1] = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
+ $data[0] = $data[1] = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
}
// Get team timeline
- if ( is_array( $timeline ) ):
+ if ( is_array( $timeline ) ) :
$team_timeline = (array) sp_array_value( $timeline, $team_id, array() );
- else:
+ else :
$team_timeline = false;
endif;
-
+
// Determine order of sections
if ( 1 == $sections ) {
- $section_order = array( 1 => __( 'Defense', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ) );
+ $section_order = array(
+ 1 => __( 'Defense', 'sportspress' ),
+ 0 => __( 'Offense', 'sportspress' ),
+ );
} else {
$section_order = array( __( 'Offense', 'sportspress' ), __( 'Defense', 'sportspress' ) );
}
-
+
foreach ( $section_order as $section_id => $section_label ) {
?>
—
-
+
@@ -259,11 +303,11 @@ class SP_Meta_Box_Event_Performance {
$player_performance ):
+ foreach ( $data as $player_id => $player_performance ) :
// Get player timeline
- if ( is_array( $team_timeline ) ):
+ if ( is_array( $team_timeline ) ) :
$player_timeline = (array) sp_array_value( $team_timeline, $player_id, array() );
- else:
+ else :
$player_timeline = false;
endif;
@@ -315,22 +359,28 @@ class SP_Meta_Box_Event_Performance {
- $label ): ?>
-
+ $label ) : ?>
+
-
-
+
+
>
-
+
-
+
@@ -363,13 +413,16 @@ class SP_Meta_Box_Event_Performance {
- $label ):
- if ( 'equation' === sp_array_value( $formats, $column, 'number' ) ) continue;
- $player_id = 0;
+ $label ) :
+ if ( 'equation' === sp_array_value( $formats, $column, 'number' ) ) {
+ continue;
+ }
+ $player_id = 0;
$player_performance = sp_array_value( $data, $player_id, array() );
- $value = sp_array_value( $player_performance, $column, '' );
- $format = sp_array_value( $formats, $column, 'number' );
- $placeholder = sp_get_format_placeholder( $format );
+ $value = sp_array_value( $player_performance, $column, '' );
+ $format = sp_array_value( $formats, $column, 'number' );
+ $placeholder = sp_get_format_placeholder( $format );
?>
@@ -389,10 +442,12 @@ class SP_Meta_Box_Event_Performance {
* Admin edit table row
*/
public static function row( $labels = array(), $player_id = 0, $player_performance = array(), $team_id = 0, $data = array(), $positions = true, $status = true, $sortable = true, $numbers = true, $section = -1, $formats = array(), $player_timeline = array(), $timed = array(), $stars = array() ) {
- if ( $player_id <= 0 ) return;
+ if ( $player_id <= 0 ) {
+ return;
+ }
$stars_type = get_option( 'sportspress_event_performance_stars_type', 0 );
- $value = sp_array_value( $player_performance, 'number', '' );
+ $value = sp_array_value( $player_performance, 'number', '' );
?>
@@ -413,51 +468,55 @@ class SP_Meta_Box_Event_Performance {
'sp_position',
- 'name' => 'sp_players[' . $team_id . '][' . $player_id . '][position][]',
- 'values' => 'term_id',
- 'orderby' => 'meta_value_num',
- 'meta_query' => array(
+ 'taxonomy' => 'sp_position',
+ 'name' => 'sp_players[' . $team_id . '][' . $player_id . '][position][]',
+ 'values' => 'term_id',
+ 'orderby' => 'meta_value_num',
+ 'meta_query' => array(
'relation' => 'OR',
array(
- 'key' => 'sp_order',
- 'compare' => 'NOT EXISTS'
+ 'key' => 'sp_order',
+ 'compare' => 'NOT EXISTS',
),
array(
- 'key' => 'sp_order',
- 'compare' => 'EXISTS'
+ 'key' => 'sp_order',
+ 'compare' => 'EXISTS',
),
),
- 'selected' => $selected,
- 'class' => 'sp-position',
- 'property' => 'multiple',
- 'chosen' => true,
+ 'selected' => $selected,
+ 'class' => 'sp-position',
+ 'property' => 'multiple',
+ 'chosen' => true,
'include_children' => ( 'no' == get_option( 'sportspress_event_hide_child_positions', 'no' ) ),
);
sp_dropdown_taxonomies( $args );
?>
- $label ):
- if ( 'equation' === sp_array_value( $formats, $column, 'number' ) ) continue;
- $value = sp_array_value( $player_performance, $column, '' );
- $intval = intval( $value );
+ $label ) :
+ if ( 'equation' === sp_array_value( $formats, $column, 'number' ) ) {
+ continue;
+ }
+ $value = sp_array_value( $player_performance, $column, '' );
+ $intval = intval( $value );
$placeholder = sp_get_format_placeholder( sp_array_value( $formats, $column, 'number' ) );
?>
@@ -479,11 +538,14 @@ class SP_Meta_Box_Event_Performance {
} else {
$times = false;
}
-
+
if ( is_array( $times ) ) {
?>
-
+
+
__( 'Starting Lineup', 'sportspress' ),
- 'sub' => __( 'Substitute', 'sportspress' ),
- ) );
+ $options = apply_filters(
+ 'sportspress_event_performance_status_options',
+ array(
+ 'lineup' => __( 'Starting Lineup', 'sportspress' ),
+ 'sub' => __( 'Substitute', 'sportspress' ),
+ )
+ );
$output = '';
- foreach( $options as $key => $name ):
+ foreach ( $options as $key => $name ) :
$output .= '' . $name . ' ';
endforeach;
@@ -556,17 +622,20 @@ class SP_Meta_Box_Event_Performance {
*/
public static function sub_select( $team_id, $player_id, $value, $data = array() ) {
- if ( ! $team_id || ! $player_id )
+ if ( ! $team_id || ! $player_id ) {
return '—';
+ }
$output = '';
$output .= '' . __( 'None', 'sportspress' ) . ' ';
// Add players as selectable options
- foreach( $data as $id => $performance ):
- if ( ! $id || $id == $player_id ) continue;
- $number = get_post_meta( $id, 'sp_number', true );
+ foreach ( $data as $id => $performance ) :
+ if ( ! $id || $id == $player_id ) {
+ continue;
+ }
+ $number = get_post_meta( $id, 'sp_number', true );
$output .= '' . ( $number ? $number . '. ' : '' ) . get_the_title( $id ) . ' ';
endforeach;
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-results.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-results.php
index b01aaaa3..4dca92fd 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-results.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-results.php
@@ -2,13 +2,15 @@
/**
* Event Results
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Event_Results
@@ -20,12 +22,13 @@ class SP_Meta_Box_Event_Results {
*/
public static function output( $post ) {
// Determine if we need checkboxes
- if ( 'manual' == get_option( 'sportspress_event_result_columns', 'auto' ) )
+ if ( 'manual' == get_option( 'sportspress_event_result_columns', 'auto' ) ) {
$has_checkboxes = true;
- else
+ } else {
$has_checkboxes = false;
+ }
- $event = new SP_Event( $post );
+ $event = new SP_Event( $post );
list( $columns, $usecolumns, $data ) = $event->results( true );
self::table( $columns, $usecolumns, $data, $has_checkboxes );
}
@@ -34,7 +37,7 @@ class SP_Meta_Box_Event_Results {
* Save meta box data
*/
public static function save( $post_id, $post ) {
- $results = (array)sp_array_value( $_POST, 'sp_results', array(), 'text' );
+ $results = (array) sp_array_value( $_POST, 'sp_results', array(), 'text' );
$main_result = get_option( 'sportspress_primary_result', null );
// Get player performance
@@ -57,15 +60,25 @@ class SP_Meta_Box_Event_Results {
if ( ! $finished ) {
foreach ( $performance as $team => $players ) {
foreach ( $players as $player => $pp ) {
- if ( 0 >= $player ) continue;
+ if ( 0 >= $player ) {
+ continue;
+ }
foreach ( $pp as $pk => $pv ) {
- if ( in_array( $pk, apply_filters( 'sportspress_event_auto_result_bypass_keys', array( 'number', 'status', 'sub' ) ) ) ) continue;
+ if ( in_array( $pk, apply_filters( 'sportspress_event_auto_result_bypass_keys', array( 'number', 'status', 'sub' ) ) ) ) {
+ continue;
+ }
- if ( is_array( $pv ) ) continue;
+ if ( is_array( $pv ) ) {
+ continue;
+ }
$pv = trim( $pv );
- if ( '' == $pv ) continue;
- if ( ! ctype_digit( $pv ) ) continue;
+ if ( '' == $pv ) {
+ continue;
+ }
+ if ( ! ctype_digit( $pv ) ) {
+ continue;
+ }
$finished = true;
break;
@@ -73,16 +86,16 @@ class SP_Meta_Box_Event_Results {
}
}
}
-
+
if ( $finished ) {
// Get results with equations
- $args = array(
- 'post_type' => 'sp_result',
- 'numberposts' => -1,
+ $args = array(
+ 'post_type' => 'sp_result',
+ 'numberposts' => -1,
'posts_per_page' => -1,
- 'meta_query' => array(
+ 'meta_query' => array(
array(
- 'key' => 'sp_equation',
+ 'key' => 'sp_equation',
'compare' => 'EXISTS',
),
),
@@ -96,25 +109,26 @@ class SP_Meta_Box_Event_Results {
$precision[ $result->post_name ] = (int) get_post_meta( $result->ID, 'sp_precision', true );
}
-
// Apply equations to empty results
foreach ( $equations as $key => $equation ) {
- if ( '' == $equation ) continue;
+ if ( '' == $equation ) {
+ continue;
+ }
foreach ( $results as $team => $team_results ) {
- if ( '' === sp_array_value( $team_results, $key, '' ) ) {
- $totals = array();
+ if ( '' === sp_array_value( $team_results, $key, '' ) ) {
+ $totals = array();
$players = sp_array_value( $performance, $team, array() );
foreach ( $players as $player => $pp ) {
foreach ( $pp as $pk => $pv ) {
- $value = sp_array_value( $totals, $pk, 0 );
- $value += floatval( $pv );
+ $value = sp_array_value( $totals, $pk, 0 );
+ $value += floatval( $pv );
$totals[ $pk ] = $value;
}
}
- $totals[ 'eventsplayed' ] = 1;
- $totals = apply_filters( 'sportspress_event_result_equation_vars', $totals, $performance, $team );
- $results[ $team ][ $key ] = sp_solve( $equation, $totals, sp_array_value( $precision, $key, 0 ), '' );
- }
+ $totals['eventsplayed'] = 1;
+ $totals = apply_filters( 'sportspress_event_result_equation_vars', $totals, $performance, $team );
+ $results[ $team ][ $key ] = sp_solve( $equation, $totals, sp_array_value( $precision, $key, 0 ), '' );
+ }
}
}
}
@@ -138,55 +152,61 @@ class SP_Meta_Box_Event_Results {
if ( count( $primary_results ) && ! in_array( null, $primary_results ) ) {
if ( count( array_unique( $primary_results ) ) === 1 ) {
- $args = array(
- 'post_type' => 'sp_outcome',
- 'numberposts' => -1,
+ $args = array(
+ 'post_type' => 'sp_outcome',
+ 'numberposts' => -1,
'posts_per_page' => -1,
- 'meta_key' => 'sp_condition',
- 'meta_value' => '=',
+ 'meta_key' => 'sp_condition',
+ 'meta_value' => '=',
);
$outcomes = get_posts( $args );
foreach ( $results as $team => $team_results ) {
- if ( array_key_exists( 'outcome', $team_results ) ) continue;
+ if ( array_key_exists( 'outcome', $team_results ) ) {
+ continue;
+ }
if ( $outcomes ) {
- $results[ $team ][ 'outcome' ] = array();
+ $results[ $team ]['outcome'] = array();
foreach ( $outcomes as $outcome ) {
- $results[ $team ][ 'outcome' ][] = $outcome->post_name;
+ $results[ $team ]['outcome'][] = $outcome->post_name;
}
}
}
} else {
// Get default outcomes
- $args = array(
- 'post_type' => 'sp_outcome',
- 'numberposts' => -1,
+ $args = array(
+ 'post_type' => 'sp_outcome',
+ 'numberposts' => -1,
'posts_per_page' => -1,
- 'meta_key' => 'sp_condition',
- 'meta_value' => 'else',
+ 'meta_key' => 'sp_condition',
+ 'meta_value' => 'else',
);
$default_outcomes = get_posts( $args );
// Get greater than outcomes
- $args = array(
- 'post_type' => 'sp_outcome',
- 'numberposts' => -1,
+ $args = array(
+ 'post_type' => 'sp_outcome',
+ 'numberposts' => -1,
'posts_per_page' => -1,
- 'meta_key' => 'sp_condition',
- 'meta_value' => '>',
+ 'meta_key' => 'sp_condition',
+ 'meta_value' => '>',
);
$gt_outcomes = get_posts( $args );
- if ( empty ( $gt_outcomes ) ) $gt_outcomes = $default_outcomes;
+ if ( empty( $gt_outcomes ) ) {
+ $gt_outcomes = $default_outcomes;
+ }
// Get less than outcomes
- $args = array(
- 'post_type' => 'sp_outcome',
- 'numberposts' => -1,
+ $args = array(
+ 'post_type' => 'sp_outcome',
+ 'numberposts' => -1,
'posts_per_page' => -1,
- 'meta_key' => 'sp_condition',
- 'meta_value' => '<',
+ 'meta_key' => 'sp_condition',
+ 'meta_value' => '<',
);
$lt_outcomes = get_posts( $args );
- if ( empty ( $lt_outcomes ) ) $lt_outcomes = $default_outcomes;
+ if ( empty( $lt_outcomes ) ) {
+ $lt_outcomes = $default_outcomes;
+ }
// Get min and max values
$min = min( $primary_results );
@@ -201,9 +221,9 @@ class SP_Meta_Box_Event_Results {
} else {
$outcomes = $default_outcomes;
}
- $results[ $key ][ 'outcome' ] = array();
+ $results[ $key ]['outcome'] = array();
foreach ( $outcomes as $outcome ) {
- $results[ $key ][ 'outcome' ][] = $outcome->post_name;
+ $results[ $key ]['outcome'][] = $outcome->post_name;
}
}
}
@@ -220,20 +240,20 @@ class SP_Meta_Box_Event_Results {
*/
public static function table( $columns = array(), $usecolumns = array(), $data = array(), $has_checkboxes = false ) {
// Get results with equations
- $args = array(
- 'post_type' => 'sp_result',
- 'numberposts' => -1,
+ $args = array(
+ 'post_type' => 'sp_result',
+ 'numberposts' => -1,
'posts_per_page' => -1,
- 'meta_query' => array(
+ 'meta_query' => array(
array(
- 'key' => 'sp_equation',
+ 'key' => 'sp_equation',
'compare' => 'NOT IN',
- 'value' => null
+ 'value' => null,
),
),
);
$dynamic_results = get_posts( $args );
- $auto_columns = wp_list_pluck( $dynamic_results, 'post_name' );
+ $auto_columns = wp_list_pluck( $dynamic_results, 'post_name' );
?>
@@ -242,14 +262,14 @@ class SP_Meta_Box_Event_Results {
- $label ): ?>
+ $label ) : ?>
-
+
>
-
+
@@ -262,35 +282,48 @@ class SP_Meta_Box_Event_Results {
$team_results ):
- if ( ! $team_id || -1 == $team_id ) continue;
+ foreach ( $data as $team_id => $team_results ) :
+ if ( ! $team_id || -1 == $team_id ) {
+ continue;
+ }
?>
-
+
- $label ):
+ $label ) :
$value = sp_array_value( $team_results, $column, '' );
?>
- placeholder="" />
+
+ placeholder="" />
'sp_outcome',
- 'name' => 'sp_results[' . $team_id . '][outcome][]',
+ 'post_type' => 'sp_outcome',
+ 'name' => 'sp_results[' . $team_id . '][outcome][]',
'option_none_value' => '',
- 'sort_order' => 'ASC',
- 'sort_column' => 'menu_order',
- 'selected' => $values,
- 'class' => 'sp-outcome',
- 'property' => 'multiple',
- 'chosen' => true,
- 'placeholder' => __( '(Auto)', 'sportspress' ),
+ 'sort_order' => 'ASC',
+ 'sort_column' => 'menu_order',
+ 'selected' => $values,
+ 'class' => 'sp-outcome',
+ 'property' => 'multiple',
+ 'chosen' => true,
+ 'placeholder' => __( '(Auto)', 'sportspress' ),
);
sp_dropdown_pages( $args );
?>
@@ -305,4 +338,4 @@ class SP_Meta_Box_Event_Results {
__( 'Results', 'sportspress' ),
- 'event_details' => __( 'Details', 'sportspress' ),
- 'event_performance' => __( 'Box Score', 'sportspress' ),
- 'event_venue' => __( 'Venue', 'sportspress' ),
- 'event_officials' => __( 'Officials', 'sportspress' ),
- 'event_teams' => __( 'Teams', 'sportspress' ),
- 'event_full' => __( 'Full Info', 'sportspress' ),
- ) );
+ $shortcodes = apply_filters(
+ 'sportspress_event_shortcodes',
+ array(
+ 'event_results' => __( 'Results', 'sportspress' ),
+ 'event_details' => __( 'Details', 'sportspress' ),
+ 'event_performance' => __( 'Box Score', 'sportspress' ),
+ 'event_venue' => __( 'Venue', 'sportspress' ),
+ 'event_officials' => __( 'Officials', 'sportspress' ),
+ 'event_teams' => __( 'Teams', 'sportspress' ),
+ 'event_full' => __( 'Full Info', 'sportspress' ),
+ )
+ );
if ( $shortcodes ) {
- ?>
+ ?>
- $label ) { ?>
+ $label ) { ?>
- ID, 'sp_specs', true );
$args = array(
- 'post_type' => 'sp_spec',
- 'numberposts' => -1,
+ 'post_type' => 'sp_spec',
+ 'numberposts' => -1,
'posts_per_page' => -1,
- 'orderby' => 'menu_order',
- 'order' => 'ASC',
+ 'orderby' => 'menu_order',
+ 'order' => 'ASC',
);
$vars = get_posts( $args );
- if ( $vars ):
- foreach ( $vars as $var ):
- ?>
+ if ( $vars ) :
+ foreach ( $vars as $var ) :
+ ?>
post_title ); ?>
- ID, 'sp_team', false );
+ $limit = get_option( 'sportspress_event_teams', 2 );
+ $teams = (array) get_post_meta( $post->ID, 'sp_team', false );
$post_type = sp_get_post_mode_type( $post->ID );
if ( $limit && 'sp_player' !== $post_type ) {
- for ( $i = 0; $i < $limit; $i ++ ):
+ for ( $i = 0; $i < $limit; $i ++ ) :
$team = array_shift( $teams );
?>
$post_type,
- 'name' => 'sp_team[]',
- 'class' => 'sportspress-pages',
+ 'post_type' => $post_type,
+ 'name' => 'sp_team[]',
+ 'class' => 'sportspress-pages',
'show_option_none' => __( '— None —', 'sportspress' ),
- 'values' => 'ID',
- 'selected' => $team,
- 'chosen' => true,
- 'tax_query' => array(),
+ 'values' => 'ID',
+ 'selected' => $team,
+ 'chosen' => true,
+ 'tax_query' => array(),
);
if ( 'yes' == get_option( 'sportspress_event_filter_teams_by_league', 'no' ) ) {
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
if ( $league_id ) {
$args['tax_query'][] = array(
'taxonomy' => 'sp_league',
- 'terms' => $league_id,
+ 'terms' => $league_id,
);
}
}
@@ -53,7 +55,7 @@ class SP_Meta_Box_Event_Teams {
if ( $season_id ) {
$args['tax_query'][] = array(
'taxonomy' => 'sp_season',
- 'terms' => $season_id,
+ 'terms' => $season_id,
);
}
}
@@ -64,34 +66,34 @@ class SP_Meta_Box_Event_Teams {
?>
__( 'Offense', 'sportspress' ),
+ 'label' => __( 'Offense', 'sportspress' ),
'post_type' => 'sp_player',
);
$tabs['sp_defense'] = array(
- 'label' => __( 'Defense', 'sportspress' ),
+ 'label' => __( 'Defense', 'sportspress' ),
'post_type' => 'sp_player',
);
} elseif ( 1 == $sections ) {
$tabs['sp_defense'] = array(
- 'label' => __( 'Defense', 'sportspress' ),
+ 'label' => __( 'Defense', 'sportspress' ),
'post_type' => 'sp_player',
);
$tabs['sp_offense'] = array(
- 'label' => __( 'Offense', 'sportspress' ),
+ 'label' => __( 'Offense', 'sportspress' ),
'post_type' => 'sp_player',
);
} else {
$tabs['sp_player'] = array(
- 'label' => __( 'Players', 'sportspress' ),
+ 'label' => __( 'Players', 'sportspress' ),
'post_type' => 'sp_player',
);
}
$tabs['sp_staff'] = array(
- 'label' => __( 'Staff', 'sportspress' ),
+ 'label' => __( 'Staff', 'sportspress' ),
'post_type' => 'sp_staff',
);
?>
@@ -99,21 +101,25 @@ class SP_Meta_Box_Event_Teams {
$tab ) {
- ?>
-
+ foreach ( $tabs as $slug => $tab ) {
+ ?>
+
- $tab ) {
do_action( 'sportspress_event_teams_meta_box_checklist', $post->ID, $tab['post_type'], ( 0 == $j ? 'block' : 'none' ), $team, $i, $slug );
$j++;
}
- ?>
+ ?>
ID ) ); ?>
$post_type,
- 'name' => 'sp_team[]',
- 'selected' => $teams,
- 'values' => 'ID',
- 'class' => 'widefat',
- 'property' => 'multiple',
- 'chosen' => true,
+ 'post_type' => $post_type,
+ 'name' => 'sp_team[]',
+ 'selected' => $teams,
+ 'values' => 'ID',
+ 'class' => 'widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
'placeholder' => __( 'None', 'sportspress' ),
);
- if ( ! sp_dropdown_pages( $args ) ):
- sp_post_adder( $post_type, __( 'Add New', 'sportspress' ) );
+ if ( ! sp_dropdown_pages( $args ) ) :
+ sp_post_adder( $post_type, __( 'Add New', 'sportspress' ) );
endif;
}
wp_nonce_field( 'sp-get-players', 'sp-get-players-nonce', false );
@@ -156,7 +162,7 @@ class SP_Meta_Box_Event_Teams {
}
sp_update_post_meta_recursive( $post_id, 'sp_player', $players );
} else {
- $tabs = array();
+ $tabs = array();
$sections = get_option( 'sportspress_event_performance_sections', -1 );
if ( -1 == $sections ) {
sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array(), 'int' ) );
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-video.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-video.php
index c5f6d346..b9153bac 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-video.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-video.php
@@ -2,13 +2,15 @@
/**
* Event Video
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Event_Video
@@ -20,8 +22,8 @@ class SP_Meta_Box_Event_Video {
*/
public static function output( $post ) {
$video = get_post_meta( $post->ID, 'sp_video', true );
- if ( $video ):
- ?>
+ if ( $video ) :
+ ?>
@@ -32,7 +34,11 @@ class SP_Meta_Box_Event_Video {
-
+
ID, 'sp_columns', true );
- $orderby = get_post_meta( $post->ID, 'sp_orderby', true );
+ $selected = (array) get_post_meta( $post->ID, 'sp_columns', true );
+ $orderby = get_post_meta( $post->ID, 'sp_orderby', true );
?>
@@ -33,7 +35,8 @@ class SP_Meta_Box_List_Columns {
} else {
_e( 'Rank', 'sportspress' );
}
- ?>
+ ?>
+
@@ -72,4 +75,4 @@ class SP_Meta_Box_List_Columns {
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array(), 'key' ) );
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php
index 00c48dd7..9f58ae0f 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php
@@ -2,13 +2,15 @@
/**
* List Data
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_List_Data
@@ -21,8 +23,8 @@ class SP_Meta_Box_List_Data {
public static function output( $post ) {
global $pagenow;
if ( is_admin() && in_array( $pagenow, array( 'post-new.php' ) ) && 'sp_list' == get_post_type() ) {
- self::table( );
- }else{
+ self::table();
+ } else {
$list = new SP_Player_List( $post );
list( $columns, $data, $placeholders, $merged, $orderby ) = $list->data( true );
$adjustments = $list->adjustments;
@@ -62,8 +64,11 @@ class SP_Meta_Box_List_Data {
- $label ): ?>
-
+ $label ) : ?>
+
@@ -72,19 +77,27 @@ class SP_Meta_Box_List_Data {
0 ):
+ if ( is_array( $data ) && sizeof( $data ) > 0 ) :
$i = 0;
- foreach ( $data as $player_id => $player_stats ):
- if ( !$player_id ) continue;
- $teams = get_post_meta( $player_id, 'sp_team', false );
- $div = get_term( $player_id, 'sp_season' );
+ foreach ( $data as $player_id => $player_stats ) :
+ if ( ! $player_id ) {
+ continue;
+ }
+ $teams = get_post_meta( $player_id, 'sp_team', false );
+ $div = get_term( $player_id, 'sp_season' );
$number = get_post_meta( $player_id, 'sp_number', true );
$default_name = sp_array_value( $player_stats, 'name', '' );
- if ( $default_name == null )
+ if ( $default_name == null ) {
$default_name = get_the_title( $player_id );
+ }
?>
-
+
-
+
@@ -112,14 +128,16 @@ class SP_Meta_Box_List_Data {
'sp_team',
- 'name' => 'sp_players[' . $player_id . '][team]',
- 'include' => $include,
- 'selected' => $selected,
- 'values' => 'ID',
+ 'name' => 'sp_players[' . $player_id . '][team]',
+ 'include' => $include,
+ 'selected' => $selected,
+ 'values' => 'ID',
);
wp_dropdown_pages( $args );
?>
@@ -129,33 +147,36 @@ class SP_Meta_Box_List_Data {
'sp_position',
- 'name' => 'sp_players[' . $player_id . '][position]',
+ $args = array(
+ 'taxonomy' => 'sp_position',
+ 'name' => 'sp_players[' . $player_id . '][position]',
'show_option_blank' => __( '(Auto)', 'sportspress' ),
- 'values' => 'term_id',
- 'orderby' => 'meta_value_num',
+ 'values' => 'term_id',
+ 'orderby' => 'meta_value_num',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'sp_order',
- 'compare' => 'NOT EXISTS'
+ 'compare' => 'NOT EXISTS',
),
array(
'key' => 'sp_order',
- 'compare' => 'EXISTS'
+ 'compare' => 'EXISTS',
),
),
- 'selected' => $selected,
+ 'selected' => $selected,
'include_children' => ( 'no' == get_option( 'sportspress_event_hide_child_positions', 'no' ) ),
);
sp_dropdown_taxonomies( $args );
?>
- $label ):
- if ( in_array( $column, array( 'number', 'team', 'position' ) ) ) continue;
- $value = sp_array_value( $player_stats, $column, '' );
+ $label ) :
+ if ( in_array( $column, array( 'number', 'team', 'position' ) ) ) {
+ continue;
+ }
+ $value = sp_array_value( $player_stats, $column, '' );
$placeholder = sp_array_value( sp_array_value( $placeholders, $player_id, array() ), $column, 0 );
?>
@@ -164,14 +185,19 @@ class SP_Meta_Box_List_Data {
+ else :
+ ?>
-
+
-
@@ -183,27 +209,41 @@ class SP_Meta_Box_List_Data {
#
- $label ): if ( in_array( $key, array( 'number', 'team', 'position' ) ) ) continue; ?>
+ $label ) :
+ if ( in_array( $key, array( 'number', 'team', 'position' ) ) ) {
+ continue;}
+ ?>
0 ):
+ if ( is_array( $data ) && sizeof( $data ) > 0 ) :
$i = 0;
- foreach ( $data as $player_id => $player_stats ):
- if ( !$player_id ) continue;
- $div = get_term( $player_id, 'sp_season' );
+ foreach ( $data as $player_id => $player_stats ) :
+ if ( ! $player_id ) {
+ continue;
+ }
+ $div = get_term( $player_id, 'sp_season' );
$number = get_post_meta( $player_id, 'sp_number', true );
?>
-
+
- $label ):
- if ( in_array( $column, array( 'number', 'team', 'position' ) ) ) continue;
+ $label ) :
+ if ( in_array( $column, array( 'number', 'team', 'position' ) ) ) {
+ continue;
+ }
$value = sp_array_value( sp_array_value( $adjustments, $player_id, array() ), $column, '' );
?>
@@ -212,14 +252,19 @@ class SP_Meta_Box_List_Data {
+ else :
+ ?>
-
+
-
@@ -227,4 +272,4 @@ class SP_Meta_Box_List_Data {
ID, 'sp_caption', true );
- $team_id = get_post_meta( $post->ID, 'sp_team', true );
- $era = get_post_meta( $post->ID, 'sp_era', true );
- $grouping = get_post_meta( $post->ID, 'sp_grouping', true );
- $orderby = get_post_meta( $post->ID, 'sp_orderby', true );
- $order = get_post_meta( $post->ID, 'sp_order', true );
- $select = get_post_meta( $post->ID, 'sp_select', true );
- $number = get_post_meta( $post->ID, 'sp_number', true );
- $crop = get_post_meta( $post->ID, 'sp_crop', true );
- $date = get_post_meta( $post->ID, 'sp_date', true );
- $date_from = get_post_meta( $post->ID, 'sp_date_from', true );
- $date_to = get_post_meta( $post->ID, 'sp_date_to', true );
- $date_past = get_post_meta( $post->ID, 'sp_date_past', true );
- $date_relative = get_post_meta( $post->ID, 'sp_date_relative', true );
- $continents = SP()->countries->continents;
- $nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
- $default_nationality = get_option( 'sportspress_default_nationality' , false );
+ $taxonomies = get_object_taxonomies( 'sp_list' );
+ $caption = get_post_meta( $post->ID, 'sp_caption', true );
+ $team_id = get_post_meta( $post->ID, 'sp_team', true );
+ $era = get_post_meta( $post->ID, 'sp_era', true );
+ $grouping = get_post_meta( $post->ID, 'sp_grouping', true );
+ $orderby = get_post_meta( $post->ID, 'sp_orderby', true );
+ $order = get_post_meta( $post->ID, 'sp_order', true );
+ $select = get_post_meta( $post->ID, 'sp_select', true );
+ $number = get_post_meta( $post->ID, 'sp_number', true );
+ $crop = get_post_meta( $post->ID, 'sp_crop', true );
+ $date = get_post_meta( $post->ID, 'sp_date', true );
+ $date_from = get_post_meta( $post->ID, 'sp_date_from', true );
+ $date_to = get_post_meta( $post->ID, 'sp_date_to', true );
+ $date_past = get_post_meta( $post->ID, 'sp_date_past', true );
+ $date_relative = get_post_meta( $post->ID, 'sp_date_relative', true );
+ $continents = SP()->countries->continents;
+ $nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
+ $default_nationality = get_option( 'sportspress_default_nationality', false );
?>
@@ -47,8 +49,8 @@ class SP_Meta_Box_List_Details {
'sp_date',
- 'id' => 'sp_date',
+ 'name' => 'sp_date',
+ 'id' => 'sp_date',
'selected' => $date,
);
sp_dropdown_dates( $args );
@@ -85,13 +87,13 @@ class SP_Meta_Box_List_Details {
'sp_team',
- 'name' => 'sp_team',
+ 'post_type' => 'sp_team',
+ 'name' => 'sp_team',
'show_option_all' => __( 'All', 'sportspress' ),
- 'selected' => $team_id,
- 'values' => 'ID',
+ 'selected' => $team_id,
+ 'values' => 'ID',
);
- if ( ! sp_dropdown_pages( $args ) ):
+ if ( ! sp_dropdown_pages( $args ) ) :
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
@@ -103,12 +105,16 @@ class SP_Meta_Box_List_Details {
-
+
- $countries ): ?>
+ $countries ) : ?>
- $country ): ?>
- >
+ $country ) : ?>
+ >
@@ -127,12 +133,12 @@ class SP_Meta_Box_List_Details {
$args = array(
'prepend_options' => array(
'number' => __( 'Squad Number', 'sportspress' ),
- 'name' => __( 'Name', 'sportspress' ),
+ 'name' => __( 'Name', 'sportspress' ),
),
- 'post_type' => array( 'sp_performance', 'sp_metric', 'sp_statistic' ),
- 'name' => 'sp_orderby',
- 'selected' => $orderby,
- 'values' => 'slug',
+ 'post_type' => array( 'sp_performance', 'sp_metric', 'sp_statistic' ),
+ 'name' => 'sp_orderby',
+ 'selected' => $orderby,
+ 'values' => 'slug',
);
sp_dropdown_pages( $args );
?>
@@ -160,11 +166,11 @@ class SP_Meta_Box_List_Details {
ID, 'sp_format', true );
?>
- formats->list as $key => $format ): ?>
+ formats->list as $key => $format ) : ?>
>
@@ -36,4 +38,4 @@ class SP_Meta_Box_List_Format {
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'list', 'key' ) );
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-shortcode.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-shortcode.php
index 254d4bd1..72d232f8 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-shortcode.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-shortcode.php
@@ -2,13 +2,15 @@
/**
* List Shortcode
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
* @version 1.6.1
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_List_Shortcode
@@ -20,7 +22,9 @@ class SP_Meta_Box_List_Shortcode {
*/
public static function output( $post ) {
$the_format = get_post_meta( $post->ID, 'sp_format', true );
- if ( ! $the_format ) $the_format = 'list';
+ if ( ! $the_format ) {
+ $the_format = 'list';
+ }
?>
@@ -28,4 +32,4 @@ class SP_Meta_Box_List_Shortcode {
ID, 'sp_visible', true );
- if ( '' === $visible ) $visible = 1;
+ if ( '' === $visible ) {
+ $visible = 1;
+ }
?>
@@ -59,4 +64,4 @@ class SP_Meta_Box_Metric_Details extends SP_Meta_Box_Config {
self::delete_duplicate( $_POST );
update_post_meta( $post_id, 'sp_visible', sp_array_value( $_POST, 'sp_visible', 1, 'int' ) );
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-outcome-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-outcome-details.php
index 8cfeec8e..a9f52fff 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-outcome-details.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-outcome-details.php
@@ -2,16 +2,19 @@
/**
* Outcome Details
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Meta_Box_Config' ) )
- include( 'class-sp-meta-box-config.php' );
+if ( ! class_exists( 'SP_Meta_Box_Config' ) ) {
+ require 'class-sp-meta-box-config.php';
+}
/**
* SP_Meta_Box_Outcome_Details
@@ -30,18 +33,24 @@ class SP_Meta_Box_Outcome_Details extends SP_Meta_Box_Config {
$readonly = false;
}
$abbreviation = get_post_meta( $post->ID, 'sp_abbreviation', true );
- $color = get_post_meta( $post->ID, 'sp_color', true );
- $condition = get_post_meta( $post->ID, 'sp_condition', true );
- $main_result = get_option( 'sportspress_primary_result', null );
- $result = get_page_by_path( $main_result, ARRAY_A, 'sp_result' );
- $label = sp_array_value( $result, 'post_title', __( 'Primary', 'sportspress' ) );
-
- if ( '' === $color ) $color = '#888888';
+ $color = get_post_meta( $post->ID, 'sp_color', true );
+ $condition = get_post_meta( $post->ID, 'sp_condition', true );
+ $main_result = get_option( 'sportspress_primary_result', null );
+ $result = get_page_by_path( $main_result, ARRAY_A, 'sp_result' );
+ $label = sp_array_value( $result, 'post_title', __( 'Primary', 'sportspress' ) );
+
+ if ( '' === $color ) {
+ $color = '#888888';
+ }
?>
- readonly="readonly">
+
+ readonly="readonly">
@@ -52,21 +61,21 @@ class SP_Meta_Box_Outcome_Details extends SP_Meta_Box_Config {
+
'—',
- '>' => sprintf( __( 'Most %s', 'sportspress' ), $label ),
- '<' => sprintf( __( 'Least %s', 'sportspress' ), $label ),
- '=' => sprintf( __( 'Equal %s', 'sportspress' ), $label ),
+ '0' => '—',
+ '>' => sprintf( __( 'Most %s', 'sportspress' ), $label ),
+ '<' => sprintf( __( 'Least %s', 'sportspress' ), $label ),
+ '=' => sprintf( __( 'Equal %s', 'sportspress' ), $label ),
'else' => sprintf( __( 'Default', 'sportspress' ), $label ),
);
- foreach ( $options as $key => $value ):
+ foreach ( $options as $key => $value ) :
printf( '%s ', $key, selected( true, $key == $condition, false ), $value );
endforeach;
?>
@@ -83,4 +92,4 @@ class SP_Meta_Box_Outcome_Details extends SP_Meta_Box_Config {
update_post_meta( $post_id, 'sp_color', sp_array_value( $_POST, 'sp_color', array(), 'text' ) );
update_post_meta( $post_id, 'sp_condition', sp_array_value( $_POST, 'sp_condition', array(), 'text' ) );
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-details.php
index 079a0ad6..a3f8ff94 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-details.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-details.php
@@ -2,16 +2,19 @@
/**
* Performance Details
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Meta_Box_Config' ) )
- include( 'class-sp-meta-box-config.php' );
+if ( ! class_exists( 'SP_Meta_Box_Config' ) ) {
+ require 'class-sp-meta-box-config.php';
+}
/**
* SP_Meta_Box_Performance_Details
@@ -29,10 +32,10 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
} else {
$readonly = false;
}
-
+
// Post Meta
$singular = get_post_meta( $post->ID, 'sp_singular', true );
- $section = get_post_meta( $post->ID, 'sp_section', true );
+ $section = get_post_meta( $post->ID, 'sp_section', true );
if ( '' === $section ) {
$section = -1;
}
@@ -56,7 +59,11 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
- readonly="readonly">
+
+ readonly="readonly">
@@ -66,8 +73,18 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
__( 'All', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
- foreach ( $options as $key => $value ):
+ $options = apply_filters(
+ 'sportspress_performance_sections',
+ array(
+ -1 => __( 'All', 'sportspress' ),
+ 0 => __( 'Offense', 'sportspress' ),
+ 1 => __(
+ 'Defense',
+ 'sportspress'
+ ),
+ )
+ );
+ foreach ( $options as $key => $value ) :
printf( '%s ', $key, selected( $key == $section, true, false ), $value );
endforeach;
?>
@@ -77,8 +94,20 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
__( 'Number', 'sportspress' ), 'time' => __( 'Time', 'sportspress' ), 'text' => __( 'Text', 'sportspress' ), 'equation' => __( 'Equation', 'sportspress' ), 'checkbox' => __( 'Checkbox', 'sportspress' ) ) );
- foreach ( $options as $key => $value ):
+ $options = apply_filters(
+ 'sportspress_performance_formats',
+ array(
+ 'number' => __( 'Number', 'sportspress' ),
+ 'time' => __( 'Time', 'sportspress' ),
+ 'text' => __( 'Text', 'sportspress' ),
+ 'equation' => __( 'Equation', 'sportspress' ),
+ 'checkbox' => __(
+ 'Checkbox',
+ 'sportspress'
+ ),
+ )
+ );
+ foreach ( $options as $key => $value ) :
printf( '%s ', $key, selected( $key == $format, true, false ), $value );
endforeach;
?>
@@ -176,4 +205,4 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
update_post_meta( $post_id, 'sp_visible', sp_array_value( $_POST, 'sp_visible', 1, 'int' ) );
}
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-equation.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-equation.php
index 0b78bf08..349b9be9 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-equation.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-equation.php
@@ -2,16 +2,19 @@
/**
* Performance Equation
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
* @version 2.1.6
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Meta_Box_Equation' ) )
- include( 'class-sp-meta-box-equation.php' );
+if ( ! class_exists( 'SP_Meta_Box_Equation' ) ) {
+ require 'class-sp-meta-box-equation.php';
+}
/**
* SP_Meta_Box_Performance_Equation
@@ -23,7 +26,7 @@ class SP_Meta_Box_Performance_Equation extends SP_Meta_Box_Equation {
*/
public static function output( $post ) {
$equation = get_post_meta( $post->ID, 'sp_equation', true );
- $groups = array( 'performance' );
+ $groups = array( 'performance' );
self::builder( $post->post_title, $equation, $groups );
}
}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-columns.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-columns.php
index 1b1506a2..c095e598 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-columns.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-columns.php
@@ -2,13 +2,15 @@
/**
* Player Columns
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Player_Columns
@@ -20,20 +22,27 @@ class SP_Meta_Box_Player_Columns {
*/
public static function output( $post ) {
$selected = (array) get_post_meta( $post->ID, 'sp_columns', true );
- $tabs = apply_filters( 'sportspress_player_column_tabs', array( 'sp_performance', 'sp_statistic' ) );
+ $tabs = apply_filters( 'sportspress_player_column_tabs', array( 'sp_performance', 'sp_statistic' ) );
?>
- $post_type ) {
sp_column_checklist( $post->ID, $post_type, ( 0 == $index ? 'block' : 'none' ), $selected );
}
- ?>
+ ?>
countries->continents;
- $number = get_post_meta( $post->ID, 'sp_number', true );
- $nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
- $default_nationality = get_option( 'sportspress_default_nationality' , false );
-
- if ( empty( $nationalities ) && $default_nationality ) {
+ $number = get_post_meta( $post->ID, 'sp_number', true );
+ $nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
+ $default_nationality = get_option( 'sportspress_default_nationality', false );
+
+ if ( empty( $nationalities ) && $default_nationality ) {
if ( $default_nationality != '' ) {
$nationalities[] = $default_nationality;
}
}
- foreach ( $nationalities as $index => $nationality ):
- if ( 2 == strlen( $nationality ) ):
- $legacy = SP()->countries->legacy;
- $nationality = strtolower( $nationality );
- $nationality = sp_array_value( $legacy, $nationality, null );
+ foreach ( $nationalities as $index => $nationality ) :
+ if ( 2 == strlen( $nationality ) ) :
+ $legacy = SP()->countries->legacy;
+ $nationality = strtolower( $nationality );
+ $nationality = sp_array_value( $legacy, $nationality, null );
$nationalities[ $index ] = $nationality;
endif;
endforeach;
- if ( taxonomy_exists( 'sp_league' ) ):
- $leagues = get_the_terms( $post->ID, 'sp_league' );
+ if ( taxonomy_exists( 'sp_league' ) ) :
+ $leagues = get_the_terms( $post->ID, 'sp_league' );
$league_ids = array();
- if ( $leagues ):
- foreach ( $leagues as $league ):
+ if ( $leagues ) :
+ foreach ( $leagues as $league ) :
$league_ids[] = $league->term_id;
endforeach;
endif;
endif;
- if ( taxonomy_exists( 'sp_season' ) ):
- $seasons = get_the_terms( $post->ID, 'sp_season' );
+ if ( taxonomy_exists( 'sp_season' ) ) :
+ $seasons = get_the_terms( $post->ID, 'sp_season' );
$season_ids = array();
- if ( $seasons ):
- foreach ( $seasons as $season ):
+ if ( $seasons ) :
+ foreach ( $seasons as $season ) :
$season_ids[] = $season->term_id;
endforeach;
endif;
endif;
- if ( taxonomy_exists( 'sp_position' ) ):
- $positions = get_the_terms( $post->ID, 'sp_position' );
+ if ( taxonomy_exists( 'sp_position' ) ) :
+ $positions = get_the_terms( $post->ID, 'sp_position' );
$position_ids = array();
- if ( $positions ):
- foreach ( $positions as $position ):
+ if ( $positions ) :
+ foreach ( $positions as $position ) :
$position_ids[] = $position->term_id;
endforeach;
endif;
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 ) );
+
+ $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_teams = array_filter( get_post_meta( $post->ID, 'sp_current_team', false ) );
?>
@@ -80,12 +87,16 @@ class SP_Meta_Box_Player_Details {
-
+
- $countries ): ?>
+ $countries ) : ?>
- $country ): ?>
- >
+ $country ) : ?>
+ >
@@ -93,83 +104,93 @@ class SP_Meta_Box_Player_Details {
-
+ 'sp_position',
- 'name' => 'tax_input[sp_position][]',
- 'selected' => $position_ids,
- 'values' => 'term_id',
+ '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,
+ 'class' => 'widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
);
sp_dropdown_taxonomies( $args );
- ?>
+ ?>
+
-
+ 'sp_team',
- 'name' => 'sp_current_team[]',
- 'selected' => $current_teams,
- 'values' => 'ID',
+ 'post_type' => 'sp_team',
+ 'name' => 'sp_current_team[]',
+ 'selected' => $current_teams,
+ 'values' => 'ID',
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
- 'class' => 'sp-current-teams widefat',
- 'property' => 'multiple',
- 'chosen' => true,
+ 'class' => 'sp-current-teams widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
);
sp_dropdown_pages( $args );
- ?>
+ ?>
+
-
+ 'sp_team',
- 'name' => 'sp_past_team[]',
- 'selected' => $past_teams,
- 'values' => 'ID',
+ '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,
+ 'class' => 'sp-past-teams widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
);
sp_dropdown_pages( $args );
- ?>
+ ?>
+
- '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,
- );
- sp_dropdown_taxonomies( $args );
- ?>
+
+ '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,
+ );
+ sp_dropdown_taxonomies( $args );
+ ?>
+
- '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,
- );
- sp_dropdown_taxonomies( $args );
- ?>
+
+ '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,
+ );
+ sp_dropdown_taxonomies( $args );
+ ?>
+
ID, 'sp_metrics', true );
$args = array(
- 'post_type' => 'sp_metric',
- 'numberposts' => -1,
+ 'post_type' => 'sp_metric',
+ 'numberposts' => -1,
'posts_per_page' => -1,
- 'orderby' => 'menu_order',
- 'order' => 'ASC',
+ 'orderby' => 'menu_order',
+ 'order' => 'ASC',
);
$vars = get_posts( $args );
- if ( $vars ):
- foreach ( $vars as $var ):
- ?>
+ if ( $vars ) :
+ foreach ( $vars as $var ) :
+ ?>
post_title ); ?>
-
get_terms_sorted_by_sp_order( 'sp_league' );
- if ( is_array ( $leagues ) ) {
+ if ( is_array( $leagues ) ) {
$league_num = sizeof( $leagues );
- }else{
- $league_num =0;
+ } else {
+ $league_num = 0;
}
- $sections = get_option( 'sportspress_player_performance_sections', -1 );
+ $sections = get_option( 'sportspress_player_performance_sections', -1 );
$show_career_totals = 'yes' === get_option( 'sportspress_player_show_career_total', 'no' ) ? true : false;
if ( $leagues ) {
if ( -1 == $sections ) {
// Loop through statistics for each league
$i = 0;
- foreach ( $leagues as $league ):
+ foreach ( $leagues as $league ) :
?>
name ); ?>
__( 'Defense', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ) );
+ $section_order = array(
+ 1 => __( 'Defense', 'sportspress' ),
+ 0 => __( 'Offense', 'sportspress' ),
+ );
} else {
$section_order = array( __( 'Offense', 'sportspress' ), __( 'Defense', 'sportspress' ) );
}
-
+
$s = 0;
foreach ( $section_order as $section_id => $section_label ) {
// Loop through statistics for each league
$i = 0;
- foreach ( $leagues as $league ):
+ foreach ( $leagues as $league ) :
?>
name ); ?> —
$teams, 'readonly' => $readonly ), $id );
+ $teams = array_filter( get_post_meta( $id, 'sp_team', false ) );
+ $buffer = apply_filters(
+ 'sportspress_meta_box_player_statistics_table_buffer',
+ array(
+ 'teams' => $teams,
+ 'readonly' => $readonly,
+ ),
+ $id
+ );
?>
-
+
- $label ): if ( $key == 'team' ) continue; ?>
+ $label ) :
+ if ( $key == 'team' ) {
+ continue;}
+ ?>
@@ -122,29 +138,34 @@ class SP_Meta_Box_Player_Statistics {
- $label ): if ( $column == 'team' ) continue;
+ $label ) :
+ if ( $column == 'team' ) {
+ continue;}
?>
-
+ ';
+ echo ' ';
} else {
- if ( 'time' === sp_array_value( $formats, $column, 'number' ) ) {
- echo ' ';
- echo ' ';
- } else {
- echo ' ';
- }
+ echo ' ';
}
- ?>
+ }
+ ?>
+
@@ -152,42 +173,54 @@ class SP_Meta_Box_Player_Statistics {
$div_stats ):
- if ( $div_id === 'statistics' ) continue;
- if ( $div_id === 0 ) continue;
+ foreach ( $data as $div_id => $div_stats ) :
+ if ( $div_id === 'statistics' ) {
+ continue;
+ }
+ if ( $div_id === 0 ) {
+ continue;
+ }
$div = get_term( $div_id, 'sp_season' );
?>
-
+
-
+
>
name, $league_id, $div_id, $div_stats );
+ if ( 0 === $div_id ) {
+ _e( 'Total', 'sportspress' );
+ } elseif ( 'WP_Error' != get_class( $div ) ) {
+ echo apply_filters( 'sportspress_meta_box_player_statistics_season_name', $div->name, $league_id, $div_id, $div_stats );
+ }
?>
-
-
+
+
-
+
'sp_team',
- 'name' => 'sp_leagues[' . $league_id . '][' . $div_id . ']',
+ 'post_type' => 'sp_team',
+ 'name' => 'sp_leagues[' . $league_id . '][' . $div_id . ']',
'show_option_none' => __( '— None —', 'sportspress' ),
- 'sort_order' => 'ASC',
- 'sort_column' => 'menu_order',
- 'selected' => $value,
- 'values' => 'ID',
- 'include' => $teams,
- 'tax_query' => array(
+ 'sort_order' => 'ASC',
+ 'sort_column' => 'menu_order',
+ 'selected' => $value,
+ 'values' => 'ID',
+ 'include' => $teams,
+ 'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'sp_league',
@@ -201,7 +234,7 @@ class SP_Meta_Box_Player_Statistics {
),
),
);
- if ( ! sp_dropdown_pages( $args ) ):
+ if ( ! sp_dropdown_pages( $args ) ) :
_e( '— None —', 'sportspress' );
endif;
?>
@@ -209,32 +242,47 @@ class SP_Meta_Box_Player_Statistics {
$columns, 'data' => $data, 'placeholders' => $placeholders, 'merged' => $merged, 'seasons_teams' => array(), 'has_checkboxes' => $has_checkboxes, 'formats' => $formats, 'total_types' => $total_types, 'buffer' => $buffer );
+ $collection = array(
+ 'columns' => $columns,
+ 'data' => $data,
+ 'placeholders' => $placeholders,
+ 'merged' => $merged,
+ 'seasons_teams' => array(),
+ 'has_checkboxes' => $has_checkboxes,
+ 'formats' => $formats,
+ 'total_types' => $total_types,
+ 'buffer' => $buffer,
+ );
list( $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes, $formats, $total_types, $buffer ) = array_values( apply_filters( 'sportspress_meta_box_player_statistics_collection', $collection, $id, $league_id, $div_id, $value ) );
?>
- $label ): if ( $column == 'team' ) continue;
+ $label ) :
+ if ( $column == 'team' ) {
+ continue;}
?>
-
+ ';
+ echo ' ';
} else {
- if ( 'time' === sp_array_value( $formats, $column, 'number' ) ) {
- echo ' ';
- echo ' ';
- } else {
- echo ' ';
- }
+ echo ' ';
}
- ?>
+ }
+ ?>
+
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-result-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-result-details.php
index f5b75055..252ab786 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-result-details.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-result-details.php
@@ -2,16 +2,19 @@
/**
* Result Details
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Meta_Box_Config' ) )
- include( 'class-sp-meta-box-config.php' );
+if ( ! class_exists( 'SP_Meta_Box_Config' ) ) {
+ require 'class-sp-meta-box-config.php';
+}
/**
* SP_Meta_Box_Result_Details
@@ -34,7 +37,11 @@ class SP_Meta_Box_Result_Details extends SP_Meta_Box_Config {
- readonly="readonly"> (for, against)
+
+ readonly="readonly"> (for, against)
@@ -50,4 +57,4 @@ class SP_Meta_Box_Result_Details extends SP_Meta_Box_Config {
self::delete_duplicate( $_POST );
update_post_meta( $post_id, 'sp_precision', (int) sp_array_value( $_POST, 'sp_precision', 1, 'int' ) );
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-result-equation.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-result-equation.php
index 1d4acb8d..9dd425e4 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-result-equation.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-result-equation.php
@@ -2,16 +2,19 @@
/**
* Result Equation
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
* @version 1.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Meta_Box_Equation' ) )
- include( 'class-sp-meta-box-equation.php' );
+if ( ! class_exists( 'SP_Meta_Box_Equation' ) ) {
+ require 'class-sp-meta-box-equation.php';
+}
/**
* SP_Meta_Box_Result_Equation
@@ -23,7 +26,7 @@ class SP_Meta_Box_Result_Equation extends SP_Meta_Box_Equation {
*/
public static function output( $post ) {
$equation = get_post_meta( $post->ID, 'sp_equation', true );
- $groups = array( 'performance' );
+ $groups = array( 'performance' );
self::builder( $post->post_title, $equation, $groups );
}
}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-spec-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-spec-details.php
index fea03e15..77966ea2 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-spec-details.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-spec-details.php
@@ -2,16 +2,19 @@
/**
* Spec Details
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Meta_Box_Config' ) )
- include( 'class-sp-meta-box-config.php' );
+if ( ! class_exists( 'SP_Meta_Box_Config' ) ) {
+ require 'class-sp-meta-box-config.php';
+}
/**
* SP_Meta_Box_Spec_Details
@@ -24,7 +27,9 @@ class SP_Meta_Box_Spec_Details extends SP_Meta_Box_Config {
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$visible = get_post_meta( $post->ID, 'sp_visible', true );
- if ( '' === $visible ) $visible = 1;
+ if ( '' === $visible ) {
+ $visible = 1;
+ }
?>
@@ -59,4 +64,4 @@ class SP_Meta_Box_Spec_Details extends SP_Meta_Box_Config {
self::delete_duplicate( $_POST );
update_post_meta( $post_id, 'sp_visible', sp_array_value( $_POST, 'sp_visible', 1, 'int' ) );
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php
index 1f38c91f..77236d6b 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php
@@ -2,13 +2,15 @@
/**
* Staff Details
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Staff_Details
@@ -23,126 +25,145 @@ class SP_Meta_Box_Staff_Details {
$continents = SP()->countries->continents;
$nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
- foreach ( $nationalities as $index => $nationality ):
- if ( 2 == strlen( $nationality ) ):
- $legacy = SP()->countries->legacy;
- $nationality = strtolower( $nationality );
- $nationality = sp_array_value( $legacy, $nationality, null );
+ foreach ( $nationalities as $index => $nationality ) :
+ if ( 2 == strlen( $nationality ) ) :
+ $legacy = SP()->countries->legacy;
+ $nationality = strtolower( $nationality );
+ $nationality = sp_array_value( $legacy, $nationality, null );
$nationalities[ $index ] = $nationality;
endif;
endforeach;
- $leagues = get_the_terms( $post->ID, 'sp_league' );
+ $leagues = get_the_terms( $post->ID, 'sp_league' );
$league_ids = array();
- if ( $leagues ):
- foreach ( $leagues as $league ):
+ if ( $leagues ) :
+ foreach ( $leagues as $league ) :
$league_ids[] = $league->term_id;
endforeach;
endif;
- $seasons = get_the_terms( $post->ID, 'sp_season' );
+ $seasons = get_the_terms( $post->ID, 'sp_season' );
$season_ids = array();
- if ( $seasons ):
- foreach ( $seasons as $season ):
+ if ( $seasons ) :
+ foreach ( $seasons as $season ) :
$season_ids[] = $season->term_id;
endforeach;
endif;
- $roles = get_the_terms( $post->ID, 'sp_role' );
+ $roles = get_the_terms( $post->ID, 'sp_role' );
$role_ids = is_array( $roles ) ? wp_list_pluck( $roles, 'term_id' ) : array();
-
- $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 ) );
+
+ $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_teams = array_filter( get_post_meta( $post->ID, 'sp_current_team', false ) );
?>
-
+ 'sp_role',
- 'name' => 'tax_input[sp_role][]',
- 'selected' => $role_ids,
- 'values' => 'term_id',
+ 'taxonomy' => 'sp_role',
+ 'name' => 'tax_input[sp_role][]',
+ 'selected' => $role_ids,
+ 'values' => 'term_id',
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Jobs', 'sportspress' ) ),
- 'class' => 'widefat',
- 'property' => 'multiple',
- 'chosen' => true,
+ 'class' => 'widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
);
- if ( ! sp_dropdown_taxonomies( $args ) ):
- sp_taxonomy_adder( 'sp_role', 'sp_staff', __( 'Add New', 'sportspress' ) );
+ if ( ! sp_dropdown_taxonomies( $args ) ) :
+ sp_taxonomy_adder( 'sp_role', 'sp_staff', __( 'Add New', 'sportspress' ) );
endif;
- ?>
+ ?>
+
-
+
- $countries ): ?>
+ $countries ) : ?>
- $country ): ?>
- >
+ $country ) : ?>
+ >
-
+ 'sp_team',
- 'name' => 'sp_current_team[]',
- 'selected' => $current_teams,
- 'values' => 'ID',
+ 'post_type' => 'sp_team',
+ 'name' => 'sp_current_team[]',
+ 'selected' => $current_teams,
+ 'values' => 'ID',
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
- 'class' => 'sp-current-teams widefat',
- 'property' => 'multiple',
- 'chosen' => true,
+ 'class' => 'sp-current-teams widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
);
sp_dropdown_pages( $args );
- ?>
+ ?>
+
-
+ 'sp_team',
- 'name' => 'sp_past_team[]',
- 'selected' => $past_teams,
- 'values' => 'ID',
+ '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,
+ 'class' => 'sp-past-teams widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
);
sp_dropdown_pages( $args );
- ?>
+ ?>
+
-
+ 'sp_league',
- 'name' => 'tax_input[sp_league][]',
- 'selected' => $league_ids,
- 'values' => 'term_id',
+ '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,
+ 'class' => 'widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
);
sp_dropdown_taxonomies( $args );
- ?>
+ ?>
+
-
+ 'sp_season',
- 'name' => 'tax_input[sp_season][]',
- 'selected' => $season_ids,
- 'values' => 'term_id',
+ '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,
+ 'class' => 'widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
);
sp_dropdown_taxonomies( $args );
- ?>
+ ?>
+
ID, 'sp_precision', true );
- $section = get_post_meta( $post->ID, 'sp_section', true );
- $format = get_post_meta( $post->ID, 'sp_format', true );
- $total = get_post_meta( $post->ID, 'sp_type', true );
- $visible = get_post_meta( $post->ID, 'sp_visible', true );
+ $section = get_post_meta( $post->ID, 'sp_section', true );
+ $format = get_post_meta( $post->ID, 'sp_format', true );
+ $total = get_post_meta( $post->ID, 'sp_type', true );
+ $visible = get_post_meta( $post->ID, 'sp_visible', true );
// Defaults
- if ( '' === $precision ) $precision = 0;
- if ( '' === $section ) $section = -1;
- if ( '' === $format ) $format = 'number';
- if ( '' === $visible ) $visible = 1;
+ if ( '' === $precision ) {
+ $precision = 0;
+ }
+ if ( '' === $section ) {
+ $section = -1;
+ }
+ if ( '' === $format ) {
+ $format = 'number';
+ }
+ if ( '' === $visible ) {
+ $visible = 1;
+ }
?>
@@ -48,8 +59,18 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
__( 'All', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
- foreach ( $options as $key => $value ):
+ $options = apply_filters(
+ 'sportspress_performance_sections',
+ array(
+ -1 => __( 'All', 'sportspress' ),
+ 0 => __( 'Offense', 'sportspress' ),
+ 1 => __(
+ 'Defense',
+ 'sportspress'
+ ),
+ )
+ );
+ foreach ( $options as $key => $value ) :
printf( '%s ', $key, selected( $key == $section, true, false ), $value );
endforeach;
?>
@@ -59,8 +80,17 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
__( 'Number', 'sportspress' ), 'time' => __( 'Time', 'sportspress' ) ) );
- foreach ( $options as $key => $value ):
+ $options = apply_filters(
+ 'sportspress_statistic_formats',
+ array(
+ 'number' => __( 'Number', 'sportspress' ),
+ 'time' => __(
+ 'Time',
+ 'sportspress'
+ ),
+ )
+ );
+ foreach ( $options as $key => $value ) :
printf( '%s ', $key, selected( $key == $format, true, false ), $value );
endforeach;
?>
@@ -70,8 +100,17 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
__( 'Total', 'sportspress' ), 'average' => __( 'Average', 'sportspress' ) ) );
- foreach ( $options as $key => $value ):
+ $options = apply_filters(
+ 'sportspress_statistic_total_types',
+ array(
+ 'total' => __( 'Total', 'sportspress' ),
+ 'average' => __(
+ 'Average',
+ 'sportspress'
+ ),
+ )
+ );
+ foreach ( $options as $key => $value ) :
printf( '%s ', $key, selected( $key == $total, true, false ), $value );
endforeach;
?>
@@ -110,4 +149,4 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
update_post_meta( $post_id, 'sp_visible', sp_array_value( $_POST, 'sp_visible', 1, 'int' ) );
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-equation.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-equation.php
index d8fad943..1a0d0826 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-equation.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-statistic-equation.php
@@ -2,16 +2,19 @@
/**
* Statistic Equation
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
* @version 1.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
-if ( ! class_exists( 'SP_Meta_Box_Equation' ) )
- include( 'class-sp-meta-box-equation.php' );
+if ( ! class_exists( 'SP_Meta_Box_Equation' ) ) {
+ require 'class-sp-meta-box-equation.php';
+}
/**
* SP_Meta_Box_Statistic_Equation
@@ -23,7 +26,7 @@ class SP_Meta_Box_Statistic_Equation extends SP_Meta_Box_Equation {
*/
public static function output( $post ) {
$equation = get_post_meta( $post->ID, 'sp_equation', true );
- $groups = array( 'player_event', 'outcome', 'result', 'performance', 'metric' );
+ $groups = array( 'player_event', 'outcome', 'result', 'performance', 'metric' );
self::builder( $post->post_title, $equation, $groups );
}
}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-data.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-data.php
index 946d0bf1..01ee68e9 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-data.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-data.php
@@ -2,13 +2,15 @@
/**
* Table Data
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Table_Data
@@ -21,12 +23,12 @@ class SP_Meta_Box_Table_Data {
public static function output( $post ) {
global $pagenow;
if ( is_admin() && in_array( $pagenow, array( 'post-new.php' ) ) && 'sp_table' == get_post_type() ) {
- self::table( );
- }else{
+ self::table();
+ } else {
$table = new SP_League_Table( $post );
list( $columns, $usecolumns, $data, $placeholders, $merged ) = $table->data( true );
$adjustments = $table->adjustments;
- $highlight = get_post_meta( $table->ID, 'sp_highlight', true );
+ $highlight = get_post_meta( $table->ID, 'sp_highlight', true );
self::table( $table->ID, $columns, $usecolumns, $data, $placeholders, $adjustments, $highlight );
}
}
@@ -45,24 +47,39 @@ class SP_Meta_Box_Table_Data {
* Admin edit table
*/
public static function table( $id = 0, $columns = array(), $usecolumns = null, $data = array(), $placeholders = array(), $adjustments = array(), $highlight = null, $readonly = false ) {
- if ( is_array( $usecolumns ) )
+ if ( is_array( $usecolumns ) ) {
$usecolumns = array_filter( $usecolumns );
+ }
$mode = sp_get_post_mode( $id );
if ( 'player' === $mode ) {
$show_team_logo = get_option( 'sportspress_list_show_photos', 'no' ) == 'yes' ? true : false;
- $icon_class = 'sp-icon-tshirt';
+ $icon_class = 'sp-icon-tshirt';
} else {
$show_team_logo = get_option( 'sportspress_table_show_logos', 'no' ) == 'yes' ? true : false;
- $icon_class = 'sp-icon-shield';
+ $icon_class = 'sp-icon-shield';
}
?>
-
+
@@ -80,7 +97,7 @@ class SP_Meta_Box_Table_Data {
- $label ): ?>
+ $label ) : ?>
>
@@ -92,22 +109,32 @@ class SP_Meta_Box_Table_Data {
0 ):
+ if ( is_array( $data ) && sizeof( $data ) > 0 ) :
$i = 0;
- foreach ( $data as $team_id => $team_stats ):
- if ( !$team_id )
+ foreach ( $data as $team_id => $team_stats ) :
+ if ( ! $team_id ) {
continue;
+ }
$default_name = sp_array_value( $team_stats, 'name', '' );
- if ( $default_name == null )
+ if ( $default_name == null ) {
$default_name = get_the_title( $team_id );
+ }
?>
-
+
>
-
+
@@ -122,8 +149,9 @@ class SP_Meta_Box_Table_Data {
- $label ):
- $value = sp_array_value( $team_stats, $column, '' );
+ $label ) :
+ $value = sp_array_value( $team_stats, $column, '' );
$placeholder = sp_array_value( sp_array_value( $placeholders, $team_id, array() ), $column, 0 );
$placeholder = wp_strip_all_tags( $placeholder );
?>
@@ -133,14 +161,19 @@ class SP_Meta_Box_Table_Data {
+ else :
+ ?>
-
+
-
@@ -151,24 +184,31 @@ class SP_Meta_Box_Table_Data {
- $label ): ?>
+ $label ) : ?>
0 ):
+ if ( is_array( $data ) && sizeof( $data ) > 0 ) :
$i = 0;
- foreach ( $data as $team_id => $team_stats ):
- if ( !$team_id )
+ foreach ( $data as $team_id => $team_stats ) :
+ if ( ! $team_id ) {
continue;
+ }
?>
-
+
- $label ):
+ $label ) :
$value = sp_array_value( sp_array_value( $adjustments, $team_id, array() ), $column, '' );
?>
@@ -177,14 +217,19 @@ class SP_Meta_Box_Table_Data {
+ else :
+ ?>
-
+
-
@@ -192,4 +237,4 @@ class SP_Meta_Box_Table_Data {
ID, 'sp_caption', true );
- $select = get_post_meta( $post->ID, 'sp_select', true );
- $post_type = sp_get_post_mode_type( $post->ID );
- $date = get_post_meta( $post->ID, 'sp_date', true );
- $date_from = get_post_meta( $post->ID, 'sp_date_from', true );
- $date_to = get_post_meta( $post->ID, 'sp_date_to', true );
- $date_past = get_post_meta( $post->ID, 'sp_date_past', true );
+ $taxonomies = get_object_taxonomies( 'sp_table' );
+ $caption = get_post_meta( $post->ID, 'sp_caption', true );
+ $select = get_post_meta( $post->ID, 'sp_select', true );
+ $post_type = sp_get_post_mode_type( $post->ID );
+ $date = get_post_meta( $post->ID, 'sp_date', true );
+ $date_from = get_post_meta( $post->ID, 'sp_date_from', true );
+ $date_to = get_post_meta( $post->ID, 'sp_date_to', true );
+ $date_past = get_post_meta( $post->ID, 'sp_date_past', true );
$date_relative = get_post_meta( $post->ID, 'sp_date_relative', true );
- $orderby = get_post_meta( $post->ID, 'sp_orderby', true );
- $order = get_post_meta( $post->ID, 'sp_order', true );
- $event_status = get_post_meta( $post->ID, 'sp_event_status', true );
+ $orderby = get_post_meta( $post->ID, 'sp_orderby', true );
+ $order = get_post_meta( $post->ID, 'sp_order', true );
+ $event_status = get_post_meta( $post->ID, 'sp_event_status', true );
if ( empty( $event_status ) ) {
$event_status = array( 'publish', 'future' );
}
@@ -45,8 +47,8 @@ class SP_Meta_Box_Table_Details {
'sp_date',
- 'id' => 'sp_date',
+ 'name' => 'sp_date',
+ 'id' => 'sp_date',
'selected' => $date,
);
sp_dropdown_dates( $args );
@@ -97,8 +99,8 @@ class SP_Meta_Box_Table_Details {
?>
- > Published/Played
- > Scheduled/Future
+ > Published/Played
+ > Scheduled/Future
@@ -107,12 +109,12 @@ class SP_Meta_Box_Table_Details {
$args = array(
'prepend_options' => array(
'default' => __( 'Default', 'sportspress' ),
- 'name' => __( 'Name', 'sportspress' ),
+ 'name' => __( 'Name', 'sportspress' ),
),
- 'post_type' => array( 'sp_column' ),
- 'name' => 'sp_orderby',
- 'selected' => $orderby,
- 'values' => 'slug',
+ 'post_type' => array( 'sp_column' ),
+ 'name' => 'sp_orderby',
+ 'selected' => $orderby,
+ 'values' => 'slug',
);
sp_dropdown_pages( $args );
?>
@@ -148,4 +150,4 @@ class SP_Meta_Box_Table_Details {
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', array(), 'text' ) );
update_post_meta( $post_id, 'sp_event_status', sp_array_value( $_POST, 'sp_event_status', array(), 'key' ) );
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-format.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-format.php
index b80eecfb..4012fb5c 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-format.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-format.php
@@ -2,13 +2,15 @@
/**
* Table Format
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Table_Format
@@ -23,7 +25,7 @@ class SP_Meta_Box_Table_Format {
$the_format = get_post_meta( $post->ID, 'sp_format', true );
?>
- formats->table as $key => $format ): ?>
+ formats->table as $key => $format ) : ?>
>
@@ -36,4 +38,4 @@ class SP_Meta_Box_Table_Format {
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'standings', 'key' ) );
}
-}
\ No newline at end of file
+}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-mode.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-mode.php
index 26519c0c..1ac0d369 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-mode.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-mode.php
@@ -5,34 +5,41 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Table_Mode
*/
class SP_Meta_Box_Table_Mode {
- /**
- * Output the metabox
- */
- public static function output( $post ) {
- $the_mode = sp_get_post_mode( $post->ID );
- ?>
-
- __( 'Team vs team', 'sportspress' ), 'player' => __( 'Player vs player', 'sportspress' ) ) as $key => $mode ): ?>
- >
-
-
- ID );
+ ?>
+
+ __( 'Team vs team', 'sportspress' ),
+ 'player' => __( 'Player vs player', 'sportspress' ),
+ ) as $key => $mode ) :
+ ?>
+ >
+
+
+ ID, 'sp_format', true );
- if ( ! $the_format ) $the_format = 'standings';
+ if ( ! $the_format ) {
+ $the_format = 'standings';
+ }
?>
@@ -28,4 +32,4 @@ class SP_Meta_Box_Table_Shortcode {
ID, 'sp_league' );
+ $team = new SP_Team( $post );
+ $leagues = get_the_terms( $post->ID, 'sp_league' );
$league_num = sizeof( $leagues );
// Loop through columns for each league
- if ( $leagues ): foreach ( $leagues as $league ):
+ if ( $leagues ) :
+ foreach ( $leagues as $league ) :
- $league_id = $league->term_id;
- ?>
+ $league_id = $league->term_id;
+ ?>
name ); ?>
- columns( $league_id );
- self::table( $league_id, $columns, $data, $placeholders );
+ columns( $league_id );
+ self::table( $league_id, $columns, $data, $placeholders );
- endforeach; endif;
+ endforeach;
+endif;
?>
-
+
@@ -66,10 +70,15 @@ class SP_Meta_Box_Team_Columns {
$div_stats ):
+ foreach ( $data as $div_id => $div_stats ) :
$div = get_term( $div_id, 'sp_season' );
?>
-
+
- $label ):
+ $label ) :
$value = sp_array_value( sp_array_value( $data, $div_id, array() ), $column, 0 );
?>
-
+ ';
- ?>
+ ?>
+
ID, 'sp_league' );
+ if ( taxonomy_exists( 'sp_league' ) ) :
+ $leagues = get_the_terms( $post->ID, 'sp_league' );
$league_ids = array();
- if ( $leagues ):
- foreach ( $leagues as $league ):
+ if ( $leagues ) :
+ foreach ( $leagues as $league ) :
$league_ids[] = $league->term_id;
endforeach;
endif;
endif;
- if ( taxonomy_exists( 'sp_season' ) ):
- $seasons = get_the_terms( $post->ID, 'sp_season' );
+ if ( taxonomy_exists( 'sp_season' ) ) :
+ $seasons = get_the_terms( $post->ID, 'sp_season' );
$season_ids = array();
- if ( $seasons ):
- foreach ( $seasons as $season ):
+ if ( $seasons ) :
+ foreach ( $seasons as $season ) :
$season_ids[] = $season->term_id;
endforeach;
endif;
endif;
- if ( taxonomy_exists( 'sp_venue' ) ):
- $venues = get_the_terms( $post->ID, 'sp_venue' );
+ if ( taxonomy_exists( 'sp_venue' ) ) :
+ $venues = get_the_terms( $post->ID, 'sp_venue' );
$venue_ids = array();
- if ( $venues ):
- foreach ( $venues as $venue ):
+ if ( $venues ) :
+ foreach ( $venues as $venue ) :
$venue_ids[] = $venue->term_id;
endforeach;
endif;
endif;
- $short_name = get_post_meta( $post->ID, 'sp_short_name', true );
+ $short_name = get_post_meta( $post->ID, 'sp_short_name', true );
$abbreviation = get_post_meta( $post->ID, 'sp_abbreviation', true );
- $redirect = get_post_meta( $post->ID, 'sp_redirect', true );
- $url = get_post_meta( $post->ID, 'sp_url', true );
+ $redirect = get_post_meta( $post->ID, 'sp_redirect', true );
+ $url = get_post_meta( $post->ID, 'sp_url', true );
?>
- '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,
- );
- sp_dropdown_taxonomies( $args );
- ?>
+
+ '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,
+ );
+ sp_dropdown_taxonomies( $args );
+ ?>
+
- '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,
- );
- sp_dropdown_taxonomies( $args );
- ?>
+
+ '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,
+ );
+ sp_dropdown_taxonomies( $args );
+ ?>
+
- 'sp_venue',
- 'name' => 'tax_input[sp_venue][]',
- 'selected' => $venue_ids,
- 'values' => 'term_id',
- 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Venue', 'sportspress' ) ),
- 'class' => 'widefat',
- 'property' => 'multiple',
- 'chosen' => true,
- );
- sp_dropdown_taxonomies( $args );
- ?>
+
+ 'sp_venue',
+ 'name' => 'tax_input[sp_venue][]',
+ 'selected' => $venue_ids,
+ 'values' => 'term_id',
+ 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Venue', 'sportspress' ) ),
+ 'class' => 'widefat',
+ 'property' => 'multiple',
+ 'chosen' => true,
+ );
+ sp_dropdown_taxonomies( $args );
+ ?>
+
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-team-lists.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-team-lists.php
index fc1e4a1f..d496230e 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-team-lists.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-team-lists.php
@@ -2,13 +2,15 @@
/**
* Team Player Lists
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin/Meta_Boxes
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
/**
* SP_Meta_Box_Team_Lists
@@ -21,13 +23,13 @@ class SP_Meta_Box_Team_Lists {
public static function output( $post ) {
global $pagenow;
- if ( $pagenow != 'post-new.php' ):
+ if ( $pagenow != 'post-new.php' ) :
- $team = new SP_Team( $post );
+ $team = new SP_Team( $post );
list( $data, $checked ) = $team->lists( true );
self::table( $data, $checked );
- else:
+ else :
printf( __( 'No results found.', 'sportspress' ) );
@@ -70,14 +72,19 @@ class SP_Meta_Box_Team_Lists {
0 ):
+ if ( is_array( $data ) ) :
+ if ( sizeof( $data ) > 0 ) :
$i = 0;
- foreach ( $data as $list ):
+ foreach ( $data as $list ) :
$players = array_filter( get_post_meta( $list->ID, 'sp_player' ) );
- $format = get_post_meta( $list->ID, 'sp_format', true );
+ $format = get_post_meta( $list->ID, 'sp_format', true );
?>
-
+
ID, $checked ) ); ?>>
@@ -87,14 +94,14 @@ class SP_Meta_Box_Team_Lists {
- ID, 'sp_league' ) ? the_terms( $list->ID, 'sp_league' ) : '—'; ?>
- ID, 'sp_season' ) ? the_terms( $list->ID, 'sp_season' ) : '—'; ?>
+ ID, 'sp_league' ) ? the_terms( $list->ID, 'sp_league' ) : '—'; ?>
+ ID, 'sp_season' ) ? the_terms( $list->ID, 'sp_season' ) : '—'; ?>
formats->list, $format, '—' ) ); ?>
@@ -103,14 +110,14 @@ class SP_Meta_Box_Team_Lists {
+ else :
+ ?>
-
@@ -118,4 +125,4 @@ class SP_Meta_Box_Team_Lists {
staff( true );
self::table( $data, $checked );
- else:
+ else :
printf( __( 'No results found.', 'sportspress' ) );
@@ -67,13 +69,18 @@ class SP_Meta_Box_Team_Staff {
0 ):
+ if ( is_array( $data ) ) :
+ if ( sizeof( $data ) > 0 ) :
$i = 0;
- foreach ( $data as $staff ):
+ foreach ( $data as $staff ) :
$role = get_post_meta( $staff->ID, 'sp_role', true );
?>
-
+
ID, $checked ) ); ?>>
@@ -82,14 +89,14 @@ class SP_Meta_Box_Team_Staff {
post_title ); ?>
- ID, 'sp_role' ) ? the_terms( $staff->ID, 'sp_role' ) : '—'; ?>
- ID, 'sp_league' ) ? the_terms( $staff->ID, 'sp_league' ) : '—'; ?>
- ID, 'sp_season' ) ? the_terms( $staff->ID, 'sp_season' ) : '—'; ?>
+ ID, 'sp_role' ) ? the_terms( $staff->ID, 'sp_role' ) : '—'; ?>
+ ID, 'sp_league' ) ? the_terms( $staff->ID, 'sp_league' ) : '—'; ?>
+ ID, 'sp_season' ) ? the_terms( $staff->ID, 'sp_season' ) : '—'; ?>
@@ -98,14 +105,14 @@ class SP_Meta_Box_Team_Staff {
+ else :
+ ?>
-
@@ -113,4 +120,4 @@ class SP_Meta_Box_Team_Staff {
tables( true );
self::table( $data, $checked );
- else:
+ else :
printf( __( 'No results found.', 'sportspress' ) );
@@ -67,14 +69,19 @@ class SP_Meta_Box_Team_Tables {
0 ):
+ if ( is_array( $data ) ) :
+ if ( sizeof( $data ) > 0 ) :
$i = 0;
- foreach ( $data as $table ):
- $teams = array_filter( get_post_meta( $table->ID, 'sp_team' ) );
+ foreach ( $data as $table ) :
+ $teams = array_filter( get_post_meta( $table->ID, 'sp_team' ) );
$format = get_post_meta( $table->ID, 'sp_format', true );
?>
-
+
ID, $checked ) ); ?>>
@@ -84,13 +91,13 @@ class SP_Meta_Box_Team_Tables {
- ID, 'sp_league' ) ? the_terms( $table->ID, 'sp_league' ) : '—'; ?>
- ID, 'sp_season' ) ? the_terms( $table->ID, 'sp_season' ) : '—'; ?>
+ ID, 'sp_league' ) ? the_terms( $table->ID, 'sp_league' ) : '—'; ?>
+ ID, 'sp_season' ) ? the_terms( $table->ID, 'sp_season' ) : '—'; ?>
@@ -99,14 +106,14 @@ class SP_Meta_Box_Team_Tables {
+ else :
+ ?>
-
@@ -114,4 +121,4 @@ class SP_Meta_Box_Team_Tables {
id = 'events';
- $this->label = __( 'Events', 'sportspress' );
- $this->template = 'event';
+ class SP_Settings_Events extends SP_Settings_Page {
- add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
- add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
- add_action( 'sportspress_admin_field_delimiter', array( $this, 'delimiter_setting' ) );
- add_action( 'sportspress_admin_field_event_layout', array( $this, 'layout_setting' ) );
- add_action( 'sportspress_admin_field_event_tabs', array( $this, 'tabs_setting' ) );
- add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
- }
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->id = 'events';
+ $this->label = __( 'Events', 'sportspress' );
+ $this->template = 'event';
- /**
- * Get settings array
- *
- * @return array
- */
- public function get_settings() {
+ add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
+ add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
+ add_action( 'sportspress_admin_field_delimiter', array( $this, 'delimiter_setting' ) );
+ add_action( 'sportspress_admin_field_event_layout', array( $this, 'layout_setting' ) );
+ add_action( 'sportspress_admin_field_event_tabs', array( $this, 'tabs_setting' ) );
+ add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
+ }
- $settings = array_merge(
- array(
- array( 'title' => __( 'Event Options', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'event_options' ),
- ),
+ /**
+ * Get settings array
+ *
+ * @return array
+ */
+ public function get_settings() {
- apply_filters( 'sportspress_event_options', array_merge(
+ $settings = array_merge(
array(
array(
- 'title' => __( 'Link', 'sportspress' ),
- 'desc' => __( 'Link events', 'sportspress' ),
- 'id' => 'sportspress_link_events',
- 'default' => 'yes',
- 'type' => 'checkbox',
+ 'title' => __( 'Event Options', 'sportspress' ),
+ 'type' => 'title',
+ 'desc' => '',
+ 'id' => 'event_options',
),
),
+ apply_filters(
+ 'sportspress_event_options',
+ array_merge(
+ array(
+ array(
+ 'title' => __( 'Link', 'sportspress' ),
+ 'desc' => __( 'Link events', 'sportspress' ),
+ 'id' => 'sportspress_link_events',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
+ ),
+ ),
+ apply_filters(
+ 'sportspress_event_template_options',
+ array(
+ array( 'type' => 'event_layout' ),
- apply_filters( 'sportspress_event_template_options', array(
- array( 'type' => 'event_layout' ),
+ array( 'type' => 'event_tabs' ),
- array( 'type' => 'event_tabs' ),
+ array(
+ 'title' => __( 'Details', 'sportspress' ),
+ 'desc' => __( 'Date', 'sportspress' ),
+ 'id' => 'sportspress_event_show_date',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'start',
+ ),
- array(
- 'title' => __( 'Details', 'sportspress' ),
- 'desc' => __( 'Date', 'sportspress' ),
- 'id' => 'sportspress_event_show_date',
- 'default' => 'yes',
- 'type' => 'checkbox',
- 'checkboxgroup' => 'start',
- ),
+ array(
+ 'desc' => __( 'Time', 'sportspress' ),
+ 'id' => 'sportspress_event_show_time',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => '',
+ ),
- array(
- 'desc' => __( 'Time', 'sportspress' ),
- 'id' => 'sportspress_event_show_time',
- 'default' => 'yes',
- 'type' => 'checkbox',
- 'checkboxgroup' => '',
- ),
+ array(
+ 'desc' => __( 'Match Day', 'sportspress' ),
+ 'id' => 'sportspress_event_show_day',
+ 'default' => 'no',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => '',
+ ),
- array(
- 'desc' => __( 'Match Day', 'sportspress' ),
- 'id' => 'sportspress_event_show_day',
- 'default' => 'no',
- 'type' => 'checkbox',
- 'checkboxgroup' => '',
- ),
+ array(
+ 'desc' => __( 'Full Time', 'sportspress' ),
+ 'id' => 'sportspress_event_show_full_time',
+ 'default' => 'no',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'end',
+ ),
+ )
+ ),
+ array(
+ array(
+ 'title' => __( 'Default mode', 'sportspress' ),
+ 'id' => 'sportspress_mode',
+ 'default' => 'team',
+ 'type' => 'radio',
+ 'options' => array(
+ 'team' => __( 'Team vs team', 'sportspress' ),
+ 'player' => __( 'Player vs player', 'sportspress' ),
+ ),
+ 'desc_tip' => _x( 'Who competes in events?', 'mode setting description', 'sportspress' ),
+ ),
- array(
- 'desc' => __( 'Full Time', 'sportspress' ),
- 'id' => 'sportspress_event_show_full_time',
- 'default' => 'no',
- 'type' => 'checkbox',
- 'checkboxgroup' => 'end',
- ),
- ) ),
+ array(
+ 'title' => __( 'Limit', 'sportspress' ),
+ 'id' => 'sportspress_event_teams',
+ 'class' => 'small-text',
+ 'default' => '2',
+ 'desc' => __( 'teams', 'sportspress' ),
+ 'type' => 'number',
+ 'custom_attributes' => array(
+ 'min' => 0,
+ 'step' => 1,
+ ),
+ ),
+ array( 'type' => 'delimiter' ),
+
+ array(
+ 'title' => __( 'Teams', 'sportspress' ),
+ 'desc' => __( 'Filter by league', 'sportspress' ),
+ 'id' => 'sportspress_event_filter_teams_by_league',
+ 'default' => 'no',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'start',
+ ),
+
+ array(
+ 'desc' => __( 'Filter by season', 'sportspress' ),
+ 'id' => 'sportspress_event_filter_teams_by_season',
+ 'default' => 'no',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'end',
+ ),
+
+ array(
+ 'title' => __( 'Full Time', 'sportspress' ),
+ 'id' => 'sportspress_event_minutes',
+ 'class' => 'small-text',
+ 'default' => '90',
+ 'desc' => __( 'mins', 'sportspress' ),
+ 'type' => 'number',
+ 'custom_attributes' => array(
+ 'min' => 0,
+ 'step' => 1,
+ ),
+ ),
+
+ array(
+ 'title' => __( 'Comments', 'sportspress' ),
+ 'desc' => __( 'Allow people to post comments on new articles', 'sportspress' ),
+ 'id' => 'sportspress_event_comment_status',
+ 'default' => 'no',
+ 'type' => 'checkbox',
+ ),
+ )
+ )
+ ),
array(
array(
- 'title' => __( 'Default mode', 'sportspress' ),
- 'id' => 'sportspress_mode',
- 'default' => 'team',
- 'type' => 'radio',
- 'options' => array(
- 'team' => __( 'Team vs team', 'sportspress' ),
- 'player' => __( 'Player vs player', 'sportspress' ),
+ 'type' => 'sectionend',
+ 'id' => 'event_options',
+ ),
+ ),
+ array(
+ array(
+ 'title' => __( 'Venues', 'sportspress' ),
+ 'type' => 'title',
+ 'desc' => '',
+ 'id' => 'venue_options',
+ ),
+ ),
+ apply_filters(
+ 'sportspress_venue_options',
+ array(
+ array(
+ 'title' => __( 'Link', 'sportspress' ),
+ 'desc' => __( 'Link venues', 'sportspress' ),
+ 'id' => 'sportspress_link_venues',
+ 'default' => 'no',
+ 'type' => 'checkbox',
),
- 'desc_tip' => _x( 'Who competes in events?', 'mode setting description', 'sportspress' ),
- ),
-
- array(
- 'title' => __( 'Limit', 'sportspress' ),
- 'id' => 'sportspress_event_teams',
- 'class' => 'small-text',
- 'default' => '2',
- 'desc' => __( 'teams', 'sportspress' ),
- 'type' => 'number',
- 'custom_attributes' => array(
- 'min' => 0,
- 'step' => 1
+
+ array(
+ 'title' => __( 'Venue Map', 'sportspress' ),
+ 'desc' => __( 'Display venue map', 'sportspress' ),
+ 'id' => 'sportspress_event_show_maps',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
),
- ),
-
- array( 'type' => 'delimiter' ),
- array(
- 'title' => __( 'Teams', 'sportspress' ),
- 'desc' => __( 'Filter by league', 'sportspress' ),
- 'id' => 'sportspress_event_filter_teams_by_league',
- 'default' => 'no',
- 'type' => 'checkbox',
- 'checkboxgroup' => 'start',
- ),
-
- array(
- 'desc' => __( 'Filter by season', 'sportspress' ),
- 'id' => 'sportspress_event_filter_teams_by_season',
- 'default' => 'no',
- 'type' => 'checkbox',
- 'checkboxgroup' => 'end',
- ),
-
- array(
- 'title' => __( 'Full Time', 'sportspress' ),
- 'id' => 'sportspress_event_minutes',
- 'class' => 'small-text',
- 'default' => '90',
- 'desc' => __( 'mins', 'sportspress' ),
- 'type' => 'number',
- 'custom_attributes' => array(
- 'min' => 0,
- 'step' => 1
+ array(
+ 'title' => __( 'Type', 'sportspress' ),
+ 'id' => 'sportspress_map_type',
+ 'default' => 'ROADMAP',
+ 'type' => 'radio',
+ 'options' => array(
+ 'ROADMAP' => __( 'Default', 'sportspress' ),
+ 'SATELLITE' => __( 'Satellite', 'sportspress' ),
+ ),
),
- ),
+ array(
+ 'title' => __( 'Zoom', 'sportspress' ),
+ 'id' => 'sportspress_map_zoom',
+ 'class' => 'small-text',
+ 'default' => '15',
+ 'desc' => '0 - 21',
+ 'type' => 'number',
+ 'custom_attributes' => array(
+ 'min' => 0,
+ 'max' => 21,
+ 'step' => 1,
+ ),
+ ),
+ )
+ ),
+ array(
array(
- 'title' => __( 'Comments', 'sportspress' ),
- 'desc' => __( 'Allow people to post comments on new articles', 'sportspress' ),
- 'id' => 'sportspress_event_comment_status',
- 'default' => 'no',
- 'type' => 'checkbox',
+ 'type' => 'sectionend',
+ 'id' => 'venue_options',
+ ),
+ ),
+ array(
+ array(
+ 'title' => __( 'Teams', 'sportspress' ),
+ 'type' => 'title',
+ 'desc' => '',
+ 'id' => 'event_logo_options',
+ ),
+ ),
+ apply_filters(
+ 'sportspress_event_logo_options',
+ array(
+ array(
+ 'title' => __( 'Order', 'sportspress' ),
+ 'desc' => __( 'Reverse order', 'sportspress' ),
+ 'id' => 'sportspress_event_reverse_teams',
+ 'default' => 'no',
+ 'type' => 'checkbox',
+ ),
+
+ array(
+ 'title' => __( 'Layout', 'sportspress' ),
+ 'id' => 'sportspress_event_logos_format',
+ 'default' => 'inline',
+ 'type' => 'radio',
+ 'options' => array(
+ 'inline' => __( 'Inline', 'sportspress' ),
+ 'block' => __( 'Block', 'sportspress' ),
+ ),
+ ),
+
+ array(
+ 'title' => __( 'Display', 'sportspress' ),
+ 'desc' => __( 'Name', 'sportspress' ),
+ 'id' => 'sportspress_event_logos_show_team_names',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'start',
+ ),
+
+ array(
+ 'desc' => __( 'Time', 'sportspress' ),
+ 'id' => 'sportspress_event_logos_show_time',
+ 'default' => 'no',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => '',
+ ),
+
+ array(
+ 'desc' => __( 'Results', 'sportspress' ),
+ 'id' => 'sportspress_event_logos_show_results',
+ 'default' => 'no',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'end',
+ ),
+ )
+ ),
+ array(
+ array(
+ 'type' => 'sectionend',
+ 'id' => 'event_logo_options',
+ ),
+ ),
+ array(
+ array(
+ 'title' => __( 'Players', 'sportspress' ),
+ 'type' => 'title',
+ 'desc' => '',
+ 'id' => 'eventplayer_options',
+ ),
+ ),
+ apply_filters(
+ 'sportspress_eventplayer_options',
+ array(
+ array(
+ 'title' => __( 'Order', 'sportspress' ),
+ 'id' => 'sportspress_event_player_sort',
+ 'default' => 'jersey',
+ 'type' => 'radio',
+ 'options' => array(
+ 'jersey' => __( 'Jersey (e.g. "33. John Doe")', 'sportspress' ),
+ 'name' => __( 'Name (e.g. "John Doe (33)")', 'sportspress' ),
+ ),
+ 'desc_tip' => 'When editing an event, this determines how the checklist of players are sorted in the Teams metabox. This does not affect the Box Score section.',
+ ),
+
+ )
+ ),
+ array(
+ array(
+ 'type' => 'sectionend',
+ 'id' => 'eventplayer_options',
+ ),
+ ),
+ array(
+ array(
+ 'title' => __( 'Event Results', 'sportspress' ),
+ 'type' => 'title',
+ 'desc' => '',
+ 'id' => 'result_options',
+ ),
+ ),
+ apply_filters(
+ 'sportspress_result_options',
+ array(
+ array(
+ 'title' => __( 'Columns', 'sportspress' ),
+ 'id' => 'sportspress_event_result_columns',
+ 'default' => 'auto',
+ 'type' => 'radio',
+ 'options' => array(
+ 'auto' => __( 'Auto', 'sportspress' ),
+ 'manual' => __( 'Manual', 'sportspress' ),
+ ),
+ ),
+
+ array(
+ 'title' => __( 'Outcome', 'sportspress' ),
+ 'desc' => __( 'Display outcome', 'sportspress' ),
+ 'id' => 'sportspress_event_show_outcome',
+ 'default' => 'no',
+ 'type' => 'checkbox',
+ ),
+ )
+ ),
+ array(
+ array(
+ 'type' => 'sectionend',
+ 'id' => 'result_options',
+ ),
+ ),
+ array(
+ array(
+ 'title' => __( 'Box Score', 'sportspress' ),
+ 'type' => 'title',
+ 'desc' => '',
+ 'id' => 'performance_options',
+ ),
+ ),
+ apply_filters(
+ 'sportspress_performance_options',
+ array_merge(
+ array(
+ array(
+ 'title' => __( 'Rows', 'sportspress' ),
+ 'desc' => __( 'Staff', 'sportspress' ),
+ 'id' => 'sportspress_event_show_staff',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'start',
+ ),
+
+ array(
+ 'desc' => __( 'Players', 'sportspress' ),
+ 'id' => 'sportspress_event_show_players',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => '',
+ ),
+
+ array(
+ 'desc' => __( 'Total', 'sportspress' ),
+ 'id' => 'sportspress_event_show_total',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'end',
+ ),
+
+ array(
+ 'title' => __( 'Columns', 'sportspress' ),
+ 'id' => 'sportspress_event_performance_columns',
+ 'default' => 'auto',
+ 'type' => 'radio',
+ 'options' => array(
+ 'auto' => __( 'Auto', 'sportspress' ),
+ 'manual' => __( 'Manual', 'sportspress' ),
+ ),
+ ),
+
+ array(
+ 'title' => __( 'Mode', 'sportspress' ),
+ 'id' => 'sportspress_event_performance_mode',
+ 'default' => 'values',
+ 'type' => 'radio',
+ 'options' => array(
+ 'values' => __( 'Values', 'sportspress' ),
+ 'icons' => __( 'Icons', 'sportspress' ),
+ ),
+ ),
+
+ array(
+ 'title' => __( 'Awards', 'sportspress' ),
+ 'id' => 'sportspress_event_performance_stars_type',
+ 'default' => 0,
+ 'type' => 'radio',
+ 'options' => array(
+ __( 'None', 'sportspress' ),
+ __( 'Player of the Match', 'sportspress' ),
+ __( 'Stars', 'sportspress' ),
+ __( 'Star Number', 'sportspress' ),
+ ),
+ ),
+
+ array(
+ 'title' => __( 'Positions', 'sportspress' ),
+ 'desc' => __( 'Top-level only', 'sportspress' ),
+ 'id' => 'sportspress_event_hide_child_positions',
+ 'default' => 'no',
+ 'type' => 'checkbox',
+ ),
+ ),
+ apply_filters(
+ 'sportspress_event_performance_display_options',
+ array(
+ array(
+ 'title' => __( 'Display', 'sportspress' ),
+ 'desc' => __( 'Squad Number', 'sportspress' ),
+ 'id' => 'sportspress_event_show_player_numbers',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'start',
+ ),
+
+ array(
+ 'desc' => __( 'Position', 'sportspress' ),
+ 'id' => 'sportspress_event_show_position',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => '',
+ ),
+
+ array(
+ 'desc' => __( 'Minutes', 'sportspress' ),
+ 'id' => 'sportspress_event_performance_show_minutes',
+ 'default' => 'no',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'end',
+ ),
+ )
+ ),
+ array(
+ array(
+ 'title' => __( 'Performance', 'sportspress' ),
+ 'id' => 'sportspress_event_performance_sections',
+ 'default' => -1,
+ 'type' => 'radio',
+ 'options' => array(
+ -1 => __( 'Combined', 'sportspress' ),
+ 0 => __( 'Offense', 'sportspress' ) . ' → ' . __( 'Defense', 'sportspress' ),
+ 1 => __( 'Defense', 'sportspress' ) . ' → ' . __( 'Offense', 'sportspress' ),
+ ),
+ ),
+
+ array(
+ 'title' => __( 'Total', 'sportspress' ),
+ 'id' => 'sportspress_event_total_performance',
+ 'default' => 'all',
+ 'type' => 'radio',
+ 'options' => array(
+ 'all' => __( 'All', 'sportspress' ),
+ 'primary' => __( 'Primary', 'sportspress' ),
+ ),
+ ),
+ )
+ )
+ ),
+ array(
+ array(
+ 'type' => 'sectionend',
+ 'id' => 'performance_options',
),
)
- ) ),
+ );
- array(
- array( 'type' => 'sectionend', 'id' => 'event_options' ),
- ),
-
- array(
- array( 'title' => __( 'Venues', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'venue_options' ),
- ),
-
- apply_filters( 'sportspress_venue_options', array(
- array(
- 'title' => __( 'Link', 'sportspress' ),
- 'desc' => __( 'Link venues', 'sportspress' ),
- 'id' => 'sportspress_link_venues',
- 'default' => 'no',
- 'type' => 'checkbox',
- ),
-
- array(
- 'title' => __( 'Venue Map', 'sportspress' ),
- 'desc' => __( 'Display venue map', 'sportspress' ),
- 'id' => 'sportspress_event_show_maps',
- 'default' => 'yes',
- 'type' => 'checkbox',
- ),
-
- array(
- 'title' => __( 'Type', 'sportspress' ),
- 'id' => 'sportspress_map_type',
- 'default' => 'ROADMAP',
- 'type' => 'radio',
- 'options' => array(
- 'ROADMAP' => __( 'Default', 'sportspress' ),
- 'SATELLITE' => __( 'Satellite', 'sportspress' ),
- ),
- ),
-
- array(
- 'title' => __( 'Zoom', 'sportspress' ),
- 'id' => 'sportspress_map_zoom',
- 'class' => 'small-text',
- 'default' => '15',
- 'desc' => '0 - 21',
- 'type' => 'number',
- 'custom_attributes' => array(
- 'min' => 0,
- 'max' => 21,
- 'step' => 1
- ),
- ),
- ) ),
-
- array(
- array( 'type' => 'sectionend', 'id' => 'venue_options' ),
- ),
-
- array(
- array( 'title' => __( 'Teams', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'event_logo_options' ),
- ),
-
- apply_filters( 'sportspress_event_logo_options', array(
- array(
- 'title' => __( 'Order', 'sportspress' ),
- 'desc' => __( 'Reverse order', 'sportspress' ),
- 'id' => 'sportspress_event_reverse_teams',
- 'default' => 'no',
- 'type' => 'checkbox',
- ),
-
- array(
- 'title' => __( 'Layout', 'sportspress' ),
- 'id' => 'sportspress_event_logos_format',
- 'default' => 'inline',
- 'type' => 'radio',
- 'options' => array(
- 'inline' => __( 'Inline', 'sportspress' ),
- 'block' => __( 'Block', 'sportspress' ),
- ),
- ),
-
- array(
- 'title' => __( 'Display', 'sportspress' ),
- 'desc' => __( 'Name', 'sportspress' ),
- 'id' => 'sportspress_event_logos_show_team_names',
- 'default' => 'yes',
- 'type' => 'checkbox',
- 'checkboxgroup' => 'start',
- ),
-
- array(
- 'desc' => __( 'Time', 'sportspress' ),
- 'id' => 'sportspress_event_logos_show_time',
- 'default' => 'no',
- 'type' => 'checkbox',
- 'checkboxgroup' => '',
- ),
-
- array(
- 'desc' => __( 'Results', 'sportspress' ),
- 'id' => 'sportspress_event_logos_show_results',
- 'default' => 'no',
- 'type' => 'checkbox',
- 'checkboxgroup' => 'end',
- ),
- ) ),
-
- array(
- array( 'type' => 'sectionend', 'id' => 'event_logo_options' ),
- ),
-
- array(
- array( 'title' => __( 'Players', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'eventplayer_options' ),
- ),
-
- apply_filters( 'sportspress_eventplayer_options', array(
- array(
- 'title' => __( 'Order', 'sportspress' ),
- 'id' => 'sportspress_event_player_sort',
- 'default' => 'jersey',
- 'type' => 'radio',
- 'options' => array(
- 'jersey'=> __( 'Jersey (e.g. "33. John Doe")', 'sportspress' ),
- 'name' => __( 'Name (e.g. "John Doe (33)")', 'sportspress' ),
- ),
- 'desc_tip' => 'When editing an event, this determines how the checklist of players are sorted in the Teams metabox. This does not affect the Box Score section.',
- ),
-
- ) ),
-
-
- array(
- array( 'type' => 'sectionend', 'id' => 'eventplayer_options' ),
- ),
-
- array(
- array( 'title' => __( 'Event Results', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'result_options' ),
- ),
-
- apply_filters( 'sportspress_result_options', array(
- array(
- 'title' => __( 'Columns', 'sportspress' ),
- 'id' => 'sportspress_event_result_columns',
- 'default' => 'auto',
- 'type' => 'radio',
- 'options' => array(
- 'auto' => __( 'Auto', 'sportspress' ),
- 'manual' => __( 'Manual', 'sportspress' ),
- ),
- ),
-
- array(
- 'title' => __( 'Outcome', 'sportspress' ),
- 'desc' => __( 'Display outcome', 'sportspress' ),
- 'id' => 'sportspress_event_show_outcome',
- 'default' => 'no',
- 'type' => 'checkbox',
- ),
- ) ),
-
- array(
- array( 'type' => 'sectionend', 'id' => 'result_options' ),
- ),
-
- array(
- array( 'title' => __( 'Box Score', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'performance_options' ),
- ),
-
- apply_filters( 'sportspress_performance_options', array_merge(
- array(
- array(
- 'title' => __( 'Rows', 'sportspress' ),
- 'desc' => __( 'Staff', 'sportspress' ),
- 'id' => 'sportspress_event_show_staff',
- 'default' => 'yes',
- 'type' => 'checkbox',
- 'checkboxgroup' => 'start',
- ),
-
- array(
- 'desc' => __( 'Players', 'sportspress' ),
- 'id' => 'sportspress_event_show_players',
- 'default' => 'yes',
- 'type' => 'checkbox',
- 'checkboxgroup' => '',
- ),
-
- array(
- 'desc' => __( 'Total', 'sportspress' ),
- 'id' => 'sportspress_event_show_total',
- 'default' => 'yes',
- 'type' => 'checkbox',
- 'checkboxgroup' => 'end',
- ),
-
- array(
- 'title' => __( 'Columns', 'sportspress' ),
- 'id' => 'sportspress_event_performance_columns',
- 'default' => 'auto',
- 'type' => 'radio',
- 'options' => array(
- 'auto' => __( 'Auto', 'sportspress' ),
- 'manual' => __( 'Manual', 'sportspress' ),
- ),
- ),
-
- array(
- 'title' => __( 'Mode', 'sportspress' ),
- 'id' => 'sportspress_event_performance_mode',
- 'default' => 'values',
- 'type' => 'radio',
- 'options' => array(
- 'values' => __( 'Values', 'sportspress' ),
- 'icons' => __( 'Icons', 'sportspress' ),
- ),
- ),
-
- array(
- 'title' => __( 'Awards', 'sportspress' ),
- 'id' => 'sportspress_event_performance_stars_type',
- 'default' => 0,
- 'type' => 'radio',
- 'options' => array(
- __( 'None', 'sportspress' ),
- __( 'Player of the Match', 'sportspress' ),
- __( 'Stars', 'sportspress' ),
- __( 'Star Number', 'sportspress' ),
- ),
- ),
-
- array(
- 'title' => __( 'Positions', 'sportspress' ),
- 'desc' => __( 'Top-level only', 'sportspress' ),
- 'id' => 'sportspress_event_hide_child_positions',
- 'default' => 'no',
- 'type' => 'checkbox',
- ),
- ),
-
- apply_filters( 'sportspress_event_performance_display_options', array(
- array(
- 'title' => __( 'Display', 'sportspress' ),
- 'desc' => __( 'Squad Number', 'sportspress' ),
- 'id' => 'sportspress_event_show_player_numbers',
- 'default' => 'yes',
- 'type' => 'checkbox',
- 'checkboxgroup' => 'start',
- ),
-
- array(
- 'desc' => __( 'Position', 'sportspress' ),
- 'id' => 'sportspress_event_show_position',
- 'default' => 'yes',
- 'type' => 'checkbox',
- 'checkboxgroup' => '',
- ),
-
- array(
- 'desc' => __( 'Minutes', 'sportspress' ),
- 'id' => 'sportspress_event_performance_show_minutes',
- 'default' => 'no',
- 'type' => 'checkbox',
- 'checkboxgroup' => 'end',
- ),
- ) ),
-
- array(
- array(
- 'title' => __( 'Performance', 'sportspress' ),
- 'id' => 'sportspress_event_performance_sections',
- 'default' => -1,
- 'type' => 'radio',
- 'options' => array(
- -1 => __( 'Combined', 'sportspress' ),
- 0 => __( 'Offense', 'sportspress' ) . ' → ' . __( 'Defense', 'sportspress' ),
- 1 => __( 'Defense', 'sportspress' ) . ' → ' . __( 'Offense', 'sportspress' ),
- ),
- ),
-
- array(
- 'title' => __( 'Total', 'sportspress' ),
- 'id' => 'sportspress_event_total_performance',
- 'default' => 'all',
- 'type' => 'radio',
- 'options' => array(
- 'all' => __( 'All', 'sportspress' ),
- 'primary' => __( 'Primary', 'sportspress' ),
- ),
- ),
- )
- ) ),
-
- array(
- array( 'type' => 'sectionend', 'id' => 'performance_options' ),
- )
-
- );
-
- return apply_filters( 'sportspress_event_settings', $settings );
- }
-
- /**
- * Save settings
- */
- public function save() {
- parent::save();
-
- if ( isset( $_POST['sportspress_event_teams_delimiter'] ) )
- update_option( 'sportspress_event_teams_delimiter', sanitize_text_field( $_POST['sportspress_event_teams_delimiter'] ) );
- }
-
- /**
- * Delimiter settings
- *
- * @access public
- * @return void
- */
- public function delimiter_setting() {
- $selection = get_option( 'sportspress_event_teams_delimiter', 'vs' );
- $limit = get_option( 'sportspress_event_teams', 2 );
- if ( 0 == $limit ) {
- $limit = 2;
+ return apply_filters( 'sportspress_event_settings', $settings );
}
- if ( 3 >= $limit ) {
- $example = str_repeat( __( 'Team', 'sportspress' ) . ' %1$s ', $limit );
- } else {
- $example = str_repeat( __( 'Team', 'sportspress' ) . ' %1$s ', 3 ) . '…';
+
+ /**
+ * Save settings
+ */
+ public function save() {
+ parent::save();
+
+ if ( isset( $_POST['sportspress_event_teams_delimiter'] ) ) {
+ update_option( 'sportspress_event_teams_delimiter', sanitize_text_field( $_POST['sportspress_event_teams_delimiter'] ) );
+ }
}
- $example = rtrim( $example, ' %1$s ' );
- ?>
+
+ /**
+ * Delimiter settings
+ *
+ * @access public
+ * @return void
+ */
+ public function delimiter_setting() {
+ $selection = get_option( 'sportspress_event_teams_delimiter', 'vs' );
+ $limit = get_option( 'sportspress_event_teams', 2 );
+ if ( 0 == $limit ) {
+ $limit = 2;
+ }
+ if ( 3 >= $limit ) {
+ $example = str_repeat( __( 'Team', 'sportspress' ) . ' %1$s ', $limit );
+ } else {
+ $example = str_repeat( __( 'Team', 'sportspress' ) . ' %1$s ', 3 ) . '…';
+ }
+ $example = rtrim( $example, ' %1$s ' );
+ ?>
-
+
-
+
>
>
@@ -507,9 +559,9 @@ class SP_Settings_Events extends SP_Settings_Page {
- id = 'general';
- $this->label = __( 'General', 'sportspress' );
+ class SP_Settings_General extends SP_Settings_Page {
- add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
- add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
- add_action( 'sportspress_admin_field_timezone', array( $this, 'timezone_setting' ) );
- add_action( 'sportspress_admin_field_colors', array( $this, 'colors_setting' ) );
- add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
- }
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->id = 'general';
+ $this->label = __( 'General', 'sportspress' );
- /**
- * Get settings array
- *
- * @return array
- */
- public function get_settings() {
-
- $presets = SP_Admin_Sports::get_preset_options();
-
- $leagues = array( '' => __( '— Select —', 'sportspress' ) );
-
- $terms = get_terms( array(
- 'taxonomy' => 'sp_league',
- 'hide_empty' => false,
- ) );
-
- if ( $terms ) {
- foreach ( $terms as $term ) {
- $leagues[ $term->term_id ] = $term->name;
- }
+ add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
+ add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
+ add_action( 'sportspress_admin_field_timezone', array( $this, 'timezone_setting' ) );
+ add_action( 'sportspress_admin_field_colors', array( $this, 'colors_setting' ) );
+ add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
- $seasons = array( '' => __( '— Select —', 'sportspress' ) );
+ /**
+ * Get settings array
+ *
+ * @return array
+ */
+ public function get_settings() {
- $terms = get_terms( array(
- 'taxonomy' => 'sp_season',
- 'hide_empty' => false,
- ) );
+ $presets = SP_Admin_Sports::get_preset_options();
- if ( $terms ) {
- foreach ( $terms as $term ) {
- $seasons[ $term->term_id ] = $term->name;
+ $leagues = array( '' => __( '— Select —', 'sportspress' ) );
+
+ $terms = get_terms(
+ array(
+ 'taxonomy' => 'sp_league',
+ 'hide_empty' => false,
+ )
+ );
+
+ if ( $terms ) {
+ foreach ( $terms as $term ) {
+ $leagues[ $term->term_id ] = $term->name;
+ }
}
- }
- $settings = array_merge(
-
- array(
- array( 'title' => __( 'General Options', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'general_options' ),
- ),
-
- apply_filters( 'sportspress_general_options', array(
- array( 'type' => 'timezone' ),
+ $seasons = array( '' => __( '— Select —', 'sportspress' ) );
+ $terms = get_terms(
array(
- 'title' => __( 'Sport', 'sportspress' ),
- 'id' => 'sportspress_sport',
- 'default' => 'none',
- 'type' => 'sport',
- 'options' => $presets,
- ),
+ 'taxonomy' => 'sp_season',
+ 'hide_empty' => false,
+ )
+ );
+ if ( $terms ) {
+ foreach ( $terms as $term ) {
+ $seasons[ $term->term_id ] = $term->name;
+ }
+ }
+
+ $settings = array_merge(
array(
- 'title' => __( 'Main League', 'sportspress' ),
- 'id' => 'sportspress_league',
- 'default' => null,
- 'type' => 'select',
- 'options' => $leagues,
- ),
-
- array(
- 'title' => __( 'Current Season', 'sportspress' ),
- 'id' => 'sportspress_season',
- 'default' => null,
- 'type' => 'select',
- 'options' => $seasons,
- ),
- )),
-
- array(
- array( 'type' => 'sectionend', 'id' => 'general_options' ),
- array( 'title' => __( 'Styles and Scripts', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'script_styling_options' ),
- )
- );
-
- $options = array(
- array( 'type' => 'colors' ),
- );
-
- if ( ( $styles = SP_Frontend_Scripts::get_styles() ) && array_key_exists( 'sportspress-general', $styles ) ):
- $options = array_merge( $options, array(
- array(
- 'title' => __( 'Align', 'sportspress' ),
- 'id' => 'sportspress_table_text_align',
- 'default' => 'default',
- 'type' => 'radio',
- 'options' => array(
- 'default' => __( 'Default', 'sportspress' ),
- 'left' => __( 'Left', 'sportspress' ),
- 'center' => __( 'Center', 'sportspress' ),
- 'right' => __( 'Right', 'sportspress' ),
+ array(
+ 'title' => __( 'General Options', 'sportspress' ),
+ 'type' => 'title',
+ 'desc' => '',
+ 'id' => 'general_options',
),
),
-
+ apply_filters(
+ 'sportspress_general_options',
+ array(
+ array( 'type' => 'timezone' ),
+
+ array(
+ 'title' => __( 'Sport', 'sportspress' ),
+ 'id' => 'sportspress_sport',
+ 'default' => 'none',
+ 'type' => 'sport',
+ 'options' => $presets,
+ ),
+
+ array(
+ 'title' => __( 'Main League', 'sportspress' ),
+ 'id' => 'sportspress_league',
+ 'default' => null,
+ 'type' => 'select',
+ 'options' => $leagues,
+ ),
+
+ array(
+ 'title' => __( 'Current Season', 'sportspress' ),
+ 'id' => 'sportspress_season',
+ 'default' => null,
+ 'type' => 'select',
+ 'options' => $seasons,
+ ),
+ )
+ ),
array(
- 'title' => __( 'Padding', 'sportspress' ),
- 'id' => 'sportspress_table_padding',
- 'class' => 'small-text',
- 'default' => null,
- 'placeholder' => __( 'Auto', 'sportspress' ),
- 'desc' => 'px',
- 'type' => 'number',
+ array(
+ 'type' => 'sectionend',
+ 'id' => 'general_options',
+ ),
+ array(
+ 'title' => __( 'Styles and Scripts', 'sportspress' ),
+ 'type' => 'title',
+ 'desc' => '',
+ 'id' => 'script_styling_options',
+ ),
+ )
+ );
+
+ $options = array(
+ array( 'type' => 'colors' ),
+ );
+
+ if ( ( $styles = SP_Frontend_Scripts::get_styles() ) && array_key_exists( 'sportspress-general', $styles ) ) :
+ $options = array_merge(
+ $options,
+ array(
+ array(
+ 'title' => __( 'Align', 'sportspress' ),
+ 'id' => 'sportspress_table_text_align',
+ 'default' => 'default',
+ 'type' => 'radio',
+ 'options' => array(
+ 'default' => __( 'Default', 'sportspress' ),
+ 'left' => __( 'Left', 'sportspress' ),
+ 'center' => __( 'Center', 'sportspress' ),
+ 'right' => __( 'Right', 'sportspress' ),
+ ),
+ ),
+
+ array(
+ 'title' => __( 'Padding', 'sportspress' ),
+ 'id' => 'sportspress_table_padding',
+ 'class' => 'small-text',
+ 'default' => null,
+ 'placeholder' => __( 'Auto', 'sportspress' ),
+ 'desc' => 'px',
+ 'type' => 'number',
+ 'custom_attributes' => array(
+ 'step' => 1,
+ ),
+ ),
+ )
+ );
+ endif;
+
+ $options = array_merge(
+ $options,
+ array(
+ array(
+ 'title' => __( 'Custom CSS', 'sportspress' ),
+ 'id' => 'sportspress_custom_css',
+ 'css' => 'width:100%; height: 130px;',
+ 'type' => 'textarea',
+ ),
+ ),
+ apply_filters(
+ 'sportspress_general_script_options',
+ array(
+ array(
+ 'title' => __( 'Scripts', 'sportspress' ),
+ 'desc' => __( 'Live countdowns', 'sportspress' ),
+ 'id' => 'sportspress_enable_live_countdowns',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'start',
+ 'desc_tip' => __( 'This will enable a script allowing the countdowns to be animated.', 'sportspress' ),
+ ),
+
+ array(
+ 'desc' => __( 'Shortcode menu', 'sportspress' ),
+ 'id' => 'sportspress_rich_editing',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'end',
+ 'desc_tip' => __( 'This will enable a shortcode menu to be displayed in the visual editor.', 'sportspress' ),
+ ),
+ )
+ ),
+ array(
+ array(
+ 'title' => __( 'Tables', 'sportspress' ),
+ 'desc' => __( 'Responsive', 'sportspress' ),
+ 'id' => 'sportspress_enable_responsive_tables',
+ 'default' => 'no',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'start',
+ ),
+
+ array(
+ 'desc' => __( 'Scrollable', 'sportspress' ),
+ 'id' => 'sportspress_enable_scrollable_tables',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => '',
+ ),
+
+ array(
+ 'desc' => __( 'Sortable', 'sportspress' ),
+ 'id' => 'sportspress_enable_sortable_tables',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'end',
+ ),
+
+ array(
+ 'title' => __( 'Widgets', 'sportspress' ),
+ 'desc' => __( 'Unique', 'sportspress' ),
+ 'id' => 'sportspress_widget_unique',
+ 'default' => 'no',
+ 'type' => 'checkbox',
+ 'desc_tip' => __( 'Hide widget when same as content.', 'sportspress' ),
+ ),
+ )
+ );
+
+ if ( apply_filters( 'sportspress_enable_header', false ) ) {
+ $options[] = array(
+ 'title' => __( 'Header Offset', 'sportspress' ),
+ 'id' => 'sportspress_header_offset',
+ 'class' => 'small-text',
+ 'default' => null,
+ 'placeholder' => __( 'Auto', 'sportspress' ),
+ 'desc' => 'px',
+ 'type' => 'number',
'custom_attributes' => array(
- 'step' => 1
+ 'step' => 1,
),
- ),
- ));
- endif;
-
- $options = array_merge( $options,
- array(
- array(
- 'title' => __( 'Custom CSS', 'sportspress' ),
- 'id' => 'sportspress_custom_css',
- 'css' => 'width:100%; height: 130px;',
- 'type' => 'textarea',
- ),
- ),
-
- apply_filters( 'sportspress_general_script_options', array(
- array(
- 'title' => __( 'Scripts', 'sportspress' ),
- 'desc' => __( 'Live countdowns', 'sportspress' ),
- 'id' => 'sportspress_enable_live_countdowns',
- 'default' => 'yes',
- 'type' => 'checkbox',
- 'checkboxgroup' => 'start',
- 'desc_tip' => __( 'This will enable a script allowing the countdowns to be animated.', 'sportspress' ),
- ),
-
- array(
- 'desc' => __( 'Shortcode menu', 'sportspress' ),
- 'id' => 'sportspress_rich_editing',
- 'default' => 'yes',
- 'type' => 'checkbox',
- 'checkboxgroup' => 'end',
- 'desc_tip' => __( 'This will enable a shortcode menu to be displayed in the visual editor.', 'sportspress' ),
- ),
- ) ),
-
- array(
- array(
- 'title' => __( 'Tables', 'sportspress' ),
- 'desc' => __( 'Responsive', 'sportspress' ),
- 'id' => 'sportspress_enable_responsive_tables',
- 'default' => 'no',
- 'type' => 'checkbox',
- 'checkboxgroup' => 'start',
- ),
-
- array(
- 'desc' => __( 'Scrollable', 'sportspress' ),
- 'id' => 'sportspress_enable_scrollable_tables',
- 'default' => 'yes',
- 'type' => 'checkbox',
- 'checkboxgroup' => '',
- ),
-
- array(
- 'desc' => __( 'Sortable', 'sportspress' ),
- 'id' => 'sportspress_enable_sortable_tables',
- 'default' => 'yes',
- 'type' => 'checkbox',
- 'checkboxgroup' => 'end',
- ),
-
- array(
- 'title' => __( 'Widgets', 'sportspress' ),
- 'desc' => __( 'Unique', 'sportspress' ),
- 'id' => 'sportspress_widget_unique',
- 'default' => 'no',
- 'type' => 'checkbox',
- 'desc_tip' => __( 'Hide widget when same as content.', 'sportspress' ),
- ),
- ) );
-
- if ( apply_filters( 'sportspress_enable_header', false ) ) {
- $options[] = array(
- 'title' => __( 'Header Offset', 'sportspress' ),
- 'id' => 'sportspress_header_offset',
- 'class' => 'small-text',
- 'default' => null,
- 'placeholder' => __( 'Auto', 'sportspress' ),
- 'desc' => 'px',
- 'type' => 'number',
- 'custom_attributes' => array(
- 'step' => 1
- ),
- );
- }
-
- $settings = array_merge( $settings, apply_filters( 'sportspress_script_styling_options', $options ), array(
- array( 'type' => 'sectionend', 'id' => 'script_styling_options' ),
- ));
-
- return apply_filters( 'sportspress_general_settings', $settings ); // End general settings
- }
-
- /**
- * Save settings
- */
- public function save() {
- if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) !== $_POST['sportspress_sport'] ):
- $sport = sanitize_key( $_POST['sportspress_sport'] );
- SP_Admin_Sports::apply_preset( $sport );
- delete_option( '_sp_needs_welcome' );
- update_option( 'sportspress_installed', 1 );
- endif;
-
- if ( isset( $_POST['add_sample_data'] ) ):
- SP_Admin_Sample_Data::delete_posts();
- SP_Admin_Sample_Data::insert_posts();
- endif;
-
- $settings = $this->get_settings();
- SP_Admin_Settings::save_fields( $settings );
-
- // Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
- if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', $_POST['timezone_string'] ) ) {
- $_POST['gmt_offset'] = preg_replace( '/UTC\+?/', '', sanitize_text_field( $_POST['timezone_string'] ) );
- $_POST['timezone_string'] = '';
- }
-
- if ( isset( $_POST['timezone_string'] ) )
- update_option( 'timezone_string', sanitize_option( 'timezone_string', $_POST['timezone_string'] ) );
-
- if ( isset( $_POST['gmt_offset'] ) )
- update_option( 'gmt_offset', sanitize_option( 'gmt_offset', $_POST['gmt_offset'] ) );
-
- if ( isset( $_POST['sportspress_frontend_css_primary'] ) ) {
-
- // Save settings
- $primary = ( ! empty( $_POST['sportspress_frontend_css_primary'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_primary'] ) : '';
- $background = ( ! empty( $_POST['sportspress_frontend_css_background'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_background'] ) : '';
- $text = ( ! empty( $_POST['sportspress_frontend_css_text'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_text'] ) : '';
- $heading = ( ! empty( $_POST['sportspress_frontend_css_heading'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_heading'] ) : '';
- $link = ( ! empty( $_POST['sportspress_frontend_css_link'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_link'] ) : '';
- $customize = ( ! empty( $_POST['sportspress_frontend_css_customize'] ) ) ? 1 : '';
-
- $colors = array(
- 'primary' => $primary,
- 'background' => $background,
- 'text' => $text,
- 'heading' => $heading,
- 'link' => $link,
- 'customize' => $customize,
- );
-
- // Merge with existing options if available
- $options = get_option( 'themeboy' );
- if ( is_array( $options ) ) {
- $colors = array_merge( $options, $colors );
+ );
}
- update_option( 'themeboy', $colors );
+ $settings = array_merge(
+ $settings,
+ apply_filters( 'sportspress_script_styling_options', $options ),
+ array(
+ array(
+ 'type' => 'sectionend',
+ 'id' => 'script_styling_options',
+ ),
+ )
+ );
+
+ return apply_filters( 'sportspress_general_settings', $settings ); // End general settings
}
- }
- /**
- * Timezone settings
- *
- * @access public
- * @return void
- */
- public function timezone_setting() {
- $current_offset = get_option( 'gmt_offset' );
- $tzstring = get_option( 'timezone_string' );
+ /**
+ * Save settings
+ */
+ public function save() {
+ if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) !== $_POST['sportspress_sport'] ) :
+ $sport = sanitize_key( $_POST['sportspress_sport'] );
+ SP_Admin_Sports::apply_preset( $sport );
+ delete_option( '_sp_needs_welcome' );
+ update_option( 'sportspress_installed', 1 );
+ endif;
- $check_zone_info = true;
+ if ( isset( $_POST['add_sample_data'] ) ) :
+ SP_Admin_Sample_Data::delete_posts();
+ SP_Admin_Sample_Data::insert_posts();
+ endif;
- // Remove old Etc mappings. Fallback to gmt_offset.
- if ( false !== strpos( $tzstring,'Etc/GMT' ) )
- $tzstring = '';
+ $settings = $this->get_settings();
+ SP_Admin_Settings::save_fields( $settings );
- if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists
- $check_zone_info = false;
- if ( 0 == $current_offset )
- $tzstring = 'UTC+0';
- elseif ($current_offset < 0)
- $tzstring = 'UTC' . $current_offset;
- else
- $tzstring = 'UTC+' . $current_offset;
+ // Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
+ if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', $_POST['timezone_string'] ) ) {
+ $_POST['gmt_offset'] = preg_replace( '/UTC\+?/', '', sanitize_text_field( $_POST['timezone_string'] ) );
+ $_POST['timezone_string'] = '';
+ }
+
+ if ( isset( $_POST['timezone_string'] ) ) {
+ update_option( 'timezone_string', sanitize_option( 'timezone_string', $_POST['timezone_string'] ) );
+ }
+
+ if ( isset( $_POST['gmt_offset'] ) ) {
+ update_option( 'gmt_offset', sanitize_option( 'gmt_offset', $_POST['gmt_offset'] ) );
+ }
+
+ if ( isset( $_POST['sportspress_frontend_css_primary'] ) ) {
+
+ // Save settings
+ $primary = ( ! empty( $_POST['sportspress_frontend_css_primary'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_primary'] ) : '';
+ $background = ( ! empty( $_POST['sportspress_frontend_css_background'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_background'] ) : '';
+ $text = ( ! empty( $_POST['sportspress_frontend_css_text'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_text'] ) : '';
+ $heading = ( ! empty( $_POST['sportspress_frontend_css_heading'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_heading'] ) : '';
+ $link = ( ! empty( $_POST['sportspress_frontend_css_link'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_link'] ) : '';
+ $customize = ( ! empty( $_POST['sportspress_frontend_css_customize'] ) ) ? 1 : '';
+
+ $colors = array(
+ 'primary' => $primary,
+ 'background' => $background,
+ 'text' => $text,
+ 'heading' => $heading,
+ 'link' => $link,
+ 'customize' => $customize,
+ );
+
+ // Merge with existing options if available
+ $options = get_option( 'themeboy' );
+ if ( is_array( $options ) ) {
+ $colors = array_merge( $options, $colors );
+ }
+
+ update_option( 'themeboy', $colors );
+ }
}
- $class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
- ?>
+
+ /**
+ * Timezone settings
+ *
+ * @access public
+ * @return void
+ */
+ public function timezone_setting() {
+ $current_offset = get_option( 'gmt_offset' );
+ $tzstring = get_option( 'timezone_string' );
+
+ $check_zone_info = true;
+
+ // Remove old Etc mappings. Fallback to gmt_offset.
+ if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) {
+ $tzstring = '';
+ }
+
+ if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists
+ $check_zone_info = false;
+ if ( 0 == $current_offset ) {
+ $tzstring = 'UTC+0';
+ } elseif ( $current_offset < 0 ) {
+ $tzstring = 'UTC' . $current_offset;
+ } else {
+ $tzstring = 'UTC+' . $current_offset;
+ }
+ }
+ $class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
+ ?>
-
+
-
+
-
-
-
+
+ array( '2b353e', 'f4f4f4', '222222', 'ffffff', '00a69c' ),
- 'Gold' => array( '333333', 'f7f7f7', '333333', 'd8bf94', '9f8958' ),
- 'Denim' => array( '0e2440', 'eae5e0', '0e2440', 'ffffff', '2b6291' ),
- 'Patriot' => array( '0d4785', 'ecedee', '333333', 'ffffff', 'c51d27' ),
- 'Metro' => array( '3a7895', '223344', 'ffffff', 'ffffff', 'ffa800' ),
- 'Stellar' => array( '313150', '050528', 'ffffff', 'ffffff', 'e00034' ),
- 'Carbon' => array( '353535', '191919', 'ededed', 'ffffff', 'f67f17' ),
- 'Avocado' => array( '00241e', '013832', 'ffffff', 'ffffff', 'efb11e' ),
- ) );
- ?>
+ /**
+ * Output the frontend styles settings.
+ *
+ * @access public
+ * @return void
+ */
+ public function colors_setting() {
+ // Define color schemes each with 5 colors: Primary, Background, Text, Heading, Link
+ $color_schemes = apply_filters(
+ 'sportspress_color_schemes',
+ array(
+ 'ThemeBoy' => array( '2b353e', 'f4f4f4', '222222', 'ffffff', '00a69c' ),
+ 'Gold' => array( '333333', 'f7f7f7', '333333', 'd8bf94', '9f8958' ),
+ 'Denim' => array( '0e2440', 'eae5e0', '0e2440', 'ffffff', '2b6291' ),
+ 'Patriot' => array( '0d4785', 'ecedee', '333333', 'ffffff', 'c51d27' ),
+ 'Metro' => array( '3a7895', '223344', 'ffffff', 'ffffff', 'ffa800' ),
+ 'Stellar' => array( '313150', '050528', 'ffffff', 'ffffff', 'e00034' ),
+ 'Carbon' => array( '353535', '191919', 'ededed', 'ffffff', 'f67f17' ),
+ 'Avocado' => array( '00241e', '013832', 'ffffff', 'ffffff', 'efb11e' ),
+ )
+ );
+ ?>
+
-
-
- $colors ) { ?>
-
+
+
+ $colors ) { ?>
+
@@ -368,14 +408,16 @@ class SP_Settings_General extends SP_Settings_Page {
-
-
-
+
+
+
- color_picker( __( 'Primary', 'sportspress' ), 'sportspress_frontend_css_primary', $colors['primary'] );
- $this->color_picker( __( 'Background', 'sportspress' ), 'sportspress_frontend_css_background', $colors['background'] );
- $this->color_picker( __( 'Text', 'sportspress' ), 'sportspress_frontend_css_text', $colors['text'] );
- $this->color_picker( __( 'Heading', 'sportspress' ), 'sportspress_frontend_css_heading', $colors['heading'] );
- $this->color_picker( __( 'Link', 'sportspress' ), 'sportspress_frontend_css_link', $colors['link'] );
+ $this->color_picker( __( 'Primary', 'sportspress' ), 'sportspress_frontend_css_primary', $colors['primary'] );
+ $this->color_picker( __( 'Background', 'sportspress' ), 'sportspress_frontend_css_background', $colors['background'] );
+ $this->color_picker( __( 'Text', 'sportspress' ), 'sportspress_frontend_css_text', $colors['text'] );
+ $this->color_picker( __( 'Heading', 'sportspress' ), 'sportspress_frontend_css_heading', $colors['heading'] );
+ $this->color_picker( __( 'Link', 'sportspress' ), 'sportspress_frontend_css_link', $colors['link'] );
- if ( ( $styles = SP_Frontend_Scripts::get_styles() ) && array_key_exists( 'sportspress-general', $styles ) ):
- ?>
-
+ if ( ( $styles = SP_Frontend_Scripts::get_styles() ) && array_key_exists( 'sportspress-general', $styles ) ) :
+ ?>
+
+
>
-
+
-
+ ' . esc_html( $name ) . '
-
+ /**
+ * Output a colour picker input box.
+ *
+ * @access public
+ * @param mixed $name
+ * @param mixed $id
+ * @param mixed $value
+ * @return void
+ */
+ function color_picker( $name, $id, $value ) {
+ echo '';
+ }
}
-}
endif;
diff --git a/includes/admin/settings/class-sp-settings-licenses.php b/includes/admin/settings/class-sp-settings-licenses.php
index b9e1c806..accb8156 100644
--- a/includes/admin/settings/class-sp-settings-licenses.php
+++ b/includes/admin/settings/class-sp-settings-licenses.php
@@ -2,63 +2,69 @@
/**
* SportsPress License Settings
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
if ( ! class_exists( 'SP_Settings_Licenses' ) ) :
-/**
- * SP_Settings_Licenses
- */
-class SP_Settings_Licenses extends SP_Settings_Page {
-
/**
- * @var array
+ * SP_Settings_Licenses
*/
- public $licenses = array();
+ class SP_Settings_Licenses extends SP_Settings_Page {
- /**
- * Constructor
- */
- public function __construct() {
- $this->id = 'licenses';
- $this->label = __( 'Licenses', 'sportspress' );
+ /**
+ * @var array
+ */
+ public $licenses = array();
- $this->licenses = apply_filters( 'sportspress_licenses', array(
- 'pro' => array(
- 'name' => 'SportsPress Pro',
- 'url' => 'https://account.themeboy.com',
- ),
- ));
-
- if ( sizeof ( $this->licenses ) <= 1 )
- return;
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->id = 'licenses';
+ $this->label = __( 'Licenses', 'sportspress' );
- add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
- add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
- add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
- }
+ $this->licenses = apply_filters(
+ 'sportspress_licenses',
+ array(
+ 'pro' => array(
+ 'name' => 'SportsPress Pro',
+ 'url' => 'https://account.themeboy.com',
+ ),
+ )
+ );
- /**
- * Output licenses
- *
- * @access public
- * @return void
- */
- public function output() {
- ?>
-
+ if ( sizeof( $this->licenses ) <= 1 ) {
+ return;
+ }
+
+ add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
+ add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
+ add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
+ }
+
+ /**
+ * Output licenses
+ *
+ * @access public
+ * @return void
+ */
+ public function output() {
+ ?>
+
licenses as $id => $license ) {
- $key = get_site_option( 'sportspress_' . $id . '_license_key' );
- $key = trim( $key );
+ $key = get_site_option( 'sportspress_' . $id . '_license_key' );
+ $key = trim( $key );
$status = get_site_option( 'sportspress_' . $id . '_license_status', false );
?>
@@ -94,121 +100,137 @@ class SP_Settings_Licenses extends SP_Settings_Page {
- $value ) {
- if ( 'sp_license_activate_' === substr( $name, 0, 20 ) ) {
- $this->activate( substr( $name, 20 ) );
- } elseif ( 'sp_license_deactivate_' === substr( $name, 0, 22 ) ) {
- $this->deactivate( substr( $name, 22 ) );
+
+ /**
+ * Save license
+ */
+ public function save() {
+ // run a quick security check
+ if ( ! check_admin_referer( 'sp_license_nonce', 'sp_license_nonce' ) ) {
+ return;
+ }
+
+ foreach ( $_POST as $name => $value ) {
+ if ( 'sp_license_activate_' === substr( $name, 0, 20 ) ) {
+ $this->activate( substr( $name, 20 ) );
+ } elseif ( 'sp_license_deactivate_' === substr( $name, 0, 22 ) ) {
+ $this->deactivate( substr( $name, 22 ) );
+ }
+ }
+ }
+
+ /**
+ * Activate license
+ */
+ public function activate( $id ) {
+
+ // return if a license key isn't set
+ if ( ! isset( $_POST[ 'sp_license_key_' . $id ] ) ) {
+ return;
+ }
+
+ // retrieve the license key
+ $license = trim( sanitize_text_field( $_POST[ 'sp_license_key_' . $id ] ) );
+
+ // get the name of the product
+ $name = $this->licenses[ $id ]['name'];
+
+ // data to send in our API request
+ $api_params = array(
+ 'edd_action' => 'activate_license',
+ 'license' => $license,
+ 'item_name' => urlencode( $name ), // the name of our product in EDD
+ 'url' => home_url(),
+ );
+
+ // Call the custom API.
+ $response = wp_remote_post(
+ $this->licenses[ $id ]['url'],
+ array(
+ 'timeout' => 15,
+ 'sslverify' => false,
+ 'body' => $api_params,
+ )
+ );
+
+ // Make sure the response came back okay
+ if ( is_wp_error( $response ) ) {
+ SP_Admin_Settings::add_error( __( 'Sorry, there has been an error.', 'sportspress' ) );
+ return false;
+ }
+
+ // Decode the license data
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
+
+ // Update license status
+ update_site_option( 'sportspress_' . $id . '_license_status', $license_data->license );
+
+ // Update License or display error
+ if ( 'valid' == $license_data->license ) {
+ update_site_option( 'sportspress_' . $id . '_license_key', $license );
+ SP_Admin_Settings::add_override( __( 'License activated.', 'sportspress' ) );
+ } else {
+ SP_Admin_Settings::add_error( __( 'License invalid.', 'sportspress' ) );
+ }
+ }
+
+ /**
+ * Deactivate license
+ */
+ public function deactivate( $id ) {
+
+ // return if a license key isn't set
+ if ( ! isset( $_POST[ 'sp_license_key_' . $id ] ) ) {
+ return;
+ }
+
+ // retrieve the license key
+ $license = trim( sanitize_text_field( $_POST[ 'sp_license_key_' . $id ] ) );
+
+ // get the name of the product
+ $name = $this->licenses[ $id ]['name'];
+
+ // data to send in our API request
+ $api_params = array(
+ 'edd_action' => 'deactivate_license',
+ 'license' => $license,
+ 'item_name' => urlencode( $name ), // the name of our product in EDD
+ 'url' => home_url(),
+ );
+
+ // Call the custom API.
+ $response = wp_remote_post(
+ $this->licenses[ $id ]['url'],
+ array(
+ 'timeout' => 15,
+ 'sslverify' => false,
+ 'body' => $api_params,
+ )
+ );
+
+ // make sure the response came back okay
+ if ( is_wp_error( $response ) ) {
+ SP_Admin_Settings::add_error( __( 'Sorry, there has been an error.', 'sportspress' ) );
+ return false;
+ }
+
+ // decode the license data
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
+
+ // $license_data->license will be either "deactivated" or "failed"
+ if ( $license_data->license == 'deactivated' ) {
+ delete_site_option( 'sportspress_' . $id . '_license_status' );
+ SP_Admin_Settings::add_override( __( 'License deactivated.', 'sportspress' ) );
+ } else {
+ SP_Admin_Settings::add_error( __( 'Sorry, there has been an error.', 'sportspress' ) );
}
}
}
- /**
- * Activate license
- */
- public function activate( $id ) {
-
- // return if a license key isn't set
- if ( ! isset( $_POST[ 'sp_license_key_' . $id ] ) )
- return;
-
- // retrieve the license key
- $license = trim( sanitize_text_field( $_POST[ 'sp_license_key_' . $id ] ) );
-
- // get the name of the product
- $name = $this->licenses[ $id ]['name'];
-
- // data to send in our API request
- $api_params = array(
- 'edd_action'=> 'activate_license',
- 'license' => $license,
- 'item_name' => urlencode( $name ), // the name of our product in EDD
- 'url' => home_url()
- );
-
- // Call the custom API.
- $response = wp_remote_post( $this->licenses[ $id ]['url'], array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
-
- // Make sure the response came back okay
- if ( is_wp_error( $response ) ) {
- SP_Admin_Settings::add_error( __( 'Sorry, there has been an error.', 'sportspress' ) );
- return false;
- }
-
- // Decode the license data
- $license_data = json_decode( wp_remote_retrieve_body( $response ) );
-
- // Update license status
- update_site_option( 'sportspress_' . $id . '_license_status', $license_data->license );
-
- // Update License or display error
- if ( 'valid' == $license_data->license ) {
- update_site_option( 'sportspress_' . $id . '_license_key', $license );
- SP_Admin_Settings::add_override( __( 'License activated.', 'sportspress' ) );
- } else {
- SP_Admin_Settings::add_error( __( 'License invalid.', 'sportspress' ) );
- }
- }
-
- /**
- * Deactivate license
- */
- public function deactivate( $id ) {
-
- // return if a license key isn't set
- if ( ! isset( $_POST[ 'sp_license_key_' . $id ] ) )
- return;
-
- // retrieve the license key
- $license = trim( sanitize_text_field( $_POST[ 'sp_license_key_' . $id ] ) );
-
- // get the name of the product
- $name = $this->licenses[ $id ]['name'];
-
- // data to send in our API request
- $api_params = array(
- 'edd_action'=> 'deactivate_license',
- 'license' => $license,
- 'item_name' => urlencode( $name ), // the name of our product in EDD
- 'url' => home_url()
- );
-
- // Call the custom API.
- $response = wp_remote_post( $this->licenses[ $id ]['url'], array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
-
- // make sure the response came back okay
- if ( is_wp_error( $response ) ) {
- SP_Admin_Settings::add_error( __( 'Sorry, there has been an error.', 'sportspress' ) );
- return false;
- }
-
- // decode the license data
- $license_data = json_decode( wp_remote_retrieve_body( $response ) );
-
- // $license_data->license will be either "deactivated" or "failed"
- if ( $license_data->license == 'deactivated' ) {
- delete_site_option( 'sportspress_' . $id . '_license_status' );
- SP_Admin_Settings::add_override( __( 'License deactivated.', 'sportspress' ) );
- } else {
- SP_Admin_Settings::add_error( __( 'Sorry, there has been an error.', 'sportspress' ) );
- }
- }
-}
-
endif;
return new SP_Settings_Licenses();
diff --git a/includes/admin/settings/class-sp-settings-modules.php b/includes/admin/settings/class-sp-settings-modules.php
index 7fc04275..84f00854 100644
--- a/includes/admin/settings/class-sp-settings-modules.php
+++ b/includes/admin/settings/class-sp-settings-modules.php
@@ -2,55 +2,60 @@
/**
* SportsPress Module Settings
*
- * @author ThemeBoy
- * @category Admin
- * @package SportsPress/Admin
- * @version 2.7.9
+ * @author ThemeBoy
+ * @category Admin
+ * @package SportsPress/Admin
+ * @version 2.7.9
*/
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly
+}
if ( ! class_exists( 'SP_Settings_Modules' ) ) :
-/**
- * SP_Settings_Modules
- */
-class SP_Settings_Modules extends SP_Settings_Page {
-
/**
- * @var array
+ * SP_Settings_Modules
*/
- public $sections = array();
+ class SP_Settings_Modules extends SP_Settings_Page {
- /**
- * Constructor
- */
- public function __construct() {
- $this->id = 'modules';
- $this->label = __( 'Modules', 'sportspress' );
+ /**
+ * @var array
+ */
+ public $sections = array();
- $this->sections = apply_filters( 'sportspress_module_sections', array(
- 'general' => __( 'General', 'sportspress' ),
- 'event' => __( 'Events', 'sportspress' ),
- 'team' => __( 'Teams', 'sportspress' ),
- 'player_staff' => __( 'Players', 'sportspress' ) . ' & ' . __( 'Staff', 'sportspress' ),
- 'admin' => __( 'Dashboard', 'sportspress' ),
- 'other' => __( 'Other', 'sportspress' ),
- ));
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->id = 'modules';
+ $this->label = __( 'Modules', 'sportspress' );
- add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
- add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
- add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
- }
+ $this->sections = apply_filters(
+ 'sportspress_module_sections',
+ array(
+ 'general' => __( 'General', 'sportspress' ),
+ 'event' => __( 'Events', 'sportspress' ),
+ 'team' => __( 'Teams', 'sportspress' ),
+ 'player_staff' => __( 'Players', 'sportspress' ) . ' & ' . __( 'Staff', 'sportspress' ),
+ 'admin' => __( 'Dashboard', 'sportspress' ),
+ 'other' => __( 'Other', 'sportspress' ),
+ )
+ );
- /**
- * Output modules
- *
- * @access public
- * @return void
- */
- public function output() {
- ?>
+ add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
+ add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
+ add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
+ }
+
+ /**
+ * Output modules
+ *
+ * @access public
+ * @return void
+ */
+ public function output() {
+ ?>