[wp-trac] [WordPress Trac] #27737: maybe a get_ajax_url() function?

WordPress Trac noreply at wordpress.org
Wed Apr 9 16:33:54 UTC 2014

#27737: maybe a get_ajax_url() function?
 Reporter:  igmoweb                     |      Owner:
     Type:  feature request             |     Status:  new
 Priority:  normal                      |  Milestone:  Awaiting Review
Component:  General                     |    Version:  3.8.2
 Severity:  normal                      |   Keywords:
  Focuses:  javascript, administration  |
 Hi there.

 I'll explain a case where the way to get the ajax URL in
 [http://codex.wordpress.org/AJAX_in_Plugins] is not working.

 If FORCE_SSL_ADMIN is set to true but not the front, then using admin_url(
 admin-ajax.php' ) in front will return a https URL that will lead us to
 the following error when we try to trigger an AJAX action:

 ...  No 'Access-Control-Allow-Origin' header is present on the requested
 resource. Origin ...

 Because if Javascript calls to an https URL it should be called from
 another https in the same site.

 So, I want to ask for an ajax_url() function that checks SSL constants and
 return a different URL depending on them.

 Basically, the function would return something like this:

 admin_url( 'admin-ajax.php', (is_ssl() ? 'https' : 'http') );

 Yeah, I could add it in every plugin but why not a function with that code
 included? Am I crazy asking for it?

Ticket URL: <https://core.trac.wordpress.org/ticket/27737>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list