@@ -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; |
@@ -52,13 +52,13 @@ |
||
52 | 52 | |
53 | 53 | // Check for extended cpts, load it if it hasn't already been loaded. |
54 | 54 | if ( ! function_exists( 'register_extended_post_type' ) ) { |
55 | - $files[] = __DIR__ . '/vendor/johnbillion/extended-cpts/extended-cpts.php'; |
|
55 | + $files[ ] = __DIR__ . '/vendor/johnbillion/extended-cpts/extended-cpts.php'; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | // Autoload the namespaces. |
59 | 59 | $namespaces = array_filter( glob( __DIR__ . '/inc/*' ), 'is_dir' ); |
60 | 60 | foreach ( $namespaces as $namespace ) { |
61 | - $files[] = $namespace . '/namespace.php'; |
|
61 | + $files[ ] = $namespace . '/namespace.php'; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | // Loop through and load all the things! |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @return string All the games in formatted HTML. |
91 | 91 | */ |
92 | 92 | function gc_get_games() { |
93 | - return Shortcode\shortcode( [] ); |
|
93 | + return Shortcode\shortcode( [ ] ); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @since 0.2 |
100 | 100 | */ |
101 | 101 | function gc_the_games() { |
102 | - echo Shortcode\shortcode( [] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
102 | + echo Shortcode\shortcode( [ ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -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 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
66 | + echo Display\get_game_title( $game ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
67 | 67 | echo Display\get_game_info( $game->ID ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
68 | 68 | ?> |
69 | 69 | |
@@ -82,7 +82,7 @@ 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 | } |
@@ -92,21 +92,21 @@ discard block |
||
92 | 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 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | ], |
53 | 53 | ], |
54 | 54 | // Dropdown filters. |
55 | - 'admin_filters' => [], |
|
55 | + 'admin_filters' => [ ], |
|
56 | 56 | ], |
57 | 57 | [ |
58 | 58 | 'singular' => __( 'Game', 'games-collector' ), |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | 'id' => $prefix . 'metabox', |
75 | 75 | 'title' => __( 'Game Details', 'games-collector' ), |
76 | 76 | 'object_types' => [ 'gc_game' ], |
77 | - ]); |
|
77 | + ] ); |
|
78 | 78 | |
79 | - $cmb->add_field([ |
|
79 | + $cmb->add_field( [ |
|
80 | 80 | 'name' => __( 'Minimum Number of Players', 'games-collector' ), |
81 | 81 | 'id' => $prefix . 'min_players', |
82 | 82 | 'type' => 'text_small', |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | 'type' => 'number', |
85 | 85 | 'placeholder' => '1', |
86 | 86 | ], |
87 | - ]); |
|
87 | + ] ); |
|
88 | 88 | |
89 | - $cmb->add_field([ |
|
89 | + $cmb->add_field( [ |
|
90 | 90 | 'name' => __( 'Maximum Number of Players', 'games-collector' ), |
91 | 91 | 'id' => $prefix . 'max_players', |
92 | 92 | 'type' => 'text_small', |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | 'type' => 'number', |
95 | 95 | 'placeholder' => '4', |
96 | 96 | ], |
97 | - ]); |
|
97 | + ] ); |
|
98 | 98 | |
99 | - $cmb->add_field([ |
|
99 | + $cmb->add_field( [ |
|
100 | 100 | 'name' => __( 'Playing Time', 'games-collector' ), |
101 | 101 | 'id' => $prefix . 'time', |
102 | 102 | 'type' => 'text_small', |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | 'attributes' => [ |
105 | 105 | 'placeholder' => '20-30', |
106 | 106 | ], |
107 | - ]); |
|
107 | + ] ); |
|
108 | 108 | |
109 | - $cmb->add_field([ |
|
109 | + $cmb->add_field( [ |
|
110 | 110 | 'name' => __( 'Ages', 'games-collector' ), |
111 | 111 | 'id' => $prefix . 'age', |
112 | 112 | 'type' => 'text_small', |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | 'type' => 'number', |
116 | 116 | 'placeholder' => '10', |
117 | 117 | ], |
118 | - ]); |
|
118 | + ] ); |
|
119 | 119 | |
120 | - $cmb->add_field([ |
|
120 | + $cmb->add_field( [ |
|
121 | 121 | 'name' => __( 'Difficulty Level', 'games-collector' ), |
122 | 122 | 'id' => $prefix . 'difficulty', |
123 | 123 | 'type' => 'radio', |
124 | 124 | 'desc' => __( 'How difficult or complex is this game?', 'games-collector' ), |
125 | 125 | 'options' => get_difficulties(), |
126 | 126 | 'default' => 'easy', |
127 | - ]); |
|
127 | + ] ); |
|
128 | 128 | |
129 | 129 | $cmb->add_field( [ |
130 | 130 | 'name' => __( 'More Info Link', 'games-collector' ), |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | |
153 | 153 | $players_min_max = get_players_min_max( $post_id ); |
154 | 154 | |
155 | - if ( isset( $players_min_max['min'] ) && isset( $players_min_max['max'] ) ) { |
|
156 | - return sprintf( '%1$s - %2$s', $players_min_max['min'], $players_min_max['max'] ); |
|
155 | + if ( isset( $players_min_max[ 'min' ] ) && isset( $players_min_max[ 'max' ] ) ) { |
|
156 | + return sprintf( '%1$s - %2$s', $players_min_max[ 'min' ], $players_min_max[ 'max' ] ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | return; |
@@ -295,20 +295,20 @@ discard block |
||
295 | 295 | $difficulty = get_post_meta( $post_id, '_gc_difficulty', true ); |
296 | 296 | $length = get_game_length( $post_id ); |
297 | 297 | |
298 | - if ( isset( $players['min'] ) ) { |
|
299 | - $classes .= ' min-' . $players['min'] . '-players'; |
|
298 | + if ( isset( $players[ 'min' ] ) ) { |
|
299 | + $classes .= ' min-' . $players[ 'min' ] . '-players'; |
|
300 | 300 | } |
301 | 301 | |
302 | - if ( isset( $players['max'] ) ) { |
|
303 | - if ( absint( $players['max'] ) >= 8 ) { |
|
302 | + if ( isset( $players[ 'max' ] ) ) { |
|
303 | + if ( absint( $players[ 'max' ] ) >= 8 ) { |
|
304 | 304 | $classes .= ' 8-or-more-players'; |
305 | 305 | } else { |
306 | - $classes .= ' max-' . $players['max'] . '-players'; |
|
306 | + $classes .= ' max-' . $players[ 'max' ] . '-players'; |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | - if ( isset( $players['min'] ) && ! isset( $players['max'] ) ) { |
|
311 | - $classes .= ' ' . $players['min'] . '-players'; |
|
310 | + if ( isset( $players[ 'min' ] ) && ! isset( $players[ 'max' ] ) ) { |
|
311 | + $classes .= ' ' . $players[ 'min' ] . '-players'; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | if ( $age ) { |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | |
345 | 345 | $game_time = str_replace( ' ', '', get_post_meta( $post_id, '_gc_time', true ) ); |
346 | 346 | $time = explode( '-', $game_time ); |
347 | - $time = isset( $time[1] ) ? $time[1] : $time[0]; |
|
347 | + $time = isset( $time[ 1 ] ) ? $time[ 1 ] : $time[ 0 ]; |
|
348 | 348 | |
349 | 349 | if ( $game_time ) { |
350 | 350 | switch ( $time ) { |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | 'gc_attribute', |
19 | 19 | 'gc_game', |
20 | 20 | [ |
21 | - 'dashboard_glance' => true, // Show this taxonomy in the 'At a Glance' widget. |
|
21 | + 'dashboard_glance' => true, // Show this taxonomy in the 'At a Glance' widget. |
|
22 | 22 | 'hierarchical' => false, |
23 | 23 | 'show_in_rest' => true, |
24 | 24 | 'rest_base' => 'attributes', |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | wp_enqueue_script( 'chosen', plugin_dir_url( dirname( __DIR__ ) ) . 'vendor/harvesthq/chosen/chosen.jquery.min.js', [ 'jquery' ], '1.8', true ); |
57 | - wp_enqueue_style( 'chosen', plugin_dir_url( dirname( __DIR__ ) ) . 'vendor/harvesthq/chosen/chosen.min.css', [], '1.8' ); |
|
57 | + wp_enqueue_style( 'chosen', plugin_dir_url( dirname( __DIR__ ) ) . 'vendor/harvesthq/chosen/chosen.min.css', [ ], '1.8' ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | */ |
189 | 189 | function save_post( $post_id ) { |
190 | 190 | // Verify nonce. |
191 | - if ( ! isset( $_POST['chosen_taxonomy_meta_box_nonce'] ) || ! wp_verify_nonce( $_POST['chosen_taxonomy_meta_box_nonce'], 'chosen-save-tax-terms' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
|
191 | + if ( ! isset( $_POST[ 'chosen_taxonomy_meta_box_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'chosen_taxonomy_meta_box_nonce' ], 'chosen-save-tax-terms' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
|
192 | 192 | return; |
193 | 193 | } |
194 | 194 | // Check autosave. |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | return; |
197 | 197 | } |
198 | 198 | |
199 | - $input = isset( $_POST['tax_input']['gc_attribute'] ) ? $_POST['tax_input']['gc_attribute'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
|
199 | + $input = isset( $_POST[ 'tax_input' ][ 'gc_attribute' ] ) ? $_POST[ 'tax_input' ][ 'gc_attribute' ] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
|
200 | 200 | |
201 | 201 | if ( empty( $input ) ) { |
202 | 202 | $taxonomy = get_taxonomy( 'gc_attribute' ); |
@@ -254,19 +254,19 @@ discard block |
||
254 | 254 | function gc_kses( $string = '' ) { |
255 | 255 | $allowed_html = array_merge( wp_kses_allowed_html( 'post' ), [ |
256 | 256 | 'svg' => [ |
257 | - 'class' => [], |
|
258 | - 'aria-labelledby' => [], |
|
259 | - 'role' => [], |
|
260 | - 'version' => [], |
|
261 | - 'xmlns' => [], |
|
262 | - 'xmlns:xlink' => [], |
|
263 | - 'height' => [], |
|
264 | - 'width' => [], |
|
265 | - 'viewbox' => [], |
|
257 | + 'class' => [ ], |
|
258 | + 'aria-labelledby' => [ ], |
|
259 | + 'role' => [ ], |
|
260 | + 'version' => [ ], |
|
261 | + 'xmlns' => [ ], |
|
262 | + 'xmlns:xlink' => [ ], |
|
263 | + 'height' => [ ], |
|
264 | + 'width' => [ ], |
|
265 | + 'viewbox' => [ ], |
|
266 | 266 | ], |
267 | - 'title' => [], |
|
267 | + 'title' => [ ], |
|
268 | 268 | 'path' => [ |
269 | - 'd' => [], |
|
269 | + 'd' => [ ], |
|
270 | 270 | ], |
271 | 271 | ] ); |
272 | 272 |
@@ -188,7 +188,8 @@ |
||
188 | 188 | */ |
189 | 189 | function save_post( $post_id ) { |
190 | 190 | // Verify nonce. |
191 | - if ( ! isset( $_POST['chosen_taxonomy_meta_box_nonce'] ) || ! wp_verify_nonce( $_POST['chosen_taxonomy_meta_box_nonce'], 'chosen-save-tax-terms' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
|
191 | + if ( ! isset( $_POST['chosen_taxonomy_meta_box_nonce'] ) || ! wp_verify_nonce( $_POST['chosen_taxonomy_meta_box_nonce'], 'chosen-save-tax-terms' ) ) { |
|
192 | +// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
|
192 | 193 | return; |
193 | 194 | } |
194 | 195 | // Check autosave. |
@@ -70,19 +70,19 @@ discard block |
||
70 | 70 | */ |
71 | 71 | function get_bgg_search_results( $query ) { |
72 | 72 | $response = wp_remote_get( bgg_search( $query ) ); |
73 | - $results = []; |
|
73 | + $results = [ ]; |
|
74 | 74 | |
75 | - if ( isset( $response['response'] ) && 200 === $response['response']['code'] ) { |
|
76 | - $xml = simplexml_load_string( wp_remote_retrieve_body( $response ) ); |
|
75 | + if ( isset( $response[ 'response' ] ) && 200 === $response[ 'response' ][ 'code' ] ) { |
|
76 | + $xml = simplexml_load_string( wp_remote_retrieve_body( $response ) ); |
|
77 | 77 | |
78 | 78 | if ( isset( $xml->boardgame ) ) { |
79 | 79 | foreach ( $xml->boardgame as $game ) { |
80 | 80 | $game = (array) $game; |
81 | 81 | |
82 | - $results[] = [ |
|
83 | - 'id' => ( isset( $game['@attributes']['objectid'] ) ) ? (int) $game['@attributes']['objectid'] : '', |
|
84 | - 'name' => ( isset( $game['name'] ) ) ? $game['name'] : '', |
|
85 | - 'year' => ( isset( $game['yearpublished'] ) ) ? $game['yearpublished'] : '', |
|
82 | + $results[ ] = [ |
|
83 | + 'id' => ( isset( $game[ '@attributes' ][ 'objectid' ] ) ) ? (int) $game[ '@attributes' ][ 'objectid' ] : '', |
|
84 | + 'name' => ( isset( $game[ 'name' ] ) ) ? $game[ 'name' ] : '', |
|
85 | + 'year' => ( isset( $game[ 'yearpublished' ] ) ) ? $game[ 'yearpublished' ] : '', |
|
86 | 86 | ]; |
87 | 87 | } |
88 | 88 | } |
@@ -100,31 +100,31 @@ discard block |
||
100 | 100 | */ |
101 | 101 | function get_bgg_game( $id ) { |
102 | 102 | $response = wp_remote_get( bgg_game( $id ) ); |
103 | - $data = []; |
|
103 | + $data = [ ]; |
|
104 | 104 | |
105 | - if ( isset( $response['response'] ) && 200 === $response['response']['code'] ) { |
|
105 | + if ( isset( $response[ 'response' ] ) && 200 === $response[ 'response' ][ 'code' ] ) { |
|
106 | 106 | $xml = simplexml_load_string( wp_remote_retrieve_body( $response ) ); |
107 | 107 | $game = $xml->item; |
108 | 108 | $data = [ |
109 | - 'title' => (string) $game->name->attributes()['value'], |
|
109 | + 'title' => (string) $game->name->attributes()[ 'value' ], |
|
110 | 110 | 'image' => (string) $game->image, |
111 | - 'minplayers' => (int) $game->minplayers->attributes()['value'], |
|
112 | - 'maxplayers' => (int) $game->maxplayers->attributes()['value'], |
|
113 | - 'minplaytime' => (int) $game->minplaytime->attributes()['value'], |
|
114 | - 'maxplaytime' => (int) $game->maxplaytime->attributes()['value'], |
|
115 | - 'minage' => (int) $game->minage->attributes()['value'], |
|
116 | - 'categories' => [], |
|
111 | + 'minplayers' => (int) $game->minplayers->attributes()[ 'value' ], |
|
112 | + 'maxplayers' => (int) $game->maxplayers->attributes()[ 'value' ], |
|
113 | + 'minplaytime' => (int) $game->minplaytime->attributes()[ 'value' ], |
|
114 | + 'maxplaytime' => (int) $game->maxplaytime->attributes()[ 'value' ], |
|
115 | + 'minage' => (int) $game->minage->attributes()[ 'value' ], |
|
116 | + 'categories' => [ ], |
|
117 | 117 | ]; |
118 | 118 | |
119 | - $categories = []; |
|
119 | + $categories = [ ]; |
|
120 | 120 | |
121 | 121 | foreach ( $game->link as $metadata ) { |
122 | - if ( 'boardgamecategory' === (string) $metadata->attributes()['type'] ) { |
|
123 | - $categories[] = (string) $metadata->attributes()['value']; |
|
122 | + if ( 'boardgamecategory' === (string) $metadata->attributes()[ 'type' ] ) { |
|
123 | + $categories[ ] = (string) $metadata->attributes()[ 'value' ]; |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | - $data['categories'] = ! empty( $categories ) ? $categories : []; |
|
127 | + $data[ 'categories' ] = ! empty( $categories ) ? $categories : [ ]; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | return $data; |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | $search_results = get_transient( 'gc_last_bgg_search' ); |
140 | 140 | |
141 | 141 | // First run. |
142 | - if ( ! $search_results || isset( $_GET['reset_search'] ) ) { |
|
142 | + if ( ! $search_results || isset( $_GET[ 'reset_search' ] ) ) { |
|
143 | 143 | |
144 | 144 | // If we're clearing the search, delete the transient and start over. |
145 | - if ( isset( $_GET['bgg_search_reset_nonce'] ) && |
|
146 | - wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['bgg_search_reset_nonce'] ) ), 'bgg_search_reset_nonce' ) ) { |
|
145 | + if ( isset( $_GET[ 'bgg_search_reset_nonce' ] ) && |
|
146 | + wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET[ 'bgg_search_reset_nonce' ] ) ), 'bgg_search_reset_nonce' ) ) { |
|
147 | 147 | delete_transient( 'gc_last_bgg_search' ); |
148 | 148 | add_action( 'admin_notices', __NAMESPACE__ . '\\search_cleared_notice' ); |
149 | 149 | } |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | * @param object $field_type_object The CMB2 field type object. |
213 | 213 | */ |
214 | 214 | function render_cmb2_bgg_search( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { |
215 | - $description = '<p class="description">' . esc_html( $field_type_object->field->args()['desc'] ) . '</p>'; |
|
215 | + $description = '<p class="description">' . esc_html( $field_type_object->field->args()[ 'desc' ] ) . '</p>'; |
|
216 | 216 | $form = sprintf( '<input id="%1$s" class="regular-text" name="%2$s" value="" placeholder="%3$s" type="text">', |
217 | - esc_attr( $field_type_object->field->args()['id'] ), |
|
218 | - esc_attr( $field_type_object->field->args()['id'] ), |
|
217 | + esc_attr( $field_type_object->field->args()[ 'id' ] ), |
|
218 | + esc_attr( $field_type_object->field->args()[ 'id' ] ), |
|
219 | 219 | __( 'A game title or search, e.g. “betrayal house hill”', 'usat' ) |
220 | 220 | ); |
221 | 221 | $hidden = '<input type="hidden" name="action" value="bgg_search_response">'; |
@@ -223,15 +223,15 @@ discard block |
||
223 | 223 | |
224 | 224 | echo wp_kses( $output, [ |
225 | 225 | 'p' => [ |
226 | - 'class' => [], |
|
226 | + 'class' => [ ], |
|
227 | 227 | ], |
228 | 228 | 'input' => [ |
229 | - 'id' => [], |
|
230 | - 'class' => [], |
|
231 | - 'name' => [], |
|
232 | - 'value' => [], |
|
233 | - 'type' => [], |
|
234 | - 'placeholder' => [], |
|
229 | + 'id' => [ ], |
|
230 | + 'class' => [ ], |
|
231 | + 'name' => [ ], |
|
232 | + 'value' => [ ], |
|
233 | + 'type' => [ ], |
|
234 | + 'placeholder' => [ ], |
|
235 | 235 | ], |
236 | 236 | ] ); |
237 | 237 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | ?> |
263 | 263 | <a href="<?php echo esc_url_raw( $url ); ?>"> |
264 | 264 | <div class="button alignright" name="bgg_search_reset"> |
265 | - <?php echo esc_html( $field_type_object->field->args['button_name'] ); ?> |
|
265 | + <?php echo esc_html( $field_type_object->field->args[ 'button_name' ] ); ?> |
|
266 | 266 | </div> |
267 | 267 | </a> |
268 | 268 | <input type="hidden" name="action" value="bgg_search_reset" /> |
@@ -270,17 +270,17 @@ discard block |
||
270 | 270 | |
271 | 271 | echo wp_kses( ob_get_clean(), [ |
272 | 272 | 'a' => [ |
273 | - 'href' => [], |
|
273 | + 'href' => [ ], |
|
274 | 274 | ], |
275 | 275 | 'div' => [ |
276 | - 'class' => [], |
|
276 | + 'class' => [ ], |
|
277 | 277 | ], |
278 | 278 | 'input' => [ |
279 | - 'type' => [], |
|
280 | - 'name' => [], |
|
281 | - 'value' => [], |
|
279 | + 'type' => [ ], |
|
280 | + 'name' => [ ], |
|
281 | + 'value' => [ ], |
|
282 | 282 | ], |
283 | - ]); |
|
283 | + ] ); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | * @return void|wp_die |
291 | 291 | */ |
292 | 292 | function search_response() { |
293 | - if ( isset( $_POST['nonce_CMB2phpbgg-search'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce_CMB2phpbgg-search'] ) ), 'nonce_CMB2phpbgg-search' ) ) { |
|
293 | + if ( isset( $_POST[ 'nonce_CMB2phpbgg-search' ] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[ 'nonce_CMB2phpbgg-search' ] ) ), 'nonce_CMB2phpbgg-search' ) ) { |
|
294 | 294 | |
295 | - $search_query = isset( $_POST['bgg_searchform'] ) ? sanitize_text_field( wp_unslash( $_POST['bgg_searchform'] ) ) : ''; |
|
295 | + $search_query = isset( $_POST[ 'bgg_searchform' ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'bgg_searchform' ] ) ) : ''; |
|
296 | 296 | $results = get_bgg_search_results( $search_query ); |
297 | 297 | set_transient( 'gc_last_bgg_search', $results, HOUR_IN_SECONDS ); |
298 | 298 | wp_safe_redirect( admin_url( 'edit.php?post_type=gc_game&page=add_from_bgg&step=2' ) ); |
@@ -330,14 +330,14 @@ discard block |
||
330 | 330 | global $submenu; |
331 | 331 | |
332 | 332 | // Store the Games Collector menu to a variable. |
333 | - $items = $submenu['edit.php?post_type=gc_game']; |
|
333 | + $items = $submenu[ 'edit.php?post_type=gc_game' ]; |
|
334 | 334 | |
335 | 335 | // Item 11 is right after Add New. Item 16 is the link for Add New from BGG. |
336 | - $submenu['edit.php?post_type=gc_game'][11] = $items[16]; // WPCS: override ok. |
|
336 | + $submenu[ 'edit.php?post_type=gc_game' ][ 11 ] = $items[ 16 ]; // WPCS: override ok. |
|
337 | 337 | // Remove item 16, the old Add New from BGG link. |
338 | - unset( $submenu['edit.php?post_type=gc_game'][16] ); |
|
338 | + unset( $submenu[ 'edit.php?post_type=gc_game' ][ 16 ] ); |
|
339 | 339 | // Re-sort the menu by index. |
340 | - ksort( $submenu['edit.php?post_type=gc_game'] ); |
|
340 | + ksort( $submenu[ 'edit.php?post_type=gc_game' ] ); |
|
341 | 341 | |
342 | 342 | return $menu_order; |
343 | 343 | } |
@@ -350,12 +350,12 @@ discard block |
||
350 | 350 | * @return array An array of options for CMB2. |
351 | 351 | */ |
352 | 352 | function bgg_search_results_options( $results ) { |
353 | - $options = []; |
|
353 | + $options = [ ]; |
|
354 | 354 | foreach ( $results as $game ) { |
355 | - $options[ absint( $game['id'] ) ] = sprintf( '%1$s [%2$s] (%3$s)', |
|
356 | - '<strong>' . esc_html( $game['name'] ) . '</strong>', |
|
357 | - esc_html( $game['year'] ), |
|
358 | - esc_html( $game['id'] ) |
|
355 | + $options[ absint( $game[ 'id' ] ) ] = sprintf( '%1$s [%2$s] (%3$s)', |
|
356 | + '<strong>' . esc_html( $game[ 'name' ] ) . '</strong>', |
|
357 | + esc_html( $game[ 'year' ] ), |
|
358 | + esc_html( $game[ 'id' ] ) |
|
359 | 359 | ); |
360 | 360 | } |
361 | 361 | |
@@ -369,9 +369,9 @@ discard block |
||
369 | 369 | * @return void|wp_die |
370 | 370 | */ |
371 | 371 | function insert_game() { |
372 | - if ( isset( $_POST['nonce_CMB2phpbgg-search-2'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce_CMB2phpbgg-search-2'] ) ), 'nonce_CMB2phpbgg-search-2' ) ) { |
|
372 | + if ( isset( $_POST[ 'nonce_CMB2phpbgg-search-2' ] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[ 'nonce_CMB2phpbgg-search-2' ] ) ), 'nonce_CMB2phpbgg-search-2' ) ) { |
|
373 | 373 | |
374 | - $game_id = isset( $_POST['bgg_search_results'] ) ? absint( wp_unslash( $_POST['bgg_search_results'] ) ) : false; |
|
374 | + $game_id = isset( $_POST[ 'bgg_search_results' ] ) ? absint( wp_unslash( $_POST[ 'bgg_search_results' ] ) ) : false; |
|
375 | 375 | $redirect_url = admin_url( 'edit.php?post_type=gc_game&page=add_from_bgg' ); |
376 | 376 | |
377 | 377 | if ( $game_id ) { |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | |
380 | 380 | // Check if game already exists. |
381 | 381 | $existing_game = get_posts( [ |
382 | - 'title' => $game['title'], |
|
382 | + 'title' => $game[ 'title' ], |
|
383 | 383 | 'post_type' => 'gc_game', |
384 | 384 | 'numberposts' => 1, |
385 | 385 | ] ); |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | |
395 | 395 | $post_id = wp_insert_post( [ |
396 | 396 | 'post_type' => 'gc_game', |
397 | - 'post_title' => esc_html( $game['title'] ), |
|
397 | + 'post_title' => esc_html( $game[ 'title' ] ), |
|
398 | 398 | 'post_status' => 'draft', |
399 | 399 | ] ); |
400 | 400 | |
@@ -402,20 +402,20 @@ discard block |
||
402 | 402 | $redirect_url = admin_url( sprintf( 'post.php?post=%d&action=edit', $post_id ) ); |
403 | 403 | |
404 | 404 | // Add game meta. |
405 | - add_post_meta( $post_id, '_gc_min_players', absint( $game['minplayers'] ) ); |
|
406 | - add_post_meta( $post_id, '_gc_max_players', absint( $game['maxplayers'] ) ); |
|
407 | - add_post_meta( $post_id, '_gc_age', absint( $game['minage'] ) ); |
|
405 | + add_post_meta( $post_id, '_gc_min_players', absint( $game[ 'minplayers' ] ) ); |
|
406 | + add_post_meta( $post_id, '_gc_max_players', absint( $game[ 'maxplayers' ] ) ); |
|
407 | + add_post_meta( $post_id, '_gc_age', absint( $game[ 'minage' ] ) ); |
|
408 | 408 | add_post_meta( $post_id, '_gc_link', sprintf( 'https://www.boardgamegeek.com/boardgame/%d/', $game_id ) ); |
409 | 409 | add_post_meta( $post_id, '_gc_bgg_id', $game_id ); |
410 | 410 | |
411 | - if ( absint( $game['minplaytime'] ) === absint( $game['maxplaytime'] ) ) { |
|
412 | - add_post_meta( $post_id, '_gc_time', esc_html( $game['minplaytime'] ) ); |
|
411 | + if ( absint( $game[ 'minplaytime' ] ) === absint( $game[ 'maxplaytime' ] ) ) { |
|
412 | + add_post_meta( $post_id, '_gc_time', esc_html( $game[ 'minplaytime' ] ) ); |
|
413 | 413 | } else { |
414 | - add_post_meta( $post_id, '_gc_time', esc_html( $game['minplaytime'] . '-' . $game['maxplaytime'] ) ); |
|
414 | + add_post_meta( $post_id, '_gc_time', esc_html( $game[ 'minplaytime' ] . '-' . $game[ 'maxplaytime' ] ) ); |
|
415 | 415 | } |
416 | 416 | |
417 | - if ( isset( $game['categories'] ) ) { |
|
418 | - foreach ( $game['categories'] as $game_attribute ) { |
|
417 | + if ( isset( $game[ 'categories' ] ) ) { |
|
418 | + foreach ( $game[ 'categories' ] as $game_attribute ) { |
|
419 | 419 | $similar_attribute = get_attribute_like( $game_attribute ); |
420 | 420 | |
421 | 421 | // If there's an existing attribute that matches the BGG category, use that. |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | return $cached_term_search[ $search ]; |
463 | 463 | } |
464 | 464 | |
465 | - $terms = []; |
|
465 | + $terms = [ ]; |
|
466 | 466 | $all_terms = get_terms( [ |
467 | 467 | 'taxonomy' => 'gc_attribute', |
468 | 468 | 'hide_empty' => false, |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | foreach ( $all_terms as $term ) { |
472 | 472 | similar_text( $term->name, $search, $similarity ); |
473 | 473 | if ( $similarity > 75 ) { |
474 | - $terms[] = $term->term_id; |
|
474 | + $terms[ ] = $term->term_id; |
|
475 | 475 | } |
476 | 476 | } |
477 | 477 | |
@@ -480,14 +480,14 @@ discard block |
||
480 | 480 | // Cache this term combination so we can access it faster later. |
481 | 481 | if ( ! $cached_term_search ) { |
482 | 482 | set_transient( 'gc_frequently_used_attributes', [ |
483 | - $search => $terms[0], |
|
483 | + $search => $terms[ 0 ], |
|
484 | 484 | ], 999 * YEAR_IN_SECONDS ); |
485 | 485 | } else { |
486 | - $cached_term_search = array_merge( $cached_term_search, [ $search => $terms[0] ] ); |
|
486 | + $cached_term_search = array_merge( $cached_term_search, [ $search => $terms[ 0 ] ] ); |
|
487 | 487 | set_transient( 'gc_frequently_used_attributes', $cached_term_search, 999 * YEAR_IN_SECONDS ); |
488 | 488 | } |
489 | 489 | |
490 | - return $terms[0]; |
|
490 | + return $terms[ 0 ]; |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | return false; |
@@ -501,6 +501,6 @@ discard block |
||
501 | 501 | * @param array $game The array of game data from BGG. |
502 | 502 | */ |
503 | 503 | function attach_bgg_image( $post_id, $game ) { |
504 | - $image_id = media_sideload_image( esc_url_raw( $game['image'] ), $post_id, esc_html( $game['title'] ), 'id' ); |
|
504 | + $image_id = media_sideload_image( esc_url_raw( $game[ 'image' ] ), $post_id, esc_html( $game[ 'title' ] ), 'id' ); |
|
505 | 505 | set_post_thumbnail( $post_id, $image_id ); |
506 | 506 | } |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | |
62 | 62 | <div class="game-info" id="game-<?php echo absint( $game_id ); ?>-info"> |
63 | 63 | <?php |
64 | - echo get_players( $game_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
64 | + echo get_players( $game_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
65 | 65 | echo get_playing_time( $game_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
66 | - echo get_age( $game_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
67 | - echo get_difficulty( $game_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
68 | - echo get_attributes( $game_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
66 | + echo get_age( $game_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
67 | + echo get_difficulty( $game_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
68 | + echo get_attributes( $game_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
69 | 69 | ?> |
70 | 70 | </div> |
71 | 71 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return string Select markup for filters. |
161 | 161 | */ |
162 | 162 | function get_filters() { |
163 | - $player_filter = '<div class="player-filter"><label for="players-filter-select">' . esc_html__( 'How many players?', 'games-collector' ) . ':</label> |
|
163 | + $player_filter = '<div class="player-filter"><label for="players-filter-select">' . esc_html__( 'How many players?', 'games-collector' ) . ':</label> |
|
164 | 164 | <select class="players-filter-select"> |
165 | 165 | <option selected>- ' . esc_html__( 'Select one', 'games-collector' ) . ' -</option> |
166 | 166 | <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> |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $attribute_list = Attributes\get_the_attribute_list( |
231 | 231 | $game_id, |
232 | 232 | '<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. |
233 | - ', ', // Seperator. |
|
233 | + ', ', // Seperator. |
|
234 | 234 | '</span></div>' // After. |
235 | 235 | ); |
236 | 236 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | function get_players( $game_id ) { |
256 | 256 | $players_min_max = Game\get_players_min_max( $game_id ); |
257 | 257 | |
258 | - if ( isset( $players_min_max['min'] ) ) { |
|
258 | + if ( isset( $players_min_max[ 'min' ] ) ) { |
|
259 | 259 | /** |
260 | 260 | * Allow the # of players to be filtered (but only if there actually are players). |
261 | 261 | * |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | $num_players = apply_filters( 'gc_filter_players', $game_id, $players_min_max, sprintf( |
269 | 269 | // Translators: 1: Minimum number of players, 2: Maximum number of players. |
270 | 270 | __( '%1$d %2$s players', 'games-collector' ), |
271 | - absint( $players_min_max['min'] ), |
|
272 | - isset( $players_min_max['max'] ) ? sprintf( '- %d', absint( $players_min_max['max'] ) ) : '+' |
|
271 | + absint( $players_min_max[ 'min' ] ), |
|
272 | + isset( $players_min_max[ 'max' ] ) ? sprintf( '- %d', absint( $players_min_max[ 'max' ] ) ) : '+' |
|
273 | 273 | ) ); |
274 | 274 | |
275 | 275 | ob_start(); |
@@ -399,9 +399,9 @@ discard block |
||
399 | 399 | return; |
400 | 400 | } |
401 | 401 | |
402 | - wp_enqueue_style( 'games-collector', dirname( plugin_dir_url( __FILE__ ), 2 ) . '/assets/css/main.css', [], '1.3.4' ); |
|
402 | + wp_enqueue_style( 'games-collector', dirname( plugin_dir_url( __FILE__ ), 2 ) . '/assets/css/main.css', [ ], '1.3.4' ); |
|
403 | 403 | wp_enqueue_script( 'games-collector', dirname( plugin_dir_url( __FILE__ ), 2 ) . '/assets/js/main.js', [ 'jquery', 'isotope' ], '1.3.4' ); |
404 | - wp_enqueue_script( 'isotope', 'https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js', [], '3.0.6' ); |
|
404 | + wp_enqueue_script( 'isotope', 'https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js', [ ], '3.0.6' ); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | ] ); |
52 | 52 | |
53 | 53 | if ( ! $existing_page ) { |
54 | - wp_insert_post([ |
|
54 | + wp_insert_post( [ |
|
55 | 55 | 'post_type' => 'page', |
56 | 56 | 'post_title' => esc_html__( 'Games', 'games-collector' ), |
57 | 57 | 'post_content' => '[games-collector]', |
@@ -74,20 +74,20 @@ discard block |
||
74 | 74 | function numbers_of_players( $game_id, $players_min_max, $output ) { |
75 | 75 | |
76 | 76 | // Deal with max number of players matching min number of players. |
77 | - if ( absint( $players_min_max['min'] ) === absint( $players_min_max['max'] ) ) { |
|
77 | + if ( absint( $players_min_max[ 'min' ] ) === absint( $players_min_max[ 'max' ] ) ) { |
|
78 | 78 | return esc_attr( sprintf( |
79 | 79 | // Translators: %d is the number of players. |
80 | - _n( '%d player', '%d players', absint( $players_min_max['min'] ), 'games-collector' ), |
|
81 | - absint( $players_min_max['min'] ) |
|
80 | + _n( '%d player', '%d players', absint( $players_min_max[ 'min' ] ), 'games-collector' ), |
|
81 | + absint( $players_min_max[ 'min' ] ) |
|
82 | 82 | ) ); |
83 | 83 | } |
84 | 84 | |
85 | 85 | // Deal with indeterminate or large number of max players. |
86 | - if ( 0 === absint( $players_min_max['max'] ) || 20 <= absint( $players_min_max['max'] ) ) { |
|
86 | + if ( 0 === absint( $players_min_max[ 'max' ] ) || 20 <= absint( $players_min_max[ 'max' ] ) ) { |
|
87 | 87 | return esc_attr( sprintf( |
88 | 88 | // Translators: %d is the minimum number players. |
89 | 89 | __( '%d+ players', 'games-collector' ), |
90 | - absint( $players_min_max['min'] ) |
|
90 | + absint( $players_min_max[ 'min' ] ) |
|
91 | 91 | ) ); |
92 | 92 | } |
93 | 93 |