本文整理汇总了PHP中wpmu_delete_blog函数的典型用法代码示例。如果您正苦于以下问题:PHP wpmu_delete_blog函数的具体用法?PHP wpmu_delete_blog怎么用?PHP wpmu_delete_blog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpmu_delete_blog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_follow_and_delete_blog
/**
* @group delete
*/
public function test_follow_and_delete_blog()
{
if (!is_multisite()) {
return;
}
// create user and blog
$u = $this->factory->user->create();
$b = $this->factory->blog->create(array('title' => 'The Foo Bar Blog', 'user_id' => $u));
// make blog creator follow own blog
$f = bp_follow_start_following(array('leader_id' => $b, 'follower_id' => $u, 'follow_type' => 'blogs'));
// assert that follow relationship worked
$this->assertTrue($f);
// now delete blog
wpmu_delete_blog($b);
// check if cache was deleted
$this->assertEmpty(wp_cache_get($u, 'bp_follow_following_blogs_count'));
$this->assertEmpty(wp_cache_get($b, 'bp_follow_followers_blogs_count'));
// check if follow relationship was deleted
$is_following = bp_follow_is_following(array('leader_id' => $b, 'follower_id' => $u, 'follow_type' => 'blogs'));
$this->assertSame(0, $is_following);
}
示例2: test_upload_directories_after_multiple_wpmu_delete_blog_with_ms_files
/**
* When a site is deleted with wpmu_delete_blog(), only the files associated with
* that site should be removed. When wpmu_delete_blog() is run a second time, nothing
* should change with upload directories.
*/
function test_upload_directories_after_multiple_wpmu_delete_blog_with_ms_files() {
$filename = rand_str().'.jpg';
$contents = rand_str();
// Upload a file to the main site on the network.
$file1 = wp_upload_bits( $filename, null, $contents );
$blog_id = $this->factory->blog->create();
switch_to_blog( $blog_id );
$file2 = wp_upload_bits( $filename, null, $contents );
restore_current_blog();
wpmu_delete_blog( $blog_id, true );
// The file on the main site should still exist. The file on the deleted site should not.
$this->assertTrue( file_exists( $file1['file'] ) );
$this->assertFalse( file_exists( $file2['file'] ) );
wpmu_delete_blog( $blog_id, true );
// The file on the main site should still exist. The file on the deleted site should not.
$this->assertTrue( file_exists( $file1['file'] ) );
$this->assertFalse( file_exists( $file2['file'] ) );
}
示例3: wpTearDownAfterClass
public static function wpTearDownAfterClass()
{
foreach (self::$site_ids as $id) {
wpmu_delete_blog($id, true);
}
wp_update_network_site_counts();
}
示例4: tearDown
public function tearDown()
{
global $wpdb;
remove_action('bp_blogs_recorded_existing_blogs', array($this, 'set_autocommit_flag'));
parent::tearDown();
// If we detect that a COMMIT has been triggered during the test, clean up blog and user fixtures.
if ($this->autocommitted) {
if (is_multisite()) {
foreach ($wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs} WHERE blog_id != 1") as $blog_id) {
wpmu_delete_blog($blog_id, true);
}
}
foreach ($wpdb->get_col("SELECT ID FROM {$wpdb->users} WHERE ID != 1") as $user_id) {
if (is_multisite()) {
wpmu_delete_user($user_id);
} else {
wp_delete_user($user_id);
}
}
}
$this->commit_transaction();
// Reactivate any components that have been deactivated.
foreach ($this->deactivated_components as $component) {
buddypress()->active_components[$component] = 1;
}
$this->deactivated_components = array();
}
示例5: wpTearDownAfterClass
public static function wpTearDownAfterClass()
{
self::delete_user(self::$user);
self::delete_user(self::$editor);
if (is_multisite()) {
wpmu_delete_blog(self::$site, true);
}
}
示例6: remove_blog
/**
* Removes completely a blog from the network
* @since 0.2.0
* @param int $blog_id the blog id
*/
public static function remove_blog($blog_id)
{
switch_to_blog($blog_id);
$wp_upload_info = wp_upload_dir();
$dir = str_replace(' ', "\\ ", trailingslashit($wp_upload_info['basedir']));
restore_current_blog();
wpmu_delete_blog($blog_id, true);
// wpmu_delete_blog leaves an empty site upload directory, that we want to remove :
MUCD_Files::rrmdir($dir);
}
示例7: test_get_active_blog_for_user_with_spam_site
/**
* @ticket 38355
*/
public function test_get_active_blog_for_user_with_spam_site()
{
$current_site_id = get_current_blog_id();
$site_id = self::factory()->blog->create(array('user_id' => self::$user_id, 'meta' => array('spam' => 1)));
add_user_to_blog($site_id, self::$user_id, 'subscriber');
update_user_meta(self::$user_id, 'primary_blog', $site_id);
$result = get_active_blog_for_user(self::$user_id);
wpmu_delete_blog($site_id, true);
$this->assertEquals($current_site_id, $result->id);
}
示例8: tearDown
function tearDown()
{
parent::tearDown();
if (is_multisite()) {
$blogs = wp_get_sites();
foreach ($blogs as $blog) {
if (1 !== (int) $blog['blog_id']) {
wpmu_delete_blog($blog['blog_id'], true);
}
}
}
}
示例9: wpTearDownAfterClass
public static function wpTearDownAfterClass()
{
global $wpdb;
foreach (self::$site_ids as $id) {
wpmu_delete_blog($id, true);
}
foreach (self::$network_ids as $id) {
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->site} WHERE id= %d", $id));
}
wp_update_network_site_counts();
}
示例10: test_get_dashboard_url_for_administrator_of_different_site
/**
* @ticket 39065
*/
public function test_get_dashboard_url_for_administrator_of_different_site()
{
if (!is_multisite()) {
$this->markTestSkipped('Test only runs in multisite.');
}
$site_id = self::factory()->blog->create(array('user_id' => self::$user_id));
remove_user_from_blog(self::$user_id, get_current_blog_id());
$expected = get_admin_url($site_id);
$result = get_dashboard_url(self::$user_id);
remove_user_from_blog(self::$user_id, $site_id);
add_user_to_blog(get_current_blog_id(), self::$user_id, 'administrator');
wpmu_delete_blog($site_id, true);
$this->assertEquals($expected, $result);
}
示例11: tearDown
public function tearDown()
{
global $wpdb;
parent::tearDown();
if (is_multisite()) {
foreach ($wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs} WHERE blog_id != 1") as $blog_id) {
wpmu_delete_blog($blog_id, true);
}
}
foreach ($wpdb->get_col("SELECT ID FROM {$wpdb->users} WHERE ID != 1") as $user_id) {
if (is_multisite()) {
wpmu_delete_user($user_id);
} else {
wp_delete_user($user_id);
}
}
$this->commit_transaction();
}
示例12: test_upload_directories_after_multiple_wpmu_delete_blog_with_ms_files
/**
* When a site is deleted with wpmu_delete_blog(), only the files associated with
* that site should be removed. When wpmu_delete_blog() is run a second time, nothing
* should change with upload directories.
*/
function test_upload_directories_after_multiple_wpmu_delete_blog_with_ms_files()
{
$filename = __FUNCTION__ . '.jpg';
$contents = __FUNCTION__ . '_contents';
// Upload a file to the main site on the network.
$file1 = wp_upload_bits($filename, null, $contents);
$blog_id = self::factory()->blog->create();
switch_to_blog($blog_id);
$file2 = wp_upload_bits($filename, null, $contents);
restore_current_blog();
wpmu_delete_blog($blog_id, true);
// The file on the main site should still exist. The file on the deleted site should not.
$this->assertFileExists($file1['file']);
$this->assertFileNotExists($file2['file']);
wpmu_delete_blog($blog_id, true);
// The file on the main site should still exist. The file on the deleted site should not.
$this->assertFileExists($file1['file']);
$this->assertFileNotExists($file2['file']);
}
示例13: test_enable_live_network_site_counts_filter
/**
* @ticket 22917
*/
function test_enable_live_network_site_counts_filter() {
$site_count_start = get_blog_count();
// false for large networks by default
add_filter( 'enable_live_network_counts', '__return_false' );
$this->factory->blog->create_many( 4 );
// count only updated when cron runs, so unchanged
$this->assertEquals( $site_count_start, (int) get_blog_count() );
add_filter( 'enable_live_network_counts', '__return_true' );
$site_ids = $this->factory->blog->create_many( 4 );
$this->assertEquals( $site_count_start + 9, (int) get_blog_count() );
//clean up
remove_filter( 'enable_live_network_counts', '__return_false' );
remove_filter( 'enable_live_network_counts', '__return_true' );
foreach ( $site_ids as $site_id ) {
wpmu_delete_blog( $site_id, true );
}
}
示例14: test_follow_and_delete_blog
/**
* @group delete
*/
public function test_follow_and_delete_blog()
{
if (!is_multisite()) {
return;
}
// create user and blog
$u = $this->factory->user->create();
$b = $this->factory->blog->create(array('title' => 'The Foo Bar Blog', 'user_id' => $u));
// make blog creator follow own blog
$f = bp_follow_start_following(array('leader_id' => $b, 'follower_id' => $u, 'follow_type' => 'blogs'));
// assert that follow relationship worked
$this->assertTrue($f);
// prime cache
new BP_Follow($b, $u, 'blogs');
bp_follow_get_the_following_count(array('user_id' => $u, 'follow_type' => 'blogs'));
bp_follow_get_the_followers_count(array('object_id' => $b, 'follow_type' => 'blogs'));
// now delete blog
wpmu_delete_blog($b);
// check if cache was deleted
$this->assertEmpty(wp_cache_get("{$b}:{$u}:blogs", 'bp_follow_data'));
$this->assertEmpty(wp_cache_get($u, 'bp_follow_user_blogs_following_count'));
$this->assertEmpty(wp_cache_get($b, 'bp_follow_blogs_followers_count'));
}
示例15: delete_network
/**
* Delete a network and all its blogs
*
* @param integer id ID of network to delete
* @param boolean $delete_blogs Flag to permit blog deletion - default setting
* of false will prevent deletion of occupied networks
*/
function delete_network($id, $delete_blogs = false)
{
global $wpdb;
$id = (int) $id;
// Ensure we have a valid network id
$network = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->site} WHERE id = %d", $id));
// Bail if network does not exist
if (empty($network)) {
return new WP_Error('network_not_exist', __('Network does not exist.', 'wp-multi-network'));
}
// ensure there are no blogs attached to this network */
$sites = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE site_id = %d", $id));
// Bail if network has blogs and blog deletion is off
if (false == $delete_blogs && !empty($sites)) {
return new WP_Error('network_not_empty', __('Cannot delete network with sites.', 'wp-multi-network'));
}
// Are we rescuing orphans or deleting them?
if (true == $delete_blogs && !empty($sites)) {
foreach ($sites as $site) {
if (RESCUE_ORPHANED_BLOGS && ENABLE_NETWORK_ZERO) {
move_site($site->blog_id, 0);
} else {
wpmu_delete_blog($site->blog_id, true);
}
}
}
// Delete from sites table
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->site} WHERE id = %d", $id));
// Delete from site meta table
$wpdb->query($wpdb->prepare($query = "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id));
do_action('delete_network', $network);
}