diff --git a/modules/sportspress-officials.php b/modules/sportspress-officials.php index f635735b..3eb86562 100644 --- a/modules/sportspress-officials.php +++ b/modules/sportspress-officials.php @@ -44,6 +44,7 @@ class SportsPress_Officials { add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_boxes' ) ); add_filter( 'sportspress_calendar_columns', array( $this, 'calendar_columns' ) ); add_filter( 'sportspress_after_event_template', array( $this, 'add_event_template' ), 30 ); + add_filter( 'sportspress_event_options', array( $this, 'add_event_options' ) ); add_filter( 'sportspress_screen_ids', array( $this, 'screen_ids' ) ); add_filter( 'sportspress_post_types', array( $this, 'add_post_type' ) ); add_filter( 'sportspress_primary_post_types', array( $this, 'add_post_type' ) ); @@ -413,6 +414,25 @@ class SportsPress_Officials { ) ); } + /** + * Add event options. + * + * @return array + */ + public function add_event_options( $options ) { + $options[] = array( + 'title' => __( 'Officials', 'sportspress' ), + 'id' => 'sportspress_event_officials_format', + 'default' => 'table', + 'type' => 'radio', + 'options' => array( + 'table' => __( 'Table', 'sportspress' ), + 'list' => __( 'List', 'sportspress' ), + ), + ); + return $options; + } + /** * Add screen ids. * diff --git a/templates/event-officials-list.php b/templates/event-officials-list.php new file mode 100644 index 00000000..d43eedd7 --- /dev/null +++ b/templates/event-officials-list.php @@ -0,0 +1,35 @@ + +
+

+
+
+ $label ) { + $appointed_officials = (array) sp_array_value( $data, $key, array() ); + if ( empty( $appointed_officials ) ) continue; + + echo '
' . $label . '
'; + + foreach ( $appointed_officials as $official_id => $official_name ) { + if ( $link_officials && sp_post_exists( $official_id ) ) { + $official_name = '' . $official_name . ''; + } + echo '
' . $official_name . '
'; + } + } + ?> +
+
+
\ No newline at end of file diff --git a/templates/event-officials-table.php b/templates/event-officials-table.php new file mode 100644 index 00000000..793077f8 --- /dev/null +++ b/templates/event-officials-table.php @@ -0,0 +1,43 @@ + +
+

+
+ + + + ' . $label . ''; + } + ?> + + + + + $official_name ) { + if ( $link_officials && sp_post_exists( $official_id ) ) { + $appointed_officials[ $official_id ] = '' . $official_name . ''; + } + } + echo ''; + } + ?> + + +
' . implode( '
', $appointed_officials ) . '
+
+
\ No newline at end of file diff --git a/templates/event-officials.php b/templates/event-officials.php index 37cf14f7..bb0b9bbf 100644 --- a/templates/event-officials.php +++ b/templates/event-officials.php @@ -4,7 +4,7 @@ * * @author ThemeBoy * @package SportsPress/Templates - * @version 1.4 + * @version 2.5 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly @@ -24,38 +24,21 @@ if ( empty( $data ) ) return; $labels = $data[0]; unset( $data[0] ); -$scrollable = get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false; $link_officials = get_option( 'sportspress_link_officials', 'no' ) == 'yes' ? true : false; -?> +$format = get_option( 'sportspress_event_officials_format', 'table' ); -
-

- -
- - - - ' . $label . ''; - } - ?> - - - - - $official_name ) { - if ( $link_officials && sp_post_exists( $official_id ) ) { - $appointed_officials[ $official_id ] = '' . $official_name . ''; - } - } - echo ''; - } - ?> - - -
' . implode( '
', $appointed_officials ) . '
-
-
+switch ( $format ): + case 'list': + sp_get_template( 'event-officials-list.php', array( + 'labels' => $labels, + 'data' => $data, + 'link_officials' => $link_officials, + ) ); + break; + default: + sp_get_template( 'event-officials-table.php', array( + 'labels' => $labels, + 'data' => $data, + 'link_officials' => $link_officials, + ) ); +endswitch; \ No newline at end of file