PHP Fatal error: Uncaught TypeError: strpos(): Argument #1 ($haystack) must be of type string, array given in /home/site/public_html/wp-content/plugins/admin-site-enhancements/classes/class-disable-components.php:522
public function disable_emoji_remove_dns_prefetch( $urls, $relation_type ) {
if ( 'dns-prefetch' == $relation_type ) {
// Strip out any URLs referencing the WordPress.org emoji location
$emoji_svg_url_base="https://s.w.org/images/core/emoji/";
foreach ( $urls as $key => $url ) {
if ( false !== strpos( $url, $emoji_svg_url_base ) ) {
unset( $urls[$key] );
}
}
}
return $urls;
}ChatGPT says: The PHP error you’re encountering is a TypeError in the disable_emoji_remove_dns_prefetch function. It occurs because strpos() expects its first argument to be a string, but an array is being passed to it. This issue can be resolved by ensuring that each element of the $urls array is a string before applying the strpos() function.
Here is a corrected section
public function disable_emoji_remove_dns_prefetch($urls, $relation_type) {
if ('dns-prefetch' == $relation_type) {
// Strip out any URLs referencing the WordPress.org emoji location
$emoji_svg_url_base="https://s.w.org/images/core/emoji/";
foreach ($urls as $key => $url) {
if (is_string($url) && false !== strpos($url, $emoji_svg_url_base)) {
unset($urls[$key]);
}
}
}
return $urls;
}
