Uncaught TypeError: strpos() | WordPress.org

[ad_1]

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;
	}
  • This topic was modified 7 hours, 23 minutes ago by tomhung.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer