From bfb06c64bcdc5ec675bbb6b3aead44a8b2ce00f3 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Sat, 12 Jul 2014 02:33:53 +1000 Subject: [PATCH] Enhance shortcode menu with Thickbox prompt --- assets/css/menu.css | 27 +- assets/js/admin/editor-lang.php | 25 +- assets/js/admin/editor.js | 239 +++++++-- includes/admin/class-sp-admin-editor.php | 4 +- includes/admin/class-sp-admin-thickbox.php | 483 ++++++++++++++++++ includes/admin/class-sp-admin.php | 6 +- .../settings/class-sp-settings-general.php | 13 +- includes/class-sp-event.php | 60 ++- includes/sp-core-functions.php | 4 +- templates/event-list.php | 5 +- templates/event-performance.php | 264 +++++----- 11 files changed, 900 insertions(+), 230 deletions(-) create mode 100644 includes/admin/class-sp-admin-thickbox.php diff --git a/assets/css/menu.css b/assets/css/menu.css index 915f07f3..dceeeb23 100644 --- a/assets/css/menu.css +++ b/assets/css/menu.css @@ -74,14 +74,35 @@ text-align: center; } -.wp-media-buttons .add_sportspress span.wp-media-buttons-icon:before { - font: normal 20px/1 sportspress, dashicons; +/* Prefs */ +.sp-prefs .button { + margin: 0 3px 4px 0; + padding: 0 7px 1px 5px; +} + +.sp-prefs .button input[type=checkbox] { + background: transparent; + border: none; + -webkit-box-shadow: none; + box-shadow: none; +} + +.sp-prefs .button input[type=checkbox]:not(:checked):before { + float: left; + display: inline-block; + vertical-align: middle; + width: 16px; + font: 400 21px/1 dashicons; speak: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; - content: '\f111'; + content: '\f335'; + margin: -3px 0 0 -4px; + color: #a00; } +/* TinyMCE */ + i.mce-i-sp_shortcodes_button:before, span.mce_sp_shortcodes_button:before { font-family: 'sportspress'; speak: none; diff --git a/assets/js/admin/editor-lang.php b/assets/js/admin/editor-lang.php index 66e8c103..088181a2 100644 --- a/assets/js/admin/editor-lang.php +++ b/assets/js/admin/editor-lang.php @@ -3,15 +3,22 @@ $strings = 'tinyMCE.addI18n({' . _WP_Editors::$mce_locale . ':{ sportspress:{ insert: "' . esc_js( __( 'SportsPress shortcodes', 'sportspress' ) ) . '", + auto: "' . esc_js( __( 'Auto', 'sportspress' ) ) . '", + manual: "' . esc_js( __( 'Manual', 'sportspress' ) ) . '", + single: "' . esc_js( __( 'Single', 'sportspress' ) ) . '", + select: "' . esc_js( __( 'Select...', 'sportspress' ) ) . '", countdown: "' . esc_js( __( 'Countdown', 'sportspress' ) ) . '", - event_details: "' . esc_js( __( 'Event Details', 'sportspress' ) ) . '", - event_results: "' . esc_js( __( 'Event Results', 'sportspress' ) ) . '", - event_performance: "' . esc_js( __( 'Event Performance', 'sportspress' ) ) . '", - event_calendar: "' . esc_js( __( 'Event Calendar', 'sportspress' ) ) . '", - event_list: "' . esc_js( __( 'Event List', 'sportspress' ) ) . '", - event_blocks: "' . esc_js( __( 'Event Blocks', 'sportspress' ) ) . '", + event: "' . esc_js( __( 'Event', 'sportspress' ) ) . '", + details: "' . esc_js( __( 'Details', 'sportspress' ) ) . '", + results: "' . esc_js( __( 'Results', 'sportspress' ) ) . '", + performance: "' . esc_js( __( 'Performance', 'sportspress' ) ) . '", + calendar: "' . esc_js( __( 'Calendar', 'sportspress' ) ) . '", + list: "' . esc_js( __( 'List', 'sportspress' ) ) . '", + blocks: "' . esc_js( __( 'Blocks', 'sportspress' ) ) . '", league_table: "' . esc_js( __( 'League Table', 'sportspress' ) ) . '", - player_list: "' . esc_js( __( 'Player List', 'sportspress' ) ) . '", - player_gallery: "' . esc_js( __( 'Player Gallery', 'sportspress' ) ) . '" + player: "' . esc_js( __( 'Player', 'sportspress' ) ) . '", + statistics: "' . esc_js( __( 'Statistics', 'sportspress' ) ) . '", + list: "' . esc_js( __( 'List', 'sportspress' ) ) . '", + gallery: "' . esc_js( __( 'Gallery', 'sportspress' ) ) . '" } -}})'; \ No newline at end of file +}})'; diff --git a/assets/js/admin/editor.js b/assets/js/admin/editor.js index 0bdf5607..c18e6dfa 100644 --- a/assets/js/admin/editor.js +++ b/assets/js/admin/editor.js @@ -10,63 +10,202 @@ menu: [ { text: ed.getLang( 'sportspress.countdown' ), - onclick: function() { - editor.insertContent( '[countdown id="" live=""]' ); - } + menu: [ + { + text: ed.getLang( 'sportspress.manual' ), + onclick: function() { + editor.insertContent( '[countdown id="" live="1"]' ); + } + }, + { + text: ed.getLang( 'sportspress.auto' ), + onclick: function() { + editor.insertContent( '[countdown]' ); + } + } + ] }, { - text: ed.getLang( 'sportspress.event_details' ), - onclick: function() { - editor.insertContent( '[event_details id=""]' ); - } - }, - { - text: ed.getLang( 'sportspress.event_results' ), - onclick: function() { - editor.insertContent( '[event_results id=""]' ); - } - }, - { - text: ed.getLang( 'sportspress.event_performance' ), - onclick: function() { - editor.insertContent( '[event_performance id=""]' ); - } - }, - { - text: ed.getLang( 'sportspress.event_calendar' ), - onclick: function() { - editor.insertContent( '[event_calendar id="" status="default" show_all_events_link="0"]' ); - } - }, - { - text: ed.getLang( 'sportspress.event_list' ), - onclick: function() { - editor.insertContent( '[event_list id="" status="default" show_all_events_link="0"]' ); - } - }, - { - text: ed.getLang( 'sportspress.event_blocks' ), - onclick: function() { - editor.insertContent( '[event_blocks id="" status="default" show_all_events_link="0"]' ); - } + text: ed.getLang( 'sportspress.event' ), + menu: [ + { + text: ed.getLang( 'sportspress.single' ), + menu: [ + { + text: ed.getLang( 'sportspress.details' ), + onclick: function() { + editor.insertContent( '[event_details id=""]' ); + } + }, + { + text: ed.getLang( 'sportspress.results' ), + onclick: function() { + editor.insertContent( '[event_results id=""]' ); + } + }, + { + text: ed.getLang( 'sportspress.performance' ), + onclick: function() { + editor.insertContent( '[event_performance id=""]' ); + } + } + ] + }, + { + text: ed.getLang( 'sportspress.calendar' ), + menu: [ + { + text: ed.getLang( 'sportspress.select' ), + onclick : function() { + // triggers the thickbox + var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width; + W = W - 80; + H = H - 84; + tb_show( 'My WIndow POPUP Title', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=sp_choose_event_calendar' ); + } + }, + { + text: ed.getLang( 'sportspress.manual' ), + onclick: function() { + editor.insertContent( '[event_calendar id="" status="default" initial="1" show_all_events_link="0"]' ); + } + }, + { + text: ed.getLang( 'sportspress.auto' ), + onclick: function() { + editor.insertContent( '[event_calendar]' ); + } + } + ] + }, + { + text: ed.getLang( 'sportspress.list' ), + menu: [ + { + text: ed.getLang( 'sportspress.select' ), + onclick : function() { + // triggers the thickbox + var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width; + W = W - 80; + H = H - 84; + tb_show( 'My WIndow POPUP Title', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=sp_choose_event_list' ); + } + }, + { + text: ed.getLang( 'sportspress.manual' ), + onclick: function() { + editor.insertContent( '[event_list id="" status="default" show_all_events_link="0"]' ); + } + } + ] + }, + { + text: ed.getLang( 'sportspress.blocks' ), + menu: [ + { + text: ed.getLang( 'sportspress.select' ), + onclick : function() { + // triggers the thickbox + var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width; + W = W - 80; + H = H - 84; + tb_show( 'My WIndow POPUP Title', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=sp_choose_event_blocks' ); + } + }, + { + text: ed.getLang( 'sportspress.manual' ), + onclick: function() { + editor.insertContent( '[event_blocks id="" status="default" show_all_events_link="0"]' ); + } + } + ] + } + ] }, { text: ed.getLang( 'sportspress.league_table' ), - onclick: function() { - editor.insertContent( '[league_table id="" number="-1" show_team_logo="1" link_posts="0" show_full_table_link="0"]' ); - } + menu: [ + { + text: ed.getLang( 'sportspress.select' ), + onclick : function() { + // triggers the thickbox + var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width; + W = W - 80; + H = H - 84; + tb_show( 'My WIndow POPUP Title', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=sp_choose_league_table' ); + } + }, + { + text: ed.getLang( 'sportspress.manual' ), + onclick: function() { + editor.insertContent( '[league_table id="" number="-1" show_team_logo="1" link_posts="0" show_full_table_link="0"]' ); + } + } + ] }, { - text: ed.getLang( 'sportspress.player_list' ), - onclick: function() { - editor.insertContent( '[player_list id="" number="-1" orderby="default" order="ASC" show_all_players_link="0"]' ); - } - }, - { - text: ed.getLang( 'sportspress.player_gallery' ), - onclick: function() { - editor.insertContent( '[event_blocks id="" number="-1" columns="3" orderby="default" order="ASC" size="thumbnail" show_all_players_link="0"]' ); - } + text: ed.getLang( 'sportspress.player' ), + menu: [ + { + text: ed.getLang( 'sportspress.single' ), + menu: [ + { + text: ed.getLang( 'sportspress.details' ), + onclick: function() { + editor.insertContent( '[player_details id=""]' ); + } + }, + { + text: ed.getLang( 'sportspress.statistics' ), + onclick: function() { + editor.insertContent( '[player_statistics id=""]' ); + } + } + ] + }, + { + text: ed.getLang( 'sportspress.list' ), + menu: [ + { + text: ed.getLang( 'sportspress.select' ), + onclick : function() { + // triggers the thickbox + var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width; + W = W - 80; + H = H - 84; + tb_show( 'My WIndow POPUP Title', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=sp_choose_player_list' ); + } + }, + { + text: ed.getLang( 'sportspress.manual' ), + onclick: function() { + editor.insertContent( '[player_list id="" number="-1" orderby="default" order="ASC" show_all_players_link="0"]' ); + } + } + ] + }, + { + text: ed.getLang( 'sportspress.gallery' ), + menu: [ + { + text: ed.getLang( 'sportspress.select' ), + onclick : function() { + // triggers the thickbox + var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width; + W = W - 80; + H = H - 84; + tb_show( 'My WIndow POPUP Title', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=sp_choose_player_gallery' ); + } + }, + { + text: ed.getLang( 'sportspress.manual' ), + onclick: function() { + editor.insertContent( '[player_gallery id="" number="-1" columns="3" orderby="default" order="ASC" size="thumbnail" show_all_players_link="0"]' ); + } + } + ] + } + ] } ] }); diff --git a/includes/admin/class-sp-admin-editor.php b/includes/admin/class-sp-admin-editor.php index 1a68bd1d..01dd4376 100644 --- a/includes/admin/class-sp-admin-editor.php +++ b/includes/admin/class-sp-admin-editor.php @@ -7,7 +7,7 @@ * @author ThemeBoy * @category Admin * @package SportsPress/Admin - * @version 2.0 + * @version 1.2 */ if ( ! defined( 'ABSPATH' ) ) { @@ -17,7 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) { /** * SP_Admin_Editor class. * - * @since 2.0 + * @since 1.2 */ class SP_Admin_Editor { diff --git a/includes/admin/class-sp-admin-thickbox.php b/includes/admin/class-sp-admin-thickbox.php new file mode 100644 index 00000000..1a015a50 --- /dev/null +++ b/includes/admin/class-sp-admin-thickbox.php @@ -0,0 +1,483 @@ + + + + 'sp_calendar', + 'name' => 'id', + 'values' => 'ID', + ); + sp_dropdown_pages( $args ); + $calendar_dropdown = ob_get_clean(); + + ob_start(); + $args = array( + 'post_type' => 'sp_table', + 'name' => 'id', + 'values' => 'ID', + ); + sp_dropdown_pages( $args ); + $league_table_dropdown = ob_get_clean(); + + ob_start(); + $args = array( + 'post_type' => 'sp_list', + 'name' => 'id', + 'values' => 'ID', + ); + sp_dropdown_pages( $args ); + $player_list_dropdown = ob_get_clean(); + + ob_start(); + $args = array( + 'prepend_options' => array( + 'default' => __( 'Default', 'sportspress' ), + 'number' => __( 'Number', 'sportspress' ), + 'name' => __( 'Name', 'sportspress' ), + 'eventsplayed' => __( 'Played', 'sportspress' ) + ), + 'post_type' => array( 'sp_metric', 'sp_performance', 'sp_statistic' ), + 'name' => 'orderby', + 'id' => 'orderby', + 'values' => 'slug' + ); + sp_dropdown_pages( $args ); + $player_list_orderby_dropdown = ob_get_clean(); + ?> + + + + + + + + + + + + + 'sportspress_enable_live_countdowns', 'default' => 'yes', 'type' => 'checkbox', - 'checkboxgroup' => 'end', + 'checkboxgroup' => '', 'desc_tip' => __( 'This will enable a script allowing the countdowns to be animated.', 'sportspress' ), ), + + array( + 'desc' => __( 'Shortcode menu', 'sportspress' ), + 'id' => 'sportspress_rich_editing', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => 'end', + 'desc_tip' => __( 'This will enable a shortcode menu to be displayed in the visual editor.', 'sportspress' ), + ), array( 'title' => __( 'Header Offset', 'sportspress' ), diff --git a/includes/class-sp-event.php b/includes/class-sp-event.php index 5691c51b..1ae62cc5 100644 --- a/includes/class-sp-event.php +++ b/includes/class-sp-event.php @@ -15,9 +15,11 @@ class SP_Event extends SP_Custom_Post{ public function status() { $post_status = $this->post->post_status; $results = get_post_meta( $this->ID, 'sp_results', true ); - foreach( $results as $result ) { - if ( count( array_filter( $result ) ) > 0 ) { - return 'results'; + if ( is_array( $results ) ) { + foreach( $results as $result ) { + if ( count( array_filter( $result ) ) > 0 ) { + return 'results'; + } } } return $post_status; @@ -54,40 +56,42 @@ class SP_Event extends SP_Custom_Post{ } public function performance( $admin = false ) { - $teams = (array)get_post_meta( $this->ID, 'sp_team', false ); + $teams = get_post_meta( $this->ID, 'sp_team', false ); $performance = (array)get_post_meta( $this->ID, 'sp_players', true ); $labels = sp_get_var_labels( 'sp_performance' ); $columns = get_post_meta( $this->ID, 'sp_columns', true ); - foreach( $teams as $i => $team_id ): - $players = sp_array_between( (array)get_post_meta( $this->ID, 'sp_player', false ), 0, $i ); - $data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) ); + if ( is_array( $teams ) ): + foreach( $teams as $i => $team_id ): + $players = sp_array_between( (array)get_post_meta( $this->ID, 'sp_player', false ), 0, $i ); + $data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) ); - $totals = array(); - foreach( $labels as $key => $label ): - $totals[ $key ] = 0; - endforeach; - - foreach( $data as $player_id => $player_performance ): + $totals = array(); foreach( $labels as $key => $label ): - if ( array_key_exists( $key, $totals ) ): - $totals[ $key ] += sp_array_value( $player_performance, $key, 0 ); + $totals[ $key ] = 0; + endforeach; + + foreach( $data as $player_id => $player_performance ): + foreach( $labels as $key => $label ): + if ( array_key_exists( $key, $totals ) ): + $totals[ $key ] += sp_array_value( $player_performance, $key, 0 ); + endif; + endforeach; + if ( ! array_key_exists( 'number', $player_performance ) ): + $performance[ $team_id ][ $player_id ]['number'] = get_post_meta( $player_id, 'sp_number', true ); + endif; + if ( ! array_key_exists( 'position', $player_performance ) || $player_performance['position'] == null ): + $performance[ $team_id ][ $player_id ]['position'] = get_post_meta( $player_id, 'sp_position', true ); endif; endforeach; - if ( ! array_key_exists( 'number', $player_performance ) ): - $performance[ $team_id ][ $player_id ]['number'] = get_post_meta( $player_id, 'sp_number', true ); - endif; - if ( ! array_key_exists( 'position', $player_performance ) || $player_performance['position'] == null ): - $performance[ $team_id ][ $player_id ]['position'] = get_post_meta( $player_id, 'sp_position', true ); - endif; - endforeach; - foreach( $totals as $key => $value ): - $manual_total = sp_array_value( sp_array_value( $performance, 0, array() ), $key, null ); - if ( $manual_total != null ): - $totals[ $key ] = $manual_total; - endif; + foreach( $totals as $key => $value ): + $manual_total = sp_array_value( sp_array_value( $performance, 0, array() ), $key, null ); + if ( $manual_total != null ): + $totals[ $key ] = $manual_total; + endif; + endforeach; endforeach; - endforeach; + endif; if ( $admin ): return array( $labels, $columns, $performance, $teams ); diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index d2598a30..4646d867 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.1.4 + * @version 1.2 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly @@ -273,7 +273,7 @@ if ( !function_exists( 'sp_array_combine' ) ) { endforeach; foreach ( $keys as $key ): - if ( ! array_key_exists( $key, $output ) ) + if ( $key !== false && ! array_key_exists( $key, $output ) ) $output[ $key ] = array(); endforeach; diff --git a/templates/event-list.php b/templates/event-list.php index e022f73c..5716235c 100644 --- a/templates/event-list.php +++ b/templates/event-list.php @@ -4,7 +4,7 @@ * * @author ThemeBoy * @package SportsPress/Templates - * @version 1.1 + * @version 1.2 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly @@ -23,6 +23,7 @@ $defaults = array( 'paginated' => get_option( 'sportspress_calendar_paginated', 'yes' ) == 'yes' ? true : false, 'rows' => get_option( 'sportspress_calendar_rows', 10 ), 'order' => 'default', + 'columns' => null, 'show_all_events_link' => false, ); @@ -39,7 +40,7 @@ $data = $calendar->data(); $usecolumns = $calendar->columns; if ( isset( $columns ) ) - $usecolumns = $columns; + $usecolumns = explode( ',', $columns ); ?>
diff --git a/templates/event-performance.php b/templates/event-performance.php index 4d127887..9a6386ee 100644 --- a/templates/event-performance.php +++ b/templates/event-performance.php @@ -4,7 +4,7 @@ * * @author ThemeBoy * @package SportsPress/Templates - * @version 1.1 + * @version 1.2 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly @@ -23,7 +23,7 @@ unset( $performance[0] ); $performance = array_filter( $performance ); -$teams = (array)get_post_meta( $id, 'sp_team', false ); +$teams = get_post_meta( $id, 'sp_team', false ); $status = $event->status(); $show_players = get_option( 'sportspress_event_show_players', 'yes' ) == 'yes' ? true : false; @@ -31,146 +31,148 @@ $link_posts = get_option( 'sportspress_event_link_players', 'yes' ) == 'yes' ? t $sortable = get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false; $responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false; -foreach( $teams as $index => $team_id ): - if ( ! $team_id ) continue; +if ( is_array( $teams ) ): + foreach( $teams as $index => $team_id ): + if ( ! $team_id ) continue; - // Get results for players in the team - $players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $index ); - $has_players = sizeof( $players ) > 1; + // Get results for players in the team + $players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $index ); + $has_players = sizeof( $players ) > 1; - if ( ! $has_players && $status != 'results' ) continue; + if ( ! $has_players && $status != 'results' ) continue; - $totals = array(); + $totals = array(); - $data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) ); - ?> -

- $id, 'index' => $index ) ); - endif; - ?> -
-
- - - - - - $label ): ?> - - - - - - - +

