Merge branch 'master' into feature-league-tables-bypass-ordering

This commit is contained in:
Brian Miyaji
2021-09-30 17:32:50 +09:00
committed by GitHub
119 changed files with 4379 additions and 2238 deletions

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.6.8
* @version 2.6.15
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -84,12 +84,6 @@ class SP_Admin_Assets {
wp_register_script( 'jquery-fitvids', SP()->plugin_url() . '/assets/js/jquery.fitvids.js', array( 'jquery' ), '1.1', true );
wp_register_script( 'google-maps', '//tboy.co/maps_js' );
wp_register_script( 'jquery-locationpicker', SP()->plugin_url() . '/assets/js/locationpicker.jquery.js', array( 'jquery', 'google-maps' ), '0.1.6', true );
wp_register_script( 'sportspress-admin-locationpicker', SP()->plugin_url() . '/assets/js/admin/locationpicker.js', array( 'jquery', 'google-maps', 'jquery-locationpicker' ), SP_VERSION, true );
wp_register_script( 'sportspress-admin-equationbuilder', SP()->plugin_url() . '/assets/js/admin/equationbuilder.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-droppable' ), SP_VERSION, true );
wp_register_script( 'sportspress-admin-colorpicker', SP()->plugin_url() . '/assets/js/admin/colorpicker.js', array( 'jquery', 'wp-color-picker', 'iris' ), SP_VERSION, true );
@@ -130,13 +124,6 @@ class SP_Admin_Assets {
wp_enqueue_script( 'sportspress-admin-widgets' );
}
// Edit venue pages
if ( in_array( $screen->id, array( 'edit-sp_venue' ) ) ) {
wp_enqueue_script( 'google-maps' );
wp_enqueue_script( 'jquery-locationpicker' );
wp_enqueue_script( 'sportspress-admin-locationpicker' );
}
// Edit color
if ( in_array( $screen->id, array( 'sp_outcome' ) ) ) {
wp_enqueue_script( 'sportspress-admin-colorpicker' );

View File

@@ -31,6 +31,7 @@ class SP_Admin_Dashboard {
* Init dashboard widgets
*/
public function init() {
wp_add_dashboard_widget( 'sportspress_dashboard_news', __( 'Sports News', 'sportspress' ), array( $this, 'news_widget' ), null, null, 'side' );
wp_add_dashboard_widget( 'sportspress_dashboard_status', __( 'SportsPress', 'sportspress' ), array( $this, 'status_widget' ) );
add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ), 10, 1 );
}
@@ -63,37 +64,61 @@ class SP_Admin_Dashboard {
* Show status widget
*/
public function status_widget() {
?>
<ul class="sp_status_list">
<?php
$count = wp_count_posts( 'sp_event' );
$scheduled_count = isset( $count->future ) ? $count->future : 0;
$published_count = isset( $count->publish ) ? $count->publish : 0;
$next_event = sp_get_next_event();
if ( $next_event ):
$now = new DateTime( current_time( 'mysql', 0 ) );
$date = new DateTime( $next_event->post_date );
$interval = date_diff( $now, $date );
?>
<li class="countdown" data-countdown="<?php echo str_replace( '-', '/', get_gmt_from_date( $next_event->post_date ) ); ?>">
<a href="<?php echo get_edit_post_link( $next_event->ID ); ?>">
<?php printf( __( '<strong>%s</strong> until next event', 'sportspress' ), $interval->days . ' ' . __( 'days', 'sportspress' ) . ' ' . sprintf( '%02s:%02s:%02s', $interval->h, $interval->i, $interval->s ) ); ?>
(<?php echo $next_event->post_title; ?>)
</a>
</li>
<?php endif; ?>
<li class="events-scheduled">
<a href="<?php echo admin_url( 'edit.php?post_type=sp_event&post_status=future' ); ?>">
<?php printf( _n( '<strong>%s event</strong> scheduled', '<strong>%s events</strong> scheduled', $scheduled_count, 'sportspress' ), $scheduled_count ); ?>
</a>
</li>
<li class="events-published">
<a href="<?php echo admin_url( 'edit.php?post_type=sp_event&post_status=publish' ); ?>">
<?php printf( _n( '<strong>%s event</strong> published', '<strong>%s events</strong> published', $published_count, 'sportspress' ), $published_count ); ?>
</a>
</li>
?>
<ul class="sp_status_list">
<?php
$count = wp_count_posts( 'sp_event' );
$scheduled_count = isset( $count->future ) ? $count->future : 0;
$published_count = isset( $count->publish ) ? $count->publish : 0;
$next_event = sp_get_next_event();
if ( $next_event ):
$now = new DateTime( current_time( 'mysql', 0 ) );
$date = new DateTime( $next_event->post_date );
$interval = date_diff( $now, $date );
?>
<li class="countdown" data-countdown="<?php echo str_replace( '-', '/', get_gmt_from_date( $next_event->post_date ) ); ?>">
<a href="<?php echo get_edit_post_link( $next_event->ID ); ?>">
<?php printf( __( '<strong>%s</strong> until next event', 'sportspress' ), $interval->days . ' ' . __( 'days', 'sportspress' ) . ' ' . sprintf( '%02s:%02s:%02s', $interval->h, $interval->i, $interval->s ) ); ?>
(<?php echo $next_event->post_title; ?>)
</a>
</li>
<?php endif; ?>
<li class="events-scheduled">
<a href="<?php echo admin_url( 'edit.php?post_type=sp_event&post_status=future' ); ?>">
<?php printf( _n( '<strong>%s event</strong> scheduled', '<strong>%s events</strong> scheduled', $scheduled_count, 'sportspress' ), $scheduled_count ); ?>
</a>
</li>
<li class="events-published">
<a href="<?php echo admin_url( 'edit.php?post_type=sp_event&post_status=publish' ); ?>">
<?php printf( _n( '<strong>%s event</strong> published', '<strong>%s events</strong> published', $published_count, 'sportspress' ), $published_count ); ?>
</a>
</li>
</ul>
<?php
}
/**
* Show news widget
*/
public function news_widget() {
$rss = fetch_feed("https://tboy.co/sportsnews/");
if (!is_wp_error($rss)) { // Checks that the object is created correctly
// Figure out how many total items there are, but limit it to 2.
$maxitems = $rss->get_item_quantity(5);
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
}
if (!empty($maxitems)) {
?>
<div class="rss-widget">
<ul>
<?php foreach ($rss_items as $item) { ?>
<li><a class="rsswidget" href="<?php echo $item->get_permalink(); ?>" target="_blank"><?php echo $item->get_title(); ?></a> <span class="rss-date"><?php echo $item->get_date('j F Y'); ?></span></li>
<?php } ?>
</ul>
<?php
</div>
<?php
}
}
}

View File

@@ -268,7 +268,7 @@ class SP_Admin_Menus {
$submenu_file = $s;
}
public static function sitemap_taxonomy_post_types( $post_types = array(), $taxonomy ) {
public static function sitemap_taxonomy_post_types( $post_types = array(), $taxonomy = 'sp_venue' ) {
$post_types = array_intersect( $post_types, sp_primary_post_types() );
// Remove teams from venues taxonomy post type array
if ( $taxonomy === 'sp_venue' && ( $key = array_search( 'sp_team', $post_types ) ) !== false ):

View File

@@ -171,7 +171,7 @@ class SP_Admin_Settings {
// Array value
if ( strstr( $option_name, '[' ) ) {
parse_str( $option_name, $option_array );
parse_str( html_entity_decode( $option_name ), $option_array );
// Option name is first key
$option_name = current( array_keys( $option_array ) );

View File

@@ -9,7 +9,7 @@
* @author WooThemes
* @category Admin
* @package SportsPress/Admin
* @version 2.6.7
* @version 2.6.15
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
@@ -101,11 +101,9 @@ class SP_Admin_Setup_Wizard {
wp_register_script( 'chosen', SP()->plugin_url() . '/assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
wp_register_script( 'jquery-tiptip', SP()->plugin_url() . '/assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true );
wp_register_script( 'google-maps', '//tboy.co/maps_js' );
wp_register_script( 'sportspress-setup', SP()->plugin_url() . '/assets/js/admin/sportspress-setup.js', array( 'jquery', 'chosen', 'jquery-tiptip' ), SP_VERSION, true );
wp_register_script( 'jquery-locationpicker', SP()->plugin_url() . '/assets/js/locationpicker.jquery.js', array( 'jquery', 'google-maps' ), '0.1.6', true );
wp_register_script( 'sportspress-admin-locationpicker', SP()->plugin_url() . '/assets/js/admin/locationpicker.js', array( 'jquery', 'jquery-locationpicker' ), SP_VERSION, true );
do_action( 'sp_setup_geocoder_scripts' );
$strings = apply_filters( 'sportspress_localized_strings', array(
'none' => __( 'None', 'sportspress' ),
@@ -115,8 +113,6 @@ class SP_Admin_Setup_Wizard {
// Localize scripts
wp_localize_script( 'sportspress-setup', 'localized_strings', $strings );
wp_enqueue_script( 'google-maps' );
if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
call_user_func( $this->steps[ $this->step ]['handler'] );
}
@@ -517,6 +513,7 @@ class SP_Admin_Setup_Wizard {
* Venue Step.
*/
public function sp_setup_venue() {
do_action( 'sp_setup_venue_geocoder_scripts' );
?>
<h1><?php _e( 'Venue Setup', 'sportspress' ); ?></h1>
<form method="post">
@@ -531,11 +528,11 @@ class SP_Admin_Setup_Wizard {
<tr>
<th scope="row"><?php _e( 'Address', 'sportspress' ); ?></th>
<td>
<input name="address" class="sp-address" type="text">
<div class="sp-location-picker"></div>
<input name="address" id="sp_address" class="sp-address" type="text" value="Marvel Stadium, Melbourne">
<div id="sp-location-picker" class="sp-location-picker" style="width: 95%; height: 320px"></div>
<p class="description"><?php _e( "Drag the marker to the venue's location.", 'sportspress' ); ?></p>
<input name="latitude" class="sp-latitude" type="hidden" value="40.7324319">
<input name="longitude" class="sp-longitude" type="hidden" value="-73.82480799999996">
<input name="latitude" id="sp_latitude" class="sp-latitude" type="hidden" value="-37.8165647">
<input name="longitude" id="sp_longitude" class="sp-longitude" type="hidden" value="144.9475055">
</td>
</tr>
</table>
@@ -546,8 +543,8 @@ class SP_Admin_Setup_Wizard {
<?php wp_nonce_field( 'sp-setup' ); ?>
</p>
</form>
<?php wp_print_scripts( 'sportspress-admin-locationpicker' ); ?>
<?php
do_action( 'sp_admin_geocoder_scripts' );
}
/**

View File

@@ -7,7 +7,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* Handles taxonomies in admin
*
* @class SP_Admin_Taxonomies
* @version 2.6.9
* @version 2.6.15
* @package SportsPress/Admin
* @category Class
* @author ThemeBoy
@@ -103,21 +103,24 @@ class SP_Admin_Taxonomies {
$term = reset( $terms );
$t_id = $term->term_id;
$term_meta = get_option( "taxonomy_$t_id" );
$latitude = sp_array_value( $term_meta, 'sp_latitude', '40.7324319' );
$longitude = sp_array_value( $term_meta, 'sp_longitude', '-73.82480799999996' );
$latitude = sp_array_value( $term_meta, 'sp_latitude', '-37.8165647' );
$longitude = sp_array_value( $term_meta, 'sp_longitude', '144.9475055' );
$address = sp_array_value( $term_meta, 'sp_address', '' );
endif;
// Sanitize latitude and longitude, fallback to default.
if( ! is_numeric( $latitude) || ! is_numeric( $longitude) ):
$latitude = '40.7324319';
$longitude = '-73.82480799999996';
$latitude = '-37.8165647';
$longitude = '144.9475055';
endif;
?>
<div class="form-field">
<label for="term_meta[sp_address]"><?php _e( 'Address', 'sportspress' ); ?></label>
<input type="text" class="sp-address" name="term_meta[sp_address]" id="term_meta[sp_address]" value="">
<p><div class="sp-location-picker"></div></p>
<div id="sp-location-picker" class="sp-location-picker" style="width: 95%; height: 320px"></div>
<p><?php _e( "Drag the marker to the venue's location.", 'sportspress' ); ?></p>
</div>
<div class="form-field">
<label for="term_meta[sp_address]"><?php _e( 'Address', 'sportspress' ); ?></label>
<input type="text" class="sp-address" name="term_meta[sp_address]" id="term_meta[sp_address]" value="<?php echo esc_attr( $address ); ?>">
</div>
<div class="form-field">
<label for="term_meta[sp_latitude]"><?php _e( 'Latitude', 'sportspress' ); ?></label>
<input type="text" class="sp-latitude" name="term_meta[sp_latitude]" id="term_meta[sp_latitude]" value="<?php echo esc_attr( $latitude ); ?>">
@@ -127,6 +130,7 @@ class SP_Admin_Taxonomies {
<input type="text" class="sp-longitude" name="term_meta[sp_longitude]" id="term_meta[sp_longitude]" value="<?php echo esc_attr( $longitude ); ?>">
</div>
<?php
do_action( 'sp_admin_geocoder_scripts' );
}
/**
@@ -137,28 +141,37 @@ class SP_Admin_Taxonomies {
*/
public function edit_venue_fields( $term ) {
$t_id = $term->term_id;
$term_meta = get_option( "taxonomy_$t_id" ); ?>
$term_meta = get_option( "taxonomy_$t_id" );
$latitude = is_numeric( esc_attr( $term_meta['sp_latitude'] ) ) ? esc_attr( $term_meta['sp_latitude'] ) : '';
$longitude = is_numeric( esc_attr( $term_meta['sp_longitude'] ) ) ? esc_attr( $term_meta['sp_longitude'] ) : '';
$address = esc_attr( $term_meta['sp_address'] ) ? esc_attr( $term_meta['sp_address'] ) : '';
?>
<tr class="form-field">
<td colspan="2">
<p><div id="sp-location-picker" class="sp-location-picker" style="width: 95%; height: 320px"></div></p>
<p class="description"><?php _e( "Drag the marker to the venue's location.", 'sportspress' ); ?></p>
</td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="term_meta[sp_address]"><?php _e( 'Address', 'sportspress' ); ?></label></th>
<td>
<input type="text" class="sp-address" name="term_meta[sp_address]" id="term_meta[sp_address]" value="<?php echo esc_attr( $term_meta['sp_address'] ) ? esc_attr( $term_meta['sp_address'] ) : ''; ?>">
<p><div class="sp-location-picker"></div></p>
<p class="description"><?php _e( "Drag the marker to the venue's location.", 'sportspress' ); ?></p>
<input type="text" class="sp-address" name="term_meta[sp_address]" id="term_meta[sp_address]" value="<?php echo $address; ?>">
</td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="term_meta[sp_latitude]"><?php _e( 'Latitude', 'sportspress' ); ?></label></th>
<td>
<input type="text" class="sp-latitude" name="term_meta[sp_latitude]" id="term_meta[sp_latitude]" value="<?php echo is_numeric( esc_attr( $term_meta['sp_latitude'] ) ) ? esc_attr( $term_meta['sp_latitude'] ) : ''; ?>">
<input type="text" class="sp-latitude" name="term_meta[sp_latitude]" id="term_meta[sp_latitude]" value="<?php echo $latitude; ?>">
</td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="term_meta[sp_longitude]"><?php _e( 'Longitude', 'sportspress' ); ?></label></th>
<td>
<input type="text" class="sp-longitude" name="term_meta[sp_longitude]" id="term_meta[sp_longitude]" value="<?php echo is_numeric( esc_attr( $term_meta['sp_longitude'] ) ) ? esc_attr( $term_meta['sp_longitude'] ) : ''; ?>">
<input type="text" class="sp-longitude" name="term_meta[sp_longitude]" id="term_meta[sp_longitude]" value="<?php echo $longitude; ?>">
</td>
</tr>
<?php
do_action( 'sp_admin_geocoder_scripts' );
}
/**

View File

@@ -9,7 +9,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.6
* @version 2.6.17
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -383,7 +383,7 @@ class SP_Admin_Welcome {
public function welcome() {
// Bail if no activation redirect transient is set
if ( ! get_transient( '_sp_activation_redirect' ) )
if ( ! get_transient( '_sp_activation_redirect' ) )
return;
// Delete the redirect transient

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Importers
* @version 2.5
* @version 2.7.1
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -472,9 +472,14 @@ if ( class_exists( 'WP_Importer' ) ) {
<td class="forminp forminp-radio" id="sp_formatdiv">
<fieldset id="post-formats-select">
<ul>
<li><input type="radio" name="sp_format" class="post-format" id="post-format-league" value="league" checked="checked"> <label for="post-format-league" class="post-format-icon post-format-league"><?php _e( 'Competitive', 'sportspress' ); ?></label></li>
<li><input type="radio" name="sp_format" class="post-format" id="post-format-friendly" value="friendly"> <label for="post-format-friendly" class="post-format-icon post-format-friendly"><?php _e( 'Friendly', 'sportspress' ); ?></label></li>
<br>
<?php
foreach( (new SP_Formats)->event as $name => $title ) {
?>
<li><input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo $name; ?>" value="<?php echo $name; ?>" checked="checked"> <label for="post-format-<?php echo $name; ?>" class="post-format-icon post-format-<?php echo $name; ?>"><?php echo $title; ?></label></li>
<?php
}
?>
</ul>
</fieldset>
</td>
</tr>

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Importers
* @version 2.5
* @version 2.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -138,6 +138,11 @@ if ( class_exists( 'WP_Importer' ) ) {
endif;
// Update venue
if ( $venue == '' ) {
$team = reset( $teams );
$team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
$venue = sp_get_the_term_id( $team_object->ID, 'sp_venue' );
}
wp_set_object_terms( $id, $venue, 'sp_venue', false );
// Update match day

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Importers
* @version 2.6.9
* @version 2.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -30,6 +30,7 @@ if ( class_exists( 'WP_Importer' ) ) {
'sp_league' => __( 'Leagues', 'sportspress' ),
'sp_season' => __( 'Seasons', 'sportspress' ),
'sp_nationality' => __( 'Nationality', 'sportspress' ),
'post_date' => __( 'Date of Birth', 'sportspress' ),
);
parent::__construct();
}
@@ -51,6 +52,9 @@ if ( class_exists( 'WP_Importer' ) ) {
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' : $_POST['sp_date_format'] );
foreach ( $rows as $row ):
@@ -69,7 +73,7 @@ if ( class_exists( 'WP_Importer' ) ) {
'sp_season',
);
foreach ( $preservable_metas_keys as $p ) {
$meta[ $key ] = '';
$meta[ $p ] = '';
}
foreach ( $columns as $index => $key ):
@@ -77,6 +81,27 @@ if ( class_exists( 'WP_Importer' ) ) {
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_array = explode( '-', $date );
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 ) . '-' .
substr( str_pad( sp_array_value( $date_array, 0, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 );
break;
case 'mm/dd/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, 0, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' .
substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 );
break;
default:
$date = substr( str_pad( sp_array_value( $date_array, 0, '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 ) . '-' .
substr( str_pad( sp_array_value( $date_array, 2, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 );
endswitch;
if ( ! $name ):
$this->skipped++;
@@ -97,6 +122,10 @@ if ( class_exists( 'WP_Importer' ) ) {
}
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;
}
$id = wp_insert_post( $args );
// Flag as import
@@ -195,7 +224,7 @@ if ( class_exists( 'WP_Importer' ) ) {
function greet() {
echo '<div class="narrow">';
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
echo '<p>' . sprintf( __( 'Players need to be defined with columns in a specific order (7 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/players-sample.csv' ) . '</p>';
echo '<p>' . sprintf( __( 'Players need to be defined with columns in a specific order (8 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/players-sample.csv' ) . '</p>';
wp_import_upload_form( 'admin.php?import=sp_player_csv&step=1' );
echo '</div>';
}
@@ -210,6 +239,26 @@ if ( class_exists( 'WP_Importer' ) ) {
?>
<table class="form-table">
<tbody>
<tr>
<th scope="row" class="titledesc">
<?php _e( 'Date of Birth Format', 'sportspress' ); ?>
</th>
<td class="forminp forminp-radio">
<fieldset>
<ul>
<li>
<label><input name="sp_date_format" value="yyyy/mm/dd" type="radio" checked> yyyy/mm/dd</label>
</li>
<li>
<label><input name="sp_date_format" value="dd/mm/yyyy" type="radio"> dd/mm/yyyy</label>
</li>
<li>
<label><input name="sp_date_format" value="mm/dd/yyyy" type="radio"> mm/dd/yyyy</label>
</li>
</ul>
</fieldset>
</td>
</tr>
<tr>
<td>
<label>

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Post_Types
* @version 2.6.5
* @version 2.7.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -44,6 +44,9 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
// Filtering
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
add_filter( 'parse_query', array( $this, 'filters_query' ) );
// Post states
add_filter( 'display_post_states', array( $this, 'post_states' ), 10, 2 );
// Call SP_Admin_CPT constructor
parent::__construct();
@@ -259,7 +262,7 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
if ( $typenow != 'sp_event' )
return;
$selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null;
$selected = isset( $_REQUEST['team'] ) ? esc_attr( $_REQUEST['team'] ) : null;
$args = array(
'post_type' => 'sp_team',
'name' => 'team',
@@ -269,7 +272,7 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
);
wp_dropdown_pages( $args );
$selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
$selected = isset( $_REQUEST['sp_league'] ) ? esc_attr( $_REQUEST['sp_league'] ) : null;
$args = array(
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
'taxonomy' => 'sp_league',
@@ -278,7 +281,7 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
);
sp_dropdown_taxonomies( $args );
$selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
$selected = isset( $_REQUEST['sp_season'] ) ? esc_attr( $_REQUEST['sp_season'] ) : null;
$args = array(
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
'taxonomy' => 'sp_season',
@@ -287,34 +290,61 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
);
sp_dropdown_taxonomies( $args );
$selected = isset( $_REQUEST['match_day'] ) ? $_REQUEST['match_day'] : null;
$selected = isset( $_REQUEST['match_day'] ) ? esc_attr( $_REQUEST['match_day'] ) : null;
echo '<input name="match_day" type="text" class="sp-tablenav-input" placeholder="' . __( 'Match Day', 'sportspress' ) . '" value="' . $selected . '">';
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;
/**
* Filter in admin based on options
*
* @param mixed $query
*/
public function filters_query( $query ) {
global $typenow, $wp_query;
if ( $typenow == 'sp_event' ) {
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_value'] = $_GET['team'];
$query->query_vars['meta_key'] = 'sp_team';
}
if ( ! empty( $_GET['match_day'] ) ) {
$query->query_vars['meta_value'] = $_GET['match_day'];
$query->query_vars['meta_key'] = 'sp_day';
}
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;

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
* @version 2.6.8
* @version 2.6.19
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -31,6 +31,7 @@ class SP_Meta_Box_Calendar_Details {
$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 );
@@ -125,6 +126,24 @@ class SP_Meta_Box_Calendar_Details {
endif;
?>
</p>
<p><strong><?php _e( 'Player', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'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' ) );
endif;
?>
</p>
<p><strong><?php _e( 'Sort by', 'sportspress' ); ?></strong></p>
<p>
<select name="sp_orderby">
@@ -163,5 +182,6 @@ class SP_Meta_Box_Calendar_Details {
update_post_meta( $post_id, 'sp_orderby', sp_array_value( $_POST, 'sp_orderby', null ) );
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', null ) );
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) );
}
}

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
* @version 2.5.5
* @version 2.7.3
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -250,7 +250,7 @@ class SP_Meta_Box_Event_Performance {
/**
* Admin edit table
*/
public static function table( $labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false, $positions = array(), $status = true, $section = -1, $formats = array(), $order = array(), $numbers = true, $team_timeline = array(), $timed = array(), $stars = array() ) {
public static function table( $labels = array(), $columns = array(), $data = array(), $team_id = null, $has_checkboxes = false, $positions = array(), $status = true, $section = -1, $formats = array(), $order = array(), $numbers = true, $team_timeline = array(), $timed = array(), $stars = array() ) {
?>
<div class="sp-data-table-container">
<table class="widefat sp-data-table sp-performance-table sp-sortable-table">
@@ -449,7 +449,8 @@ class SP_Meta_Box_Event_Performance {
$placeholder = sp_get_format_placeholder( sp_array_value( $formats, $column, 'number' ) );
?>
<td>
<?php if ( 'time' === sp_array_value( $formats, $column, 'number' ) ) { ?>
<?php $format = sp_array_value( $formats, $column, 'number' ); ?>
<?php if ( 'time' === $format ) { ?>
<?php
$intval = intval( $value );
$timeval = gmdate( 'i:s', $intval );
@@ -463,6 +464,9 @@ class SP_Meta_Box_Event_Performance {
<input class="sp-player-<?php echo $column; ?>-input sp-convert-time-input sp-sync-input" type="text" name="sp_times[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo esc_attr( $timeval ); ?>" placeholder="<?php echo $placeholder; ?>" />
<input class="sp-convert-time-output" type="hidden" name="sp_players[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo esc_attr( $value ); ?>" />
<?php } elseif ( 'checkbox' === $format ) { ?>
<input type="hidden" name="sp_players[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="0" />
<input class="sp-player-<?php echo $column; ?>-input sp-sync-input" type="checkbox" name="sp_players[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="1" data-value="<?php echo $value; ?>" <?php checked( $value ); ?> />
<?php } else { ?>
<input class="sp-player-<?php echo $column; ?>-input sp-sync-input" type="text" name="sp_players[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo $placeholder; ?>" />
<?php } ?>
@@ -499,8 +503,10 @@ class SP_Meta_Box_Event_Performance {
?>
<?php echo self::status_select( $team_id, $player_id, sp_array_value( $player_performance, 'status', null ) ); ?><br>
<?php echo self::sub_select( $team_id, $player_id, sp_array_value( $player_performance, 'sub', null ), $data ); ?><br>
<input class="sp-sync-input small-text" type="text" name="sp_timeline[<?php echo $team_id; ?>][<?php echo $player_id; ?>][sub][]" value="<?php echo esc_attr( sp_array_value( $times, 0, '' ) ); ?>" placeholder="-" />
<span class="description"><?php _e( 'mins', 'sportspress' ); ?></span>
<?php if ( is_array( $times ) ) { ?>
<input class="sp-sync-input small-text" type="text" name="sp_timeline[<?php echo $team_id; ?>][<?php echo $player_id; ?>][sub][]" value="<?php echo esc_attr( sp_array_value( $times, 0, '' ) ); ?>" placeholder="-" />
<span class="description"><?php _e( 'mins', 'sportspress' ); ?></span>
<?php } ?>
</td>
<?php } ?>
<?php if ( $stars_type ) { ?>

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
* @version 2.1
* @version 2.7.1
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -48,6 +48,7 @@ class SP_Meta_Box_List_Columns {
<?php _e( 'Position', 'sportspress' ); ?>
</label>
</li>
<?php do_action( 'sportspress_list_general_columns', $selected ); ?>
</ul>
<p><strong><?php _e( 'Data', 'sportspress' ); ?></strong></p>
<div class="sp-instance">

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
* @version 2.5.5
* @version 2.7.1
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -34,6 +34,9 @@ class SP_Meta_Box_List_Details {
$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 );
?>
<div>
<p><strong><?php _e( 'Heading', 'sportspress' ); ?></strong></p>
@@ -98,6 +101,19 @@ class SP_Meta_Box_List_Details {
<option value="past" <?php selected( 'past', $era ); ?>><?php _e( 'Past', 'sportspress' ); ?></option>
</select>
</p>
<p><strong><?php _e( 'Nationality', 'sportspress' ); ?></strong></p>
<p>
<select id="sp_nationality" name="sp_nationality[]" data-placeholder="<?php printf( __( 'Select %s', 'sportspress' ), __( 'Nationality', 'sportspress' ) ); ?>" class="widefat chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?>" multiple="multiple">
<option value=""></option>
<?php foreach ( $continents as $continent => $countries ): ?>
<optgroup label="<?php echo $continent; ?>">
<?php foreach ( $countries as $code => $country ): ?>
<option value="<?php echo $code; ?>" <?php selected ( in_array( $code, $nationalities ) ); ?>><?php echo $country; ?></option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select>
</p>
<p><strong><?php _e( 'Grouping', 'sportspress' ); ?></strong></p>
<p>
<select name="sp_grouping">
@@ -143,7 +159,16 @@ class SP_Meta_Box_List_Details {
</p>
<?php
if ( 'manual' == $select ) {
sp_post_checklist( $post->ID, 'sp_player', ( 'auto' == $select ? 'none' : 'block' ), array( 'sp_league', 'sp_season', 'sp_current_team' ) );
$player_filters = array( 'sp_league', 'sp_season' );
if ( $team_id ) {
if ( in_array( $era, [ 'all', 'past' ] ) ) {
$player_filters[] = 'sp_past_team';
}
if ( in_array( $era, [ 'all', 'current' ] ) ) {
$player_filters[] = 'sp_current_team';
}
}
sp_post_checklist( $post->ID, 'sp_player', ( 'auto' == $select ? 'none' : 'block' ), $player_filters );
sp_post_adder( 'sp_player', __( 'Add New', 'sportspress' ) );
} else {
?>
@@ -178,5 +203,6 @@ class SP_Meta_Box_List_Details {
update_post_meta( $post_id, 'sp_select', sp_array_value( $_POST, 'sp_select', array() ) );
update_post_meta( $post_id, 'sp_number', sp_array_value( $_POST, 'sp_number', array() ) );
sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) );
sp_update_post_meta_recursive( $post_id, 'sp_nationality', sp_array_value( $_POST, 'sp_nationality', array() ) );
}
}
}

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
* @version 2.6.3
* @version 2.6.15
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -65,9 +65,7 @@ class SP_Meta_Box_Outcome_Details extends SP_Meta_Box_Config {
'=' => sprintf( __( 'Equal %s', 'sportspress' ), $label ),
'else' => sprintf( __( 'Default', 'sportspress' ), $label ),
);
for( $i = 1; $i <= $count->publish; $i++ ):
$options[ $i ] = $i;
endfor;
foreach ( $options as $key => $value ):
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $condition, false ), $value );
endforeach;

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
* @version 2.3
* @version 2.6.19
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -77,7 +77,7 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
<p class="sp-format-selector">
<select name="sp_format">
<?php
$options = apply_filters( 'sportspress_performance_formats', array( 'number' => __( 'Number', 'sportspress' ), 'time' => __( 'Time', 'sportspress' ), 'text' => __( 'Text', 'sportspress' ), 'equation' => __( 'Equation', 'sportspress' ) ) );
$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( '<option value="%s" %s>%s</option>', $key, selected( $key == $format, true, false ), $value );
endforeach;
@@ -157,6 +157,8 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
</ul>
<?php
}
do_action( 'sportspress_meta_box_performance_details', $post );
}
/**

View File

@@ -92,7 +92,7 @@ class SP_Meta_Box_Player_Statistics {
/**
* Admin edit table
*/
public static function table( $id = null, $league_id, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $leagues = array(), $has_checkboxes = false, $team_select = false, $formats = array(), $total_types = array() ) {
public static function table( $id = null, $league_id = null, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $leagues = array(), $has_checkboxes = false, $team_select = false, $formats = array(), $total_types = array() ) {
$readonly = false;
$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 );

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
* @version 2.5.5
* @version 2.6.15
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -19,11 +19,16 @@ class SP_Meta_Box_Table_Data {
* Output the metabox
*/
public static function output( $post ) {
$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 );
self::table( $table->ID, $columns, $usecolumns, $data, $placeholders, $adjustments, $highlight );
global $pagenow;
if ( is_admin() && in_array( $pagenow, array( 'post-new.php' ) ) && 'sp_table' == get_post_type() ) {
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 );
self::table( $table->ID, $columns, $usecolumns, $data, $placeholders, $adjustments, $highlight );
}
}
/**
@@ -39,7 +44,7 @@ class SP_Meta_Box_Table_Data {
/**
* Admin edit table
*/
public static function table( $id, $columns = array(), $usecolumns = null, $data = array(), $placeholders = array(), $adjustments = array(), $highlight = null, $readonly = false ) {
public static function table( $id = 0, $columns = array(), $usecolumns = null, $data = array(), $placeholders = array(), $adjustments = array(), $highlight = null, $readonly = false ) {
if ( is_array( $usecolumns ) )
$usecolumns = array_filter( $usecolumns );

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
* @version 2.5.5
* @version 2.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -31,6 +31,10 @@ class SP_Meta_Box_Table_Details {
$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 );
if ( empty( $event_status ) ) {
$event_status = array( 'publish', 'future' );
}
?>
<div>
<p><strong><?php _e( 'Heading', 'sportspress' ); ?></strong></p>
@@ -91,6 +95,11 @@ class SP_Meta_Box_Table_Details {
sp_post_adder( $post_type, __( 'Add New', 'sportspress' ) );
}
?>
<p><strong><?php _e( 'Event Status (with results)', 'sportspress' ); ?></strong></p>
<p>
<input type="checkbox" name="sp_event_status[]" value="publish" <?php echo ( in_array( "publish" , $event_status) ) ? 'checked' : false; ?>> Published/Played<br>
<input type="checkbox" name="sp_event_status[]" value="future" <?php echo ( in_array( "future" , $event_status) ) ? 'checked' : false; ?>> Scheduled/Future<br>
</p>
</div>
<p><strong><?php _e( 'Sort by', 'sportspress' ); ?></strong></p>
<p>
@@ -137,5 +146,6 @@ class SP_Meta_Box_Table_Details {
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
update_post_meta( $post_id, 'sp_orderby', sp_array_value( $_POST, 'sp_orderby', array() ) );
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', array() ) );
update_post_meta( $post_id, 'sp_event_status', sp_array_value( $_POST, 'sp_event_status', array() ) );
}
}

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.6
* @version 2.7.1.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -181,8 +181,8 @@ class SP_Settings_Events extends SP_Settings_Page {
),
array(
'title' => __( 'Google Maps', 'sportspress' ),
'desc' => __( 'Display maps', 'sportspress' ),
'title' => __( 'Venue Map', 'sportspress' ),
'desc' => __( 'Display venue map', 'sportspress' ),
'id' => 'sportspress_event_show_maps',
'default' => 'yes',
'type' => 'checkbox',
@@ -469,7 +469,7 @@ class SP_Settings_Events extends SP_Settings_Page {
parent::save();
if ( isset( $_POST['sportspress_event_teams_delimiter'] ) )
update_option( 'sportspress_event_teams_delimiter', $_POST['sportspress_event_teams_delimiter'] );
update_option( 'sportspress_event_teams_delimiter', sanitize_text_field( $_POST['sportspress_event_teams_delimiter'] ) );
}
/**

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.6
* @version 2.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -81,6 +81,14 @@ class SP_Settings_Teams extends SP_Settings_Page {
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Comments', 'sportspress' ),
'desc' => __( 'Allow people to post comments on Team page', 'sportspress' ),
'id' => 'sportspress_team_comment_status',
'default' => 'no',
'type' => 'checkbox',
),
)),
array(

View File

@@ -5,7 +5,7 @@
* The SportsPress REST API class handles all API-related hooks.
*
* @class SP_REST_API
* @version 2.6.1
* @version 2.7.8
* @package SportsPress/Classes
* @category Class
* @package SportsPress/API
@@ -120,21 +120,53 @@ class SP_REST_API {
)
);
register_rest_field( 'sp_event',
'day',
array(
'get_callback' => 'SP_REST_API::get_post_data',
'update_callback' => 'SP_REST_API::update_post_meta',
'schema' => array(
'description' => __( 'Match Day', 'sportspress' ),
'type' => 'string',
'context' => array( 'view', 'edit', 'embed' ),
'arg_options' => array(
'sanitize_callback' => 'sanitize_text_field',
),
register_rest_field( 'sp_event',
'format',
array(
'get_callback' => 'SP_REST_API::get_post_data',
'update_callback' => 'SP_REST_API::update_post_meta',
'schema' => array(
'description' => __( 'Format', 'sportspress' ),
'type' => 'string',
'context' => array( 'view', 'edit', 'embed' ),
'arg_options' => array(
'sanitize_callback' => 'sanitize_text_field',
),
)
);
),
)
);
register_rest_field( 'sp_event',
'mode',
array(
'get_callback' => 'SP_REST_API::get_post_data',
'update_callback' => 'SP_REST_API::update_post_meta',
'schema' => array(
'description' => __( 'Mode', 'sportspress' ),
'type' => 'string',
'context' => array( 'view', 'edit', 'embed' ),
'arg_options' => array(
'sanitize_callback' => 'sanitize_text_field',
),
),
)
);
register_rest_field( 'sp_event',
'day',
array(
'get_callback' => 'SP_REST_API::get_post_data',
'update_callback' => 'SP_REST_API::update_post_meta',
'schema' => array(
'description' => __( 'Match Day', 'sportspress' ),
'type' => 'string',
'context' => array( 'view', 'edit', 'embed' ),
'arg_options' => array(
'sanitize_callback' => 'sanitize_text_field',
),
),
)
);
register_rest_field( 'sp_event',
'minutes',
@@ -223,7 +255,7 @@ class SP_REST_API {
'update_callback' => 'SP_REST_API::update_post_meta_arrays',
'schema' => array(
'description' => __( 'Results', 'sportspress' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'sanitize_callback' => 'rest_sanitize_request_arg',
@@ -239,7 +271,7 @@ class SP_REST_API {
'update_callback' => 'SP_REST_API::update_post_meta_arrays_multi',
'schema' => array(
'description' => __( 'Box Score', 'sportspress' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'sanitize_callback' => 'rest_sanitize_request_arg',
@@ -430,7 +462,6 @@ class SP_REST_API {
'update_callback' => 'SP_REST_API::update_post_meta_array',
'schema' => array(
'description' => __( 'Metrics', 'sportspress' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'sanitize_callback' => 'rest_sanitize_request_arg',
@@ -446,7 +477,7 @@ class SP_REST_API {
'update_callback' => 'SP_REST_API::update_post_meta_arrays_multi',
'schema' => array(
'description' => __( 'Statistics', 'sportspress' ),
'type' => 'array',
'type' => 'object',
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'sanitize_callback' => 'rest_sanitize_request_arg',
@@ -564,6 +595,11 @@ class SP_REST_API {
* @return bool|int
*/
public static function update_post_meta_array( $value, $object, $field_name ) {
// Convert PHP object to array
if ( is_object( $value ) ) {
$value = (array) $value;
}
if ( ! is_array( $value ) ) return false;
$type = $object->post_type;

View File

@@ -6,5 +6,15 @@ if ( class_exists( 'WP_REST_Posts_Controller' ) ) {
parent::__construct( $post_type );
$this->namespace = 'sportspress/v2';
}
}
public function check_read_permission( $post ) {
if ( 'sp_event' === $post->post_type ) {
if ( in_array( $post->post_status, array( 'publish', 'future' ) ) || current_user_can( 'read_post', $post->ID ) ) {
return true;
}
} else {
return WP_REST_Posts_Controller::check_read_permission( $post );
}
}
}
}

View File

@@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
* AJAX Event Handler
*
* @class SP_AJAX
* @version 2.6.12
* @version 2.7
* @package SportsPress/Classes
* @category Class
* @author ThemeBoy
@@ -628,6 +628,7 @@ class SP_AJAX {
'season' => __( 'Season', 'sportspress' ),
'venue' => __( 'Venue', 'sportspress' ),
'article' => __( 'Article', 'sportspress' ),
'event_specs' => __( 'Specs', 'sportspress' ),
);
$field_name = 'columns[]';
$field_id = 'columns';
@@ -912,6 +913,18 @@ class SP_AJAX {
<?php _e( 'Display link to view full table', 'sportspress' ); ?>
</label>
</p>
<p>
<?php _e( 'Event Status:', 'sportspress' ); ?><br/>
<label>
<input type="checkbox" name="show_published_events" id="show_published_events" checked>
<?php _e( 'Include Published/Played Events with results', 'sportspress' ); ?>
</label>
<br/>
<label>
<input type="checkbox" name="show_future_events" id="show_future_events" checked>
<?php _e( 'Include Scheduled/Future Events with results', 'sportspress' ); ?>
</label>
</p>
<?php do_action( 'sportspress_ajax_shortcode_form', 'league-table' ); ?>
<p class="submit">
<input type="button" class="button-primary" value="<?php _e( 'Insert Shortcode', 'sportspress' ); ?>" onclick="insertSportsPress('team_standings');" />
@@ -1348,6 +1361,8 @@ class SP_AJAX {
args.number = $div.find('[name=number]').val();
args.columns = $div.find('[name="columns[]"]:checked').map(function() { return this.value; }).get().join(',');
args.show_team_logo = $div.find('[name=show_team_logo]:checked').length;
args.show_published_events = $div.find('[name=show_published_events]:checked').length;
args.show_future_events = $div.find('[name=show_future_events]:checked').length;
args.show_full_table_link = $div.find('[name=show_full_table_link]:checked').length;
} else if ( 'team_gallery' == type ) {
args.title = $div.find('[name=title]').val();

View File

@@ -8,7 +8,7 @@
* https://wordpress.org/support/topic/timezone-issues-with-schedule-calendar-list/
*
* @class SP_Calendar
* @version 2.6.11
* @version 2.6.20
* @package SportsPress/Classes
* @category Class
* @author ThemeBoy
@@ -154,7 +154,6 @@ class SP_Calendar extends SP_Secondary_Post {
'posts_per_page' => $this->number,
'orderby' => $this->orderby,
'order' => $this->order,
'post_status' => $this->status,
'meta_query' => array(
'relation' => 'AND'
),
@@ -335,6 +334,7 @@ class SP_Calendar extends SP_Secondary_Post {
$seasons = get_the_terms( $this->ID, 'sp_season' );
$venues = get_the_terms( $this->ID, 'sp_venue' );
$teams = array_filter( get_post_meta( $this->ID, 'sp_team', false ) );
$players = array_filter( get_post_meta( $this->ID, 'sp_player', false ) );
$table = get_post_meta( $this->ID, 'sp_table', true );
if ( ! isset( $league_ids ) ) $league_ids = array();
@@ -388,17 +388,24 @@ class SP_Calendar extends SP_Secondary_Post {
}
if ( ! empty( $teams ) ) {
$args['meta_query'] = array(
array(
'key' => 'sp_team',
'value' => $teams,
'compare' => 'IN',
),
$args['meta_query'][] = array(
'key' => 'sp_team',
'value' => $teams,
'compare' => 'IN',
);
}
if ( ! empty( $players ) ) {
$args['meta_query'][] = array(
'key' => 'sp_player',
'value' => $players,
'compare' => 'IN',
);
}
if ( $this->event) {
$args['p'] = $this->event;
$args['post_status'] = array( 'publish', 'future' );
}
if ( 'auto' === $this->date && 'any' === $this->status ) {
@@ -415,23 +422,13 @@ class SP_Calendar extends SP_Secondary_Post {
$events = array_merge_recursive( $results, $fixtures );
} else {
$args['post_status'] = $this->status == 'any' ? array('publish', 'future') : explode ( ',', $this->status );
$events = get_posts( $args );
}
else:
$events = null;
endif;
// Filter out unessecary events if we are showing past meetings
if ( $this->teams_past ){
$events_past = array();
foreach ( $events as $single_event ) {
if ( sort( get_post_meta( $single_event->ID, 'sp_team' ) ) === sort( $this->teams_past ) ) {
$events_past[] = $single_event;
}
}
$events = $events_past;
}
// Remove any calendar selection filters
remove_filter( 'posts_where', array( $this, 'range' ) );

View File

@@ -5,7 +5,7 @@
* The SportsPress countries class stores continent/country data.
*
* @class SP_Countries
* @version 2.6.8
* @version 2.7.3
* @package SportsPress/Classes
* @category Class
* @author ThemeBoy
@@ -68,6 +68,7 @@ class SP_Countries {
'nam',
'nga',
'nig',
'reu',
'rsa',
'rwa',
'sdn',
@@ -207,6 +208,8 @@ class SP_Countries {
'cuw',
'dma',
'dom',
'glp',
'grl',
'grn',
'gua',
'hai',
@@ -214,12 +217,14 @@ class SP_Countries {
'jam',
'lca',
'mex',
'mtq',
'msr',
'nca',
'pan',
'pur',
'skn',
'slv',
'sxm',
'tca',
'usa',
'vgb',
@@ -242,6 +247,7 @@ class SP_Countries {
'nzl',
'plw',
'png',
'pyf',
'sam',
'sol',
'tah',
@@ -257,6 +263,7 @@ class SP_Countries {
'chi',
'col',
'ecu',
'guf',
'guy',
'par',
'per',
@@ -320,7 +327,7 @@ class SP_Countries {
'cub' => __( "Cuba", 'sportspress' ),
'cuw' => __( "Curacao", 'sportspress' ),
'cyp' => __( "Cyprus", 'sportspress' ),
'cze' => __( "Czech Republic", 'sportspress' ),
'cze' => __( "Czechia", 'sportspress' ),
'den' => __( "Denmark", 'sportspress' ),
'dji' => __( "Djibouti", 'sportspress' ),
'dma' => __( "Dominica", 'sportspress' ),
@@ -338,6 +345,8 @@ class SP_Countries {
'fin' => __( "Finland", 'sportspress' ),
'fra' => __( "France", 'sportspress' ),
'fro' => __( "Faroe Islands", 'sportspress' ),
'guf' => __( "French Guiana", 'sportspress' ),
'pyf' => __( "French Polynesia", 'sportspress' ),
'fsm' => __( "Micronesia", 'sportspress' ),
'gab' => __( "Gabon", 'sportspress' ),
'gam' => __( "Gambia", 'sportspress' ),
@@ -346,8 +355,10 @@ class SP_Countries {
'ger' => __( "Germany", 'sportspress' ),
'gha' => __( "Ghana", 'sportspress' ),
'gib' => __( "Gibraltar", 'sportspress' ),
'glp' => __( "Guadeloupe", 'sportspress' ),
'gnb' => __( "Guinea-Bissau", 'sportspress' ),
'gre' => __( "Greece", 'sportspress' ),
'grl' => __( "Greenland", 'sportspress' ),
'grn' => __( "Grenada", 'sportspress' ),
'gua' => __( "Guatemala", 'sportspress' ),
'gui' => __( "Guinea", 'sportspress' ),
@@ -373,6 +384,7 @@ class SP_Countries {
'kos' => __( "Kosovo", 'sportspress' ),
'kgz' => __( "Kyrgyzstan", 'sportspress' ),
'kir' => __( "Kiribati", 'sportspress' ),
'mtq' => __( "Martinique", 'sportspress' ),
'kor' => __( "South Korea", 'sportspress' ),
'ksa' => __( "Saudi Arabia", 'sportspress' ),
'kuw' => __( "Kuwait", 'sportspress' ),
@@ -395,7 +407,7 @@ class SP_Countries {
'mdv' => __( "Maldives", 'sportspress' ),
'mex' => __( "Mexico", 'sportspress' ),
'mhl' => __( "Marshall Islands", 'sportspress' ),
'mkd' => __( "Macedonia", 'sportspress' ),
'mkd' => __( "North Macedonia", 'sportspress' ),
'mli' => __( "Mali", 'sportspress' ),
'mlt' => __( "Malta", 'sportspress' ),
'mne' => __( "Montenegro", 'sportspress' ),
@@ -405,7 +417,7 @@ class SP_Countries {
'msr' => __( "Montserrat", 'sportspress' ),
'mtn' => __( "Mauritania", 'sportspress' ),
'mwi' => __( "Malawi", 'sportspress' ),
'mya' => __( "Burma", 'sportspress' ),
'mya' => __( "Myanmar", 'sportspress' ),
'nam' => __( "Namibia", 'sportspress' ),
'nca' => __( "Nicaragua", 'sportspress' ),
'ncl' => __( "New Caledonia", 'sportspress' ),
@@ -433,6 +445,7 @@ class SP_Countries {
'qat' => __( "Qatar", 'sportspress' ),
'rou' => __( "Romania", 'sportspress' ),
'rsa' => __( "South Africa", 'sportspress' ),
'reu' => __( "Reunion", 'sportspress' ),
'rus' => __( "Russia", 'sportspress' ),
'rwa' => __( "Rwanda", 'sportspress' ),
'sam' => __( "Samoa", 'sportspress' ),
@@ -456,7 +469,8 @@ class SP_Countries {
'svk' => __( "Slovakia", 'sportspress' ),
'svn' => __( "Slovenia", 'sportspress' ),
'swe' => __( "Sweden", 'sportspress' ),
'swz' => __( "Swaziland", 'sportspress' ),
'swz' => __( "Eswatini", 'sportspress' ),
'sxm' => __( "Sint Maarten", 'sportspress' ),
'syr' => __( "Syria", 'sportspress' ),
'tah' => __( "Tahiti", 'sportspress' ),
'tan' => __( "Tanzania", 'sportspress' ),

View File

@@ -26,10 +26,20 @@ class SP_Event extends SP_Custom_Post{
return $post_status;
}
public function format() {
$format = get_post_meta( $this->ID, 'sp_format', true );
return $format;
}
public function day() {
$day = get_post_meta( $this->ID, 'sp_day', true );
return $day;
}
}
public function mode() {
$mode = get_post_meta( $this->ID, 'sp_mode', true );
return $mode;
}
public function minutes() {
$minutes = get_post_meta( $this->ID, 'sp_minutes', true );

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Classes
* @version 2.3
* @version 2.6.17
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -85,8 +85,20 @@ class SP_Install {
// Flush rules after install
flush_rewrite_rules();
// Redirect to welcome screen
set_transient( '_sp_activation_redirect', 1, 60 * 60 );
// Get current major version
$version = explode( '.', $current_version, 3 );
unset( $version[2] );
$major_current_version = implode( '.', $version );
// Get new major version
$version = explode( '.', SP()->version, 3 );
unset( $version[2] );
$major_version = implode( '.', $version );
// Redirect to welcome screen if major version has changed
if ( $major_current_version !== $major_version ) {
set_transient( '_sp_activation_redirect', 1, 60 * 60 );
}
}
/**

View File

@@ -5,7 +5,7 @@
* The SportsPress league table class handles individual league table data.
*
* @class SP_League_Table
* @version 2.6.6
* @version 2.7
* @package SportsPress/Classes
* @category Class
* @author ThemeBoy
@@ -23,11 +23,17 @@ class SP_League_Table extends SP_Secondary_Post {
/** @var array Teams to check for tiebreakers. */
public $tiebreakers = array();
//** @var strings
public $orderby;
public $orderbyorder;
/** @var int Show Published events. */
public $show_published_events;
/** @var int Show Scheduled events. */
public $show_future_events;
/**
* Returns formatted data
*
@@ -231,10 +237,40 @@ class SP_League_Table extends SP_Secondary_Post {
endif;
endforeach;
// Get which event status to include
$event_status = get_post_meta( $this->ID, 'sp_event_status', true );
if ( empty( $event_status ) ) {
$event_status = array( 'publish', 'future' );
}
if ( isset( $this->show_published_events ) ) { // If an attribute was pass through shortcode
if ( $this->show_published_events == '1' ) {
$event_status[] = 'publish';
}else{
if ( ( $status_key = array_search( 'publish', $event_status ) ) !== false ) {
unset( $event_status[ $status_key ] );
}
}
}
if ( isset( $this->show_future_events ) ) { // If an attribute was pass through shortcode
if ( $this->show_future_events == '1' ) {
$event_status[] = 'future';
}else{
if ( ( $status_key = array_search('future', $event_status) ) !== false ) {
unset( $event_status[ $status_key ] );
}
}
}
// Make sure to have unique values in the array
$event_status = array_unique( $event_status );
$args = array(
'post_type' => 'sp_event',
'post_status' => array( 'publish', 'future' ),
'post_status' => $event_status,
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'post_date',
@@ -810,12 +846,12 @@ class SP_League_Table extends SP_Secondary_Post {
if ( sp_array_value( $a, $priority['column'], 0 ) != sp_array_value( $b, $priority['column'], 0 ) ):
// Compare column values
$output = sp_array_value( $a, $priority['column'], 0 ) - sp_array_value( $b, $priority['column'], 0 );
$output = (float) sp_array_value( $a, $priority['column'], 0 ) - (float) sp_array_value( $b, $priority['column'], 0 );
// Flip value if descending order
if ( $priority['order'] == 'DESC' ) $output = 0 - $output;
return ( $output > 0 );
return ( $output > 0 ? 1 : -1 );
endif;

View File

@@ -5,7 +5,7 @@
* The SportsPress modules class stores available modules.
*
* @class SP_Modules
* @version 2.6.9
* @version 2.6.15
* @package SportsPress/Classes
* @category Class
* @author ThemeBoy
@@ -43,6 +43,13 @@ class SP_Modules {
'link' => 'https://www.themeboy.com/sportspress-extensions/scoreboard/',
'desc' => __( 'Display multiple event results in a horizontal scoreboard.', 'sportspress' ),
),
'google_maps' => array(
'label' => __( 'Google Maps', 'sportspress' ),
'class' => 'SportsPress_Google_Maps',
'icon' => 'sp-icon-location',
'link' => 'https://www.themeboy.com/sportspress-extensions/google-maps/',
'desc' => __( 'Use Google Maps instead of OpenStreetMap for venues.', 'sportspress' ),
),
'user_scores' => array(
'label' => __( 'User Scores', 'sportspress' ),
'class' => 'SportsPress_User_Scores',

View File

@@ -5,7 +5,7 @@
* The SportsPress player list class handles individual player list data.
*
* @class SP_Player_List
* @version 2.6.9
* @version 2.7.5
* @package SportsPress/Classes
* @category Class
* @author ThemeBoy
@@ -59,6 +59,7 @@ class SP_Player_List extends SP_Secondary_Post {
$crop = get_post_meta( $this->ID, 'sp_crop', true );
$order = get_post_meta( $this->ID, 'sp_order', true );
$select = get_post_meta( $this->ID, 'sp_select', true );
$nationalities = get_post_meta( $this->ID, 'sp_nationality', false );
$this->date = $this->__get( 'date' );
@@ -86,6 +87,27 @@ class SP_Player_List extends SP_Secondary_Post {
}
}
$weekday = array (
0 => 'Sunday',
1 => 'Monday',
2 => 'Tuesday',
3 => 'Wednesday',
4 => 'Thursday',
5 => 'Friday',
6 => 'Saturday',
);
$start_of_week = get_option('start_of_week');
$firstday = $weekday[ $start_of_week ];
if ( $start_of_week != 0 ) {
$lastday = $weekday[ ( $start_of_week - 1 ) ];
}else{
$lastday = $weekday[6];
}
$today = date('l');
// Get labels from performance variables
$performance_labels = (array)sp_get_var_labels( 'sp_performance' );
@@ -110,6 +132,9 @@ class SP_Player_List extends SP_Secondary_Post {
'tax_query' => array(
'relation' => 'AND',
),
'meta_query' => array(
'relation' => 'AND',
),
);
if ( $league_ids ):
@@ -138,7 +163,7 @@ class SP_Player_List extends SP_Secondary_Post {
$team_key = 'sp_past_team';
break;
endswitch;
$args['meta_query'] = array(
$args['meta_query'][] = array(
array(
'key' => $team_key,
'value' => $team
@@ -153,6 +178,16 @@ class SP_Player_List extends SP_Secondary_Post {
'terms' => $position_ids
);
endif;
if ( $nationalities ):
$args['meta_query'][] = array(
array(
'key' => 'sp_nationality',
'value' => $nationalities,
'compare' => 'IN'
),
);
endif;
$args = apply_filters( 'sportspress_player_list_args', $args, $team );
@@ -229,9 +264,14 @@ class SP_Player_List extends SP_Secondary_Post {
if ( get_option( 'sportspress_player_statistics_mode', 'values' ) == 'icons' && ( $stat->post_type == 'sp_performance' || $stat->post_type == 'sp_statistic' ) ) {
$icon = apply_filters( 'sportspress_event_performance_icons', '', $stat->ID, 1 );
if ( $icon != '' ) {
$columns[ $stat->post_name ] = apply_filters( 'sportspress_event_performance_icons', '', $stat->ID, 1 );
$columns[ $stat->post_name ] = $icon;
}else{
$columns[ $stat->post_name ] = $stat->post_title;
if ( has_post_thumbnail( $stat ) ) {
$icon = get_the_post_thumbnail( $stat, 'sportspress-fit-mini', array( 'title' => sp_get_singular_name( $stat ) ) );
$columns[ $stat->post_name ] = apply_filters( 'sportspress_event_performance_icons', $icon, $stat->ID, 1 );
}else{
$columns[ $stat->post_name ] = $stat->post_title;
}
}
}else{
$columns[ $stat->post_name ] = $stat->post_title;
@@ -355,22 +395,117 @@ class SP_Player_List extends SP_Secondary_Post {
'terms' => $season_ids
);
endif;
$team_key = 'sp_team';
if ( $team ):
$args['meta_query'][] = array(
array(
'key' => $team_key,
'value' => $team,
'compare' => 'IN',
),
);
endif;
if ( $this->date !== 0 ):
if ( $this->date == 'w' ):
$args['year'] = date_i18n('Y');
$args['w'] = date_i18n('W');
elseif ( $this->date == 'day' ):
$args['year'] = date_i18n('Y');
$args['day'] = date_i18n('j');
$args['monthnum'] = date_i18n('n');
elseif ( $this->date == 'range' ):
if ( $this->relative ):
add_filter( 'posts_where', array( $this, 'relative' ) );
else:
add_filter( 'posts_where', array( $this, 'range' ) );
endif;
endif;
switch ( $this->date ):
case '-day':
$date = new DateTime( date_i18n('Y-m-d') );
$date->modify( '-1 day' );
$args['year'] = $date->format('Y');
$args['day'] = $date->format('j');
$args['monthnum'] = $date->format('n');
break;
case 'day':
$args['year'] = date_i18n('Y');
$args['day'] = date_i18n('j');
$args['monthnum'] = date_i18n('n');
break;
case '+day':
$date = new DateTime( date_i18n('Y-m-d') );
$date->modify( '+1 day' );
$args['year'] = $date->format('Y');
$args['day'] = $date->format('j');
$args['monthnum'] = $date->format('n');
break;
case '-w':
if ( $start_of_week != '1' ) { //If start of week is not Monday
if ( $today == $firstday ) { //If today is start of Week
$after = date_i18n('Y-m-d', strtotime("last $firstday"));
$before = date_i18n('Y-m-d', strtotime("last $lastday")).' 23:59:59';
}else{
$after = date_i18n('Y-m-d', strtotime("-2 $firstday"));
$before = date_i18n('Y-m-d', strtotime("last $lastday")).' 23:59:59';
}
$args['date_query'] = array(
array(
'after' => $after,
'before' => $before,
'inclusive' => true,
),
);
}else{
$date = new DateTime( date_i18n('Y-m-d') );
$date->modify( '-1 week' );
$args['year'] = $date->format('Y');
$args['w'] = $date->format('W');
}
break;
case 'w':
if ( $start_of_week != '1' ) { //If start of week is not Monday
if ( $today == $firstday ) { //If today is start of Week
$after = date_i18n('Y-m-d');
$before = date_i18n('Y-m-d', strtotime("next $lastday")).' 23:59:59';
}elseif ( $today == $lastday ) { //If today is the end of Week
$after = date_i18n('Y-m-d', strtotime("last $firstday"));
$before = date_i18n('Y-m-d').' 23:59:59';
}else{
$after = date_i18n('Y-m-d', strtotime("last $firstday"));
$before = date_i18n('Y-m-d', strtotime("next $lastday")).' 23:59:59';
}
$args['date_query'] = array(
array(
'after' => $after,
'before' => $before,
'inclusive' => true,
),
);
}else{
$args['year'] = date_i18n('Y');
$args['w'] = date_i18n('W');
}
break;
case '+w':
if ( $start_of_week != '1' ) { //If start of week is not Monday
if ( $today == $lastday ) { //If today is the end of Week
$after = date_i18n('Y-m-d', strtotime("next $firstday"));
$before = date_i18n('Y-m-d', strtotime("next $lastday")).' 23:59:59';
}else{
$after = date_i18n('Y-m-d', strtotime("next $firstday"));
$before = date_i18n('Y-m-d', strtotime("+2 $lastday")).' 23:59:59';
}
$args['date_query'] = array(
array(
'after' => $after,
'before' => $before,
'inclusive' => true,
),
);
}else{
$date = new DateTime( date_i18n('Y-m-d') );
$date->modify( '+1 week' );
$args['year'] = $date->format('Y');
$args['w'] = $date->format('W');
}
break;
case 'range':
if ( $this->relative ):
add_filter( 'posts_where', array( $this, 'relative' ) );
else:
add_filter( 'posts_where', array( $this, 'range' ) );
endif;
break;
endswitch;
endif;
$args = apply_filters( 'sportspress_list_data_event_args', $args );
@@ -387,10 +522,13 @@ class SP_Player_List extends SP_Secondary_Post {
$team_performance = get_post_meta( $event->ID, 'sp_players', true );
$timeline = (array)get_post_meta( $event->ID, 'sp_timeline', true );
$minutes = get_post_meta( $event->ID, 'sp_minutes', true );
$showdob = get_option( 'sportspress_player_show_birthday', 'no' );
$showage = get_option( 'sportspress_player_show_age', 'no' );
if ( $minutes === '' ) $minutes = get_option( 'sportspress_event_minutes', 90 );
// Add all team performance
if ( is_array( $team_performance ) ): foreach ( $team_performance as $team_id => $players ):
if ( $team && $team_id != $team ) continue;
if ( is_array( $players ) ): foreach ( $players as $player_id => $player_performance ):
if ( array_key_exists( $player_id, $totals ) && is_array( $totals[ $player_id ] ) ):
@@ -420,8 +558,8 @@ class SP_Player_List extends SP_Secondary_Post {
endif;
endforeach;
elseif ( array_key_exists( $key, $totals[ $player_id ] ) ):
$value = floatval( $value );
$totals[ $player_id ][ $key ] += $value;
$add = apply_filters( 'sportspress_player_performance_add_value', floatval( $value ), $key );
$totals[ $player_id ][ $key ] += $add;
endif;
endforeach;
@@ -499,6 +637,9 @@ class SP_Player_List extends SP_Secondary_Post {
endforeach;
endif;
//Make sure that is a number (i.e. convert 90+2' to 90')
$played_minutes = (float)$played_minutes;
$totals[ $player_id ]['eventminutes'] += max( 0, $played_minutes );
if ( sp_array_value( $player_performance, 'status' ) == 'lineup' ):
@@ -541,18 +682,19 @@ class SP_Player_List extends SP_Secondary_Post {
if ( sizeof( $results ) ):
foreach ( $results as $id => $team_results ):
if ( $team_id == $id ) continue;
$team_results['outcome'] = null;
unset( $team_results['outcome'] );
foreach ( $team_results as $result_slug => $team_result ):
if ( is_array( $team_results ) ):
unset( $team_results['outcome'] );
foreach ( $team_results as $result_slug => $team_result ):
// Add to total
$value = sp_array_value( $totals[ $player_id ], $result_slug . 'against', 0 );
$value += floatval( $team_result );
$totals[ $player_id ][ $result_slug . 'against' ] = $value;
// Add to total
$value = sp_array_value( $totals[ $player_id ], $result_slug . 'against', 0 );
$value += floatval( $team_result );
$totals[ $player_id ][ $result_slug . 'against' ] = $value;
// Add subset
$totals[ $player_id ][ $result_slug . 'against' . ( $i + 1 ) ] = $team_result;
endforeach;
// Add subset
$totals[ $player_id ][ $result_slug . 'against' . ( $i + 1 ) ] = $team_result;
endforeach;
endif;
endforeach;
endif;
endif;
@@ -591,23 +733,34 @@ class SP_Player_List extends SP_Secondary_Post {
endif;
endif;
if ( $placeholder !== '' && is_numeric( $placeholder ) ):
$placeholder = sp_array_value( $placeholders[ $player_id ], $stat->post_name, 0 ) + $placeholder;
else:
$placeholder = sp_array_value( $placeholders[ $player_id ], $stat->post_name, '-' );
endif;
if ( ! $stat->equation ) {
if ( $placeholder !== '' && is_numeric( $placeholder ) ):
$placeholder = sp_array_value( $placeholders[ $player_id ], $stat->post_name, 0 ) + $placeholder;
else:
$placeholder = sp_array_value( $placeholders[ $player_id ], $stat->post_name, '-' );
endif;
}
if ( is_numeric( $placeholder ) && $stat->precision ):
$placeholder = number_format( $placeholder, $stat->precision, '.', '' );
endif;
$placeholders[ $player_id ][ $stat->post_name ] = $placeholder;
$placeholders[ $player_id ][ $stat->post_name ] = apply_filters( 'sportspress_player_performance_table_placeholder', $placeholder, $stat->post_name );
endforeach;
endforeach;
// Merge the data and placeholders arrays
foreach( $placeholders as $player_id => $player_data ):
if ( in_array( 'dob', $this->columns ) ):
$player_data['dob'] = get_the_date( get_option( 'date_format') , $player_id );
endif;
if ( in_array( 'age', $this->columns ) ):
$birthdayclass = new SportsPress_Birthdays();
$player_data['age'] = $birthdayclass->get_age( get_the_date( 'm-d-Y', $player_id ) );
endif;
$player_data = array_merge( $column_order, $player_data );
$placeholders[ $player_id ] = $player_data;
@@ -695,6 +848,10 @@ class SP_Player_List extends SP_Secondary_Post {
$labels[ $key ] = __( 'Team', 'sportspress' );
elseif ( $key == 'position' ):
$labels[ $key ] = __( 'Position', 'sportspress' );
elseif ( $key == 'dob' && $showdob ):
$labels[ $key ] = __( 'Date of Birth', 'sportspress' );
elseif ( $key == 'age' && $showage ):
$labels[ $key ] = __( 'Age', 'sportspress' );
elseif ( array_key_exists( $key, $columns ) ):
$labels[ $key ] = $columns[ $key ];
endif;
@@ -744,6 +901,12 @@ class SP_Player_List extends SP_Secondary_Post {
if ( in_array( 'position', $this->columns ) ) {
$labels['position'] = __( 'Position', 'sportspress' );
}
if ( in_array( 'dob', $this->columns ) && $showdob ) {
$labels['dob'] = __( 'Date of Birth', 'sportspress' );
}
if ( in_array( 'age', $this->columns ) && $showage ) {
$labels['age'] = __( 'Age', 'sportspress' );
}
$merged[0] = array_merge( $labels, $columns );
return $merged;

View File

@@ -5,7 +5,7 @@
* The SportsPress player class handles individual player data.
*
* @class SP_Player
* @version 2.6.9
* @version 2.7.5
* @package SportsPress/Classes
* @category Class
* @author ThemeBoy
@@ -175,9 +175,14 @@ class SP_Player extends SP_Custom_Post {
if ( get_option( 'sportspress_player_statistics_mode', 'values' ) == 'icons' ) {
$icon = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
if ( $icon != '' ) {
$performance_labels[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
$performance_labels[ $post->post_name ] = $icon;
}else{
$performance_labels[ $post->post_name ] = $post->post_title;
if ( has_post_thumbnail( $post ) ) {
$icon = get_the_post_thumbnail( $post, 'sportspress-fit-mini', array( 'title' => sp_get_singular_name( $post ) ) );
$performance_labels[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', $icon, $post->ID, 1 );
}else{
$performance_labels[ $post->post_name ] = $post->post_title;
}
}
}else{
$performance_labels[ $post->post_name ] = $post->post_title;
@@ -193,9 +198,14 @@ class SP_Player extends SP_Custom_Post {
if ( get_option( 'sportspress_player_statistics_mode', 'values' ) == 'icons' ) {
$icon = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
if ( $icon != '' ) {
$performance_labels[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
$performance_labels[ $post->post_name ] = $icon;
}else{
$performance_labels[ $post->post_name ] = $post->post_title;
if ( has_post_thumbnail( $post ) ) {
$icon = get_the_post_thumbnail( $post, 'sportspress-fit-mini', array( 'title' => sp_get_singular_name( $post ) ) );
$performance_labels[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', $icon, $post->ID, 1 );
}else{
$performance_labels[ $post->post_name ] = $post->post_title;
}
}
}else{
$performance_labels[ $post->post_name ] = $post->post_title;
@@ -369,8 +379,8 @@ class SP_Player extends SP_Custom_Post {
foreach ( $player_performance as $key => $value ):
if ( array_key_exists( $key, $totals ) ):
$value = floatval( $value );
$totals[ $key ] += $value;
$add = apply_filters( 'sportspress_player_performance_add_value', floatval( $value ), $key );
$totals[ $key ] += $add;
endif;
endforeach;
@@ -446,6 +456,9 @@ class SP_Player extends SP_Custom_Post {
endforeach;
endif;
//Make sure that is a number (i.e. convert 90+2' to 90')
$played_minutes = (float)$played_minutes;
$totals['eventminutes'] += max( 0, $played_minutes );
if ( sp_array_value( $player_performance, 'status' ) == 'lineup' ):
@@ -504,17 +517,19 @@ class SP_Player extends SP_Custom_Post {
// Loop through away teams
if ( sizeof( $results ) ):
foreach ( $results as $team_results ):
unset( $team_results['outcome'] );
foreach ( $team_results as $result_slug => $team_result ):
if ( is_array( $team_results ) ):
unset( $team_results['outcome'] );
foreach ( $team_results as $result_slug => $team_result ):
// Add to total
$value = sp_array_value( $totals, $result_slug . 'against', 0 );
$value += floatval( $team_result );
$totals[ $result_slug . 'against' ] = $value;
// Add to total
$value = sp_array_value( $totals, $result_slug . 'against', 0 );
$value += floatval( $team_result );
$totals[ $result_slug . 'against' ] = $value;
// Add subset
$totals[ $result_slug . 'against' . ( $i + 1 ) ] = $team_result;
endforeach;
// Add subset
$totals[ $result_slug . 'against' . ( $i + 1 ) ] = $team_result;
endforeach;
endif;
endforeach;
endif;
endif;
@@ -552,7 +567,7 @@ class SP_Player extends SP_Custom_Post {
endforeach;
foreach ( $performance_labels as $key => $label ):
$placeholders[ $div_id ][ $key ] = sp_array_value( $totals, $key, 0 );
$placeholders[ $div_id ][ $key ] = apply_filters( 'sportspress_player_performance_table_placeholder', sp_array_value( $totals, $key, 0 ), $key );
endforeach;
endforeach;
@@ -575,9 +590,14 @@ class SP_Player extends SP_Custom_Post {
if ( get_option( 'sportspress_player_statistics_mode', 'values' ) == 'icons' ) {
$icon = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
if ( $icon != '' ) {
$stats[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
$stats[ $post->post_name ] = $icon;
}else{
$stats[ $post->post_name ] = $post->post_title;
if ( has_post_thumbnail( $post ) ) {
$icon = get_the_post_thumbnail( $post, 'sportspress-fit-mini', array( 'title' => sp_get_singular_name( $post ) ) );
$stats[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', $icon, $post->ID, 1 );
}else{
$stats[ $post->post_name ] = $post->post_title;
}
}
}else{
$stats[ $post->post_name ] = $post->post_title;
@@ -595,9 +615,14 @@ class SP_Player extends SP_Custom_Post {
if ( get_option( 'sportspress_player_statistics_mode', 'values' ) == 'icons' ) {
$icon = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
if ( $icon != '' ) {
$stats[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
} else {
$stats[ $post->post_name ] = $post->post_title;
$stats[ $post->post_name ] = $icon;
}else{
if ( has_post_thumbnail( $post ) ) {
$icon = get_the_post_thumbnail( $post, 'sportspress-fit-mini', array( 'title' => sp_get_singular_name( $post ) ) );
$stats[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', $icon, $post->ID, 1 );
}else{
$stats[ $post->post_name ] = $post->post_title;
}
}
} else {
$stats[ $post->post_name ] = $post->post_title;
@@ -608,9 +633,14 @@ class SP_Player extends SP_Custom_Post {
if ( get_option( 'sportspress_player_statistics_mode', 'values' ) == 'icons' ) {
$icon = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
if ( $icon != '' ) {
$stats[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
} else {
$stats[ $post->post_name ] = $post->post_title;
$stats[ $post->post_name ] = $icon;
}else{
if ( has_post_thumbnail( $post ) ) {
$icon = get_the_post_thumbnail( $post, 'sportspress-fit-mini', array( 'title' => sp_get_singular_name( $post ) ) );
$stats[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', $icon, $post->ID, 1 );
}else{
$stats[ $post->post_name ] = $post->post_title;
}
}
} else {
$stats[ $post->post_name ] = $post->post_title;
@@ -621,7 +651,7 @@ class SP_Player extends SP_Custom_Post {
if ( get_option( 'sportspress_player_statistics_mode', 'values' ) == 'icons' ) {
$icon = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
if ( $icon != '' ) {
$stats[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
$stats[ $post->post_name ] = $icon;
}else{
$stats[ $post->post_name ] = $post->post_title;
}
@@ -728,7 +758,8 @@ class SP_Player extends SP_Custom_Post {
foreach ( $stats as $key => $value ):
if ( in_array( $key, array( 'name', 'team' ) ) ) continue;
$value = floatval( $value );
$career[ $key ] = sp_array_value( $career, $key, 0 ) + $value;
$add = apply_filters( 'sportspress_player_performance_add_value', floatval( $value ), $key );
$career[ $key ] = sp_array_value( $career, $key, 0 ) + $add;
endforeach;
endforeach;
@@ -742,6 +773,9 @@ class SP_Player extends SP_Custom_Post {
$career[ $post->post_name ] = sp_solve( $value['equation'], $totals, $precision );
}
// Filter career total placeholders
$career = apply_filters( 'sportspress_player_performance_table_placeholders', $career );
// Get manually entered career totals
$manual_career = sp_array_value( $data, 0, array() );
$manual_career = array_filter( $manual_career, 'sp_filter_non_empty' );
@@ -771,13 +805,9 @@ class SP_Player extends SP_Custom_Post {
$labels = array();
if ( 'no' === get_option( 'sportspress_player_show_statistics', 'yes' ) ) {
$merged = array();
} else {
$labels['name'] = __( 'Season', 'sportspress' );
$labels['team'] = __( 'Team', 'sportspress' );
}
$labels['name'] = __( 'Season', 'sportspress' );
$labels['team'] = __( 'Team', 'sportspress' );
if ( 'no' === get_option( 'sportspress_player_show_total', 'no' ) ) {
unset( $merged[-1] );
}

View File

@@ -9,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* Registers post types and taxonomies
*
* @class SP_Post_types
* @version 2.6.13
* @version 2.7.1
* @package SportsPress/Classes
* @category Class
* @author ThemeBoy
@@ -22,7 +22,7 @@ class SP_Post_types {
public function __construct() {
add_action( 'init', array( __CLASS__, 'register_post_types' ), 5 );
add_action( 'init', array( __CLASS__, 'register_taxonomies' ), 10 );
add_action( 'wp_trash_post', array( $this, 'delete_config_post' ) );
add_action( 'trashed_post', array( $this, 'delete_config_post' ) );
add_filter( 'the_posts', array( $this, 'display_scheduled_events' ) );
}
@@ -392,6 +392,7 @@ class SP_Post_types {
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
'featured_image' => __( 'Icon', 'sportspress' ),
'set_featured_image' => __( 'Select Icon', 'sportspress' ),
'remove_featured_image' => __( 'Remove icon', 'sportspress' ),
'use_featured_image' => __( 'Add icon', 'sportspress' ),
@@ -403,7 +404,7 @@ class SP_Post_types {
'publicly_queryable' => false,
'exclude_from_search' => true,
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
'supports' => array( 'title', 'thumbnail', 'page-attributes', 'excerpt' ),
'has_archive' => false,
'show_in_nav_menus' => false,
'can_export' => false,
@@ -447,9 +448,7 @@ class SP_Post_types {
register_post_type( 'sp_event', apply_filters( 'sportspress_register_post_type_event', $args ) );
register_post_type( 'sp_team',
apply_filters( 'sportspress_register_post_type_team',
array(
$args = array(
'labels' => array(
'name' => __( 'Teams', 'sportspress' ),
'singular_name' => __( 'Team', 'sportspress' ),
@@ -480,9 +479,13 @@ class SP_Post_types {
'show_in_rest' => true,
'rest_controller_class' => 'SP_REST_Posts_Controller',
'rest_base' => 'teams',
)
)
);
);
if ( get_option( 'sportspress_team_comment_status', 'no' ) == 'yes' ):
$args[ 'supports' ][] = 'comments';
endif;
register_post_type( 'sp_team', apply_filters( 'sportspress_register_post_type_team', $args ) );
register_post_type( 'sp_player',
apply_filters( 'sportspress_register_post_type_player',

View File

@@ -5,7 +5,7 @@
* The SportsPress team class handles individual team data.
*
* @class SP_Team
* @version 2.6.3
* @version 2.7.1
* @package SportsPress/Classes
* @category Class
* @author ThemeBoy
@@ -488,7 +488,7 @@ class SP_Team extends SP_Custom_Post {
);
$tables_by_terms = get_posts( $args );
$tables = array_merge( $tables_by_id, $tables_by_terms );
$tables = array_merge( $tables_by_terms, $tables_by_id );
$checked = (array) get_post_meta( $this->ID, 'sp_table' );

View File

@@ -7,7 +7,7 @@
* @author ThemeBoy
* @category Core
* @package SportsPress/Functions
* @version 2.6.6
* @version 2.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -178,7 +178,7 @@ function sp_get_performance( $post = 0 ) {
function sp_get_singular_name( $post = 0 ) {
$singular = get_post_meta( $post, 'sp_singular', true );
if ( '' !== $singular ) {
if ( $singular && '' !== $singular ) {
return $singular;
} else {
return get_the_title( $post );
@@ -364,6 +364,25 @@ function sp_get_player_number( $post = 0 ) {
return get_post_meta( $post, 'sp_number', true );
}
function sp_get_player_number_in_event( $player_id, $team_id, $event_id ) {
$event_players = get_post_meta( $event_id, 'sp_players', true );
if ( ! array_key_exists( $team_id, $event_players ) ) {
return;
}
if ( ! array_key_exists( $player_id, $event_players[ $team_id ] ) ) {
return;
}
return $event_players[ $team_id ][ $player_id ][ 'number' ];
}
function sp_get_player_number_in_event_or_profile( $player_id, $team_id, $event_id ) {
$number = sp_get_player_number_in_event( $player_id, $team_id, $event_id );
if ( is_null( $number ) ) {
$number = sp_get_player_number( $player_id );
}
return $number;
}
function sp_get_player_name( $post = 0 ) {
return apply_filters( 'sportspress_player_name', get_the_title( $post ), $post );
}

View File

@@ -7,7 +7,7 @@
* @author ThemeBoy
* @category Core
* @package SportsPress/Functions
* @version 2.6.8
* @version 2.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -533,7 +533,7 @@ if ( !function_exists( 'sp_get_post_format' ) ) {
function sp_get_post_format( $post_id ) {
$format = get_post_meta ( $post_id, 'sp_format', true );
if ( isset( $format ) ):
$options = apply_filters( 'sportspress_performance_formats', array( 'number' => __( 'Number', 'sportspress' ), 'time' => __( 'Time', 'sportspress' ), 'text' => __( 'Text', 'sportspress' ), 'equation' => __( 'Equation', 'sportspress' ) ) );
$options = apply_filters( 'sportspress_performance_formats', array( 'number' => __( 'Number', 'sportspress' ), 'time' => __( 'Time', 'sportspress' ), 'text' => __( 'Text', 'sportspress' ), 'equation' => __( 'Equation', 'sportspress' ), 'checkbox' => __( 'Checkbox', 'sportspress' ) ) );
return sp_array_value( $options, $format, __( 'Number', 'sportspress' ) );
else:
return __( 'Number', 'sportspress' );
@@ -547,6 +547,7 @@ if ( !function_exists( 'sp_get_format_placeholder' ) ) {
'number' => 0,
'time' => '0:00',
'text' => '&nbsp;',
'checkbox' => '&nbsp;',
) );
return sp_array_value( $placeholders, $key, 0 );
}
@@ -1481,7 +1482,9 @@ if ( ! function_exists( 'sp_sort_terms' ) ) {
$b = intval( $b );
$b = get_term( $b );
}
return get_term_meta( $a->term_id, 'sp_order', true ) > get_term_meta( $b->term_id, 'sp_order', true );
$term_meta_a = get_term_meta( $a->term_id, 'sp_order', true );
$term_meta_b = get_term_meta( $b->term_id, 'sp_order', true );
return $term_meta_a == $term_meta_b ? 0 : ($term_meta_a > $term_meta_b ? 1 : -1);
}
}
@@ -1579,6 +1582,7 @@ function sp_get_text_options() {
__( 'Full Time', 'sportspress' ),
__( 'Home', 'sportspress' ),
__( 'League', 'sportspress' ),
__( 'Leagues', 'sportspress' ),
__( 'League Table', 'sportspress' ),
__( 'Match Day', 'sportspress' ),
__( 'Nationality', 'sportspress' ),
@@ -1598,6 +1602,7 @@ function sp_get_text_options() {
__( 'Recap', 'sportspress' ),
__( 'Results', 'sportspress' ),
__( 'Season', 'sportspress' ),
__( 'Seasons', 'sportspress' ),
__( 'Staff', 'sportspress' ),
__( 'Statistics', 'sportspress' ),
__( 'TBD', 'sportspress' ),
@@ -1683,3 +1688,51 @@ if( ! function_exists( 'array_replace' ) ) {
return $res;
}
}
/**
* Check if a shortcode is shown on content
* @return bool
*/
function sp_has_shortcodes( $content, $tags ) {
if( is_array( $tags ) ) {
foreach ( $tags as $tag ) {
preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
if ( empty( $matches ) )
return false;
foreach ( $matches as $shortcode ) {
if ( $tag === $shortcode[2] )
return true;
}
}
} else {
if ( shortcode_exists( $tags ) ) {
preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
if ( empty( $matches ) )
return false;
foreach ( $matches as $shortcode ) {
if ( $tags === $shortcode[2] )
return true;
}
}
}
return false;
}
/**
* Check if a custom flag was uploaded from the user
* @return bool
*/
function sp_flags( $nationality ) {
$nationality = strtolower( $nationality );
$flag = '';
global $wpdb;
$flag_post_id = intval( $wpdb->get_var( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value LIKE '%/$nationality'" ) );
if ( $flag_post_id ) {
$flag_src = wp_get_attachment_image_url( $flag_post_id, array( 23,15), false );
$flag = '<img src="' . $flag_src . '" alt="' . $nationality . '">';
}else{
$flag = '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/flags/' . $nationality . '.png" alt="' . $nationality . '">';
}
return $flag;
}

View File

@@ -7,7 +7,7 @@
* @author ThemeBoy
* @category Core
* @package SportsPress/Functions
* @version 2.4
* @version 2.7.3
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -189,9 +189,9 @@ if ( ! function_exists( 'sp_rgb_from_hex' ) ) {
// Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
$color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
$rgb['R'] = hexdec( $color{0}.$color{1} );
$rgb['G'] = hexdec( $color{2}.$color{3} );
$rgb['B'] = hexdec( $color{4}.$color{5} );
$rgb['R'] = hexdec( $color[0].$color[1] );
$rgb['G'] = hexdec( $color[2].$color[3] );
$rgb['B'] = hexdec( $color[4].$color[5] );
return $rgb;
}
}

View File

@@ -8,8 +8,9 @@ class SP_Widget_Birthdays extends WP_Widget {
function widget( $args, $instance ) {
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
$date = empty($instance['date']) ? 'day' : strip_tags($instance['date']);
$title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base );
$date = empty( $instance['date']) ? 'day' : strip_tags($instance['date'] );
$birthday_format = empty( $instance['birthday_format']) ? 'birthday' : strip_tags( $instance['birthday_format'] );
do_action( 'sportspress_before_widget', $args, $instance, 'birthdays' );
echo $before_widget;
@@ -20,7 +21,7 @@ class SP_Widget_Birthdays extends WP_Widget {
// Action to hook into
do_action( 'sportspress_before_widget_template', $args, $instance, 'birthdays' );
sp_get_template( 'birthdays.php', array( 'date' => $date ) );
sp_get_template( 'birthdays.php', array( 'date' => $date, 'birthday_format' => $birthday_format ) );
// Action to hook into
do_action( 'sportspress_after_widget_template', $args, $instance, 'birthdays' );
@@ -31,8 +32,9 @@ class SP_Widget_Birthdays extends WP_Widget {
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['date'] = strip_tags($new_instance['date']);
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['date'] = strip_tags( $new_instance['date'] );
$instance['birthday_format'] = strip_tags( $new_instance['birthday_format'] );
// Filter to hook into
$instance = apply_filters( 'sportspress_widget_update', $instance, $new_instance, $old_instance, 'birthdays' );
@@ -41,14 +43,21 @@ class SP_Widget_Birthdays extends WP_Widget {
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'date' => 'day' ) );
$title = strip_tags($instance['title']);
$date = strip_tags($instance['date']);
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'date' => 'day', 'birthday_format' => 'birthday' ) );
$title = strip_tags( $instance['title'] );
$date = strip_tags( $instance['date'] );
$options = array(
'day' => __( 'Today', 'sportspress' ),
'week' => __( 'This week', 'sportspress' ),
'month' => __( 'This month', 'sportspress' ),
);
$birthday_format = strip_tags( $instance['birthday_format'] );
$birthday_options = array(
'hide' => __( 'Hide', 'sportspress' ),
'birthday' => __( 'Birthday', 'sportspress' ),
'age' => __( 'Age', 'sportspress' ),
'birthdayage' => __( 'Birthday (Age)', 'sportspress' ),
);
// Action to hook into
do_action( 'sportspress_before_widget_template_form', $this, $instance, 'birthdays' );
@@ -64,6 +73,14 @@ class SP_Widget_Birthdays extends WP_Widget {
<?php } ?>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id('birthday_format'); ?>"><?php _e( 'Format:', 'sportspress' ); ?></label>
<select name="<?php echo $this->get_field_name('birthday_format'); ?>" id="<?php echo $this->get_field_id('birthday_format'); ?>" class="postform widefat">
<?php foreach ( $birthday_options as $value => $label ) { ?>
<option value="<?php echo $value; ?>" <?php selected( $value, $birthday_format ); ?>><?php echo $label; ?></option>
<?php } ?>
</select>
</p>
<?php
// Action to hook into
do_action( 'sportspress_after_widget_template_form', $this, $instance, 'birthdays' );

View File

@@ -16,6 +16,10 @@ class SP_Widget_Countdown extends WP_Widget {
$show_venue = empty($instance['show_venue']) ? false : $instance['show_venue'];
$show_league = empty($instance['show_league']) ? false : $instance['show_league'];
$show_date = empty($instance['show_date']) ? false : $instance['show_date'];
$show_excluded = empty($instance['show_excluded']) ? false : $instance['show_excluded'];
$order = empty($instance['order']) ? false : $instance['order'];
$orderby = empty($instance['orderby']) ? false : $instance['orderby'];
$show_status = empty($instance['show_status']) ? false : $instance['show_status'];
do_action( 'sportspress_before_widget', $args, $instance, 'countdown' );
echo $before_widget;
@@ -26,7 +30,7 @@ class SP_Widget_Countdown extends WP_Widget {
// Action to hook into
do_action( 'sportspress_before_widget_template', $args, $instance, 'countdown' );
sp_get_template( 'countdown.php', array( 'calendar' => $calendar, 'team' => $team, 'id' => $id, 'title' => $caption, 'show_venue' => $show_venue, 'show_league' => $show_league, 'show_date' => $show_date ) );
sp_get_template( 'countdown.php', array( 'calendar' => $calendar, 'team' => $team, 'id' => $id, 'title' => $caption, 'show_venue' => $show_venue, 'show_league' => $show_league, 'show_date' => $show_date, 'show_excluded' => $show_excluded, 'order' => $order, 'orderby' => $orderby, 'show_status' => $show_status ) );
// Action to hook into
do_action( 'sportspress_after_widget_template', $args, $instance, 'countdown' );
@@ -45,6 +49,10 @@ class SP_Widget_Countdown extends WP_Widget {
$instance['show_venue'] = intval($new_instance['show_venue']);
$instance['show_league'] = intval($new_instance['show_league']);
$instance['show_date'] = intval($new_instance['show_date']);
$instance['show_excluded'] = intval($new_instance['show_excluded']);
$instance['order'] = strip_tags($new_instance['order']);
$instance['orderby'] = strip_tags($new_instance['orderby']);
$instance['show_status'] = strip_tags($new_instance['show_status']);
// Filter to hook into
$instance = apply_filters( 'sportspress_widget_update', $instance, $new_instance, $old_instance, 'countdown' );
@@ -53,7 +61,7 @@ class SP_Widget_Countdown extends WP_Widget {
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'calendar' => '', 'team' => '', 'id' => '', 'caption' => '', 'show_venue' => false, 'show_league' => false, 'show_date' => false ) );
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'calendar' => '', 'team' => '', 'id' => '', 'caption' => '', 'show_venue' => false, 'show_league' => false, 'show_date' => false, 'show_excluded' => false, 'order' => '', 'orderby' => '', 'show_status' => true ) );
$title = strip_tags($instance['title']);
$caption = strip_tags($instance['caption']);
$calendar = intval($instance['calendar']);
@@ -62,6 +70,10 @@ class SP_Widget_Countdown extends WP_Widget {
$show_venue = intval($instance['show_venue']);
$show_league = intval($instance['show_league']);
$show_date = intval($instance['show_date']);
$show_excluded = intval($instance['show_excluded']);
$order = strip_tags($instance['order']);
$orderby = strip_tags($instance['orderby']);
$show_status = intval($instance['show_status']);
// Action to hook into
do_action( 'sportspress_before_widget_template_form', $this, $instance, 'countdown' );
@@ -88,6 +100,21 @@ class SP_Widget_Countdown extends WP_Widget {
endif;
?>
</p>
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id('orderby'); ?>"><?php printf( __( 'Sort by:', 'sportspress' ) ); ?></label>
<select name="<?php echo $this->get_field_name('orderby'); ?>" class="postform widefat">
<option value="" <?php selected( 'default', $orderby ); ?>><?php _e( 'Default', 'sportspress' ); ?></option>
<option value="date" <?php selected( 'date', $orderby ); ?>><?php _e( 'Date', 'sportspress' ); ?></option>
<option value="day" <?php selected( 'day', $orderby ); ?>><?php _e( 'Match Day', 'sportspress' ); ?></option>
</select>
</p>
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id('order'); ?>"><?php printf( __( 'Sort Order:', 'sportspress' ) ); ?></label>
<select name="<?php echo $this->get_field_name('order'); ?>" class="postform widefat">
<option value="ASC" <?php selected( 'ASC', $order ); ?>><?php _e( 'Ascending', 'sportspress' ); ?></option>
<option value="DESC" <?php selected( 'DESC', $order ); ?>><?php _e( 'Descending', 'sportspress' ); ?></option>
</select>
</p>
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id('team'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Team', 'sportspress' ) ); ?></label>
<?php
@@ -135,6 +162,12 @@ class SP_Widget_Countdown extends WP_Widget {
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_date'); ?>" name="<?php echo $this->get_field_name('show_date'); ?>" value="1" <?php checked( $show_date, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_date'); ?>"><?php _e( 'Display date', 'sportspress' ); ?></label></p>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_excluded'); ?>" name="<?php echo $this->get_field_name('show_excluded'); ?>" value="1" <?php checked( $show_excluded, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_excluded'); ?>"><?php _e( 'Display excluded events', 'sportspress' ); ?></label></p>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_status'); ?>" name="<?php echo $this->get_field_name('show_status'); ?>" value="1" <?php checked( $show_status, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_status'); ?>"><?php _e( 'Display event status', 'sportspress' ); ?></label></p>
<?php
// Action to hook into
do_action( 'sportspress_after_widget_template_form', $this, $instance, 'countdown' );