bp_admin_forum_repair_tools_wrapper_function()

Wrapper function to handle Repair Forums all the actions.

Description

Source

File: bp-forums/admin/tools.php

function bp_admin_forum_repair_tools_wrapper_function() {

	$type = isset( $_POST['type'] ) ? $_POST['type'] : '';

	$response = array(
		'feedback' => sprintf(
			'<div class="bp-feedback error bp-ajax-message"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>',
			esc_html__( 'There was a problem performing this action. Please try again.', 'buddyboss' )
		),
	);

	// Bail if not a POST action.
	if ( ! bp_is_post_request() ) {
		wp_send_json_error( $response );
	}

	if ( empty( $_POST['nonce'] ) ) {
		wp_send_json_error( $response );
	}

	// Use default nonce
	$nonce = $_POST['nonce'];
	$check = 'bbpress-do-counts';

	// Nonce check!
	if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, $check ) ) {
		wp_send_json_error( $response );
	}

	if( is_multisite() && bp_is_network_activated() ){
		switch_to_blog( $_POST['site_id'] );
	}

	if ( 'bbp-sync-topic-meta' === $type ) {
		$status = bbp_admin_repair_topic_meta();
	} elseif ( 'bbp-sync-forum-meta' === $type ) {
		$status = bbp_admin_repair_forum_meta();
	} elseif ( 'bbp-sync-forum-visibility' === $type ) {
		$status = bbp_admin_repair_forum_visibility();
	} elseif ( 'bbp-sync-all-topics-forums' === $type ) {
		$status = bbp_admin_repair_freshness();
	} elseif ( 'bbp-sync-all-topics-sticky' === $type ) {
		$status = bbp_admin_repair_sticky();
	} elseif ( 'bbp-sync-all-reply-positions' === $type ) {
		$status = bbp_admin_repair_reply_menu_order();
	} elseif ( 'bbp-group-forums' === $type ) {
		$status = bbp_admin_repair_group_forum_relationship();
	} elseif ( 'bbp-forum-topics' === $type ) {
		$status = bbp_admin_repair_forum_topic_count();
	} elseif ( 'bbp-forum-replies' === $type ) {
		$status = bbp_admin_repair_forum_reply_count();
	} elseif ( 'bbp-topic-replies' === $type ) {
		$status = bbp_admin_repair_topic_reply_count();
	} elseif ( 'bbp-topic-members' === $type ) {
		$status = bbp_admin_repair_topic_voice_count();
	} elseif ( 'bbp-topic-hidden-replies' === $type ) {
		$status = bbp_admin_repair_topic_hidden_reply_count();
	} elseif ( 'bbp-user-topics' === $type ) {
		$status = bbp_admin_repair_user_topic_count();
	} elseif ( 'bbp-user-replies' === $type ) {
		$status = bbp_admin_repair_user_reply_count();
	} elseif ( 'bbp-user-favorites' === $type ) {
		$status = bbp_admin_repair_user_favorites();
	} elseif ( 'bbp-user-topic-subscriptions' === $type ) {
		$status = bbp_admin_repair_user_topic_subscriptions();
	} elseif ( 'bbp-user-forum-subscriptions' === $type ) {
		$status = bbp_admin_repair_user_forum_subscriptions();
	} elseif ( 'bbp-user-role-map' === $type ) {
		$status = bbp_admin_repair_user_roles();
	} elseif ( 'bbp-wp-role-restore' === $type ) {
		$status = bbp_restore_caps_from_wp_roles();
	}

	if( is_multisite() && bp_is_network_activated() ) {
		restore_current_blog();
	}

	if ( 0 === $status['status'] ) {
		wp_send_json_error( $status );
	} else {
		wp_send_json_success( $status );
	}
}

Changelog

Changelog
Version Description
BuddyBoss 1.1.8 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.