England striker Callum Wilson, 34, has agreed a new one-year deal at West Ham just weeks after his departure looked imminent.