GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — develop (#42)
by Chris
02:20
created
inc/functions.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
99 99
  * @since 0.2
100 100
  */
101 101
 function gc_the_games() {
102
-	echo Shortcode\shortcode( [] ); // WPCS: XSS ok. Already sanitized.
102
+	echo Shortcode\shortcode( [ ] ); // WPCS: XSS ok. Already sanitized.
103 103
 }
104 104
 
105 105
 /**
Please login to merge, or discard this patch.
inc/api/namespace.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,27 +28,27 @@
 block discarded – undo
28 28
 	$link        = get_post_meta( $post->ID, '_gc_link' );
29 29
 
30 30
 	if ( $min_players ) {
31
-		$data->data['min_players'] = $min_players;
31
+		$data->data[ 'min_players' ] = $min_players;
32 32
 	}
33 33
 
34 34
 	if ( $max_players ) {
35
-		$data->data['max_players'] = $max_players;
35
+		$data->data[ 'max_players' ] = $max_players;
36 36
 	}
37 37
 
38 38
 	if ( $time ) {
39
-		$data->data['time'] = $time;
39
+		$data->data[ 'time' ] = $time;
40 40
 	}
41 41
 
42 42
 	if ( $age ) {
43
-		$data->data['age'] = $age;
43
+		$data->data[ 'age' ] = $age;
44 44
 	}
45 45
 
46 46
 	if ( $difficulty ) {
47
-		$data->data['difficulty'] = $difficulty;
47
+		$data->data[ 'difficulty' ] = $difficulty;
48 48
 	}
49 49
 
50 50
 	if ( $link ) {
51
-		$data->data['url'] = $link;
51
+		$data->data[ 'url' ] = $link;
52 52
 	}
53 53
 
54 54
 	return $data;
Please login to merge, or discard this patch.
plugin.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 	// Autoload the namespaces.
56 56
 	$namespaces = array_filter( glob( dirname( __FILE__ ) . '/inc/*' ), 'is_dir' );
57 57
 	foreach ( $namespaces as $namespace ) {
58
-		$files[] = $namespace . '/namespace.php';
58
+		$files[ ] = $namespace . '/namespace.php';
59 59
 	}
60 60
 
61 61
 	// Loop through and load all the things!
Please login to merge, or discard this patch.
inc/attributes/namespace.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 function register_taxonomy() {
18 18
 	register_extended_taxonomy( 'gc_attribute', 'gc_game', [
19
-			'dashboard_glance' => true,   // Show this taxonomy in the 'At a Glance' widget.
19
+			'dashboard_glance' => true, // Show this taxonomy in the 'At a Glance' widget.
20 20
 			'hierarchical'     => false,
21 21
 			'show_in_rest'     => true,
22 22
 			'rest_base'        => 'attributes',
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	}
52 52
 
53 53
 	wp_enqueue_script( 'chosen', plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'vendor/chosen-js/chosen.jquery.js', [ 'jquery' ], '1.6.2', true );
54
-	wp_enqueue_style( 'chosen', plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'vendor/chosen-js/chosen.css', [], '1.6.2' );
54
+	wp_enqueue_style( 'chosen', plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'vendor/chosen-js/chosen.css', [ ], '1.6.2' );
55 55
 }
56 56
 
57 57
 /**
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
  */
185 185
 function save_post( $post_id ) {
186 186
 	// Verify nonce.
187
-	if ( ! isset( $_POST['chosen_taxonomy_meta_box_nonce'] ) || ! wp_verify_nonce( $_POST['chosen_taxonomy_meta_box_nonce'], 'chosen-save-tax-terms' ) ) {
187
+	if ( ! isset( $_POST[ 'chosen_taxonomy_meta_box_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'chosen_taxonomy_meta_box_nonce' ], 'chosen-save-tax-terms' ) ) {
188 188
 		return;
189 189
 	}
190 190
 	// Check autosave.
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 		return;
193 193
 	}
194 194
 
195
-	$input = isset( $_POST['tax_input']['gc_attribute'] ) ? $_POST['tax_input']['gc_attribute'] : '';
195
+	$input = isset( $_POST[ 'tax_input' ][ 'gc_attribute' ] ) ? $_POST[ 'tax_input' ][ 'gc_attribute' ] : '';
196 196
 
197 197
 	if ( empty( $input ) ) {
198 198
 		$taxonomy = get_taxonomy( 'gc_attribute' );
@@ -250,19 +250,19 @@  discard block
 block discarded – undo
250 250
 function gc_kses( $string = '' ) {
251 251
 	$allowed_html = array_merge( wp_kses_allowed_html( 'post' ), [
252 252
 		'svg'   => [
253
-			'class'           => [],
254
-			'aria-labelledby' => [],
255
-			'role'            => [],
256
-			'version'         => [],
257
-			'xmlns'           => [],
258
-			'xmlns:xlink'     => [],
259
-			'height'          => [],
260
-			'width'           => [],
261
-			'viewbox'         => [],
253
+			'class'           => [ ],
254
+			'aria-labelledby' => [ ],
255
+			'role'            => [ ],
256
+			'version'         => [ ],
257
+			'xmlns'           => [ ],
258
+			'xmlns:xlink'     => [ ],
259
+			'height'          => [ ],
260
+			'width'           => [ ],
261
+			'viewbox'         => [ ],
262 262
 		],
263
-		'title' => [],
263
+		'title' => [ ],
264 264
 		'path'  => [
265
-			'd'               => [],
265
+			'd'               => [ ],
266 266
 		],
267 267
 	] );
268 268
 
Please login to merge, or discard this patch.
inc/shortcode/namespace.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -21,20 +21,20 @@  discard block
 block discarded – undo
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
 	$games = get_games( $post_ids );
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			<div <?php post_class( Game\get_game_classes( 'game-single', $game->ID ), $game->ID ); ?> id="game-<?php echo absint( $game->ID ); ?>">
53 53
 
54 54
 				<?php
55
-				echo Display\get_game_title( $game );    // WPCS: XSS ok, already sanitized.
55
+				echo Display\get_game_title( $game ); // WPCS: XSS ok, already sanitized.
56 56
 				echo Display\get_game_info( $game->ID ); // WPCS: XSS ok, already sanitized.
57 57
 				?>
58 58
 
@@ -71,31 +71,31 @@  discard block
 block discarded – undo
71 71
  * @param  array $post_ids  An array of game post IDs.
72 72
  * @return array            An array of Game WP_Post objects.
73 73
  */
74
-function get_games( $post_ids = [] ) {
74
+function get_games( $post_ids = [ ] ) {
75 75
 	if ( empty( $post_ids ) ) {
76 76
 		$post_ids = false;
77 77
 	}
78 78
 
79 79
 	if ( $post_ids ) {
80 80
 		// If we're only displaying select games, don't show the filters.
81
-		add_filter( 'gc_filter_buttons',      '__return_null' );
81
+		add_filter( 'gc_filter_buttons', '__return_null' );
82 82
 		add_filter( 'gc_filter_game_filters', '__return_null' );
83 83
 
84
-		return get_posts([
84
+		return get_posts( [
85 85
 			'posts_per_page' => count( $post_ids ),
86 86
 			'post_type'      => 'gc_game',
87 87
 			'post__in'       => $post_ids,
88 88
 			'orderby'        => 'title',
89 89
 			'order'          => 'ASC',
90
-		]);
90
+		] );
91 91
 	}
92 92
 
93
-	return get_posts([
93
+	return get_posts( [
94 94
 		'posts_per_page' => -1,
95 95
 		'post_type'      => 'gc_game',
96 96
 		'orderby'        => 'title',
97 97
 		'order'          => 'ASC',
98
-	]);
98
+	] );
99 99
 }
100 100
 
101 101
 /**
Please login to merge, or discard this patch.
inc/display/namespace.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 		return;
385 385
 	}
386 386
 
387
-	wp_enqueue_style( 'games-collector', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/assets/css/games-collector.css', [], '1.1.0-r2' );
387
+	wp_enqueue_style( 'games-collector', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/assets/css/games-collector.css', [ ], '1.1.0-r2' );
388 388
 	wp_enqueue_script( 'isotope', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/assets/js/isotope.pkgd.min.js', [ 'jquery' ], '3.0.1', true );
389 389
 	wp_enqueue_script( 'games-collector', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/assets/js/games-collector.js', [ 'jquery', 'isotope' ], '0.2' );
390 390
 }
Please login to merge, or discard this patch.
inc/game/namespace.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 			],
51 51
 		],
52 52
 		// Dropdown filters.
53
-		'admin_filters'       => [],
53
+		'admin_filters'       => [ ],
54 54
 		], [
55 55
 			'singular'      => __( 'Game', 'games-collector' ),
56 56
 			'plural'        => __( 'Games', 'games-collector' ),
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
 		'id'            => $prefix . 'metabox',
72 72
 		'title'         => __( 'Game Details', 'games-collector' ),
73 73
 		'object_types'  => [ 'gc_game' ],
74
-	]);
74
+	] );
75 75
 
76
-	$cmb->add_field([
76
+	$cmb->add_field( [
77 77
 		'name'       => __( 'Minimum Number of Players', 'games-collector' ),
78 78
 		'id'         => $prefix . 'min_players',
79 79
 		'type'       => 'text_small',
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
 			'type'        => 'number',
82 82
 			'placeholder' => '1',
83 83
 		],
84
-	]);
84
+	] );
85 85
 
86
-	$cmb->add_field([
86
+	$cmb->add_field( [
87 87
 		'name'       => __( 'Maximum Number of Players', 'games-collector' ),
88 88
 		'id'         => $prefix . 'max_players',
89 89
 		'type'       => 'text_small',
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 			'type'        => 'number',
92 92
 			'placeholder' => '4',
93 93
 		],
94
-	]);
94
+	] );
95 95
 
96
-	$cmb->add_field([
96
+	$cmb->add_field( [
97 97
 		'name'       => __( 'Playing Time', 'games-collector' ),
98 98
 		'id'         => $prefix . 'time',
99 99
 		'type'       => 'text_small',
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 		'attributes' => [
102 102
 			'placeholder' => '20-30',
103 103
 		],
104
-	]);
104
+	] );
105 105
 
106
-	$cmb->add_field([
106
+	$cmb->add_field( [
107 107
 		'name'       => __( 'Ages', 'games-collector' ),
108 108
 		'id'         => $prefix . 'age',
109 109
 		'type'       => 'text_small',
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
 			'type'        => 'number',
113 113
 			'placeholder' => '10',
114 114
 		],
115
-	]);
115
+	] );
116 116
 
117
-	$cmb->add_field([
117
+	$cmb->add_field( [
118 118
 		'name'       => __( 'Difficulty Level', 'games-collector' ),
119 119
 		'id'         => $prefix . 'difficulty',
120 120
 		'type'       => 'radio',
121 121
 		'desc'       => __( 'How difficult or complex is this game?', 'games-collector' ),
122 122
 		'options'    => get_difficulties(),
123 123
 		'default'    => 'easy',
124
-	]);
124
+	] );
125 125
 
126 126
 	$cmb->add_field( array(
127 127
 		'name'       => __( 'More Info Link', 'games-collector' ),
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 
150 150
 	$players_min_max = get_players_min_max( $post_id );
151 151
 
152
-	if ( isset( $players_min_max['min'] ) && isset( $players_min_max['max'] ) ) {
153
-		return sprintf( '%1$s - %2$s', $players_min_max['min'], $players_min_max['max'] );
152
+	if ( isset( $players_min_max[ 'min' ] ) && isset( $players_min_max[ 'max' ] ) ) {
153
+		return sprintf( '%1$s - %2$s', $players_min_max[ 'min' ], $players_min_max[ 'max' ] );
154 154
 	}
155 155
 
156 156
 	return;
@@ -292,20 +292,20 @@  discard block
 block discarded – undo
292 292
 	$difficulty = get_post_meta( $post_id, '_gc_difficulty', true );
293 293
 	$length     = get_game_length( $post_id );
294 294
 
295
-	if ( isset( $players['min'] ) ) {
296
-		$classes .= ' min-' . $players['min'] . '-players';
295
+	if ( isset( $players[ 'min' ] ) ) {
296
+		$classes .= ' min-' . $players[ 'min' ] . '-players';
297 297
 	}
298 298
 
299
-	if ( isset( $players['max'] ) ) {
300
-		if ( absint( $players['max'] ) >= 8 ) {
299
+	if ( isset( $players[ 'max' ] ) ) {
300
+		if ( absint( $players[ 'max' ] ) >= 8 ) {
301 301
 			$classes .= ' 8-or-more-players';
302 302
 		} else {
303
-			$classes .= ' max-' . $players['max'] . '-players';
303
+			$classes .= ' max-' . $players[ 'max' ] . '-players';
304 304
 		}
305 305
 	}
306 306
 
307
-	if ( isset( $players['min'] ) && ! isset( $players['max'] ) ) {
308
-		$classes .= ' ' . $players['min'] . '-players';
307
+	if ( isset( $players[ 'min' ] ) && ! isset( $players[ 'max' ] ) ) {
308
+		$classes .= ' ' . $players[ 'min' ] . '-players';
309 309
 	}
310 310
 
311 311
 	if ( $age ) {
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 
342 342
 	$game_time = str_replace( ' ', '', get_post_meta( $post_id, '_gc_time', true ) );
343 343
 	$time      = explode( '-', $game_time );
344
-	$time      = isset( $time[1] ) ? $time[1] : $time[0];
344
+	$time      = isset( $time[ 1 ] ) ? $time[ 1 ] : $time[ 0 ];
345 345
 
346 346
 	if ( $game_time ) {
347 347
 		switch ( $time ) {
Please login to merge, or discard this patch.
inc/namespace.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
  */
41 41
 function activate() {
42 42
 	if ( ! get_page_by_title( esc_html__( 'Games', 'games-collector' ) ) ) {
43
-		wp_insert_post([
43
+		wp_insert_post( [
44 44
 			'post_type'    => 'page',
45 45
 			'post_title'   => esc_html__( 'Games', 'games-collector' ),
46 46
 			'post_content' => '[games-collector]',
@@ -63,20 +63,20 @@  discard block
 block discarded – undo
63 63
 function numbers_of_players( $game_id, $players_min_max, $output ) {
64 64
 
65 65
 	// Deal with max number of players matching min number of players.
66
-	if ( absint( $players_min_max['min'] ) === absint( $players_min_max['max'] ) ) {
66
+	if ( absint( $players_min_max[ 'min' ] ) === absint( $players_min_max[ 'max' ] ) ) {
67 67
 		return esc_attr( sprintf(
68 68
 			// Translators: %d is the number of players.
69
-			_n( '%d player', '%d players', absint( $players_min_max['min'] ), 'games-collector' ),
70
-			absint( $players_min_max['min'] )
69
+			_n( '%d player', '%d players', absint( $players_min_max[ 'min' ] ), 'games-collector' ),
70
+			absint( $players_min_max[ 'min' ] )
71 71
 		) );
72 72
 	}
73 73
 
74 74
 	// Deal with indeterminate or large number of max players.
75
-	if ( 0 === absint( $players_min_max['max'] ) || 20 <= absint( $players_min_max['max'] ) ) {
75
+	if ( 0 === absint( $players_min_max[ 'max' ] ) || 20 <= absint( $players_min_max[ 'max' ] ) ) {
76 76
 		return esc_attr( sprintf(
77 77
 			// Translators: %d is the minimum number players.
78 78
 			__( '%d+ players', 'games-collector' ),
79
-			absint( $players_min_max['min'] )
79
+			absint( $players_min_max[ 'min' ] )
80 80
 		) );
81 81
 	}
82 82
 
Please login to merge, or discard this patch.
inc/bgg/namespace.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -70,19 +70,19 @@  discard block
 block discarded – undo
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' => (int) $game['@attributes']['objectid'],
84
-					'name' => $game['name'],
85
-					'year' => $game['yearpublished'],
82
+				$results[ ] = [
83
+					'id' => (int) $game[ '@attributes' ][ 'objectid' ],
84
+					'name' => $game[ 'name' ],
85
+					'year' => $game[ 'yearpublished' ],
86 86
 				];
87 87
 			}
88 88
 		}
@@ -100,31 +100,31 @@  discard block
 block discarded – undo
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;
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
  * @param  object $field_type_object The CMB2 field type object.
201 201
  */
202 202
 function render_cmb2_bgg_search( $field, $escaped_value, $object_id, $object_type, $field_type_object ) {
203
-	$description = '<p class="description">' . esc_html( $field_type_object->field->args()['desc'] ) . '</p>';
203
+	$description = '<p class="description">' . esc_html( $field_type_object->field->args()[ 'desc' ] ) . '</p>';
204 204
 	$form = sprintf( '<input id="%1$s" class="regular-text" name="%2$s" value="" placeholder="%3$s" type="text">',
205
-		esc_attr( $field_type_object->field->args()['id'] ),
206
-		esc_attr( $field_type_object->field->args()['id'] ),
205
+		esc_attr( $field_type_object->field->args()[ 'id' ] ),
206
+		esc_attr( $field_type_object->field->args()[ 'id' ] ),
207 207
 		__( 'A game title or search, e.g. &ldquo;betrayal house hill&rdquo;', 'usat' )
208 208
 	);
209 209
 	$hidden = '<input type="hidden" name="action" value="bgg_search_response">';
@@ -211,15 +211,15 @@  discard block
 block discarded – undo
211 211
 
212 212
 	echo wp_kses( $output, [
213 213
 		'p'     => [
214
-			'class'       => [],
214
+			'class'       => [ ],
215 215
 		],
216 216
 		'input' => [
217
-			'id'          => [],
218
-			'class'       => [],
219
-			'name'        => [],
220
-			'value'       => [],
221
-			'type'        => [],
222
-			'placeholder' => [],
217
+			'id'          => [ ],
218
+			'class'       => [ ],
219
+			'name'        => [ ],
220
+			'value'       => [ ],
221
+			'type'        => [ ],
222
+			'placeholder' => [ ],
223 223
 		],
224 224
 	] );
225 225
 }
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
  * @return void|wp_die
232 232
  */
233 233
 function search_response() {
234
-	if ( isset( $_POST['nonce_CMB2phpbgg-search'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce_CMB2phpbgg-search'] ) ), 'nonce_CMB2phpbgg-search' ) ) {
234
+	if ( isset( $_POST[ 'nonce_CMB2phpbgg-search' ] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[ 'nonce_CMB2phpbgg-search' ] ) ), 'nonce_CMB2phpbgg-search' ) ) {
235 235
 
236
-		$search_query = isset( $_POST['bgg_searchform'] ) ? sanitize_text_field( wp_unslash( $_POST['bgg_searchform'] ) ) : '';
236
+		$search_query = isset( $_POST[ 'bgg_searchform' ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'bgg_searchform' ] ) ) : '';
237 237
 		$results      = get_bgg_search_results( $search_query );
238 238
 		set_transient( 'gc_last_bgg_search', $results, DAY_IN_SECONDS );
239 239
 		wp_safe_redirect( admin_url( 'edit.php?post_type=gc_game&page=add_from_bgg&step=2' ) );
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
  * @return array          An array of options for CMB2.
252 252
  */
253 253
 function bgg_search_results_options( $results ) {
254
-	$options = [];
254
+	$options = [ ];
255 255
 	foreach ( $results as $game ) {
256
-		$options[ absint( $game['id'] ) ] = sprintf( '%1$s [%2$s] (%3$s)',
257
-			'<strong>' . esc_html( $game['name'] ) . '</strong>',
258
-			esc_html( $game['year'] ),
259
-			esc_html( $game['id'] )
256
+		$options[ absint( $game[ 'id' ] ) ] = sprintf( '%1$s [%2$s] (%3$s)',
257
+			'<strong>' . esc_html( $game[ 'name' ] ) . '</strong>',
258
+			esc_html( $game[ 'year' ] ),
259
+			esc_html( $game[ 'id' ] )
260 260
 		);
261 261
 	}
262 262
 
@@ -270,16 +270,16 @@  discard block
 block discarded – undo
270 270
  * @return void|wp_die
271 271
  */
272 272
 function insert_game() {
273
-	if ( isset( $_POST['nonce_CMB2phpbgg-search-2'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce_CMB2phpbgg-search-2'] ) ), 'nonce_CMB2phpbgg-search-2' ) ) {
273
+	if ( isset( $_POST[ 'nonce_CMB2phpbgg-search-2' ] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[ 'nonce_CMB2phpbgg-search-2' ] ) ), 'nonce_CMB2phpbgg-search-2' ) ) {
274 274
 
275
-		$game_id      = isset( $_POST['bgg_search_results'] ) ? absint( wp_unslash( $_POST['bgg_search_results'] ) ) : false;
275
+		$game_id      = isset( $_POST[ 'bgg_search_results' ] ) ? absint( wp_unslash( $_POST[ 'bgg_search_results' ] ) ) : false;
276 276
 		$redirect_url = admin_url( 'edit.php?post_type=gc_game&page=add_from_bgg' );
277 277
 
278 278
 		if ( $game_id ) {
279 279
 			$game = get_bgg_game( $game_id );
280 280
 
281 281
 			// Check if game already exists.
282
-			if ( get_page_by_title( $game['title'], OBJECT, 'gc_game' ) ) {
282
+			if ( get_page_by_title( $game[ 'title' ], OBJECT, 'gc_game' ) ) {
283 283
 				return wp_die(
284 284
 					esc_html__( 'A game with that title already exists. Please try again.', 'games-collector' ),
285 285
 					esc_html__( 'Duplicate game found', 'games-collector' ),
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 
290 290
 			$post_id = wp_insert_post( [
291 291
 				'post_type'   => 'gc_game',
292
-				'post_title'  => esc_html( $game['title'] ),
292
+				'post_title'  => esc_html( $game[ 'title' ] ),
293 293
 				'post_status' => 'draft',
294 294
 			] );
295 295
 
@@ -297,19 +297,19 @@  discard block
 block discarded – undo
297 297
 				$redirect_url = admin_url( sprintf( 'post.php?post=%d&action=edit', $post_id ) );
298 298
 
299 299
 				// Add game meta.
300
-				add_post_meta( $post_id, '_gc_min_players', absint( $game['minplayers'] ) );
301
-				add_post_meta( $post_id, '_gc_max_players', absint( $game['maxplayers'] ) );
302
-				add_post_meta( $post_id, '_gc_age', absint( $game['minage'] ) );
300
+				add_post_meta( $post_id, '_gc_min_players', absint( $game[ 'minplayers' ] ) );
301
+				add_post_meta( $post_id, '_gc_max_players', absint( $game[ 'maxplayers' ] ) );
302
+				add_post_meta( $post_id, '_gc_age', absint( $game[ 'minage' ] ) );
303 303
 				add_post_meta( $post_id, '_gc_link', sprintf( 'https://www.boardgamegeek.com/boardgame/%d/', $game_id ) );
304 304
 
305
-				if ( absint( $game['minplaytime'] ) === absint( $game['maxplaytime'] ) ) {
306
-					add_post_meta( $post_id, '_gc_time', esc_html( $game['minplaytime'] ) );
305
+				if ( absint( $game[ 'minplaytime' ] ) === absint( $game[ 'maxplaytime' ] ) ) {
306
+					add_post_meta( $post_id, '_gc_time', esc_html( $game[ 'minplaytime' ] ) );
307 307
 				} else {
308
-					add_post_meta( $post_id, '_gc_time', esc_html( $game['minplaytime'] . '-' . $game['maxplaytime'] ) );
308
+					add_post_meta( $post_id, '_gc_time', esc_html( $game[ 'minplaytime' ] . '-' . $game[ 'maxplaytime' ] ) );
309 309
 				}
310 310
 
311
-				if ( isset( $game['categories'] ) ) {
312
-					foreach ( $game['categories'] as $game_attribute ) {
311
+				if ( isset( $game[ 'categories' ] ) ) {
312
+					foreach ( $game[ 'categories' ] as $game_attribute ) {
313 313
 						$similar_attribute = get_attribute_like( $game_attribute );
314 314
 
315 315
 						// If there's an existing attribute that matches the BGG category, use that.
@@ -363,14 +363,14 @@  discard block
 block discarded – undo
363 363
 		// Cache this term combination so we can access it faster later.
364 364
 		if ( ! $cached_term_search ) {
365 365
 			set_transient( 'gc_frequently_used_attributes', [
366
-				$search => $terms[0],
366
+				$search => $terms[ 0 ],
367 367
 			], 999 * YEAR_IN_SECONDS );
368 368
 		} else {
369
-			$cached_term_search = array_merge( $cached_term_search, [ $search => $terms[0] ] );
369
+			$cached_term_search = array_merge( $cached_term_search, [ $search => $terms[ 0 ] ] );
370 370
 			set_transient( 'gc_frequently_used_attributes', $cached_term_search, 999 * YEAR_IN_SECONDS );
371 371
 		}
372 372
 
373
-		return $terms[0];
373
+		return $terms[ 0 ];
374 374
 	}
375 375
 
376 376
 	return false;
@@ -384,6 +384,6 @@  discard block
 block discarded – undo
384 384
  * @param  array $game    The array of game data from BGG.
385 385
  */
386 386
 function attach_bgg_image( $post_id, $game ) {
387
-	$image_id = media_sideload_image( esc_url_raw( $game['image'] ), $post_id, esc_html( $game['title'] ), 'id' );
387
+	$image_id = media_sideload_image( esc_url_raw( $game[ 'image' ] ), $post_id, esc_html( $game[ 'title' ] ), 'id' );
388 388
 	set_post_thumbnail( $post_id, $image_id );
389 389
 }
Please login to merge, or discard this patch.