Index: wp-admin/includes/template.php
===================================================================
--- wp-admin/includes/template.php	(revision 33871)
+++ wp-admin/includes/template.php	(working copy)
@@ -169,16 +169,18 @@
  * @param array|string $args {
  *     Optional. Array or string of arguments for generating a terms checklist. Default empty array.
  *
- *     @type int    $descendants_and_self ID of the category to output along with its descendants.
- *                                        Default 0.
- *     @type array  $selected_cats        List of categories to mark as checked. Default false.
- *     @type array  $popular_cats         List of categories to receive the "popular-category" class.
- *                                        Default false.
- *     @type object $walker               Walker object to use to build the output.
- *                                        Default is a Walker_Category_Checklist instance.
- *     @type string $taxonomy             Taxonomy to generate the checklist for. Default 'category'.
- *     @type bool   $checked_ontop        Whether to move checked items out of the hierarchy and to
- *                                        the top of the list. Default true.
+ *     @type int      $descendants_and_self ID of the category to output along with its descendants.
+ *                                          Default 0.
+ *     @type array    $selected_cats        List of categories to mark as checked. Default false.
+ *     @type array    $popular_cats         List of categories to receive the "popular-category" class.
+ *                                          Default false.
+ *     @type object   $walker               Walker object to use to build the output.
+ *                                          Default is a Walker_Category_Checklist instance.
+ *     @type string   $taxonomy             Taxonomy to generate the checklist for. Default 'category'.
+ *     @type bool     $checked_ontop        Whether to move checked items out of the hierarchy and to
+ *                                          the top of the list. Default true.
+ *     @type bool|int $echo                 Whether to echo or return the generated markup. Accepts 0, 1, or their
+ *                                          bool equivalents. Default 1.
  * }
  */
 function wp_terms_checklist( $post_id = 0, $args = array() ) {
@@ -188,7 +190,8 @@
 		'popular_cats' => false,
 		'walker' => null,
 		'taxonomy' => 'category',
-		'checked_ontop' => true
+		'checked_ontop' => true,
+		'echo' => 1
 	);
 
 	/**
@@ -251,6 +254,8 @@
 		$categories = (array) get_terms( $taxonomy, array( 'get' => 'all' ) );
 	}
 
+	$output = '';
+
 	if ( $r['checked_ontop'] ) {
 		// Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
 		$checked_categories = array();
@@ -264,10 +269,16 @@
 		}
 
 		// Put checked cats on top
-		echo call_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) );
+		$output .= call_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) );
 	}
 	// Then the rest of them
-	echo call_user_func_array( array( $walker, 'walk' ), array( $categories, 0, $args ) );
+	$output .= call_user_func_array( array( $walker, 'walk' ), array( $categories, 0, $args ) );
+
+	if( $r['echo'] ){
+		echo $output;
+	}
+
+	return $output;
 }
 
 /**
