[buddypress-trac] [BuddyPress] #2599: bp_core_add_ajax_url_js() generating wrong ajaxurl value

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Fri Jan 28 14:52:24 UTC 2011


#2599: bp_core_add_ajax_url_js() generating wrong ajaxurl value
----------------------+-------------------------
  Reporter:  Kawauso  |      Owner:
      Type:  defect   |     Status:  new
  Priority:  normal   |  Milestone:  1.4
 Component:  Core     |    Version:
Resolution:           |   Keywords:  needs-patch
----------------------+-------------------------

Comment (by kawauso):

 Attached a first pass at converting BuddyPress' AJAX functions to
 WordPress standard compliant ones and also stripped out some redundant
 `global $bp;` calls.

 Key differences:

 * WordPress has different actions for logged in and non-logged in users,
 `wp_ajax` and `wp_ajax_nopriv` respectively. BuddyPress combines these
 under `wp_ajax`.

 * WordPress requires that all functions end with `die()`, otherwise a `0`
 will be appended. This noticeably breaks JSON-based functions.

 * BuddyPress runs with `DOING_AJAX` and `WP_ADMIN` both undefined. These
 are defined as `true` under WordPress.

 I've taken out `is_user_logged_in()` where present in favour of using just
 `wp_ajax` and I think there are `wp_ajax_nopriv` hooks where needed, but
 I'm not overly familiar with the code, so it could use some testing.

-- 
Ticket URL: <https://trac.buddypress.org/ticket/2599#comment:9>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list