$id in function pre_get_shortlink is 0 if it's called for the current blog post so the id needs to come from the post instead. Otherwise wordpress will not serve the youlrs url in the shortlink meta tag and http header.