@@ -21,20 +21,20 @@ discard block |
||
21 | 21 | * @return string Displays a list of all games. |
22 | 22 | */ |
23 | 23 | function shortcode( $atts ) { |
24 | - $atts = shortcode_atts([ |
|
24 | + $atts = shortcode_atts( [ |
|
25 | 25 | 'gc_game' => '', |
26 | 26 | ], $atts ); |
27 | 27 | |
28 | 28 | // Get the ID from the atts, if one was set, so we can get a single game (or all games). |
29 | 29 | $post_ids = null; |
30 | - if ( '' === $atts['gc_game'] ) { |
|
31 | - $post_ids = []; |
|
32 | - } elseif ( is_array( $atts['gc_game'] ) ) { |
|
33 | - $post_ids = $atts['gc_game']; |
|
34 | - } elseif ( false !== strpos( (string) $atts['gc_game'], ',' ) ) { |
|
35 | - $post_ids = explode( ',', $atts['gc_game'] ); |
|
36 | - } elseif ( ! is_array( $atts['gc_game'] ) ) { |
|
37 | - $post_ids = [ $atts['gc_game'] ]; |
|
30 | + if ( '' === $atts[ 'gc_game' ] ) { |
|
31 | + $post_ids = [ ]; |
|
32 | + } elseif ( is_array( $atts[ 'gc_game' ] ) ) { |
|
33 | + $post_ids = $atts[ 'gc_game' ]; |
|
34 | + } elseif ( false !== strpos( (string) $atts[ 'gc_game' ], ',' ) ) { |
|
35 | + $post_ids = explode( ',', $atts[ 'gc_game' ] ); |
|
36 | + } elseif ( ! is_array( $atts[ 'gc_game' ] ) ) { |
|
37 | + $post_ids = [ $atts[ 'gc_game' ] ]; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | return render_games( $post_ids ); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param array $post_ids An array of post IDs (or an empty array). |
48 | 48 | * @return string The games HTML. |
49 | 49 | */ |
50 | -function render_games( $post_ids = [] ) { |
|
50 | +function render_games( $post_ids = [ ] ) { |
|
51 | 51 | $games = get_games( $post_ids ); |
52 | 52 | ob_start(); ?> |
53 | 53 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | <div <?php post_class( Game\get_game_classes( 'game-single', $game->ID ), $game->ID ); ?> id="game-<?php echo absint( $game->ID ); ?>"> |
64 | 64 | |
65 | 65 | <?php |
66 | - echo Display\get_game_title( $game ); // WPCS: XSS ok, already sanitized. |
|
66 | + echo Display\get_game_title( $game ); // WPCS: XSS ok, already sanitized. |
|
67 | 67 | echo Display\get_game_info( $game->ID ); // WPCS: XSS ok, already sanitized. |
68 | 68 | ?> |
69 | 69 | |
@@ -82,31 +82,31 @@ discard block |
||
82 | 82 | * @param array $post_ids An array of game post IDs. |
83 | 83 | * @return array An array of Game WP_Post objects. |
84 | 84 | */ |
85 | -function get_games( $post_ids = [] ) { |
|
85 | +function get_games( $post_ids = [ ] ) { |
|
86 | 86 | if ( empty( $post_ids ) ) { |
87 | 87 | $post_ids = false; |
88 | 88 | } |
89 | 89 | |
90 | 90 | if ( $post_ids ) { |
91 | 91 | // If we're only displaying select games, don't show the filters. |
92 | - add_filter( 'gc_filter_buttons', '__return_null' ); |
|
92 | + add_filter( 'gc_filter_buttons', '__return_null' ); |
|
93 | 93 | add_filter( 'gc_filter_game_filters', '__return_null' ); |
94 | 94 | |
95 | - return get_posts([ |
|
95 | + return get_posts( [ |
|
96 | 96 | 'posts_per_page' => count( $post_ids ), |
97 | 97 | 'post_type' => 'gc_game', |
98 | 98 | 'post__in' => $post_ids, |
99 | 99 | 'orderby' => 'title', |
100 | 100 | 'order' => 'ASC', |
101 | - ]); |
|
101 | + ] ); |
|
102 | 102 | } |
103 | 103 | |
104 | - return get_posts([ |
|
104 | + return get_posts( [ |
|
105 | 105 | 'posts_per_page' => -1, |
106 | 106 | 'post_type' => 'gc_game', |
107 | 107 | 'orderby' => 'title', |
108 | 108 | 'order' => 'ASC', |
109 | - ]); |
|
109 | + ] ); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | |
60 | 60 | <div class="game-info" id="game-<?php echo absint( $game_id ); ?>-info"> |
61 | 61 | <?php |
62 | - echo get_players( $game_id ); // WPCS: XSS ok, already sanitized. |
|
62 | + echo get_players( $game_id ); // WPCS: XSS ok, already sanitized. |
|
63 | 63 | echo get_playing_time( $game_id ); // WPCS: XSS ok, already sanitized. |
64 | - echo get_age( $game_id ); // WPCS: XSS ok, already sanitized. |
|
65 | - echo get_difficulty( $game_id ); // WPCS: XSS ok, already sanitized. |
|
66 | - echo get_attributes( $game_id ); // WPCS: XSS ok, already sanitized. |
|
64 | + echo get_age( $game_id ); // WPCS: XSS ok, already sanitized. |
|
65 | + echo get_difficulty( $game_id ); // WPCS: XSS ok, already sanitized. |
|
66 | + echo get_attributes( $game_id ); // WPCS: XSS ok, already sanitized. |
|
67 | 67 | ?> |
68 | 68 | </div> |
69 | 69 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return string Select markup for filters. |
158 | 158 | */ |
159 | 159 | function get_filters() { |
160 | - $player_filter = '<div class="player-filter"><label for="players-filter-select">' . esc_html__( 'How many players?', 'games-collector' ) . ':</label> |
|
160 | + $player_filter = '<div class="player-filter"><label for="players-filter-select">' . esc_html__( 'How many players?', 'games-collector' ) . ':</label> |
|
161 | 161 | <select class="players-filter-select"> |
162 | 162 | <option selected>- ' . esc_html__( 'Select one', 'games-collector' ) . ' -</option> |
163 | 163 | <option value=".2-players,.min-2-players,.max-2-players,.max-3-players,.max-4-players,.max-5-players,.max-6-players,.max-7-players,.8-or-more-players">' . esc_html__( '2+ players', 'games-collector' ) . '</option> |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $attribute_list = Attributes\get_the_attribute_list( |
228 | 228 | $game_id, |
229 | 229 | '<div class="game-attributes"><span class="gc-icon icon-game-attributes">' . get_svg( 'tags', false ) . '</span><span class="game-attributes" id="game-' . absint( $game_id ) . '-attributes">', // Before. |
230 | - ', ', // Seperator. |
|
230 | + ', ', // Seperator. |
|
231 | 231 | '</span></div>' // After. |
232 | 232 | ); |
233 | 233 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | function get_players( $game_id ) { |
253 | 253 | $players_min_max = Game\get_players_min_max( $game_id ); |
254 | 254 | |
255 | - if ( isset( $players_min_max['min'] ) ) { |
|
255 | + if ( isset( $players_min_max[ 'min' ] ) ) { |
|
256 | 256 | /** |
257 | 257 | * Allow the # of players to be filtered (but only if there actually are players). |
258 | 258 | * |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | $num_players = apply_filters( 'gc_filter_players', $game_id, $players_min_max, sprintf( |
266 | 266 | // Translators: 1: Minimum number of players, 2: Maximum number of players. |
267 | 267 | __( '%1$d %2$s players', 'games-collector' ), |
268 | - absint( $players_min_max['min'] ), |
|
269 | - isset( $players_min_max['max'] ) ? sprintf( '- %d', absint( $players_min_max['max'] ) ) : '+' |
|
268 | + absint( $players_min_max[ 'min' ] ), |
|
269 | + isset( $players_min_max[ 'max' ] ) ? sprintf( '- %d', absint( $players_min_max[ 'max' ] ) ) : '+' |
|
270 | 270 | ) ); |
271 | 271 | |
272 | 272 | ob_start(); |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | return; |
383 | 383 | } |
384 | 384 | |
385 | - wp_enqueue_style( 'games-collector', dirname( plugin_dir_url( __FILE__ ), 2 ) . '/assets/css/main.css', [], '1.3.0' ); |
|
385 | + wp_enqueue_style( 'games-collector', dirname( plugin_dir_url( __FILE__ ), 2 ) . '/assets/css/main.css', [ ], '1.3.0' ); |
|
386 | 386 | wp_enqueue_script( 'games-collector', dirname( plugin_dir_url( __FILE__ ), 2 ) . '/assets/js/main.js', [ 'jquery' ], '1.3.0' ); |
387 | 387 | } |
388 | 388 |
@@ -29,31 +29,31 @@ |
||
29 | 29 | $attributes = wp_get_object_terms( $post->ID, 'gc_attribute', [ 'fields' => 'names' ] ); |
30 | 30 | |
31 | 31 | if ( $min_players ) { |
32 | - $data->data['min_players'] = $min_players; |
|
32 | + $data->data[ 'min_players' ] = $min_players; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | if ( $max_players ) { |
36 | - $data->data['max_players'] = $max_players; |
|
36 | + $data->data[ 'max_players' ] = $max_players; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | if ( $time ) { |
40 | - $data->data['time'] = $time; |
|
40 | + $data->data[ 'time' ] = $time; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | if ( $age ) { |
44 | - $data->data['age'] = $age; |
|
44 | + $data->data[ 'age' ] = $age; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | if ( $difficulty ) { |
48 | - $data->data['difficulty'] = $difficulty; |
|
48 | + $data->data[ 'difficulty' ] = $difficulty; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | if ( $link ) { |
52 | - $data->data['url'] = $link; |
|
52 | + $data->data[ 'url' ] = $link; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | if ( $attributes ) { |
56 | - $data->data['attributes'] = $attributes; |
|
56 | + $data->data[ 'attributes' ] = $attributes; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | return $data; |
@@ -17,7 +17,7 @@ |
||
17 | 17 | $js_file = plugin_dir_url( dirname( __FILE__, 2 ) ) . 'assets/js/editor.js'; |
18 | 18 | wp_enqueue_script( 'games-collector-gberg-editor', $js_file, [ 'wp-i18n', 'wp-blocks', 'wp-element' ], '1.3.0' ); |
19 | 19 | wp_enqueue_style( 'games-collector-gberg-editor', dirname( plugin_dir_url( __FILE__ ), 2 ) . '/assets/css/editor.css', [ 'wp-blocks' ], '1.3.0' ); |
20 | - wp_enqueue_style( 'games-collector', dirname( plugin_dir_url( __FILE__ ), 2 ) . '/assets/css/main.css', [], '1.3.0' ); |
|
20 | + wp_enqueue_style( 'games-collector', dirname( plugin_dir_url( __FILE__ ), 2 ) . '/assets/css/main.css', [ ], '1.3.0' ); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |