@@ -79,7 +79,7 @@ |
||
79 | 79 | /** |
80 | 80 | * Returns an array of tokens this test wants to listen for. |
81 | 81 | * |
82 | - * @return array |
|
82 | + * @return integer[] |
|
83 | 83 | */ |
84 | 84 | public function register() { |
85 | 85 | return array( |
@@ -104,21 +104,21 @@ discard block |
||
104 | 104 | $this->text_domain = self::$text_domain_override; |
105 | 105 | } |
106 | 106 | |
107 | - if ( '_' === $token['content'] ) { |
|
107 | + if ( '_' === $token[ 'content' ] ) { |
|
108 | 108 | $phpcs_file->addError( 'Found single-underscore "_()" function when double-underscore expected.', $stack_ptr, 'SingleUnderscoreGetTextFunction' ); |
109 | 109 | } |
110 | 110 | |
111 | - if ( ! isset( $this->i18n_functions[ $token['content'] ] ) ) { |
|
111 | + if ( ! isset( $this->i18n_functions[ $token[ 'content' ] ] ) ) { |
|
112 | 112 | return; |
113 | 113 | } |
114 | - $translation_function = $token['content']; |
|
114 | + $translation_function = $token[ 'content' ]; |
|
115 | 115 | |
116 | 116 | if ( in_array( $translation_function, array( 'translate', 'translate_with_gettext_context' ), true ) ) { |
117 | 117 | $phpcs_file->addWarning( 'Use of the "%s()" function is reserved for low-level API usage.', $stack_ptr, 'LowLevelTranslationFunction', array( $translation_function ) ); |
118 | 118 | } |
119 | 119 | |
120 | 120 | $func_open_paren_token = $phpcs_file->findNext( T_WHITESPACE, ( $stack_ptr + 1 ), null, true ); |
121 | - if ( ! $func_open_paren_token || T_OPEN_PARENTHESIS !== $tokens[ $func_open_paren_token ]['code'] ) { |
|
121 | + if ( ! $func_open_paren_token || T_OPEN_PARENTHESIS !== $tokens[ $func_open_paren_token ][ 'code' ] ) { |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
@@ -126,73 +126,73 @@ discard block |
||
126 | 126 | $argument_tokens = array(); |
127 | 127 | |
128 | 128 | // Look at arguments. |
129 | - for ( $i = ( $func_open_paren_token + 1 ); $i < $tokens[ $func_open_paren_token ]['parenthesis_closer']; $i += 1 ) { |
|
129 | + for ( $i = ( $func_open_paren_token + 1 ); $i < $tokens[ $func_open_paren_token ][ 'parenthesis_closer' ]; $i += 1 ) { |
|
130 | 130 | $this_token = $tokens[ $i ]; |
131 | - $this_token['token_index'] = $i; |
|
132 | - if ( in_array( $this_token['code'], PHP_CodeSniffer_Tokens::$emptyTokens, true ) ) { |
|
131 | + $this_token[ 'token_index' ] = $i; |
|
132 | + if ( in_array( $this_token[ 'code' ], PHP_CodeSniffer_Tokens::$emptyTokens, true ) ) { |
|
133 | 133 | continue; |
134 | 134 | } |
135 | - if ( T_COMMA === $this_token['code'] ) { |
|
136 | - $arguments_tokens[] = $argument_tokens; |
|
135 | + if ( T_COMMA === $this_token[ 'code' ] ) { |
|
136 | + $arguments_tokens[ ] = $argument_tokens; |
|
137 | 137 | $argument_tokens = array(); |
138 | 138 | continue; |
139 | 139 | } |
140 | 140 | |
141 | 141 | // Merge consecutive single or double quoted strings (when they span multiple lines). |
142 | - if ( T_CONSTANT_ENCAPSED_STRING === $this_token['code'] || T_DOUBLE_QUOTED_STRING === $this_token['code'] ) { |
|
143 | - for ( $j = ( $i + 1 ); $j < $tokens[ $func_open_paren_token ]['parenthesis_closer']; $j += 1 ) { |
|
144 | - if ( $this_token['code'] === $tokens[ $j ]['code'] ) { |
|
145 | - $this_token['content'] .= $tokens[ $j ]['content']; |
|
142 | + if ( T_CONSTANT_ENCAPSED_STRING === $this_token[ 'code' ] || T_DOUBLE_QUOTED_STRING === $this_token[ 'code' ] ) { |
|
143 | + for ( $j = ( $i + 1 ); $j < $tokens[ $func_open_paren_token ][ 'parenthesis_closer' ]; $j += 1 ) { |
|
144 | + if ( $this_token[ 'code' ] === $tokens[ $j ][ 'code' ] ) { |
|
145 | + $this_token[ 'content' ] .= $tokens[ $j ][ 'content' ]; |
|
146 | 146 | $i = $j; |
147 | 147 | } else { |
148 | 148 | break; |
149 | 149 | } |
150 | 150 | } |
151 | 151 | } |
152 | - $argument_tokens[] = $this_token; |
|
152 | + $argument_tokens[ ] = $this_token; |
|
153 | 153 | |
154 | 154 | // Include everything up to and including the parenthesis_closer if this token has one. |
155 | - if ( ! empty( $this_token['parenthesis_closer'] ) ) { |
|
156 | - for ( $j = ( $i + 1 ); $j <= $this_token['parenthesis_closer']; $j += 1 ) { |
|
157 | - $tokens[ $j ]['token_index'] = $j; |
|
158 | - $argument_tokens[] = $tokens[ $j ]; |
|
155 | + if ( ! empty( $this_token[ 'parenthesis_closer' ] ) ) { |
|
156 | + for ( $j = ( $i + 1 ); $j <= $this_token[ 'parenthesis_closer' ]; $j += 1 ) { |
|
157 | + $tokens[ $j ][ 'token_index' ] = $j; |
|
158 | + $argument_tokens[ ] = $tokens[ $j ]; |
|
159 | 159 | } |
160 | - $i = $this_token['parenthesis_closer']; |
|
160 | + $i = $this_token[ 'parenthesis_closer' ]; |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | if ( ! empty( $argument_tokens ) ) { |
164 | - $arguments_tokens[] = $argument_tokens; |
|
164 | + $arguments_tokens[ ] = $argument_tokens; |
|
165 | 165 | } |
166 | 166 | unset( $argument_tokens ); |
167 | 167 | |
168 | 168 | $argument_assertions = array(); |
169 | 169 | if ( 'simple' === $this->i18n_functions[ $translation_function ] ) { |
170 | - $argument_assertions[] = array( 'arg_name' => 'text', 'tokens' => array_shift( $arguments_tokens ) ); |
|
171 | - $argument_assertions[] = array( 'arg_name' => 'domain', 'tokens' => array_shift( $arguments_tokens ) ); |
|
170 | + $argument_assertions[ ] = array( 'arg_name' => 'text', 'tokens' => array_shift( $arguments_tokens ) ); |
|
171 | + $argument_assertions[ ] = array( 'arg_name' => 'domain', 'tokens' => array_shift( $arguments_tokens ) ); |
|
172 | 172 | } elseif ( 'context' === $this->i18n_functions[ $translation_function ] ) { |
173 | - $argument_assertions[] = array( 'arg_name' => 'text', 'tokens' => array_shift( $arguments_tokens ) ); |
|
174 | - $argument_assertions[] = array( 'arg_name' => 'context', 'tokens' => array_shift( $arguments_tokens ) ); |
|
175 | - $argument_assertions[] = array( 'arg_name' => 'domain', 'tokens' => array_shift( $arguments_tokens ) ); |
|
173 | + $argument_assertions[ ] = array( 'arg_name' => 'text', 'tokens' => array_shift( $arguments_tokens ) ); |
|
174 | + $argument_assertions[ ] = array( 'arg_name' => 'context', 'tokens' => array_shift( $arguments_tokens ) ); |
|
175 | + $argument_assertions[ ] = array( 'arg_name' => 'domain', 'tokens' => array_shift( $arguments_tokens ) ); |
|
176 | 176 | } elseif ( 'number' === $this->i18n_functions[ $translation_function ] ) { |
177 | - $argument_assertions[] = array( 'arg_name' => 'single', 'tokens' => array_shift( $arguments_tokens ) ); |
|
178 | - $argument_assertions[] = array( 'arg_name' => 'plural', 'tokens' => array_shift( $arguments_tokens ) ); |
|
177 | + $argument_assertions[ ] = array( 'arg_name' => 'single', 'tokens' => array_shift( $arguments_tokens ) ); |
|
178 | + $argument_assertions[ ] = array( 'arg_name' => 'plural', 'tokens' => array_shift( $arguments_tokens ) ); |
|
179 | 179 | array_shift( $arguments_tokens ); |
180 | - $argument_assertions[] = array( 'arg_name' => 'domain', 'tokens' => array_shift( $arguments_tokens ) ); |
|
180 | + $argument_assertions[ ] = array( 'arg_name' => 'domain', 'tokens' => array_shift( $arguments_tokens ) ); |
|
181 | 181 | } elseif ( 'number_context' === $this->i18n_functions[ $translation_function ] ) { |
182 | - $argument_assertions[] = array( 'arg_name' => 'single', 'tokens' => array_shift( $arguments_tokens ) ); |
|
183 | - $argument_assertions[] = array( 'arg_name' => 'plural', 'tokens' => array_shift( $arguments_tokens ) ); |
|
182 | + $argument_assertions[ ] = array( 'arg_name' => 'single', 'tokens' => array_shift( $arguments_tokens ) ); |
|
183 | + $argument_assertions[ ] = array( 'arg_name' => 'plural', 'tokens' => array_shift( $arguments_tokens ) ); |
|
184 | 184 | array_shift( $arguments_tokens ); |
185 | - $argument_assertions[] = array( 'arg_name' => 'context', 'tokens' => array_shift( $arguments_tokens ) ); |
|
186 | - $argument_assertions[] = array( 'arg_name' => 'domain', 'tokens' => array_shift( $arguments_tokens ) ); |
|
185 | + $argument_assertions[ ] = array( 'arg_name' => 'context', 'tokens' => array_shift( $arguments_tokens ) ); |
|
186 | + $argument_assertions[ ] = array( 'arg_name' => 'domain', 'tokens' => array_shift( $arguments_tokens ) ); |
|
187 | 187 | } elseif ( 'noopnumber' === $this->i18n_functions[ $translation_function ] ) { |
188 | - $argument_assertions[] = array( 'arg_name' => 'single', 'tokens' => array_shift( $arguments_tokens ) ); |
|
189 | - $argument_assertions[] = array( 'arg_name' => 'plural', 'tokens' => array_shift( $arguments_tokens ) ); |
|
190 | - $argument_assertions[] = array( 'arg_name' => 'domain', 'tokens' => array_shift( $arguments_tokens ) ); |
|
188 | + $argument_assertions[ ] = array( 'arg_name' => 'single', 'tokens' => array_shift( $arguments_tokens ) ); |
|
189 | + $argument_assertions[ ] = array( 'arg_name' => 'plural', 'tokens' => array_shift( $arguments_tokens ) ); |
|
190 | + $argument_assertions[ ] = array( 'arg_name' => 'domain', 'tokens' => array_shift( $arguments_tokens ) ); |
|
191 | 191 | } elseif ( 'noopnumber_context' === $this->i18n_functions[ $translation_function ] ) { |
192 | - $argument_assertions[] = array( 'arg_name' => 'single', 'tokens' => array_shift( $arguments_tokens ) ); |
|
193 | - $argument_assertions[] = array( 'arg_name' => 'plural', 'tokens' => array_shift( $arguments_tokens ) ); |
|
194 | - $argument_assertions[] = array( 'arg_name' => 'context', 'tokens' => array_shift( $arguments_tokens ) ); |
|
195 | - $argument_assertions[] = array( 'arg_name' => 'domain', 'tokens' => array_shift( $arguments_tokens ) ); |
|
192 | + $argument_assertions[ ] = array( 'arg_name' => 'single', 'tokens' => array_shift( $arguments_tokens ) ); |
|
193 | + $argument_assertions[ ] = array( 'arg_name' => 'plural', 'tokens' => array_shift( $arguments_tokens ) ); |
|
194 | + $argument_assertions[ ] = array( 'arg_name' => 'context', 'tokens' => array_shift( $arguments_tokens ) ); |
|
195 | + $argument_assertions[ ] = array( 'arg_name' => 'domain', 'tokens' => array_shift( $arguments_tokens ) ); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | if ( ! empty( $arguments_tokens ) ) { |
@@ -200,18 +200,18 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | foreach ( $argument_assertions as $argument_assertion_context ) { |
203 | - if ( empty( $argument_assertion_context['tokens'][0] ) ) { |
|
204 | - $argument_assertion_context['stack_ptr'] = $func_open_paren_token; |
|
203 | + if ( empty( $argument_assertion_context[ 'tokens' ][ 0 ] ) ) { |
|
204 | + $argument_assertion_context[ 'stack_ptr' ] = $func_open_paren_token; |
|
205 | 205 | } else { |
206 | - $argument_assertion_context['stack_ptr'] = $argument_assertion_context['tokens'][0]['token_index']; |
|
206 | + $argument_assertion_context[ 'stack_ptr' ] = $argument_assertion_context[ 'tokens' ][ 0 ][ 'token_index' ]; |
|
207 | 207 | } |
208 | 208 | call_user_func( array( $this, 'check_argument_tokens' ), $phpcs_file, $argument_assertion_context ); |
209 | 209 | } |
210 | 210 | |
211 | 211 | // For _n*() calls, compare the singular and plural strings. |
212 | 212 | if ( false !== strpos( $this->i18n_functions[ $translation_function ], 'number' ) ) { |
213 | - $single_context = $argument_assertions[0]; |
|
214 | - $plural_context = $argument_assertions[1]; |
|
213 | + $single_context = $argument_assertions[ 0 ]; |
|
214 | + $plural_context = $argument_assertions[ 1 ]; |
|
215 | 215 | |
216 | 216 | $this->compare_single_and_plural_arguments( $phpcs_file, $stack_ptr, $single_context, $plural_context ); |
217 | 217 | } |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | * @return bool |
226 | 226 | */ |
227 | 227 | protected function check_argument_tokens( PHP_CodeSniffer_File $phpcs_file, $context ) { |
228 | - $stack_ptr = $context['stack_ptr']; |
|
229 | - $tokens = $context['tokens']; |
|
230 | - $arg_name = $context['arg_name']; |
|
231 | - $method = empty( $context['warning'] ) ? 'addError' : 'addWarning'; |
|
232 | - $content = $tokens[0]['content']; |
|
228 | + $stack_ptr = $context[ 'stack_ptr' ]; |
|
229 | + $tokens = $context[ 'tokens' ]; |
|
230 | + $arg_name = $context[ 'arg_name' ]; |
|
231 | + $method = empty( $context[ 'warning' ] ) ? 'addError' : 'addWarning'; |
|
232 | + $content = $tokens[ 0 ][ 'content' ]; |
|
233 | 233 | |
234 | 234 | if ( 0 === count( $tokens ) ) { |
235 | 235 | $code = 'MissingArg' . ucfirst( $arg_name ); |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | if ( count( $tokens ) > 1 ) { |
242 | 242 | $contents = ''; |
243 | 243 | foreach ( $tokens as $token ) { |
244 | - $contents .= $token['content']; |
|
244 | + $contents .= $token[ 'content' ]; |
|
245 | 245 | } |
246 | 246 | $code = 'NonSingularStringLiteral' . ucfirst( $arg_name ); |
247 | 247 | $phpcs_file->$method( 'The $%s arg must be a single string literal, not "%s".', $stack_ptr, $code, array( $arg_name, $contents ) ); |
@@ -252,14 +252,14 @@ discard block |
||
252 | 252 | $this->check_text( $phpcs_file, $context ); |
253 | 253 | } |
254 | 254 | |
255 | - if ( T_CONSTANT_ENCAPSED_STRING === $tokens[0]['code'] ) { |
|
255 | + if ( T_CONSTANT_ENCAPSED_STRING === $tokens[ 0 ][ 'code' ] ) { |
|
256 | 256 | if ( 'domain' === $arg_name && ! empty( $this->text_domain ) && trim( $content, '\'""' ) !== $this->text_domain ) { |
257 | 257 | $phpcs_file->$method( 'Mismatch text domain. Expected \'%s\' but got %s.', $stack_ptr, 'TextDomainMismatch', array( $this->text_domain, $content ) ); |
258 | 258 | return false; |
259 | 259 | } |
260 | 260 | return true; |
261 | 261 | } |
262 | - if ( T_DOUBLE_QUOTED_STRING === $tokens[0]['code'] ) { |
|
262 | + if ( T_DOUBLE_QUOTED_STRING === $tokens[ 0 ][ 'code' ] ) { |
|
263 | 263 | $interpolated_variables = $this->get_interpolated_variables( $content ); |
264 | 264 | foreach ( $interpolated_variables as $interpolated_variable ) { |
265 | 265 | $code = 'InterpolatedVariable' . ucfirst( $arg_name ); |
@@ -291,20 +291,20 @@ discard block |
||
291 | 291 | * @return void |
292 | 292 | */ |
293 | 293 | protected function compare_single_and_plural_arguments( PHP_CodeSniffer_File $phpcs_file, $stack_ptr, $single_context, $plural_context ) { |
294 | - $single_content = $single_context['tokens'][0]['content']; |
|
295 | - $plural_content = $plural_context['tokens'][0]['content']; |
|
294 | + $single_content = $single_context[ 'tokens' ][ 0 ][ 'content' ]; |
|
295 | + $plural_content = $plural_context[ 'tokens' ][ 0 ][ 'content' ]; |
|
296 | 296 | |
297 | 297 | preg_match_all( self::$sprintf_placeholder_regex, $single_content, $single_placeholders ); |
298 | - $single_placeholders = $single_placeholders[0]; |
|
298 | + $single_placeholders = $single_placeholders[ 0 ]; |
|
299 | 299 | |
300 | 300 | preg_match_all( self::$sprintf_placeholder_regex, $plural_content, $plural_placeholders ); |
301 | - $plural_placeholders = $plural_placeholders[0]; |
|
301 | + $plural_placeholders = $plural_placeholders[ 0 ]; |
|
302 | 302 | |
303 | 303 | // English conflates "singular" with "only one", described in the codex: |
304 | 304 | // https://codex.wordpress.org/I18n_for_WordPress_Developers#Plurals . |
305 | 305 | if ( count( $single_placeholders ) < count( $plural_placeholders ) ) { |
306 | 306 | $error_string = 'Missing singular placeholder, needed for some languages. See https://codex.wordpress.org/I18n_for_WordPress_Developers#Plurals'; |
307 | - $single_index = $single_context['tokens'][0]['token_index']; |
|
307 | + $single_index = $single_context[ 'tokens' ][ 0 ][ 'token_index' ]; |
|
308 | 308 | |
309 | 309 | $phpcs_file->addError( $error_string, $single_index, 'MissingSingularPlaceholder' ); |
310 | 310 | } |
@@ -326,14 +326,14 @@ discard block |
||
326 | 326 | * @return void |
327 | 327 | */ |
328 | 328 | protected function check_text( PHP_CodeSniffer_File $phpcs_file, $context ) { |
329 | - $stack_ptr = $context['stack_ptr']; |
|
330 | - $arg_name = $context['arg_name']; |
|
331 | - $content = $context['tokens'][0]['content']; |
|
332 | - $fixable_method = empty( $context['warning'] ) ? 'addFixableError' : 'addFixableWarning'; |
|
329 | + $stack_ptr = $context[ 'stack_ptr' ]; |
|
330 | + $arg_name = $context[ 'arg_name' ]; |
|
331 | + $content = $context[ 'tokens' ][ 0 ][ 'content' ]; |
|
332 | + $fixable_method = empty( $context[ 'warning' ] ) ? 'addFixableError' : 'addFixableWarning'; |
|
333 | 333 | |
334 | 334 | // UnorderedPlaceholders: Check for multiple unordered placeholders. |
335 | 335 | preg_match_all( self::$unordered_sprintf_placeholder_regex, $content, $unordered_matches ); |
336 | - $unordered_matches = $unordered_matches[0]; |
|
336 | + $unordered_matches = $unordered_matches[ 0 ]; |
|
337 | 337 | $unordered_matches_count = count( $unordered_matches ); |
338 | 338 | |
339 | 339 | if ( $unordered_matches_count >= 2 ) { |
@@ -83,7 +83,7 @@ |
||
83 | 83 | * |
84 | 84 | * @since 0.8.0 |
85 | 85 | * |
86 | - * @return array |
|
86 | + * @return integer[] |
|
87 | 87 | */ |
88 | 88 | public function register() { |
89 | 89 | return array( |
@@ -86,9 +86,9 @@ |
||
86 | 86 | * @return array |
87 | 87 | */ |
88 | 88 | public function register() { |
89 | - return array( |
|
90 | - T_VARIABLE, |
|
91 | - ); |
|
89 | + return array( |
|
90 | + T_VARIABLE, |
|
91 | + ); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $this->init( $phpcsFile ); |
108 | 108 | |
109 | 109 | // Check for $wpdb variable. |
110 | - if ( '$wpdb' !== $this->tokens[ $stackPtr ]['content'] ) { |
|
110 | + if ( '$wpdb' !== $this->tokens[ $stackPtr ][ 'content' ] ) { |
|
111 | 111 | return; |
112 | 112 | } |
113 | 113 | |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | |
122 | 122 | for ( $this->i; $this->i < $this->end; $this->i++ ) { |
123 | 123 | |
124 | - if ( isset( $this->ignored_tokens[ $this->tokens[ $this->i ]['code'] ] ) ) { |
|
124 | + if ( isset( $this->ignored_tokens[ $this->tokens[ $this->i ][ 'code' ] ] ) ) { |
|
125 | 125 | continue; |
126 | 126 | } |
127 | 127 | |
128 | - if ( T_DOUBLE_QUOTED_STRING === $this->tokens[ $this->i ]['code'] ) { |
|
128 | + if ( T_DOUBLE_QUOTED_STRING === $this->tokens[ $this->i ][ 'code' ] ) { |
|
129 | 129 | |
130 | 130 | $bad_variables = array_filter( |
131 | - $this->get_interpolated_variables( $this->tokens[ $this->i ]['content'] ), |
|
131 | + $this->get_interpolated_variables( $this->tokens[ $this->i ][ 'content' ] ), |
|
132 | 132 | create_function( '$symbol', 'return ! in_array( $symbol, array( "wpdb" ), true );' ) // Replace this with closure once 5.3 is minimum requirement. |
133 | 133 | ); |
134 | 134 | |
@@ -139,25 +139,25 @@ discard block |
||
139 | 139 | 'NotPrepared', |
140 | 140 | array( |
141 | 141 | $bad_variable, |
142 | - $this->tokens[ $this->i ]['content'], |
|
142 | + $this->tokens[ $this->i ][ 'content' ], |
|
143 | 143 | ) |
144 | 144 | ); |
145 | 145 | } |
146 | 146 | continue; |
147 | 147 | } |
148 | 148 | |
149 | - if ( T_VARIABLE === $this->tokens[ $this->i ]['code'] ) { |
|
150 | - if ( '$wpdb' === $this->tokens[ $this->i ]['content'] ) { |
|
149 | + if ( T_VARIABLE === $this->tokens[ $this->i ][ 'code' ] ) { |
|
150 | + if ( '$wpdb' === $this->tokens[ $this->i ][ 'content' ] ) { |
|
151 | 151 | $this->is_wpdb_method_call( $this->i ); |
152 | 152 | continue; |
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | - if ( T_STRING === $this->tokens[ $this->i ]['code'] ) { |
|
156 | + if ( T_STRING === $this->tokens[ $this->i ][ 'code' ] ) { |
|
157 | 157 | |
158 | 158 | if ( |
159 | - isset( self::$SQLEscapingFunctions[ $this->tokens[ $this->i ]['content'] ] ) |
|
160 | - || isset( self::$SQLAutoEscapedFunctions[ $this->tokens[ $this->i ]['content'] ] ) |
|
159 | + isset( self::$SQLEscapingFunctions[ $this->tokens[ $this->i ][ 'content' ] ] ) |
|
160 | + || isset( self::$SQLAutoEscapedFunctions[ $this->tokens[ $this->i ][ 'content' ] ] ) |
|
161 | 161 | ) { |
162 | 162 | |
163 | 163 | // Find the opening parenthesis. |
@@ -165,14 +165,14 @@ discard block |
||
165 | 165 | |
166 | 166 | if ( |
167 | 167 | $opening_paren |
168 | - && T_OPEN_PARENTHESIS === $this->tokens[ $opening_paren ]['code'] |
|
169 | - && isset( $this->tokens[ $opening_paren ]['parenthesis_closer'] ) |
|
168 | + && T_OPEN_PARENTHESIS === $this->tokens[ $opening_paren ][ 'code' ] |
|
169 | + && isset( $this->tokens[ $opening_paren ][ 'parenthesis_closer' ] ) |
|
170 | 170 | ) { |
171 | 171 | // Skip past the end of the function. |
172 | - $this->i = $this->tokens[ $opening_paren ]['parenthesis_closer']; |
|
172 | + $this->i = $this->tokens[ $opening_paren ][ 'parenthesis_closer' ]; |
|
173 | 173 | continue; |
174 | 174 | } |
175 | - } elseif ( isset( self::$formattingFunctions[ $this->tokens[ $this->i ]['content'] ] ) ) { |
|
175 | + } elseif ( isset( self::$formattingFunctions[ $this->tokens[ $this->i ][ 'content' ] ] ) ) { |
|
176 | 176 | continue; |
177 | 177 | } |
178 | 178 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | 'Use placeholders and $wpdb->prepare(); found %s', |
182 | 182 | $this->i, |
183 | 183 | 'NotPrepared', |
184 | - array( $this->tokens[ $this->i ]['content'] ) |
|
184 | + array( $this->tokens[ $this->i ][ 'content' ] ) |
|
185 | 185 | ); |
186 | 186 | } |
187 | 187 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | } |
214 | 214 | |
215 | 215 | $methodPtr = $this->phpcsFile->findNext( array( T_WHITESPACE ), ( $is_object_call + 1 ), null, true, null, true ); |
216 | - $method = $this->tokens[ $methodPtr ]['content']; |
|
216 | + $method = $this->tokens[ $methodPtr ][ 'content' ]; |
|
217 | 217 | |
218 | 218 | // Find the opening parenthesis. |
219 | 219 | $opening_paren = $this->phpcsFile->findNext( T_WHITESPACE, ( $methodPtr + 1 ), null, true, null, true ); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | $this->i = $opening_paren; |
226 | 226 | |
227 | - if ( T_OPEN_PARENTHESIS !== $this->tokens[ $opening_paren ]['code'] ) { |
|
227 | + if ( T_OPEN_PARENTHESIS !== $this->tokens[ $opening_paren ][ 'code' ] ) { |
|
228 | 228 | return false; |
229 | 229 | } |
230 | 230 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | // Find the end of the first parameter. |
237 | 237 | $this->end = $this->phpcsFile->findEndOfStatement( $opening_paren + 1 ); |
238 | 238 | |
239 | - if ( T_COMMA !== $this->tokens[ $this->end ]['code'] ) { |
|
239 | + if ( T_COMMA !== $this->tokens[ $this->end ][ 'code' ] ) { |
|
240 | 240 | $this->end += 1; |
241 | 241 | } |
242 | 242 |
@@ -96,7 +96,7 @@ |
||
96 | 96 | /** |
97 | 97 | * Returns an array of tokens this test wants to listen for. |
98 | 98 | * |
99 | - * @return array |
|
99 | + * @return integer[] |
|
100 | 100 | */ |
101 | 101 | public function register() { |
102 | 102 | return array( |
@@ -134,20 +134,20 @@ discard block |
||
134 | 134 | |
135 | 135 | $this->init( $phpcsFile ); |
136 | 136 | |
137 | - $function = $this->tokens[ $stackPtr ]['content']; |
|
137 | + $function = $this->tokens[ $stackPtr ][ 'content' ]; |
|
138 | 138 | |
139 | 139 | // Find the opening parenthesis (if present; T_ECHO might not have it). |
140 | 140 | $open_paren = $phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true ); |
141 | 141 | |
142 | 142 | // If function, not T_ECHO nor T_PRINT. |
143 | - if ( T_STRING === $this->tokens[ $stackPtr ]['code'] ) { |
|
143 | + if ( T_STRING === $this->tokens[ $stackPtr ][ 'code' ] ) { |
|
144 | 144 | // Skip if it is a function but is not of the printing functions. |
145 | - if ( ! isset( self::$printingFunctions[ $this->tokens[ $stackPtr ]['content'] ] ) ) { |
|
145 | + if ( ! isset( self::$printingFunctions[ $this->tokens[ $stackPtr ][ 'content' ] ] ) ) { |
|
146 | 146 | return; |
147 | 147 | } |
148 | 148 | |
149 | - if ( isset( $this->tokens[ $open_paren ]['parenthesis_closer'] ) ) { |
|
150 | - $end_of_statement = $this->tokens[ $open_paren ]['parenthesis_closer']; |
|
149 | + if ( isset( $this->tokens[ $open_paren ][ 'parenthesis_closer' ] ) ) { |
|
150 | + $end_of_statement = $this->tokens[ $open_paren ][ 'parenthesis_closer' ]; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // These functions only need to have the first argument escaped. |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | |
181 | 181 | // Check for the ternary operator. We only need to do this here if this |
182 | 182 | // echo is lacking parenthesis. Otherwise it will be handled below. |
183 | - if ( T_OPEN_PARENTHESIS !== $this->tokens[ $open_paren ]['code'] || T_CLOSE_PARENTHESIS !== $this->tokens[ $last_token ]['code'] ) { |
|
183 | + if ( T_OPEN_PARENTHESIS !== $this->tokens[ $open_paren ][ 'code' ] || T_CLOSE_PARENTHESIS !== $this->tokens[ $last_token ][ 'code' ] ) { |
|
184 | 184 | |
185 | 185 | $ternary = $phpcsFile->findNext( T_INLINE_THEN, $stackPtr, $end_of_statement ); |
186 | 186 | |
187 | 187 | // If there is a ternary skip over the part before the ?. However, if |
188 | 188 | // the ternary is within parentheses, it will be handled in the loop. |
189 | - if ( $ternary && empty( $this->tokens[ $ternary ]['nested_parenthesis'] ) ) { |
|
189 | + if ( $ternary && empty( $this->tokens[ $ternary ][ 'nested_parenthesis' ] ) ) { |
|
190 | 190 | $stackPtr = $ternary; |
191 | 191 | } |
192 | 192 | } |
@@ -202,29 +202,29 @@ discard block |
||
202 | 202 | for ( $i = $stackPtr; $i < $end_of_statement; $i++ ) { |
203 | 203 | |
204 | 204 | // Ignore whitespaces and comments. |
205 | - if ( in_array( $this->tokens[ $i ]['code'], PHP_CodeSniffer_Tokens::$emptyTokens, true ) ) { |
|
205 | + if ( in_array( $this->tokens[ $i ][ 'code' ], PHP_CodeSniffer_Tokens::$emptyTokens, true ) ) { |
|
206 | 206 | continue; |
207 | 207 | } |
208 | 208 | |
209 | - if ( T_OPEN_PARENTHESIS === $this->tokens[ $i ]['code'] ) { |
|
209 | + if ( T_OPEN_PARENTHESIS === $this->tokens[ $i ][ 'code' ] ) { |
|
210 | 210 | |
211 | 211 | if ( $in_cast ) { |
212 | 212 | |
213 | 213 | // Skip to the end of a function call if it has been casted to a safe value. |
214 | - $i = $this->tokens[ $i ]['parenthesis_closer']; |
|
214 | + $i = $this->tokens[ $i ][ 'parenthesis_closer' ]; |
|
215 | 215 | $in_cast = false; |
216 | 216 | |
217 | 217 | } else { |
218 | 218 | |
219 | 219 | // Skip over the condition part of a ternary (i.e., to after the ?). |
220 | - $ternary = $phpcsFile->findNext( T_INLINE_THEN, $i, $this->tokens[ $i ]['parenthesis_closer'] ); |
|
220 | + $ternary = $phpcsFile->findNext( T_INLINE_THEN, $i, $this->tokens[ $i ][ 'parenthesis_closer' ] ); |
|
221 | 221 | |
222 | 222 | if ( $ternary ) { |
223 | 223 | |
224 | - $next_paren = $phpcsFile->findNext( T_OPEN_PARENTHESIS, ( $i + 1 ), $this->tokens[ $i ]['parenthesis_closer'] ); |
|
224 | + $next_paren = $phpcsFile->findNext( T_OPEN_PARENTHESIS, ( $i + 1 ), $this->tokens[ $i ][ 'parenthesis_closer' ] ); |
|
225 | 225 | |
226 | 226 | // We only do it if the ternary isn't within a subset of parentheses. |
227 | - if ( ! $next_paren || $ternary > $this->tokens[ $next_paren ]['parenthesis_closer'] ) { |
|
227 | + if ( ! $next_paren || $ternary > $this->tokens[ $next_paren ][ 'parenthesis_closer' ] ) { |
|
228 | 228 | $i = $ternary; |
229 | 229 | } |
230 | 230 | } |
@@ -234,34 +234,34 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | // Handle arrays for those functions that accept them. |
237 | - if ( T_ARRAY === $this->tokens[ $i ]['code'] ) { |
|
237 | + if ( T_ARRAY === $this->tokens[ $i ][ 'code' ] ) { |
|
238 | 238 | $i++; // Skip the opening parenthesis. |
239 | 239 | continue; |
240 | 240 | } |
241 | 241 | |
242 | - if ( in_array( $this->tokens[ $i ]['code'], array( T_DOUBLE_ARROW, T_CLOSE_PARENTHESIS ), true ) ) { |
|
242 | + if ( in_array( $this->tokens[ $i ][ 'code' ], array( T_DOUBLE_ARROW, T_CLOSE_PARENTHESIS ), true ) ) { |
|
243 | 243 | continue; |
244 | 244 | } |
245 | 245 | |
246 | 246 | // Handle magic constants for debug functions. |
247 | - if ( isset( $this->magic_constant_tokens[ $this->tokens[ $i ]['type'] ] ) ) { |
|
247 | + if ( isset( $this->magic_constant_tokens[ $this->tokens[ $i ][ 'type' ] ] ) ) { |
|
248 | 248 | continue; |
249 | 249 | } |
250 | 250 | |
251 | 251 | // Wake up on concatenation characters, another part to check. |
252 | - if ( in_array( $this->tokens[ $i ]['code'], array( T_STRING_CONCAT ), true ) ) { |
|
252 | + if ( in_array( $this->tokens[ $i ][ 'code' ], array( T_STRING_CONCAT ), true ) ) { |
|
253 | 253 | $watch = true; |
254 | 254 | continue; |
255 | 255 | } |
256 | 256 | |
257 | 257 | // Wake up after a ternary else (:). |
258 | - if ( $ternary && in_array( $this->tokens[ $i ]['code'], array( T_INLINE_ELSE ), true ) ) { |
|
258 | + if ( $ternary && in_array( $this->tokens[ $i ][ 'code' ], array( T_INLINE_ELSE ), true ) ) { |
|
259 | 259 | $watch = true; |
260 | 260 | continue; |
261 | 261 | } |
262 | 262 | |
263 | 263 | // Wake up for commas. |
264 | - if ( T_COMMA === $this->tokens[ $i ]['code'] ) { |
|
264 | + if ( T_COMMA === $this->tokens[ $i ][ 'code' ] ) { |
|
265 | 265 | $in_cast = false; |
266 | 266 | $watch = true; |
267 | 267 | continue; |
@@ -273,23 +273,23 @@ discard block |
||
273 | 273 | |
274 | 274 | // Allow T_CONSTANT_ENCAPSED_STRING eg: echo 'Some String'; |
275 | 275 | // Also T_LNUMBER, e.g.: echo 45; exit -1; and booleans. |
276 | - if ( in_array( $this->tokens[ $i ]['code'], array( T_CONSTANT_ENCAPSED_STRING, T_LNUMBER, T_MINUS, T_TRUE, T_FALSE, T_NULL ), true ) ) { |
|
276 | + if ( in_array( $this->tokens[ $i ][ 'code' ], array( T_CONSTANT_ENCAPSED_STRING, T_LNUMBER, T_MINUS, T_TRUE, T_FALSE, T_NULL ), true ) ) { |
|
277 | 277 | continue; |
278 | 278 | } |
279 | 279 | |
280 | 280 | $watch = false; |
281 | 281 | |
282 | 282 | // Allow int/double/bool casted variables. |
283 | - if ( in_array( $this->tokens[ $i ]['code'], array( T_INT_CAST, T_DOUBLE_CAST, T_BOOL_CAST ), true ) ) { |
|
283 | + if ( in_array( $this->tokens[ $i ][ 'code' ], array( T_INT_CAST, T_DOUBLE_CAST, T_BOOL_CAST ), true ) ) { |
|
284 | 284 | $in_cast = true; |
285 | 285 | continue; |
286 | 286 | } |
287 | 287 | |
288 | 288 | // Now check that next token is a function call. |
289 | - if ( T_STRING === $this->tokens[ $i ]['code'] ) { |
|
289 | + if ( T_STRING === $this->tokens[ $i ][ 'code' ] ) { |
|
290 | 290 | |
291 | 291 | $ptr = $i; |
292 | - $functionName = $this->tokens[ $i ]['content']; |
|
292 | + $functionName = $this->tokens[ $i ][ 'content' ]; |
|
293 | 293 | $function_opener = $this->phpcsFile->findNext( array( T_OPEN_PARENTHESIS ), ( $i + 1 ), null, null, null, true ); |
294 | 294 | $is_formatting_function = isset( self::$formattingFunctions[ $functionName ] ); |
295 | 295 | |
@@ -301,13 +301,13 @@ discard block |
||
301 | 301 | $mapped_function = $this->phpcsFile->findNext( |
302 | 302 | PHP_CodeSniffer_Tokens::$emptyTokens, |
303 | 303 | ( $function_opener + 1 ), |
304 | - $this->tokens[ $function_opener ]['parenthesis_closer'], |
|
304 | + $this->tokens[ $function_opener ][ 'parenthesis_closer' ], |
|
305 | 305 | true |
306 | 306 | ); |
307 | 307 | |
308 | 308 | // If we're able to resolve the function name, do so. |
309 | - if ( $mapped_function && T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $mapped_function ]['code'] ) { |
|
310 | - $functionName = trim( $this->tokens[ $mapped_function ]['content'], '\'' ); |
|
309 | + if ( $mapped_function && T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $mapped_function ][ 'code' ] ) { |
|
310 | + $functionName = trim( $this->tokens[ $mapped_function ][ 'content' ], '\'' ); |
|
311 | 311 | $ptr = $mapped_function; |
312 | 312 | } |
313 | 313 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | $i = ( $function_opener + 1 ); |
320 | 320 | $watch = true; |
321 | 321 | } else { |
322 | - $i = $this->tokens[ $function_opener ]['parenthesis_closer']; |
|
322 | + $i = $this->tokens[ $function_opener ][ 'parenthesis_closer' ]; |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $content = $functionName; |
336 | 336 | |
337 | 337 | } else { |
338 | - $content = $this->tokens[ $i ]['content']; |
|
338 | + $content = $this->tokens[ $i ][ 'content' ]; |
|
339 | 339 | $ptr = $i; |
340 | 340 | } |
341 | 341 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * Returns the lines where errors should occur. |
29 | 29 | * |
30 | - * @return array <int line number> => <int number of errors> |
|
30 | + * @return integer[] <int line number> => <int number of errors> |
|
31 | 31 | */ |
32 | 32 | public function getErrorList() { |
33 | 33 | return array( |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | /** |
87 | 87 | * Returns the lines where warnings should occur. |
88 | 88 | * |
89 | - * @return array <int line number> => <int number of warnings> |
|
89 | + * @return integer[] <int line number> => <int number of warnings> |
|
90 | 90 | */ |
91 | 91 | public function getWarningList() { |
92 | 92 | return array( |
@@ -21,19 +21,19 @@ 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 | - if ( '' === $atts['gc_game'] ) { |
|
30 | - $post_ids = []; |
|
31 | - } elseif ( is_array( $atts['gc_game'] ) ) { |
|
32 | - $post_ids = $atts['gc_game']; |
|
33 | - } elseif ( false !== strpos( (string) $atts['gc_game'], ',' ) ) { |
|
34 | - $post_ids = explode( ',', $atts['gc_game'] ); |
|
35 | - } elseif ( ! is_array( $atts['gc_game'] ) ) { |
|
36 | - $post_ids = [ $atts['gc_game'] ]; |
|
29 | + if ( '' === $atts[ 'gc_game' ] ) { |
|
30 | + $post_ids = [ ]; |
|
31 | + } elseif ( is_array( $atts[ 'gc_game' ] ) ) { |
|
32 | + $post_ids = $atts[ 'gc_game' ]; |
|
33 | + } elseif ( false !== strpos( (string) $atts[ 'gc_game' ], ',' ) ) { |
|
34 | + $post_ids = explode( ',', $atts[ 'gc_game' ] ); |
|
35 | + } elseif ( ! is_array( $atts[ 'gc_game' ] ) ) { |
|
36 | + $post_ids = [ $atts[ 'gc_game' ] ]; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | $games = get_games( $post_ids ); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | <div <?php post_class( Game\get_game_classes( 'game-single', $game->ID ), $game->ID ); ?> id="game-<?php echo absint( $game->ID ); ?>"> |
52 | 52 | |
53 | 53 | <?php |
54 | - echo Display\get_game_title( $game ); // WPCS: XSS ok, already sanitized. |
|
54 | + echo Display\get_game_title( $game ); // WPCS: XSS ok, already sanitized. |
|
55 | 55 | echo Display\get_game_info( $game->ID ); // WPCS: XSS ok, already sanitized. |
56 | 56 | ?> |
57 | 57 | |
@@ -70,31 +70,31 @@ discard block |
||
70 | 70 | * @param array $post_ids An array of game post IDs. |
71 | 71 | * @return array An array of Game WP_Post objects. |
72 | 72 | */ |
73 | -function get_games( $post_ids = [] ) { |
|
73 | +function get_games( $post_ids = [ ] ) { |
|
74 | 74 | if ( empty( $post_ids ) ) { |
75 | 75 | $post_ids = false; |
76 | 76 | } |
77 | 77 | |
78 | 78 | if ( $post_ids ) { |
79 | 79 | // If we're only displaying select games, don't show the filters. |
80 | - add_filter( 'gc_filter_buttons', '__return_null' ); |
|
80 | + add_filter( 'gc_filter_buttons', '__return_null' ); |
|
81 | 81 | add_filter( 'gc_filter_game_filters', '__return_null' ); |
82 | 82 | |
83 | - return get_posts([ |
|
83 | + return get_posts( [ |
|
84 | 84 | 'posts_per_page' => count( $post_ids ), |
85 | 85 | 'post_type' => 'gc_game', |
86 | 86 | 'post__in' => $post_ids, |
87 | 87 | 'orderby' => 'title', |
88 | 88 | 'order' => 'ASC', |
89 | - ]); |
|
89 | + ] ); |
|
90 | 90 | } |
91 | 91 | |
92 | - return get_posts([ |
|
92 | + return get_posts( [ |
|
93 | 93 | 'posts_per_page' => -1, |
94 | 94 | 'post_type' => 'gc_game', |
95 | 95 | 'orderby' => 'title', |
96 | 96 | 'order' => 'ASC', |
97 | - ]); |
|
97 | + ] ); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -16,7 +16,7 @@ discard block |
||
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 |
||
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 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | <?php |
74 | 74 | if ( current_user_can( 'edit_posts' ) ) { |
75 | 75 | $taxonomy = get_taxonomy( $tax ); |
76 | - $label = apply_filters( 'ctm_tax_label' , $taxonomy->labels->name, $tax, 'gc_game' ); |
|
76 | + $label = apply_filters( 'ctm_tax_label', $taxonomy->labels->name, $tax, 'gc_game' ); |
|
77 | 77 | |
78 | 78 | $terms = get_terms( $tax, [ 'hide_empty' => 0 ] ); |
79 | 79 | $current_terms = wp_get_post_terms( get_the_ID(), $tax, [ 'fields' => 'ids' ] ); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | function save_post( $post_id ) { |
187 | 187 | // verify nonce |
188 | - if ( ! isset( $_POST['chosen_taxonomy_meta_box_nonce'] ) || ! wp_verify_nonce( $_POST['chosen_taxonomy_meta_box_nonce'], 'chosen-save-tax-terms' ) ) { |
|
188 | + if ( ! isset( $_POST[ 'chosen_taxonomy_meta_box_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'chosen_taxonomy_meta_box_nonce' ], 'chosen-save-tax-terms' ) ) { |
|
189 | 189 | return; |
190 | 190 | } |
191 | 191 | // check autosave |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | } |
195 | 195 | $post_type = get_post_type( $post_id ); |
196 | 196 | |
197 | - $input = isset( $_POST['tax_input']['gc_attribute'] ) ? $_POST['tax_input']['gc_attribute'] : ''; |
|
197 | + $input = isset( $_POST[ 'tax_input' ][ 'gc_attribute' ] ) ? $_POST[ 'tax_input' ][ 'gc_attribute' ] : ''; |
|
198 | 198 | |
199 | 199 | if ( empty( $input ) ) { |
200 | 200 | $taxonomy = get_taxonomy( 'gc_attribute' ); |
@@ -252,19 +252,19 @@ discard block |
||
252 | 252 | function gc_kses( $string = '' ) { |
253 | 253 | $allowed_html = array_merge( wp_kses_allowed_html( 'post' ), [ |
254 | 254 | 'svg' => [ |
255 | - 'class' => [], |
|
256 | - 'aria-labelledby' => [], |
|
257 | - 'role' => [], |
|
258 | - 'version' => [], |
|
259 | - 'xmlns' => [], |
|
260 | - 'xmlns:xlink' => [], |
|
261 | - 'height' => [], |
|
262 | - 'width' => [], |
|
263 | - 'viewbox' => [], |
|
255 | + 'class' => [ ], |
|
256 | + 'aria-labelledby' => [ ], |
|
257 | + 'role' => [ ], |
|
258 | + 'version' => [ ], |
|
259 | + 'xmlns' => [ ], |
|
260 | + 'xmlns:xlink' => [ ], |
|
261 | + 'height' => [ ], |
|
262 | + 'width' => [ ], |
|
263 | + 'viewbox' => [ ], |
|
264 | 264 | ], |
265 | - 'title' => [], |
|
265 | + 'title' => [ ], |
|
266 | 266 | 'path' => [ |
267 | - 'd' => [], |
|
267 | + 'd' => [ ], |
|
268 | 268 | ], |
269 | 269 | ] ); |
270 | 270 |
@@ -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( [] ); // WPCS: XSS ok. Already sanitized. |
|
102 | + echo Shortcode\shortcode( [ ] ); // WPCS: XSS ok. Already sanitized. |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -14,17 +14,17 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function bootstrap() { |
16 | 16 | // Add all your plugin hooks here. |
17 | - add_action( 'cmb2_init', __NAMESPACE__ . '\\Game\\fields' ); |
|
18 | - add_action( 'init', __NAMESPACE__ . '\\Game\\register_cpt' ); |
|
19 | - add_action( 'init', __NAMESPACE__ . '\\Attributes\\register_taxonomy' ); |
|
20 | - add_action( 'admin_init', __NAMESPACE__ . '\\Attributes\\create_default_attributes' ); |
|
21 | - add_action( 'add_meta_boxes', __NAMESPACE__ . '\\Attributes\\metabox' ); |
|
22 | - add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\\Attributes\\enqueue_scripts' ); |
|
23 | - add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\Display\\enqueue_scripts' ); |
|
24 | - add_action( 'register_shortcode_ui', __NAMESPACE__ . '\\Shortcode\\register_all_games_shortcode' ); |
|
25 | - add_action( 'register_shortcode_ui', __NAMESPACE__ . '\\Shortcode\\register_individual_games_shortcode' ); |
|
26 | - add_filter( 'rest_prepare_gc_game', __NAMESPACE__ . '\\Api\\filter_games_json', 10, 2 ); |
|
27 | - add_shortcode( 'games-collector', __NAMESPACE__ . '\\Shortcode\\shortcode' ); |
|
17 | + add_action( 'cmb2_init', __NAMESPACE__ . '\\Game\\fields' ); |
|
18 | + add_action( 'init', __NAMESPACE__ . '\\Game\\register_cpt' ); |
|
19 | + add_action( 'init', __NAMESPACE__ . '\\Attributes\\register_taxonomy' ); |
|
20 | + add_action( 'admin_init', __NAMESPACE__ . '\\Attributes\\create_default_attributes' ); |
|
21 | + add_action( 'add_meta_boxes', __NAMESPACE__ . '\\Attributes\\metabox' ); |
|
22 | + add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\\Attributes\\enqueue_scripts' ); |
|
23 | + add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\Display\\enqueue_scripts' ); |
|
24 | + add_action( 'register_shortcode_ui', __NAMESPACE__ . '\\Shortcode\\register_all_games_shortcode' ); |
|
25 | + add_action( 'register_shortcode_ui', __NAMESPACE__ . '\\Shortcode\\register_individual_games_shortcode' ); |
|
26 | + add_filter( 'rest_prepare_gc_game', __NAMESPACE__ . '\\Api\\filter_games_json', 10, 2 ); |
|
27 | + add_shortcode( 'games-collector', __NAMESPACE__ . '\\Shortcode\\shortcode' ); |
|
28 | 28 | add_shortcode( 'games-collector-list', __NAMESPACE__ . '\\Shortcode\\shortcode' ); |
29 | 29 | } |
30 | 30 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | function activate() { |
38 | 38 | if ( ! get_page_by_title( esc_html__( 'Games', 'games-collector' ) ) ) { |
39 | - $post_id = wp_insert_post([ |
|
39 | + $post_id = wp_insert_post( [ |
|
40 | 40 | 'post_type' => 'page', |
41 | 41 | 'post_title' => esc_html__( 'Games', 'games-collector' ), |
42 | 42 | 'post_content' => '[games-collector]', |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | ], |
50 | 50 | ], |
51 | 51 | // Dropdown filters. |
52 | - 'admin_filters' => [], |
|
52 | + 'admin_filters' => [ ], |
|
53 | 53 | ], [ |
54 | 54 | 'singular' => __( 'Game', 'games-collector' ), |
55 | 55 | 'plural' => __( 'Games', 'games-collector' ), |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | 'id' => $prefix . 'metabox', |
71 | 71 | 'title' => __( 'Game Details', 'games-collector' ), |
72 | 72 | 'object_types' => [ 'gc_game' ], |
73 | - ]); |
|
73 | + ] ); |
|
74 | 74 | |
75 | - $cmb->add_field([ |
|
75 | + $cmb->add_field( [ |
|
76 | 76 | 'name' => __( 'Minimum Number of Players', 'games-collector' ), |
77 | 77 | 'id' => $prefix . 'min_players', |
78 | 78 | 'type' => 'text_small', |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | 'type' => 'number', |
81 | 81 | 'placeholder' => '1', |
82 | 82 | ], |
83 | - ]); |
|
83 | + ] ); |
|
84 | 84 | |
85 | - $cmb->add_field([ |
|
85 | + $cmb->add_field( [ |
|
86 | 86 | 'name' => __( 'Maximum Number of Players', 'games-collector' ), |
87 | 87 | 'id' => $prefix . 'max_players', |
88 | 88 | 'type' => 'text_small', |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | 'type' => 'number', |
91 | 91 | 'placeholder' => '4', |
92 | 92 | ], |
93 | - ]); |
|
93 | + ] ); |
|
94 | 94 | |
95 | - $cmb->add_field([ |
|
95 | + $cmb->add_field( [ |
|
96 | 96 | 'name' => __( 'Playing Time', 'games-collector' ), |
97 | 97 | 'id' => $prefix . 'time', |
98 | 98 | 'type' => 'text_small', |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | 'attributes' => [ |
101 | 101 | 'placeholder' => '20-30', |
102 | 102 | ], |
103 | - ]); |
|
103 | + ] ); |
|
104 | 104 | |
105 | - $cmb->add_field([ |
|
105 | + $cmb->add_field( [ |
|
106 | 106 | 'name' => __( 'Ages', 'games-collector' ), |
107 | 107 | 'id' => $prefix . 'age', |
108 | 108 | 'type' => 'text_small', |
@@ -111,16 +111,16 @@ discard block |
||
111 | 111 | 'type' => 'number', |
112 | 112 | 'placeholder' => '10', |
113 | 113 | ], |
114 | - ]); |
|
114 | + ] ); |
|
115 | 115 | |
116 | - $cmb->add_field([ |
|
116 | + $cmb->add_field( [ |
|
117 | 117 | 'name' => __( 'Difficulty Level', 'games-collector' ), |
118 | 118 | 'id' => $prefix . 'difficulty', |
119 | 119 | 'type' => 'radio', |
120 | 120 | 'desc' => __( 'How difficult or complex is this game?', 'games-collector' ), |
121 | 121 | 'options' => get_difficulties(), |
122 | 122 | 'default' => 'easy', |
123 | - ]); |
|
123 | + ] ); |
|
124 | 124 | |
125 | 125 | $cmb->add_field( array( |
126 | 126 | 'name' => __( 'More Info Link', 'games-collector' ), |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | |
149 | 149 | $players_min_max = get_players_min_max( $post_id ); |
150 | 150 | |
151 | - if ( isset( $players_min_max['min'] ) && isset( $players_min_max['max'] ) ) { |
|
152 | - return sprintf( '%1$s - %2$s', $players_min_max['min'], $players_min_max['max'] ); |
|
151 | + if ( isset( $players_min_max[ 'min' ] ) && isset( $players_min_max[ 'max' ] ) ) { |
|
152 | + return sprintf( '%1$s - %2$s', $players_min_max[ 'min' ], $players_min_max[ 'max' ] ); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | return; |
@@ -291,20 +291,20 @@ discard block |
||
291 | 291 | $difficulty = get_post_meta( $post_id, '_gc_difficulty', true ); |
292 | 292 | $length = get_game_length( $post_id ); |
293 | 293 | |
294 | - if ( isset( $players['min'] ) ) { |
|
295 | - $classes .= ' min-' . $players['min'] . '-players'; |
|
294 | + if ( isset( $players[ 'min' ] ) ) { |
|
295 | + $classes .= ' min-' . $players[ 'min' ] . '-players'; |
|
296 | 296 | } |
297 | 297 | |
298 | - if ( isset( $players['max'] ) ) { |
|
299 | - if ( absint( $players['max'] ) >= 8 ) { |
|
298 | + if ( isset( $players[ 'max' ] ) ) { |
|
299 | + if ( absint( $players[ 'max' ] ) >= 8 ) { |
|
300 | 300 | $classes .= ' 8-or-more-players'; |
301 | 301 | } else { |
302 | - $classes .= ' max-' . $players['max'] . '-players'; |
|
302 | + $classes .= ' max-' . $players[ 'max' ] . '-players'; |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
306 | - if ( isset( $players['min'] ) && ! isset( $players['max'] ) ) { |
|
307 | - $classes .= ' ' . $players['min'] . '-players'; |
|
306 | + if ( isset( $players[ 'min' ] ) && ! isset( $players[ 'max' ] ) ) { |
|
307 | + $classes .= ' ' . $players[ 'min' ] . '-players'; |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | if ( $age ) { |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | |
341 | 341 | $game_time = str_replace( ' ', '', get_post_meta( $post_id, '_gc_time', true ) ); |
342 | 342 | $time = explode( '-', $game_time ); |
343 | - $time = isset( $time[1] ) ? $time[1] : $time[0]; |
|
343 | + $time = isset( $time[ 1 ] ) ? $time[ 1 ] : $time[ 0 ]; |
|
344 | 344 | |
345 | 345 | if ( $game_time ) { |
346 | 346 | switch ( $time ) { |