| 1 |
<?php |
| 2 |
namespace WGMSRM\Traits; |
| 3 |
|
| 4 |
if (!defined('ABSPATH')) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Filters related to the plugin will be listed here |
| 10 |
*/ |
| 11 |
trait Filters |
| 12 |
{ |
| 13 |
|
| 14 |
/** |
| 15 |
* In case of Google Map API loaded by other plugins or themes, it will prevent and load a blank script (Only removes by user consent) |
| 16 |
* |
| 17 |
* @param string $tag |
| 18 |
* @param string $handle |
| 19 |
* @param string $src |
| 20 |
* @return mixed|string |
| 21 |
* @since 1.7.5 |
| 22 |
*/ |
| 23 |
public function do_prevent_others_google_maps_tag($tag, $handle, $src) |
| 24 |
{ |
| 25 |
// Validate and sanitize $src before using in regex |
| 26 |
$src = is_string($src) ? $src : ''; |
| 27 |
if (preg_match('/maps\.google/i', $src)) { |
| 28 |
if (is_string($handle) && $handle !== 'wp-gmap-api') { |
| 29 |
return ''; |
| 30 |
} |
| 31 |
} |
| 32 |
// Escape output for XSS protection if outputting $tag elsewhere |
| 33 |
return $tag; |
| 34 |
} |
| 35 |
} |
| 36 |
|