TypeError thrown

str_replace(): Argument #3 ($subject) must be of type array|string, WP_Error given