diff --git a/includes/admin/post-types/class-sp-admin-cpt-list.php b/includes/admin/post-types/class-sp-admin-cpt-list.php
index babf3f5c..3527725f 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-list.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-list.php
@@ -101,7 +101,7 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
$selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
$args = array(
- 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
+ 'show_option_all' => __( 'Show all competitions', 'sportspress' ),
'taxonomy' => 'sp_league',
'name' => 'sp_league',
'selected' => $selected
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php
index 964078d1..d8c65d69 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php
@@ -22,22 +22,23 @@ class SP_Meta_Box_Calendar_Data {
$calendar = new SP_Calendar( $post );
$data = $calendar->data();
$usecolumns = $calendar->columns;
- $title_format = $calendar->title_format;
- self::table( $data, $usecolumns, $title_format );
+ self::table( $data, $usecolumns );
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
- update_post_meta( $post_id, 'sp_title_format', sp_array_value( $_POST, 'sp_title_format', 'title' ) );
update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) );
}
/**
* Admin edit table
*/
- public static function table( $data = array(), $usecolumns = null, $title_format = null ) {
+ public static function table( $data = array(), $usecolumns = null ) {
+ $title_format = get_option( 'sportspress_event_list_title_format', 'title' );
+ $time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
+
if ( is_array( $usecolumns ) )
$usecolumns = array_filter( $usecolumns );
?>
@@ -51,19 +52,37 @@ class SP_Meta_Box_Calendar_Data {
>
-
- >
- >
- > |
-
+ |
>
-
+
+
+
+
+ >
+
+
+
+
>
@@ -139,15 +158,30 @@ class SP_Meta_Box_Calendar_Data {
?>
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
ID, 'sp_league' ); ?>
ID, 'sp_season' ); ?>
ID, 'sp_venue' ); ?>
diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php
index 87db4d7b..9fe1bf8c 100644
--- a/includes/sp-core-functions.php
+++ b/includes/sp-core-functions.php
@@ -7,7 +7,7 @@
* @author ThemeBoy
* @category Core
* @package SportsPress/Functions
- * @version 1.4.4
+ * @version 1.5
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -297,6 +297,12 @@ if ( !function_exists( 'sp_numbers_to_words' ) ) {
}
}
+if ( !function_exists( 'sp_column_active' ) ) {
+ function sp_column_active( $array = null, $value = null ) {
+ return $array == null || in_array( $value, $array );
+ }
+}
+
if ( !function_exists( 'sp_get_the_term_id' ) ) {
function sp_get_the_term_id( $post_id, $taxonomy ) {
$terms = get_the_terms( $post_id, $taxonomy );
@@ -477,10 +483,11 @@ if ( !function_exists( 'sp_dropdown_taxonomies' ) ) {
'selected' => null,
'hide_empty' => false,
'values' => 'slug',
- 'class' => null,
- 'property' => null,
- 'placeholder' => null,
- 'chosen' => false,
+ 'class' => null,
+ 'property' => null,
+ 'placeholder' => null,
+ 'chosen' => false,
+ 'parent' => 0,
);
$args = array_merge( $defaults, $args );
if ( ! $args['taxonomy'] ) return false;
@@ -539,6 +546,26 @@ if ( !function_exists( 'sp_dropdown_taxonomies' ) ) {
endif;
printf( '%s ', $this_value, $selected_prop, $term->name );
+
+ $term_children = get_term_children( $term->term_id, $args['taxonomy'] );
+
+ foreach ( $term_children as $term_child_id ):
+ $term_child = get_term_by( 'id', $term_child_id, $args['taxonomy'] );
+
+ if ( $args['values'] == 'term_id' ):
+ $this_value = $term_child->term_id;
+ else:
+ $this_value = $term_child->slug;
+ endif;
+
+ if ( strpos( $property, 'multiple' ) !== false ):
+ $selected_prop = in_array( $this_value, $selected ) ? 'selected' : '';
+ else:
+ $selected_prop = selected( $this_value, $selected, false );
+ endif;
+
+ printf( '%s ', $this_value, $selected_prop, '— ' . $term_child->name );
+ endforeach;
endforeach;
print( '' );
return true;
diff --git a/includes/widgets/class-sp-widget-event-list.php b/includes/widgets/class-sp-widget-event-list.php
index 35e79427..783f3042 100644
--- a/includes/widgets/class-sp-widget-event-list.php
+++ b/includes/widgets/class-sp-widget-event-list.php
@@ -136,7 +136,7 @@ class SP_Widget_Event_List extends WP_Widget {
__( 'Event', 'sportspress' ),
- 'time' => __( 'Time', 'sportspress' ),
+ 'time' => __( 'Time/Results', 'sportspress' ),
'venue' => __( 'Venue', 'sportspress' ),
'article' => __( 'Article', 'sportspress' ),
);
diff --git a/templates/event-list.php b/templates/event-list.php
index 09b8b8ea..80b1281e 100644
--- a/templates/event-list.php
+++ b/templates/event-list.php
@@ -43,7 +43,8 @@ if ( $order != 'default' )
$calendar->order = $order;
$data = $calendar->data();
$usecolumns = $calendar->columns;
-$title_format = $calendar->title_format;
+$title_format = get_option( 'sportspress_event_list_title_format', 'title' );
+$time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
if ( isset( $columns ) ):
if ( is_array( $columns ) )
@@ -51,6 +52,10 @@ if ( isset( $columns ) ):
else
$usecolumns = explode( ',', $columns );
endif;
+
+if ( $id ) {
+ echo '' . get_the_title( $id ) . ' ';
+}
?>
@@ -60,25 +65,47 @@ endif;
' . __( 'Date', 'sportspress' ) . '
';
- if ( $usecolumns == null || in_array( 'event', $usecolumns ) ):
- if ( $title_format == 'homeaway' ):
- echo '' . __( 'Home', 'sportspress' ) . ' ';
- elseif ( $title_format == 'teams' ):
- echo '' . __( 'Teams', 'sportspress' ) . ' ';
- else:
- echo '' . __( 'Event', 'sportspress' ) . ' ';
- endif;
- endif;
+ switch ( $title_format ) {
+ case 'homeaway':
+ if ( sp_column_active( $usecolumns, 'event' ) ) {
+ echo '' . __( 'Home', 'sportspress' ) . ' ';
- if ( $usecolumns == null || in_array( 'time', $usecolumns ) ):
- if ( $usecolumns == null || in_array( 'event', $usecolumns ) && $title_format == 'homeaway' )
- echo ' ';
- else
- echo '' . __( 'Time/Results', 'sportspress' ) . ' ';
- endif;
+ if ( 'combined' == $time_format && sp_column_active( $usecolumns, 'time' ) ) {
+ echo ' ';
+ } elseif ( in_array( $time_format, array( 'separate', 'results' ) ) && sp_column_active( $usecolumns, 'results' ) ) {
+ echo ' ';
+ }
- if ( $usecolumns == null || in_array( 'event', $usecolumns ) && $title_format == 'homeaway' )
- echo '' . __( 'Away', 'sportspress' ) . ' ';
+ echo '' . __( 'Away', 'sportspress' ) . ' ';
+
+ if ( in_array( $time_format, array( 'separate', 'time' ) ) && sp_column_active( $usecolumns, 'time' ) ) {
+ echo '' . __( 'Time', 'sportspress' ) . ' ';
+ }
+ }
+ break;
+ default:
+ if ( sp_column_active( $usecolumns, 'event' ) ) {
+ if ( $title_format == 'teams' )
+ echo '' . __( 'Teams', 'sportspress' ) . ' ';
+ else
+ echo '' . __( 'Event', 'sportspress' ) . ' ';
+ }
+
+ switch ( $time_format ) {
+ case 'separate':
+ echo '' . __( 'Time', 'sportspress' ) . ' ';
+ echo '' . __( 'Results', 'sportspress' ) . ' ';
+ break;
+ case 'time':
+ echo '' . __( 'Time', 'sportspress' ) . ' ';
+ break;
+ case 'results':
+ echo '' . __( 'Results', 'sportspress' ) . ' ';
+ break;
+ default:
+ echo '' . __( 'Time/Results', 'sportspress' ) . ' ';
+ }
+ }
if ( $usecolumns == null || in_array( 'league', $usecolumns ) )
echo '' . __( 'Competition', 'sportspress' ) . ' ';
@@ -110,7 +137,7 @@ endif;
$main_results = sp_get_main_results( $event );
$teams_output = '';
- $teams_array = '';
+ $teams_array = array();
if ( $teams ):
foreach ( $teams as $team ):
@@ -143,33 +170,95 @@ endif;
echo '' . get_post_time( 'Y-m-d H:i:s', false, $event ) . ' ' . get_post_time( get_option( 'date_format' ), false, $event, true ) . ' ';
- if ( $usecolumns == null || in_array( 'event', $usecolumns ) ):
- if ( $title_format == 'homeaway' ):
- $team = array_shift( $teams_array );
- echo '' . $team . ' ';
- else:
- if ( $title_format == 'teams' ):
- echo '' . $teams_output . ' ';
- else:
- echo '' . $event->post_title . ' ';
- endif;
- endif;
- endif;
+ switch ( $title_format ) {
+ case 'homeaway':
+ if ( sp_column_active( $usecolumns, 'event' ) ) {
+ $team = array_shift( $teams_array );
+ echo '' . $team . ' ';
- if ( $usecolumns == null || in_array( 'time', $usecolumns ) ):
- echo '';
- if ( ! empty( $main_results ) ):
- echo implode( ' - ', $main_results );
- else:
- echo ' ' . get_post_time( 'H:i:s', false, $event ) . ' ' . sp_get_time( $event );
- endif;
- echo ' ';
- endif;
+ if ( 'combined' == $time_format && sp_column_active( $usecolumns, 'time' ) ) {
+ echo '';
+ if ( ! empty( $main_results ) ):
+ echo implode( ' - ', $main_results );
+ else:
+ echo ' ' . get_post_time( 'H:i:s', false, $event ) . ' ' . sp_get_time( $event );
+ endif;
+ echo ' ';
+ } elseif ( in_array( $time_format, array( 'separate', 'results' ) ) && sp_column_active( $usecolumns, 'results' ) ) {
+ echo '';
+ if ( ! empty( $main_results ) ):
+ echo implode( ' - ', $main_results );
+ else:
+ echo '-';
+ endif;
+ echo ' ';
+ }
- if ( $usecolumns == null || in_array( 'event', $usecolumns ) && $title_format == 'homeaway' ):
- $team = array_shift( $teams_array );
- echo '' . $team . ' ';
- endif;
+ $team = array_shift( $teams_array );
+ echo '' . $team . ' ';
+
+ if ( in_array( $time_format, array( 'separate', 'time' ) ) && sp_column_active( $usecolumns, 'time' ) ) {
+ echo '';
+ echo ' ' . get_post_time( 'H:i:s', false, $event ) . ' ' . sp_get_time( $event );
+ echo ' ';
+ }
+ }
+ break;
+ default:
+ if ( sp_column_active( $usecolumns, 'event' ) ) {
+ if ( $title_format == 'teams' )
+ echo '' . $teams_output . ' ';
+ else
+ echo '' . $event->post_title . ' ';
+ }
+
+ switch ( $time_format ) {
+ case 'separate':
+ if ( sp_column_active( $usecolumns, 'time' ) ) {
+ echo '';
+ echo ' ' . get_post_time( 'H:i:s', false, $event ) . ' ' . sp_get_time( $event );
+ echo ' ';
+ }
+ if ( sp_column_active( $usecolumns, 'results' ) ) {
+ echo '';
+ if ( ! empty( $main_results ) ):
+ echo implode( ' - ', $main_results );
+ else:
+ echo '-';
+ endif;
+ echo ' ';
+ }
+ break;
+ case 'time':
+ if ( sp_column_active( $usecolumns, 'time' ) ) {
+ echo '';
+ echo ' ' . get_post_time( 'H:i:s', false, $event ) . ' ' . sp_get_time( $event );
+ echo ' ';
+ }
+ break;
+ case 'results':
+ if ( sp_column_active( $usecolumns, 'results' ) ) {
+ echo '';
+ if ( ! empty( $main_results ) ):
+ echo implode( ' - ', $main_results );
+ else:
+ echo '-';
+ endif;
+ echo ' ';
+ }
+ break;
+ default:
+ if ( sp_column_active( $usecolumns, 'time' ) ) {
+ echo '';
+ if ( ! empty( $main_results ) ):
+ echo implode( ' - ', $main_results );
+ else:
+ echo ' ' . get_post_time( 'H:i:s', false, $event ) . ' ' . sp_get_time( $event );
+ endif;
+ echo ' ';
+ }
+ }
+ }
if ( $usecolumns == null || in_array( 'league', $usecolumns ) ):
echo '';
@@ -231,8 +320,8 @@ endif;
-
-' . __( 'View all events', 'sportspress' ) . '';
-?>
\ No newline at end of file
+ ' . __( 'View all events', 'sportspress' ) . '';
+ ?>
+
\ No newline at end of file