+ $id, 'index' => $index ) ); + endif; + ?> +
+
#
+ + + + + + $label ): ?> + + + + + + + $sub ): - if ( ! $sub_id ) - continue; - $lineup_sub_relation[ sp_array_value( $sub, 'sub', 0 ) ] = $sub_id; - endforeach; - - $i = 0; - foreach( $data as $player_id => $row ): - - if ( ! $player_id ) - continue; - - $name = get_the_title( $player_id ); - - if ( ! $name ) - continue; - - echo ''; - - $number = sp_array_value( $row, 'number', ' ' ); - - // Player number - echo ''; - - if ( $link_posts ): - $permalink = get_post_permalink( $player_id ); - $name = '' . $name . ''; - if ( isset( $row['status'] ) && $row['status'] == 'sub' ): - $name = '(' . $name . ')'; - endif; - endif; - - if ( array_key_exists( $player_id, $lineup_sub_relation ) ): - $name .= ' ' . sp_array_value( sp_array_value( $data, $lineup_sub_relation[ $player_id ], array() ), 'number', null ) . ''; - elseif ( isset( $row['sub'] ) && $row['sub'] ): - $name .= ' ' . sp_array_value( sp_array_value( $data, $row['sub'], array() ), 'number', null ) . ''; - endif; - - echo ''; - - - foreach( $labels as $key => $label ): - if ( $key == 'name' ) + $lineup_sub_relation = array(); + foreach ( $subs as $sub_id => $sub ): + if ( ! $sub_id ) continue; - if ( $key == 'position' ): - if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): - $position = get_term_by( 'id', $row[ $key ], 'sp_position' ); - $value = $position->name; - else: - $value = '—'; - endif; - else: - if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): - $value = $row[ $key ]; - else: - $value = 0; - endif; - endif; - if ( ! array_key_exists( $key, $totals ) ): - $totals[ $key ] = 0; - endif; - $totals[ $key ] += $value; - echo ''; + $lineup_sub_relation[ sp_array_value( $sub, 'sub', 0 ) ] = $sub_id; endforeach; - echo ''; + $i = 0; + foreach( $data as $player_id => $row ): - $i++; - - endforeach; - ?> - - - - <> - -  '; - echo ''; - endif; - - $row = $data[0]; - - foreach( $labels as $key => $label ): - if ( $key == 'name' ) + if ( ! $player_id ) continue; - if ( $key == 'position' ): - $value = '—'; - elseif ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): - $value = $row[ $key ]; - else: - $value = sp_array_value( $totals, $key, 0 ); + + $name = get_the_title( $player_id ); + + if ( ! $name ) + continue; + + echo ''; + + $number = sp_array_value( $row, 'number', ' ' ); + + // Player number + echo ''; + + if ( $link_posts ): + $permalink = get_post_permalink( $player_id ); + $name = '' . $name . ''; + if ( isset( $row['status'] ) && $row['status'] == 'sub' ): + $name = '(' . $name . ')'; + endif; endif; - echo ''; + + if ( array_key_exists( $player_id, $lineup_sub_relation ) ): + $name .= ' ' . sp_array_value( sp_array_value( $data, $lineup_sub_relation[ $player_id ], array() ), 'number', null ) . ''; + elseif ( isset( $row['sub'] ) && $row['sub'] ): + $name .= ' ' . sp_array_value( sp_array_value( $data, $row['sub'], array() ), 'number', null ) . ''; + endif; + + echo ''; + + + foreach( $labels as $key => $label ): + if ( $key == 'name' ) + continue; + if ( $key == 'position' ): + if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): + $position = get_term_by( 'id', $row[ $key ], 'sp_position' ); + $value = $position->name; + else: + $value = '—'; + endif; + else: + if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): + $value = $row[ $key ]; + else: + $value = 0; + endif; + endif; + if ( ! array_key_exists( $key, $totals ) ): + $totals[ $key ] = 0; + endif; + $totals[ $key ] += $value; + echo ''; + endforeach; + + echo ''; + + $i++; + endforeach; ?> - - > - -
#
' . $number . '' . $name . '' . $value . '
' . __( 'Total', 'sportspress' ) . '
' . $number . '' . $value . '' . $name . '' . $value . '
-
- + + + <> + +  '; + echo '' . __( 'Total', 'sportspress' ) . ''; + endif; + + $row = $data[0]; + + foreach( $labels as $key => $label ): + if ( $key == 'name' ) + continue; + if ( $key == 'position' ): + $value = '—'; + elseif ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): + $value = $row[ $key ]; + else: + $value = sp_array_value( $totals, $key, 0 ); + endif; + echo '' . $value . ''; + endforeach; + ?> + + > + + + +