[wp-trac] [WordPress Trac] #35154: The admin_url filter might break ajaxurl usage

WordPress Trac noreply at wordpress.org
Fri Dec 18 12:46:07 UTC 2015


#35154: The admin_url filter might break ajaxurl usage
--------------------------+-----------------------------
 Reporter:  jadpm         |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 `ajaxurl` is a javascript global generated basically as
 {{{
 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>';
 }}}

 `admin_url()` results get filtered by `admin_url`, which might add query
 arguments into `ajaxurl`, or at least modify it on a substantial way.

 We have several instances where we assume that `ajaxurl` will be an URL
 without query arguments, like this one:
 {{{
 // wp-admin\js\tags-box.js 179
 ajaxurl + '?action=ajax-tag-search&tax=' + tax,
 }}}

 That assumption might be completely wrong.

 I am attaching a list of places where we define `ajax_url` and a list of
 places where we assume it is a clean, query-arguments-free URL. Note that
 those lists might not be complete, although I greped against WordPress
 trunk.

 As a solution idea, we might want to create a javascript version of
 `add_query_arg()` and use it extensively.

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


More information about the wp-trac mailing list