Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(revision 24155)
+++ wp-includes/media.php	(working copy)
@@ -1906,24 +1906,37 @@
  * @param int $limit Optional. The number of medias to return
  * @return array A list of parsed shortcodes or extracted srcs
  */
-function get_content_media( $type, &$content, $html = true, $remove = false, $limit = 0 ) {
+function get_content_media( $args = array() ) {
+	$defaults = array(
+		'type'                => null,
+		'content'             => &$content,
+		'return_html'         => true,
+		'remove_from_content' => false,
+		'media_count'         => 0
+	);
+	
+	$args = wp_parse_args( $args, $defaults );
+	
+	if ( null == $args['type'] )
+		return;
+
 	$items = array();
 
-	if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
+	if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $args['content'], $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
 		foreach ( $matches as $shortcode ) {
-			if ( $type === $shortcode[2] ) {
+			if ( $args['type'] === $shortcode[2] ) {
 				$count = 1;
-				if ( $remove )
-					$content =& str_replace( $shortcode[0], '', $content, $count );
+				if ( $args['remove_from_content'] )
+					$args['content'] =& str_replace( $shortcode[0], '', $args['content'], $count );
 
 				$items[] = do_shortcode_tag( $shortcode );
-				if ( $limit > 0 && count( $items ) >= $limit )
+				if ( $args['media_count'] > 0 && count( $items ) >= $args['media_count'] )
 					break;
 			}
 		}
 	}
 
-	if ( $html )
+	if ( $args['return_html'] )
 		return $items;
 
 	$data = array();
@@ -1948,34 +1961,46 @@
  *
  * @since 3.6.0
  *
- * @param string $type Type of media: audio or video
+ * @param array $args (optional) An array of arguments.
  * @param string $content A string which might contain media data.
  * @param boolean $remove Whether to remove the found URL from the passed content.
  * @param int $limit Optional. The number of galleries to return
  * @return array A list of found HTML media embeds and possibly a URL by itself
  */
-function get_embedded_media( $type, &$content, $remove = false, $limit = 0 ) {
+function get_embedded_media( $args = array() ) {
+	$defaults = array(
+		'type'                => null,
+		'content'             => &$content,
+		'remove_from_content' => false,
+		'media_count'         => 0 
+	);
+	
+	$args = wp_parse_args( $args, $defaults );
+	
+	if ( null == $args['type'] )
+		return;
+	
 	$html = array();
 
-	foreach ( array( $type, 'object', 'embed', 'iframe' ) as $tag ) {
-		if ( preg_match( '#' . get_tag_regex( $tag ) . '#', $content, $matches ) ) {
+	foreach ( array( $args['type'], 'object', 'embed', 'iframe' ) as $tag ) {
+		if ( preg_match( '#' . get_tag_regex( $tag ) . '#', $args['content'], $matches ) ) {
 			$html[] = $matches[0];
-			if ( $remove )
-				$content = str_replace( $matches[0], '', $content );
+			if ( $args['remove_from_content'] )
+				$args['content'] = str_replace( $matches[0], '', $args['content'] );
 
-			if ( $limit > 0 && count( $html ) >= $limit )
+			if ( $args['media_count'] > 0 && count( $html ) >= $args['media_count'] )
 				break;
 		}
 	}
 
-	if ( ! empty( $html ) && count( $html ) >= $limit )
+	if ( ! empty( $html ) && count( $html ) >= $args['media_count'] )
 		return $html;
 
-	$lines = explode( "\n", trim( $content ) );
+	$lines = explode( "\n", trim( $args['content'] ) );
 	$line = trim( array_shift( $lines  ) );
 	if ( 0 === stripos( $line, 'http' ) ) {
-		if ( $remove )
-			$content = join( "\n", $lines );
+		if ( $args['remove_from_content'] )
+			$args['content'] = join( "\n", $lines );
 
 		$html[] = $line;
 	}
@@ -1987,14 +2012,15 @@
  *
  * @since 3.6.0
  *
+ * @param array $args (optional) An array of arguments.
  * @param string $content A string which might contain audio data.
  * @param boolean $html Whether to return HTML or URLs
  * @param boolean $remove Whether to remove the found URL from the passed content.
  * @return array A list of lists. Each item has a list of HTML or srcs corresponding
  *		to an [audio]'s HTML or primary src and specified fallbacks
  */
-function get_content_audio( &$content, $html = true, $remove = false ) {
-	return get_content_media( 'audio', $content, $html, $remove );
+function get_content_audio( $args = array() ) {
+	return get_content_media( array_unshift( $args, array( 'type' => 'audio' ) ) );
 }
 
 /**
@@ -2007,8 +2033,8 @@
  * @param boolean $remove Whether to remove the found URL from the passed content.
  * @return array A list of found HTML audio embeds and possibly a URL by itself
  */
-function get_embedded_audio( &$content, $remove = false ) {
-	return get_embedded_media( 'audio', $content, $remove );
+function get_embedded_audio( $args = array() ) {
+	return get_embedded_media( array_unshift( $args, array( 'type' => 'audio' ) ) );
 }
 
 /**
@@ -2022,8 +2048,8 @@
  * @return array A list of lists. Each item has a list of HTML or srcs corresponding
  *		to a [video]'s HTML or primary src and specified fallbacks
  */
-function get_content_video( &$content, $html = true, $remove = false ) {
-	return get_content_media( 'video', $content, $html, $remove );
+function get_content_video( $args = array() ) {
+	return get_content_media( array_unshift( $args, array( 'type' => 'video' ) ) );
 }
 
 /**
@@ -2036,8 +2062,8 @@
  * @param boolean $remove Whether to remove the found URL from the passed content.
  * @return array A list of found HTML video embeds and possibly a URL by itself
  */
-function get_embedded_video( &$content, $remove = false ) {
-	return get_embedded_media( 'video', $content, $remove );
+function get_embedded_video( $args = array() ) {
+	return get_embedded_media( array_unshift( $args, array( 'type' => 'video' ) ) );
 }
 
 /**
@@ -2102,7 +2128,14 @@
 	// these functions expect a reference, so we should make a copy of post content to avoid changing it
 	$content = $post->post_content;
 
-	$htmls = get_content_media( $type, $content, true, true, $limit );
+	$htmls = get_content_media( array(
+		'type'                => $type,
+		'content'             => $content,
+		'return_html'         => true,
+		'remove_from_content' => true,
+		'media_count'         => $limit
+	) );
+
 	if ( ! empty( $htmls ) ) {
 		$html = reset( $htmls );
 		$post->split_content = $content;
@@ -2110,7 +2143,13 @@
 		return $post->format_content[ $cache_key ];
 	}
 
-	$embeds = get_embedded_media( $type, $content, true, 1 );
+	$embeds = get_embedded_media( array(
+		'type'                => $type,
+		'content'             => $content,
+		'remove_from_content' => true,
+		'media_count'         => 1
+	) );
+	
 	if ( ! empty( $embeds ) ) {
 		$embed = reset( $embeds );
 		$post->split_content = $content;
@@ -2202,25 +2241,34 @@
  * @param int $limit Optional. The number of image srcs to return
  * @return array The found images or srcs
  */
-function get_content_images( &$content, $html = true, $remove = false, $limit = 0 ) {
+function get_content_images( $args = array() ) {
+	$defaults = array(
+		'content'             => &$content,
+		'return_html'         => true,
+		'remove_from_content' => false,
+		'media_count'         => 0
+	);
+	
+	$args = wp_parse_args( $args, $defaults );
+
 	$tags = array();
 	$captions = array();
 
-	if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
+	if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $args['content'], $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
 		foreach ( $matches as $shortcode ) {
 			if ( 'caption' === $shortcode[2] ) {
 				$captions[] = $shortcode[0];
-				if ( $html )
+				if ( $args['return_html'] )
 					$tags[] = do_shortcode( $shortcode[0] );
 			}
 
-			if ( $limit > 0 && count( $tags ) >= $limit )
+			if ( $args['media_count'] > 0 && count( $tags ) >= $args['media_count'] )
 				break;
 		}
 	}
 
 	foreach ( array( 'a', 'img' ) as $tag ) {
-		if ( preg_match_all( '#' . get_tag_regex( $tag ) .  '#i', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
+		if ( preg_match_all( '#' . get_tag_regex( $tag ) .  '#i', $args['content'], $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
 			foreach ( $matches as $node ) {
 				if ( ! strstr( $node[0], '<img ' ) )
 					continue;
@@ -2231,24 +2279,24 @@
 				foreach ( $captions as $caption ) {
 					if ( strstr( $caption, $node[0] ) ) {
 						$found = true;
-						if ( $remove )
-							$content = str_replace( $caption, '', $content, $count );
+						if ( $args['remove_from_content'] )
+							$args['content'] = str_replace( $caption, '', $args['content'], $count );
 					}
 				}
 
-				if ( $remove )
-					$content = str_replace( $node[0], '', $content, $count );
+				if ( $args['remove_from_content'] )
+					$content = str_replace( $node[0], '', $args['content'], $count );
 
 				if ( ! $found )
 					$tags[] = $node[0];
 
-				if ( $limit > 0 && count( $tags ) >= $limit )
+				if ( $args['media_count'] > 0 && count( $tags ) >= $args['media_count'] )
 					break 2;
 			}
 		}
 	}
 
-	if ( $html )
+	if ( $args['return_html'] )
 		return $tags;
 
 	$srcs = array();
@@ -2257,12 +2305,12 @@
 		preg_match( '#src=[\'"](.+?)[\'"]#is', $tag, $src );
 		if ( ! empty( $src[1] ) ) {
 			$srcs[] = $src[1];
-			if ( $limit > 0 && count( $srcs ) >= $limit )
+			if ( $args['media_count'] > 0 && count( $srcs ) >= $args['media_count'] )
 				break;
 		}
 	}
 
-	return apply_filters( 'content_images', array_values( array_unique( $srcs ) ), $content );
+	return apply_filters( 'content_images', array_values( array_unique( $srcs ) ), $args['content'] );
 }
 
 /**
@@ -2275,12 +2323,20 @@
  * @param boolean $remove Whether to remove the found data from the passed content.
  * @return string The found data
  */
-function get_content_image( &$content, $html = true, $remove = false ) {
-	$srcs = get_content_images( $content, $html, $remove, 1 );
+function get_content_image( $args = array() ) {
+	$defaults = array(
+		'content' => &$content,
+		'return_html' => true,
+		'remove_from_content' => false
+	);
+	
+	$args = wp_parse_args( $args, $defaults );
+	
+	$srcs = get_content_images( array_merge( $args, array( 'media_count' => 1 ) ) );
 	if ( empty( $srcs ) )
 		return '';
 
-	return apply_filters( 'content_image', reset( $srcs ), $content );
+	return apply_filters( 'content_image', reset( $srcs ), $args['content'] );
 }
 
 /**
@@ -2294,20 +2350,29 @@
  * @param int $limit Optional. The number of galleries to return
  * @return array A list of galleries, which in turn are a list of their srcs in order
  */
-function get_content_galleries( &$content, $html = true, $remove = false, $limit = 0 ) {
+function get_content_galleries( $args = array() ) {
+	$defaults = array(
+		'content'             => &$content,
+		'return_html'         => true,
+		'remove_from_content' => false,
+		'media_count'         => 0
+	);
+	
+	$args = wp_parse_args( $args, $defaults );
+
 	$galleries = array();
 
-	if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
+	if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $args['content'], $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
 		foreach ( $matches as $shortcode ) {
 			if ( 'gallery' === $shortcode[2] ) {
 				$srcs = array();
 				$count = 1;
-				if ( $remove )
-					$content = str_replace( $shortcode[0], '', $content, $count );
+				if ( $args['remove_from_content'] )
+					$args['content'] = str_replace( $shortcode[0], '', $args['content'], $count );
 
 				$data = shortcode_parse_atts( $shortcode[3] );
 				$gallery = do_shortcode_tag( $shortcode );
-				if ( $html ) {
+				if ( $args['return_html'] ) {
 					$galleries[] = $gallery;
 				} else {
 					preg_match_all( '#src=[\'"](.+?)[\'"]#is', $gallery, $src, PREG_SET_ORDER );
@@ -2320,13 +2385,13 @@
 					$galleries[] = $data;
 				}
 
-				if ( $limit > 0 && count( $galleries ) >= $limit )
+				if ( $args['media_count'] > 0 && count( $galleries ) >= $args['media_count'] )
 					break;
 			}
 		}
 	}
 
-	return apply_filters( 'content_galleries', $galleries, $content );
+	return apply_filters( 'content_galleries', $galleries, $args['content'] );
 }
 
 /**
@@ -2339,12 +2404,24 @@
  * @return array A list of arrays, each containing gallery data and srcs parsed
  *		from the expanded shortcode
  */
-function get_post_galleries( $post_id = 0, $html = true ) {
-	$post = empty( $post_id ) ? clone get_post() : get_post( $post_id );
+function get_post_galleries( $args = array() ) {
+	$defaults = array(
+		'id'          => 0,
+		'return_html' => true
+	);
+	
+	$args = wp_parse_args( $args, $defaults );
+
+	$post = 0 == $args['id'] ? clone get_post() : get_post( $args['id'] );
 	if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' )  )
 		return array();
 
-	return get_content_galleries( $post->post_content, $html );
+	$galleries = get_content_galleries( array(
+		'content'     => $post->post_content,
+		'return_html' => $args['return_html']
+	) );
+	
+	return $galleries;
 }
 
 /**
@@ -2361,7 +2438,11 @@
 	if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' )  )
 		return array();
 
-	$data = get_content_galleries( $post->post_content, false );
+	$data = get_content_galleries( array(
+		'content'     => $post->post_content,
+		'return_html' => false
+	) );
+
 	return wp_list_pluck( $data, 'src' );
 }
 
@@ -2374,12 +2455,25 @@
  * @param boolean $html Whether to return HTML or data
  * @return array Gallery data and srcs parsed from the expanded shortcode
  */
-function get_post_gallery( $post_id = 0, $html = true ) {
-	$post = empty( $post_id ) ? clone get_post() : get_post( $post_id );
+function get_post_gallery( $args = array() ) {
+	$defaults = array(
+		'id'          => 0,
+		'return_html' => true
+	);
+	
+	$args = wp_parse_args( $args, $defaults );
+
+	$post = 0 == $args['id'] ? clone get_post() : get_post( $args['id'] );
 	if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' ) )
 		return array();
 
-	$data = get_content_galleries( $post->post_content, $html, false, 1 );
+	$data = get_content_galleries( array(
+		'content'             => $post->post_content,
+		'return_html'         => $args['return_html'],
+		'remove_from_content' => false,
+		'media_count'         => 1
+	) );
+
 	return reset( $data );
 }
 
@@ -2401,7 +2495,11 @@
  * @return array A list of a gallery's image srcs in order
  */
 function get_post_gallery_images( $post_id = 0 ) {
-	$gallery = get_post_gallery( $post_id, false );
+	$gallery = get_post_gallery( array(
+		'id'          => $post_id,
+		'return_html' => false
+	) );
+
 	if ( empty( $gallery['src'] ) )
 		return array();
 
@@ -2529,7 +2627,13 @@
 	}
 
 	$content = $post->post_content;
-	$htmls = get_content_images( $content, true, true, 1 );
+	$htmls = get_content_images( array(
+		'content'             => $content,
+		'return_html'         => true,
+		'remove_from_content' => true,
+		'media_count'         => 1
+	) );
+
 	if ( ! empty( $htmls ) ) {
 		$html = reset( $htmls );
 		$post->split_content = $content;
Index: wp-includes/post-formats.php
===================================================================
--- wp-includes/post-formats.php	(revision 24155)
+++ wp-includes/post-formats.php	(working copy)
@@ -353,11 +353,11 @@
 				if ( ! preg_match( '#' . $esc_url . '[^/&\?]?#', $content ) ) {
 					$url = $meta['link_url'];
 				} else {
-					$url = get_content_url( $content, true );
+					$url = get_content_url( array( 'content' => $content, 'remove_from_content' => true ) );
 				}
 			} else {
 				$content_before = $content;
-				$url = get_content_url( $content, true );
+				$url = get_content_url( array( 'content' => $content, 'remove_from_content' => true ) );
 				if ( $content_before == $content )
 					$url = '';
 			}
@@ -529,10 +529,17 @@
  * @param boolean $remove Whether to remove the found data from the passed content.
  * @return array A chat log as structured data
  */
-function get_content_chat( &$content, $remove = false ) {
+function get_content_chat( $args = array() ) {
 	global $_wp_chat_parsers;
 
-	$trimmed = strip_tags( trim( $content ) );
+	$defaults = array(
+		'content'             => &$content,
+		'remove_from_content' => false
+	);
+
+	$args = wp_parse_args( $args, $defaults );
+
+	$trimmed = strip_tags( trim( $args['content'] ) );
 	if ( empty( $trimmed ) )
 		return array();
 
@@ -620,7 +627,7 @@
 	if ( ! empty( $stanza ) )
 		$stanzas[] = $stanza;
 
-	if ( $remove ) {
+	if ( $args['remove_from_content'] ) {
 		if ( 0 === $found_index ) {
 			$removed = array_slice( $lines, $last_index );
 		} else {
@@ -628,7 +635,7 @@
 			$after = array_slice( $lines, $last_index + 1 );
 			$removed = array_filter( array_merge( $before, $after ) );
 		}
-		$content = trim( join( "\n", $removed ) );
+		$args['content'] = trim( join( "\n", $removed ) );
 	}
 
 	return $stanzas;
@@ -639,15 +646,15 @@
  *
  * @since 3.6.0
  *
- * @param int $id (optional) The post ID.
+ * @param int $post_id (optional) The post ID.
  * @return array The chat content.
  */
-function get_the_post_format_chat( $id = 0 ) {
-	$post = empty( $id ) ? clone get_post() : get_post( $id );
+function get_the_post_format_chat( $post_id = 0 ) {
+	$post = empty( $post_id ) ? clone get_post() : get_post( $post_id );
 	if ( empty( $post ) )
 		return array();
 
-	$data = get_content_chat( get_paged_content( $post->post_content ) );
+	$data = get_content_chat( array( 'content' => get_paged_content( $post->post_content ) ) );
 	if ( empty( $data ) )
 		return array();
 
@@ -704,19 +711,27 @@
  * @param string $replace (optional) Content to replace the quote content with.
  * @return string The quote content.
  */
-function get_content_quote( &$content, $remove = false, $replace = '' ) {
-	if ( empty( $content ) )
+function get_content_quote( $args = array() ) {
+	$defaults = array(
+		'content' => &$content,
+		'remove_from_content' => false,
+		'replace_with' => ''
+	);
+	
+	$args = wp_parse_args( $args, $defaults );
+	
+	if ( empty( $args['content'] ) )
 		return '';
 
-	if ( ! preg_match( '/<blockquote[^>]*>(.+?)<\/blockquote>/is', $content, $matches ) ) {
-		$quote = $content;
-		if ( $remove || ! empty( $replace ) )
-			$content = $replace;
+	if ( ! preg_match( '/<blockquote[^>]*>(.+?)<\/blockquote>/is', $args['content'], $matches ) ) {
+		$quote = $args['content'];
+		if ( $args['remove_from_content'] || ! empty( $args['replace_with'] ) )
+			$args['content'] = $args['replace_with'];
 		return $quote;
 	}
 
-	if ( $remove || ! empty( $replace ) )
-		$content = preg_replace( '/<blockquote[^>]*>(.+?)<\/blockquote>/is', addcslashes( $replace, '\\$' ), $content, 1 );
+	if ( $args['remove_from_content'] || ! empty( $args['replace_with'] ) )
+		$args['content'] = preg_replace( '/<blockquote[^>]*>(.+?)<\/blockquote>/is', addcslashes( $args['replace_with'], '\\$' ), $args['content'], 1 );
 
 	return $matches[1];
 }
@@ -739,7 +754,11 @@
 		return '';
 
 	$content = $post->post_content;
-	$quote = get_content_quote( $content, true );
+	$quote = get_content_quote( array( 
+		'content'             => $content,
+		'remove_from_content' => true
+	) );
+
 	$post->split_content = $content;
 
 	if ( ! empty( $quote ) )
@@ -778,18 +797,25 @@
  * @return string The found URL.
  */
 function get_content_url( &$content, $remove = false ) {
-	if ( empty( $content ) )
+	$defaults = array(
+		'content'             => &$content,
+		'remove_from_content' => false
+	);
+	
+	$args = wp_parse_args( $args, $defaults );
+	
+	if ( empty( $args['content'] ) )
 		return '';
 
 	// the content is a URL
-	$trimmed = trim( $content );
+	$trimmed = trim( $args['content'] );
 	if ( 0 === stripos( $trimmed, 'http' ) && ! preg_match( '#\s#', $trimmed ) ) {
-		if ( $remove )
-			$content = '';
+		if ( $args['remove_from_content'] )
+			$args['content'] = '';
 
 		return $trimmed;
 	// the content is HTML so we grab the first href
-	} elseif ( preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', $content, $matches ) ) {
+	} elseif ( preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', $args['content'], $matches ) ) {
 		return esc_url_raw( $matches[1] );
 	}
 
@@ -798,8 +824,8 @@
 
 	// the content is a URL followed by content
 	if ( 0 === stripos( $line, 'http' ) ) {
-		if ( $remove )
-			$content = trim( join( "\n", $lines ) );
+		if ( $args['remove_from_content'] )
+			$args['content'] = trim( join( "\n", $lines ) );
 
 		return esc_url_raw( $line );
 	}
@@ -845,7 +871,7 @@
 	}
 
 	if ( ! empty( $post->post_content ) )
-		return apply_filters( 'get_the_post_format_url', get_content_url( $post->post_content ), $post );
+		return apply_filters( 'get_the_post_format_url', get_content_url( array( 'content' => $post->post_content ) ), $post );
 }
 
 /**
