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

WordPress Trac noreply at wordpress.org
Thu Oct 24 09:33:33 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 toscho):

 Replying to [comment:5 bpetty]:
 > Also note that WordPress does not use the `wp` prefix with `is_*`
 methods.

 I’m always afraid of too generic names in the global namespace, but … ok.
 :)

 There are also some `wp_is_*` functions. Our naming scheme is not optimal.

 > If we're following convention here, it would just be `is_ajax()`, or
 `is_ajax_request()` if you want to be really clear.

 `is_ajax_request()` sounds better.

 > However, do we want to clutter the global namespace with more non-
 prefixed `is_*_request()` methods (for all of the constants listed above),
 or work through a single object like `WP_Screen`? The latter option might
 require promoting `WP_Screen` to `wp-includes` instead of just admin, or
 building a somewhat different `WP_Request` object instead using the same
 design model.

 `WP_Screen` might not be the best candidate for that. It’s scope already
 too wide: it handles states, the help content (might be changed soon), the
 screen options box and page parent relations. And it is made for the admin
 pages only.

 A `WP_State` class with static members would be better, but that might
 need too much time.

 Based on [#comment:4 @rmccue’s suggestion], I would like to see something
 like this:

 {{{
 function is_ajax_request() {
         return apply_filters( 'is_ajax_request', defined( 'DOING_AJAX' )
 && DOING_AJAX );
 }
 }}}

 Which file would be the best place? `wp-includes/functions.php` is already
 almost unreadable.
 We could move all state functions to a file `wp-includes/states.php`.
 Suggestions?

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


More information about the wp-trac mailing list