davvalent commited on 2022-04-27 02:29:22
Showing 2 changed files, with 77 additions and 64 deletions.
| ... | ... |
@@ -1,16 +1,15 @@ |
| 1 | 1 |
<?php |
| 2 |
- |
|
| 3 |
-/* tracked */ |
|
| 4 |
- |
|
| 5 | 2 |
/** |
| 6 | 3 |
* Event Blocks |
| 7 | 4 |
* |
| 8 | 5 |
* @author ThemeBoy |
| 9 | 6 |
* @package SportsPress/Templates |
| 10 |
- * @version 2.2 |
|
| 7 |
+ * @version 2.7.14 |
|
| 11 | 8 |
*/ |
| 12 | 9 |
|
| 13 |
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 10 |
+if ( ! defined( 'ABSPATH' ) ) {
|
|
| 11 |
+ exit; // Exit if accessed directly |
|
| 12 |
+} |
|
| 14 | 13 |
|
| 15 | 14 |
$defaults = array( |
| 16 | 15 |
'id' => null, |
| ... | ... |
@@ -34,24 +33,31 @@ $defaults = array( |
| 34 | 33 |
extract( $defaults, EXTR_SKIP ); |
| 35 | 34 |
|
| 36 | 35 |
$calendar = new SP_Calendar( $id ); |
| 37 |
-if ( $date != 'default' ) |
|
| 36 |
+if ( $date != 'default' ) {
|
|
| 38 | 37 |
$calendar->date = $date; |
| 39 |
-if ( $date_from != 'default' ) |
|
| 38 |
+} |
|
| 39 |
+if ( $date_from != 'default' ) {
|
|
| 40 | 40 |
$calendar->from = $date_from; |
| 41 |
-if ( $date_to != 'default' ) |
|
| 41 |
+} |
|
| 42 |
+if ( $date_to != 'default' ) {
|
|
| 42 | 43 |
$calendar->to = $date_to; |
| 43 |
-if ( $league ) |
|
| 44 |
+} |
|
| 45 |
+if ( $league ) {
|
|
| 44 | 46 |
$calendar->league = $league; |
| 45 |
-if ( $season ) |
|
| 47 |
+} |
|
| 48 |
+if ( $season ) {
|
|
| 46 | 49 |
$calendar->season = $season; |
| 47 |
-if ( $team ) |
|
| 50 |
+} |
|
| 51 |
+if ( $team ) {
|
|
| 48 | 52 |
$calendar->team = $team; |
| 49 |
-if ( $player ) |
|
| 53 |
+} |
|
| 54 |
+if ( $player ) {
|
|
| 50 | 55 |
$calendar->player = $player; |
| 56 |
+} |
|
| 51 | 57 |
|
| 52 | 58 |
$args = array( |
| 53 | 59 |
'id' => $id, |
| 54 |
- 'title' => __( 'Fixtures', 'sportspress' ), |
|
| 60 |
+ 'title' => esc_attr__( 'Fixtures', 'sportspress' ), |
|
| 55 | 61 |
'status' => 'future', |
| 56 | 62 |
'date' => $date, |
| 57 | 63 |
'date_from' => $date_from, |
| ... | ... |
@@ -65,8 +71,7 @@ $args = array( |
| 65 | 71 |
'link_events' => $link_events, |
| 66 | 72 |
'paginated' => $paginated, |
| 67 | 73 |
'rows' => $rows, |
| 68 |
-// ICICICICICICICICICICICICICICICICICICICICICICICICICICICICICICICICI |
|
| 69 |
- 'order' => 'ASC', |
|
| 74 |
+ 'order' => 'ASC', // MODIF |
|
| 70 | 75 |
'show_all_events_link' => false, |
| 71 | 76 |
'show_title' => true, |
| 72 | 77 |
'show_league' => $show_league, |
| ... | ... |
@@ -81,7 +86,7 @@ ob_start(); |
| 81 | 86 |
sp_get_template( 'event-blocks.php', $args ); |
| 82 | 87 |
$fixtures = ob_get_clean(); |
| 83 | 88 |
|
| 84 |
-$args['title'] = __( 'Results', 'sportspress' ); |
|
| 89 |
+$args['title'] = esc_attr__( 'Results', 'sportspress' ); |
|
| 85 | 90 |
$args['status'] = 'publish'; |
| 86 | 91 |
$args['order'] = 'DESC'; |
| 87 | 92 |
|
| ... | ... |
@@ -91,17 +96,17 @@ $results = ob_get_clean(); |
| 91 | 96 |
|
| 92 | 97 |
if ( false == $fixtures || false == $results ) {
|
| 93 | 98 |
|
| 94 |
- echo $fixtures; |
|
| 95 |
- echo $results; |
|
| 99 |
+ echo $fixtures; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 100 |
+ echo $results; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 96 | 101 |
|
| 97 | 102 |
} else {
|
| 98 | 103 |
|
| 99 | 104 |
echo '<div class="sp-widget-align-left">'; |
| 100 |
- echo $fixtures; |
|
| 105 |
+ echo $fixtures; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 101 | 106 |
echo '</div>'; |
| 102 | 107 |
|
| 103 | 108 |
echo '<div class="sp-widget-align-right">'; |
| 104 |
- echo $results; |
|
| 109 |
+ echo $results; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 105 | 110 |
echo '</div>'; |
| 106 | 111 |
} |
| 107 | 112 |
|
| ... | ... |
@@ -1,16 +1,15 @@ |
| 1 | 1 |
<?php |
| 2 |
- |
|
| 3 |
-/* tracked */ |
|
| 4 |
- |
|
| 5 | 2 |
/** |
| 6 | 3 |
* Player List |
| 7 | 4 |
* |
| 8 | 5 |
* @author ThemeBoy |
| 9 | 6 |
* @package SportsPress/Templates |
| 10 |
- * @version 2.6.15 |
|
| 7 |
+ * @version 2.7.9 |
|
| 11 | 8 |
*/ |
| 12 | 9 |
|
| 13 |
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 10 |
+if ( ! defined( 'ABSPATH' ) ) {
|
|
| 11 |
+ exit; // Exit if accessed directly |
|
| 12 |
+} |
|
| 14 | 13 |
|
| 15 | 14 |
$defaults = array( |
| 16 | 15 |
'id' => get_the_ID(), |
| ... | ... |
@@ -41,24 +40,29 @@ $defaults = array( |
| 41 | 40 |
extract( $defaults, EXTR_SKIP ); |
| 42 | 41 |
|
| 43 | 42 |
// Backward compatibility |
| 44 |
-if ( isset( $performance ) ) |
|
| 43 |
+if ( isset( $performance ) ) {
|
|
| 45 | 44 |
$columns = $performance; |
| 45 |
+} |
|
| 46 | 46 |
|
| 47 | 47 |
// Determine number of players to display |
| 48 | 48 |
if ( -1 === $number ) : |
| 49 | 49 |
$number = (int) get_post_meta( $id, 'sp_number', true ); |
| 50 |
- if ( $number <= 0 ) $number = -1; |
|
| 50 |
+ if ( $number <= 0 ) {
|
|
| 51 |
+ $number = -1; |
|
| 52 |
+ } |
|
| 51 | 53 |
endif; |
| 52 | 54 |
|
| 53 | 55 |
// Explode into array |
| 54 |
-if ( null !== $columns && ! is_array( $columns ) ) |
|
| 56 |
+if ( null !== $columns && ! is_array( $columns ) ) {
|
|
| 55 | 57 |
$columns = explode( ',', $columns ); |
| 58 |
+} |
|
| 56 | 59 |
|
| 57 | 60 |
$list = new SP_Player_List( $id ); |
| 58 | 61 |
if ( isset( $columns ) && null !== $columns ) : |
| 59 | 62 |
$list->columns = $columns; |
| 60 | 63 |
endif; |
| 61 |
-$data = $list->data( false, $leagues, $seasons, $team ); |
|
| 64 |
+ |
|
| 65 |
+$data = apply_filters( 'sportspress_player_list_data', $list->data( false, $leagues, $seasons, $team ), $id ); |
|
| 62 | 66 |
|
| 63 | 67 |
// The first row should be labels |
| 64 | 68 |
$labels = $data[0]; |
| ... | ... |
@@ -92,30 +96,35 @@ endif; |
| 92 | 96 |
$output = ''; |
| 93 | 97 |
|
| 94 | 98 |
if ( $grouping === 'position' ) : |
| 95 |
- $groups = get_terms( 'sp_position', array( |
|
| 99 |
+ $groups = get_terms( |
|
| 100 |
+ 'sp_position', |
|
| 101 |
+ array( |
|
| 96 | 102 |
'orderby' => 'meta_value_num', |
| 97 | 103 |
'meta_query' => array( |
| 98 | 104 |
'relation' => 'OR', |
| 99 | 105 |
array( |
| 100 | 106 |
'key' => 'sp_order', |
| 101 |
- 'compare' => 'NOT EXISTS' |
|
| 107 |
+ 'compare' => 'NOT EXISTS', |
|
| 102 | 108 |
), |
| 103 | 109 |
array( |
| 104 | 110 |
'key' => 'sp_order', |
| 105 |
- 'compare' => 'EXISTS' |
|
| 111 |
+ 'compare' => 'EXISTS', |
|
| 106 | 112 |
), |
| 107 | 113 |
), |
| 108 |
- ) ); |
|
| 114 |
+ ) |
|
| 115 |
+ ); |
|
| 109 | 116 |
else : |
| 110 | 117 |
if ( $show_title && false === $title && $id ) : |
| 111 | 118 |
$caption = $list->caption; |
| 112 |
- if ( $caption ) |
|
| 119 |
+ if ( $caption ) {
|
|
| 113 | 120 |
$title = $caption; |
| 114 |
- else |
|
| 121 |
+ } else {
|
|
| 115 | 122 |
$title = get_the_title( $id ); |
| 123 |
+ } |
|
| 116 | 124 |
endif; |
| 117 |
- if ( $title ) |
|
| 125 |
+ if ( $title ) {
|
|
| 118 | 126 |
$output .= '<' . $grouptag . ' class="sp-table-caption">' . $title . '</' . $grouptag . '>'; |
| 127 |
+ } |
|
| 119 | 128 |
$group = new stdClass(); |
| 120 | 129 |
$group->term_id = null; |
| 121 | 130 |
$group->name = null; |
| ... | ... |
@@ -126,8 +135,9 @@ endif; |
| 126 | 135 |
foreach ( $groups as $group ) : |
| 127 | 136 |
$i = 0; |
| 128 | 137 |
|
| 129 |
- if ( intval( $number ) > 0 ) |
|
| 138 |
+ if ( intval( $number ) > 0 ) {
|
|
| 130 | 139 |
$limit = $number; |
| 140 |
+ } |
|
| 131 | 141 |
|
| 132 | 142 |
$thead = '<thead>' . '<tr>'; |
| 133 | 143 |
|
| ... | ... |
@@ -135,47 +145,40 @@ foreach ( $groups as $group ): |
| 135 | 145 |
if ( in_array( $orderby, array( 'number', 'name' ) ) ) : |
| 136 | 146 |
$thead .= '<th class="data-number">#</th>'; |
| 137 | 147 |
else : |
| 138 |
-// ICICICICICICICICICICICICICICICICI********************************************************************** |
|
| 139 |
- |
|
| 140 |
-// Afficher le libellé "#" même s'il n'est pas sélectionné |
|
| 141 |
- |
|
| 142 |
-// $thead .= '<th class="data-rank">' . __( 'Rank', 'sportspress' ) . '</th>'; |
|
| 143 |
- |
|
| 144 |
- $thead .= '<th class="data-number">#</th>'; |
|
| 148 |
+// $thead .= '<th class="data-rank">' . esc_attr__( 'Rank', 'sportspress' ) . '</th>'; |
|
| 149 |
+ $thead .= '<th class="data-number">#</th>'; // MODIF |
|
| 145 | 150 |
endif; |
| 146 | 151 |
endif; |
| 147 | 152 |
|
| 148 | 153 |
foreach ( $labels as $key => $label ) : |
| 149 |
- if ( $key !== 'number' && ( ! is_array( $columns ) || $key == 'name' || in_array( $key, $columns ) ) ) |
|
| 154 |
+ if ( $key !== 'number' && ( ! is_array( $columns ) || $key == 'name' || in_array( $key, $columns ) ) ) {
|
|
| 150 | 155 |
$thead .= '<th class="data-' . $key . '">' . $label . '</th>'; |
| 156 |
+ } |
|
| 151 | 157 |
endforeach; |
| 152 | 158 |
|
| 153 | 159 |
$thead .= '</tr>' . '</thead>'; |
| 154 | 160 |
|
| 155 | 161 |
$tbody = ''; |
| 156 | 162 |
|
| 157 |
- foreach( $data as $player_id => $row ): if ( empty( $group->term_id ) || has_term( $group->term_id, 'sp_position', $player_id ) ): |
|
| 163 |
+ foreach ( $data as $player_id => $row ) : |
|
| 164 |
+ if ( empty( $group->term_id ) || has_term( $group->term_id, 'sp_position', $player_id ) ) : |
|
| 158 | 165 |
|
| 159 |
- if ( isset( $limit ) && $i >= $limit ) continue; |
|
| 166 |
+ if ( isset( $limit ) && $i >= $limit ) {
|
|
| 167 |
+ continue; |
|
| 168 |
+ } |
|
| 160 | 169 |
|
| 161 | 170 |
$name = sp_array_value( $row, 'name', null ); |
| 162 |
- if ( ! $name ) continue; |
|
| 171 |
+ if ( ! $name ) {
|
|
| 172 |
+ continue; |
|
| 173 |
+ } |
|
| 163 | 174 |
|
| 164 | 175 |
$tbody .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">'; |
| 165 | 176 |
|
| 166 | 177 |
// Rank or number |
| 167 | 178 |
if ( ! is_array( $labels ) || array_key_exists( 'number', $labels ) ) : |
| 168 | 179 |
if ( isset( $orderby ) && $orderby != 'number' ) : |
| 169 |
-// ICICICICICICICICICICICICICICICICI******************************************************************* |
|
| 170 |
- |
|
| 171 |
-// Afficher le numéro du joueur au lieu du rang |
|
| 172 |
- |
|
| 173 |
-// $tbody .= '<td class="data-rank" data-label="'.$labels['number'].'">' . ( $i + 1 ) . '</td>'; |
|
| 174 |
- |
|
| 175 |
- $tbody .= '<td class="data-number" data-label="'.$labels['number'].'">' . sp_array_value( $row, 'number', ' ' ) . '</td>'; |
|
| 176 |
- |
|
| 180 |
+ $tbody .= '<td class="data-number" data-label="' . $labels['number'] . '">' . sp_array_value( $row, 'number', ' ' ) . '</td>'; // MODIF copier le else dans le if. |
|
| 177 | 181 |
else : |
| 178 |
- |
|
| 179 | 182 |
$tbody .= '<td class="data-number" data-label="' . $labels['number'] . '">' . sp_array_value( $row, 'number', ' ' ) . '</td>'; |
| 180 | 183 |
endif; |
| 181 | 184 |
endif; |
| ... | ... |
@@ -195,7 +198,7 @@ foreach ( $groups as $group ): |
| 195 | 198 |
$nationalities = $player->nationalities(); |
| 196 | 199 |
if ( ! empty( $nationalities ) ) : |
| 197 | 200 |
foreach ( $nationalities as $nationality ) : |
| 198 |
- $name = '<span class="player-flag"><img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"></span>' . $name; |
|
| 201 |
+ $name = '<span class="player-flag">' . sp_flags( $nationality ) . '</span>' . $name; |
|
| 199 | 202 |
endforeach; |
| 200 | 203 |
$name_class .= ' has-photo'; |
| 201 | 204 |
endif; |
| ... | ... |
@@ -233,11 +236,12 @@ foreach ( $groups as $group ): |
| 233 | 236 |
endif; |
| 234 | 237 |
|
| 235 | 238 |
foreach ( $labels as $key => $value ) : |
| 236 |
- if ( in_array( $key, array( 'number', 'name', 'team', 'position' ) ) ) |
|
| 239 |
+ if ( in_array( $key, array( 'number', 'name', 'team', 'position' ) ) ) {
|
|
| 237 | 240 |
continue; |
| 241 |
+ } |
|
| 238 | 242 |
if ( ! is_array( $columns ) || in_array( $key, $columns ) ) {
|
| 239 | 243 |
$label = $labels[ $key ]; |
| 240 |
- if ( preg_match ( "/title=\"(.*?)\"/", $value, $new_label ) ) {
|
|
| 244 |
+ if ( preg_match( '/title="(.*?)"/', $value, $new_label ) ) {
|
|
| 241 | 245 |
$label = $new_label[1]; |
| 242 | 246 |
} |
| 243 | 247 |
$tbody .= '<td class="data-' . $key . '" data-label="' . $label . '">' . sp_array_value( $row, $key, '—' ) . '</td>'; |
| ... | ... |
@@ -248,9 +252,12 @@ foreach ( $groups as $group ): |
| 248 | 252 |
|
| 249 | 253 |
$i++; |
| 250 | 254 |
|
| 251 |
- endif; endforeach; |
|
| 255 |
+ endif; |
|
| 256 |
+endforeach; |
|
| 252 | 257 |
|
| 253 |
- if ( $i === 0 ) continue; |
|
| 258 |
+ if ( $i === 0 ) {
|
|
| 259 |
+ continue; |
|
| 260 |
+ } |
|
| 254 | 261 |
|
| 255 | 262 |
$output .= '<div class="sp-template sp-template-player-list">'; |
| 256 | 263 |
|
| ... | ... |
@@ -269,10 +276,11 @@ foreach ( $groups as $group ): |
| 269 | 276 |
$output .= '</tbody>' . '</table>' . '</div>'; |
| 270 | 277 |
|
| 271 | 278 |
if ( $show_all_players_link ) : |
| 272 |
- $output .= '<div class="sp-player-list-link sp-view-all-link"><a href="' . get_permalink( $id ) . '">' . __( 'View all players', 'sportspress' ) . '</a></div>'; |
|
| 279 |
+ $output .= '<div class="sp-player-list-link sp-view-all-link"><a href="' . get_permalink( $id ) . '">' . esc_attr__( 'View all players', 'sportspress' ) . '</a></div>'; |
|
| 273 | 280 |
endif; |
| 274 | 281 |
|
| 275 | 282 |
$output .= '</div>'; |
| 276 | 283 |
endforeach; |
| 277 | 284 |
?> |
| 278 |
-<?php echo $output; ?> |
|
| 285 |
+<?php |
|
| 286 |
+echo wp_kses_post( $output ); |
|
| 279 | 287 |