mirror of
https://github.com/buddypress/buddypress.git
synced 2026-07-22 20:56:55 +08:00
Version 5.1.0 of WordPress deprecated two hooks (`wpmu_new_blog` & `delete_blog`) BuddyPress is using to run some of the BP Blogs component's features. In order to preserve these features for the versions of WordPress we support and that are older than 5.1.0 as well as start using the replacement hooks introduced in 5.1.0 (`wp_initialize_site` & `wp_validate_site_deletion`), we are introducing a compatibility mechanism to make sure BuddyPress is using the right hooks depending on the installed WordPress it's activated on. Props boonebgorges & I ;) Fixes #7984 git-svn-id: https://buddypress.svn.wordpress.org/trunk@12606 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* @group url
|
|
*/
|
|
class BP_Tests_URL extends BP_UnitTestCase {
|
|
function test_bp_core_ajax_url() {
|
|
$forced = force_ssl_admin();
|
|
$old_https = isset( $_SERVER['HTTPS'] ) ? $_SERVER['HTTPS'] : null;
|
|
|
|
// (1) HTTPS off
|
|
force_ssl_admin( false );
|
|
$_SERVER['HTTPS'] = 'off';
|
|
|
|
// (1a) Front-end
|
|
$this->go_to( '/' );
|
|
$this->assertEquals( bp_core_ajax_url(), get_site_url( bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'http' ) );
|
|
|
|
// (1b) Dashboard
|
|
$this->go_to( '/wp-admin' );
|
|
$this->assertEquals( bp_core_ajax_url(), get_site_url( bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'http' ) );
|
|
|
|
// (2) FORCE_SSL_ADMIN
|
|
force_ssl_admin( true );
|
|
|
|
// (2a) Front-end
|
|
$this->go_to( '/' );
|
|
$this->assertEquals( bp_core_ajax_url(), get_site_url( bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'http' ) );
|
|
|
|
// (2b) Dashboard
|
|
$_SERVER['HTTPS'] = 'on';
|
|
$this->go_to( '/wp-admin' );
|
|
$this->assertEquals( bp_core_ajax_url(), get_site_url( bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'https' ) );
|
|
|
|
// Restore to defaults.
|
|
force_ssl_admin( $forced );
|
|
if ( is_null( $old_https ) ) {
|
|
unset( $_SERVER['HTTPS'] );
|
|
} else {
|
|
$_SERVER['HTTPS'] = $old_https;
|
|
}
|
|
|
|
// (3) Multisite, root blog other than 1
|
|
if ( is_multisite() ) {
|
|
$original_root_blog = bp_get_root_blog_id();
|
|
$blog_id = self::factory()->blog->create( array(
|
|
'path' => '/path' . rand() . time() . '/',
|
|
) );
|
|
|
|
buddypress()->root_blog_id = $blog_id;
|
|
$blog_url = get_blog_option( $blog_id, 'siteurl' );
|
|
|
|
$this->go_to( trailingslashit( $blog_url ) );
|
|
switch_to_blog( $blog_id );
|
|
|
|
buddypress()->root_blog_id = $original_root_blog;
|
|
$ajax_url = bp_core_ajax_url();
|
|
|
|
restore_current_blog();
|
|
$this->go_to( '/' );
|
|
|
|
$this->assertEquals( $blog_url . '/wp-admin/admin-ajax.php', $ajax_url );
|
|
}
|
|
}
|
|
}
|