private function handle_reassign_sites() {
		$to   = array_map( 'absint', (array) filter_input( INPUT_POST, 'to', FILTER_FORCE_ARRAY ) );
		$from = array_map( 'absint', (array) filter_input( INPUT_POST, 'from', FILTER_FORCE_ARRAY ) );

		// Bail early if no movement.
		if ( empty( $to ) && empty( $from ) ) {
			return;
		}

		$network_id = filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );

		$moving_to   = array();
		$moving_from = array();

		$sites_list = get_sites( array(
			'network_id' => $network_id,
			'fields'     => 'ids',
		) );

		// Move sites out of current network.
		foreach ( $from as $site_id ) {
			if ( in_array( $site_id, $sites_list, true ) ) {
				$moving_from[] = $site_id;
			}
		}

		// Move sites into current network.
		foreach ( $to as $site_id ) {
			if ( ! in_array( $site_id, $sites_list, true ) ) {
				$moving_to[] = $site_id;
			}
		}

		$moving = array_filter( array_merge( $moving_to, $moving_from ) );

		// Loop through and move sites.
		foreach ( $moving as $site_id ) {
			$site = get_site( $site_id );

			// Skip if missing or main site.
			if ( empty( $site ) || is_main_site( $site->id, $site->network_id ) ) {
				continue;
			}

			if ( in_array( $site_id, $to, true ) && ! in_array( $site_id, $sites_list, true ) ) {
				move_site( $site_id, $network_id );
			} elseif ( in_array( $site_id, $from, true ) ) {
				move_site( $site_id, 0 );
			}
		}
	}
private function handle_reassign_sites() {
		$to   = array_map( 'absint', (array) filter_input( INPUT_POST, 'to', FILTER_FORCE_ARRAY ) );
		$from = array_map( 'absint', (array) filter_input( INPUT_POST, 'from', FILTER_FORCE_ARRAY ) );

		// Bail early if no movement.
		if ( empty( $to ) && empty( $from ) ) {
			return;
		}

		$network_id = filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );

		$moving_to   = array();
		$moving_from = array();

		$sites_list = get_sites( array(
			'network_id' => $network_id,
			'fields'     => 'ids',
		) );

		// Move sites out of current network.
		foreach ( $from as $site_id ) {
			if ( in_array( $site_id, $sites_list, true ) ) {
				$moving_from[] = $site_id;
			}
		}

		// Move sites into current network.
		foreach ( $to as $site_id ) {
			if ( ! in_array( $site_id, $sites_list, true ) ) {
				$moving_to[] = $site_id;
			}
		}

		$moving = array_filter( array_merge( $moving_to, $moving_from ) );

		// Loop through and move sites.
		foreach ( $moving as $site_id ) {
			$site = get_site( $site_id );

			// Skip if missing or main site.
			if ( empty( $site ) || is_main_site( $site->id, $site->network_id ) ) {
				continue;
			}

			if ( in_array( $site_id, $to, true ) && ! in_array( $site_id, $sites_list, true ) ) {
				move_site( $site_id, $network_id );
			} elseif ( in_array( $site_id, $from, true ) ) {
				move_site( $site_id, 0 );
			}
		}
	}
private function handle_reassign_sites ( ) { $ to = array_map ( 'absint' , ( array ) filter_input ( INPUT_POST , 'to' , FILTER_FORCE_ARRAY ) ) ; $ from = array_map ( 'absint' , ( array ) filter_input ( INPUT_POST , 'from' , FILTER_FORCE_ARRAY ) ) ; // Bail early if no movement. if ( empty ( $ to ) && empty ( $ from ) ) { return ; } $ network_id = filter_input ( INPUT_GET , 'id' , FILTER_SANITIZE_NUMBER_INT ) ; $ moving_to = array ( ) ; $ moving_from = array ( ) ; $ sites_list = get_sites ( array ( 'network_id' => $ network_id , 'fields' => 'ids' , ) ) ; // Move sites out of current network. foreach ( $ from as $ site_id ) { if ( in_array ( $ site_id , $ sites_list , true ) ) { $ moving_from [ ] = $ site_id ; } } // Move sites into current network. foreach ( $ to as $ site_id ) { if ( ! in_array ( $ site_id , $ sites_list , true ) ) { $ moving_to [ ] = $ site_id ; } } $ moving = array_filter ( array_merge ( $ moving_to , $ moving_from ) ) ; // Loop through and move sites. foreach ( $ moving as $ site_id ) { $ site = get_site ( $ site_id ) ; // Skip if missing or main site. if ( empty ( $ site ) || is_main_site ( $ site -> id , $ site -> network_id ) ) { continue ; } if ( in_array ( $ site_id , $ to , true ) && ! in_array ( $ site_id , $ sites_list , true ) ) { move_site ( $ site_id , $ network_id ) ; } elseif ( in_array ( $ site_id , $ from , true ) ) { move_site ( $ site_id , 0 ) ; } } }
Handles the request to reassign sites to another network.

@since 2.0.0
Handles the request to reassign sites to another network .