Skip to:
Content

Changeset 6826 for trunk


Ignore:
Timestamp:
03/01/2013 08:57:30 PM (5 years ago)
Author:
boonebgorges
Message:

Improvements in the way ajaxurl is determined

Introduces bp_core_ajax_url() for easier unit testing

Switches bp_core_ajax_url() back to using admin_url(), but now it's more
sensitive to various HTTPS setups, including FORCE_SSL_ADMIN.

Corresponding unit test: https://github.com/buddypress/BuddyPress-Unit-Tests/commit/5cec5a154f568c83fd97f1e8ce5333a9183f2a4d

Partially reverts r6790. See #4850.

Fixes #4761

Props r-a-y

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-cssjs.php

    r6809 r6826  
    138138
    139139/**
    140  * bp_core_add_ajax_url_js()
    141  *
    142140 * Adds AJAX target URL so themes can access the WordPress AJAX functionality.
    143141 *
     
    147145?>
    148146
    149     <script type="text/javascript">var ajaxurl = '<?php echo network_site_url( '/wp-admin/admin-ajax.php' ); ?>';</script>
     147    <script type="text/javascript">var ajaxurl = '<?php echo bp_core_ajax_url(); ?>';</script>
    150148
    151149<?php
    152150}
    153151add_action( 'wp_head', 'bp_core_add_ajax_url_js' );
     152
     153/**
     154 * Returns the proper value for BP's ajaxurl
     155 *
     156 * Designed to be sensitive to FORCE_SSL_ADMIN and non-standard multisite
     157 * configurations.
     158 *
     159 * @since BuddyPress (1.7)
     160 *
     161 * @return string
     162 */
     163function bp_core_ajax_url() {
     164    return apply_filters( 'bp_core_ajax_url', admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ) );
     165}
Note: See TracChangeset for help on using the changeset viewer.