Title: Uncaught TypeError: strpos()
Last modified: December 5, 2023

---

# Uncaught TypeError: strpos()

 *  Resolved [tomhung](https://wordpress.org/support/users/tomhung/)
 * (@tomhung)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/uncaught-typeerror-strpos/)
 * 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
 *     ```wp-block-code
       	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
 *     ```wp-block-code
       	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;
       	}
       ```
   
    -  This topic was modified 2 years, 5 months ago by [tomhung](https://wordpress.org/support/users/tomhung/).

Viewing 1 replies (of 1 total)

 *  Plugin Author [Bowo](https://wordpress.org/support/users/qriouslad/)
 * (@qriouslad)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/uncaught-typeerror-strpos/#post-17255890)
 * [@tomhung](https://wordpress.org/support/users/tomhung/) Thanks!
 * The fix you provided will be included in the next release.

Viewing 1 replies (of 1 total)

The topic ‘Uncaught TypeError: strpos()’ is closed to new replies.

 * ![](https://ps.w.org/admin-site-enhancements/assets/icon-256x256.png?rev=3099794)
 * [Admin and Site Enhancements (ASE)](https://wordpress.org/plugins/admin-site-enhancements/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/admin-site-enhancements/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/admin-site-enhancements/)
 * [Active Topics](https://wordpress.org/support/plugin/admin-site-enhancements/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/admin-site-enhancements/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/admin-site-enhancements/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Bowo](https://wordpress.org/support/users/qriouslad/)
 * Last activity: [2 years, 5 months ago](https://wordpress.org/support/topic/uncaught-typeerror-strpos/#post-17255890)
 * Status: resolved