Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack
File: functions.is-mobile.php
<?php // phpcs:ignore WordPress.Files.FileName.NotHyphenatedLowercase
[0] Fix | Delete
/**
[1] Fix | Delete
* This file holds a function that needs to be loaded before WordPress itself
[2] Fix | Delete
* on WordPress.com.
[3] Fix | Delete
*
[4] Fix | Delete
* @package automattic/jetpack
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
use Automattic\Jetpack\Device_Detection;
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Determine if the current User Agent matches the passed $kind
[11] Fix | Delete
*
[12] Fix | Delete
* @param string $kind Category of mobile device to check for.
[13] Fix | Delete
* Either: any, dumb, smart.
[14] Fix | Delete
* @param bool $return_matched_agent Boolean indicating if the UA should be returned.
[15] Fix | Delete
*
[16] Fix | Delete
* @return bool|string Boolean indicating if current UA matches $kind. If
[17] Fix | Delete
* $return_matched_agent is true, returns the UA string
[18] Fix | Delete
*/
[19] Fix | Delete
function jetpack_is_mobile( $kind = 'any', $return_matched_agent = false ) {
[20] Fix | Delete
[21] Fix | Delete
if ( function_exists( 'apply_filters' ) ) {
[22] Fix | Delete
/**
[23] Fix | Delete
* Filter the value of jetpack_is_mobile before it is calculated.
[24] Fix | Delete
*
[25] Fix | Delete
* Passing a truthy value to the filter will short-circuit determining the
[26] Fix | Delete
* mobile type, returning the passed value instead.
[27] Fix | Delete
*
[28] Fix | Delete
* @since 4.2.0
[29] Fix | Delete
*
[30] Fix | Delete
* @param bool|string $matches Boolean if current UA matches $kind or not. If
[31] Fix | Delete
* $return_matched_agent is true, should return the UA string
[32] Fix | Delete
* @param string $kind Category of mobile device being checked
[33] Fix | Delete
* @param bool $return_matched_agent Boolean indicating if the UA should be returned
[34] Fix | Delete
*/
[35] Fix | Delete
$pre = apply_filters( 'pre_jetpack_is_mobile', null, $kind, $return_matched_agent );
[36] Fix | Delete
if ( $pre ) {
[37] Fix | Delete
return $pre;
[38] Fix | Delete
}
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
$return = false;
[42] Fix | Delete
$device_info = Device_Detection::get_info();
[43] Fix | Delete
[44] Fix | Delete
if ( 'any' === $kind ) {
[45] Fix | Delete
$return = $device_info['is_phone'];
[46] Fix | Delete
} elseif ( 'smart' === $kind ) {
[47] Fix | Delete
$return = $device_info['is_smartphone'];
[48] Fix | Delete
} elseif ( 'dumb' === $kind ) {
[49] Fix | Delete
$return = $device_info['is_phone'] && ! $device_info['is_smartphone'];
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
if ( $return_matched_agent && true === $return ) {
[53] Fix | Delete
$return = $device_info['is_phone_matched_ua'];
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
if ( function_exists( 'apply_filters' ) ) {
[57] Fix | Delete
/**
[58] Fix | Delete
* Filter the value of jetpack_is_mobile
[59] Fix | Delete
*
[60] Fix | Delete
* @since 4.2.0
[61] Fix | Delete
*
[62] Fix | Delete
* @param bool|string $matches Boolean if current UA matches $kind or not. If
[63] Fix | Delete
* $return_matched_agent is true, should return the UA string
[64] Fix | Delete
* @param string $kind Category of mobile device being checked
[65] Fix | Delete
* @param bool $return_matched_agent Boolean indicating if the UA should be returned
[66] Fix | Delete
*/
[67] Fix | Delete
$return = apply_filters( 'jetpack_is_mobile', $return, $kind, $return_matched_agent );
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
return $return;
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function