@@ -177,7 +177,6 @@ private static function is_mobile( $kind, $return_matched_agent, $ua_info ) {
177177 'dumb ' => false ,
178178 'any ' => false ,
179179 );
180- $ first_run = true ;
181180 $ matched_agent = '' ;
182181
183182 // If an invalid kind is passed in, reset it to default.
@@ -207,42 +206,38 @@ private static function is_mobile( $kind, $return_matched_agent, $ua_info ) {
207206 return false ;
208207 }
209208
210- if ( $ first_run ) {
211- $ first_run = false ;
212-
213- // checks for iPhoneTier devices & RichCSS devices.
214- if ( $ ua_info ->isTierIphone () || $ ua_info ->isTierRichCSS () ) {
215- $ kinds ['smart ' ] = true ;
216- $ matched_agent = $ ua_info ->matched_agent ;
217- }
209+ // checks for iPhoneTier devices & RichCSS devices.
210+ if ( $ ua_info ->isTierIphone () || $ ua_info ->isTierRichCSS () ) {
211+ $ kinds ['smart ' ] = true ;
212+ $ matched_agent = $ ua_info ->matched_agent ;
213+ }
218214
219- if ( ! $ kinds ['smart ' ] ) {
220- // if smart, we are not dumb so no need to check.
221- $ dumb_agents = $ ua_info ->dumb_agents ;
215+ if ( ! $ kinds ['smart ' ] ) {
216+ // if smart, we are not dumb so no need to check.
217+ $ dumb_agents = $ ua_info ->dumb_agents ;
222218
223- foreach ( $ dumb_agents as $ dumb_agent ) {
224- if ( false !== strpos ( $ agent , $ dumb_agent ) ) {
225- $ kinds ['dumb ' ] = true ;
226- $ matched_agent = $ dumb_agent ;
219+ foreach ( $ dumb_agents as $ dumb_agent ) {
220+ if ( false !== strpos ( $ agent , $ dumb_agent ) ) {
221+ $ kinds ['dumb ' ] = true ;
222+ $ matched_agent = $ dumb_agent ;
227223
228- break ;
229- }
224+ break ;
230225 }
226+ }
231227
232- if ( ! $ kinds ['dumb ' ] ) {
233- if ( isset ( $ _SERVER ['HTTP_X_WAP_PROFILE ' ] ) ) {
234- $ kinds ['dumb ' ] = true ;
235- $ matched_agent = 'http_x_wap_profile ' ;
236- } elseif ( isset ( $ _SERVER ['HTTP_ACCEPT ' ] ) && ( preg_match ( '/wap\.|\.wap/i ' , $ _SERVER ['HTTP_ACCEPT ' ] ) || false !== strpos ( strtolower ( $ _SERVER ['HTTP_ACCEPT ' ] ), 'application/vnd.wap.xhtml+xml ' ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- This is doing the validating.
237- $ kinds ['dumb ' ] = true ;
238- $ matched_agent = 'vnd.wap.xhtml+xml ' ;
239- }
228+ if ( ! $ kinds ['dumb ' ] ) {
229+ if ( isset ( $ _SERVER ['HTTP_X_WAP_PROFILE ' ] ) ) {
230+ $ kinds ['dumb ' ] = true ;
231+ $ matched_agent = 'http_x_wap_profile ' ;
232+ } elseif ( isset ( $ _SERVER ['HTTP_ACCEPT ' ] ) && ( preg_match ( '/wap\.|\.wap/i ' , $ _SERVER ['HTTP_ACCEPT ' ] ) || false !== strpos ( strtolower ( $ _SERVER ['HTTP_ACCEPT ' ] ), 'application/vnd.wap.xhtml+xml ' ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- This is doing the validating.
233+ $ kinds ['dumb ' ] = true ;
234+ $ matched_agent = 'vnd.wap.xhtml+xml ' ;
240235 }
241236 }
237+ }
242238
243- if ( $ kinds ['dumb ' ] || $ kinds ['smart ' ] ) {
244- $ kinds ['any ' ] = true ;
245- }
239+ if ( $ kinds ['dumb ' ] || $ kinds ['smart ' ] ) {
240+ $ kinds ['any ' ] = true ;
246241 }
247242
248243 $ value = $ kinds [ $ kind ];
0 commit comments