Enable CORS in wordpress

Headers manipulation should be done before template output starts. In WordPress it is typically done in template_redirect hook, which is right before template load but after core has fully loaded.