You could use a macro:
#if __VERSION__ < 130
#define TEXTURE2D texture2D
#else
#define TEXTURE2D texture
#endif
...
vec4 textureColor = TEXTURE2D(mySampler, fragmentUV);
I found this answerthis answer, that seems to have a compatibility include that handles more than just texture2d.