Code Duplication    Length = 5-6 lines in 2 locations

json-endpoints/class.wpcom-json-api-menus-v1-1-endpoint.php 2 locations

@@ 218-223 (lines=6) @@
215
		foreach ( $menus as &$menu ) {
216
			$widget_locations = array();
217
218
			foreach ( $nav_menu_widgets as $key => $widget ) {
219
				if ( is_array( $widget ) && isset( $widget['nav_menu'] ) &&
220
				    $widget['nav_menu'] === $menu['id'] ) {
221
					$widget_locations[] = 'nav_menu_widget-' . $key;
222
				}
223
			}
224
			$menu['locations'] = array_merge( $menu['locations'], $widget_locations );
225
		}
226
@@ 416-420 (lines=5) @@
413
		}
414
415
		// Remove menus from all custom menu widget locations
416
		foreach ( $nav_menu_widgets as &$widget ) {
417
			if ( is_array( $widget ) && isset( $widget['nav_menu'] ) &&  $widget['nav_menu'] == $menu_id ) {
418
				$widget['nav_menu'] = 0;
419
			}
420
		}
421
422
		if ( is_array( $locations ) ) {
423
			foreach ( $locations as $location ) {