[wp-trac] [WordPress Trac] #25669: Introduce helper function for AJAX checks

WordPress Trac noreply at wordpress.org
Thu Oct 24 13:25:43 UTC 2013


#25669: Introduce helper function for AJAX checks
-------------------------+------------------------------
 Reporter:  toscho       |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  General      |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |
-------------------------+------------------------------

Comment (by TJNowell):

 The problems:

  - Code relying on DOING_AJAX is harder to test in isolation than code
 that relies on a function
  - It's easier to filter such a functions output than to redefine it (
 after all what would be the point if we swapped redefining a constant with
 redefining a function? )
  - A lot of codebases and developers define functions exactly like this,
 thus this function results in a reduction in boilerplate and duplication
  - I can't count the number of times I've assumed something like this was
 already present and had to either use the boilerplate or implement my own
 version

 As for why one might need to do it, not all code should run on an AJAX
 request. E.g. Yoasts SEO plugin has no business being loaded in my AJAX
 call to autocomplete a field name in a frontend form. It makes no sense to
 add the menus to the Admin toolbar when the response is a json object etc

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25669#comment:9>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list