Index: wp-includes/post-formats.php
===================================================================
--- wp-includes/post-formats.php	(revision 24177)
+++ 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( $content, array( 'remove' => true ) );
 				}
 			} else {
 				$content_before = $content;
-				$url = get_content_url( $content, true );
+				$url = get_content_url( $content, array( 'remove' => true ) );
 				if ( $content_before == $content )
 					$url = '';
 			}
@@ -418,8 +418,12 @@
 			$quote = get_the_post_format_quote( $post );
 
 			// Replace the existing quote in-place.
-			if ( ! empty( $quote ) )
-				get_content_quote( $content, true, $quote );
+			if ( ! empty( $quote ) ) {
+				get_content_quote( $content, array(
+					'remove'  => true,
+					'replace' => $quote,
+				) );
+			}
 			break;
 
 		case 'video':
@@ -523,15 +527,24 @@
  *     )
  * )
  *
+ * $args contents:
+ * - remove - Whether to remove the found data from the passed content.
+ *
  * @since 3.6.0
  *
  * @param string $content A string which might contain chat data, passed by reference.
- * @param boolean $remove Whether to remove the found data from the passed content.
+ * @param array $args (optional) arguments.
  * @return array A chat log as structured data
  */
-function get_content_chat( &$content, $remove = false ) {
+function get_content_chat( &$content, $args = array() ) {
 	global $_wp_chat_parsers;
 
+	$defaults = array(
+		'remove' => false,
+	);
+
+	$args = wp_parse_args( $args, $defaults );
+
 	$trimmed = strip_tags( trim( $content ) );
 	if ( empty( $trimmed ) )
 		return array();
@@ -620,7 +633,7 @@
 	if ( ! empty( $stanza ) )
 		$stanzas[] = $stanza;
 
-	if ( $remove ) {
+	if ( $args['remove'] ) {
 		if ( 0 === $found_index ) {
 			$removed = array_slice( $lines, $last_index );
 		} else {
@@ -639,15 +652,18 @@
  *
  * @since 3.6.0
  *
- * @param int $id (optional) The post ID.
+ * @uses get_content_chat()
+ *
+ * @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 ) );
+	$content = get_paged_content( $post->post_content );
+	$data = get_content_chat( $content );
 	if ( empty( $data ) )
 		return array();
 
@@ -697,26 +713,36 @@
  * If $content does not have a blockquote, assume the whole string
  * is the quote.
  *
+ * $args contents:
+ * - remove - Whether to remove the quote from the content.
+ * - replace - Content to replace the quote content with.
+ *
  * @since 3.6.0
  *
  * @param string $content A string which might contain chat data, passed by reference.
- * @param bool $remove (optional) Whether to remove the quote from the content.
- * @param string $replace (optional) Content to replace the quote content with.
+ * @param array $args An optional array of arguments.
  * @return string The quote content.
  */
-function get_content_quote( &$content, $remove = false, $replace = '' ) {
+function get_content_quote( &$content, $args = array() ) {
+	$defaults = array(
+		'remove'  => false,
+		'replace' => '',
+	);
+
+	$args = wp_parse_args( $args, $defaults );
+
 	if ( empty( $content ) )
 		return '';
 
 	if ( ! preg_match( '/<blockquote[^>]*>(.+?)<\/blockquote>/is', $content, $matches ) ) {
 		$quote = $content;
-		if ( $remove || ! empty( $replace ) )
-			$content = $replace;
+		if ( $args['remove'] || ! empty( $args['replace'] ) )
+			$content = $args['replace'];
 		return $quote;
 	}
 
-	if ( $remove || ! empty( $replace ) )
-		$content = preg_replace( '/<blockquote[^>]*>(.+?)<\/blockquote>/is', addcslashes( $replace, '\\$' ), $content, 1 );
+	if ( $args['remove'] || ! empty( $args['replace'] ) )
+		$content = preg_replace( '/<blockquote[^>]*>(.+?)<\/blockquote>/is', addcslashes( $args['replace'], '\\$' ), $content, 1 );
 
 	return $matches[1];
 }
@@ -740,7 +766,10 @@
 		return '';
 
 	$content = $post->post_content;
-	$quote = get_content_quote( $content, true );
+	$quote = get_content_quote( $content, array(
+		'remove' => true,
+	) );
+
 	$post->split_content = $content;
 
 	if ( ! empty( $quote ) )
@@ -773,20 +802,29 @@
  * Extract a URL from passed content, if possible
  * Checks for a URL on the first line of the content or the first encountered href attribute.
  *
+ * $args contents:
+ * - remove - Whether to remove the found URL from the passed content.
+ *
  * @since 3.6.0
  *
  * @param string $content A string which might contain a URL, passed by reference.
- * @param boolean $remove Whether to remove the found URL from the passed content.
+ * @param array $args An optional array of arguments.
  * @return string The found URL.
  */
-function get_content_url( &$content, $remove = false ) {
+function get_content_url( &$content, $args = array() ) {
+	$defaults = array(
+		'remove' => false,
+	);
+
+	$args = wp_parse_args( $args, $defaults );
+
 	if ( empty( $content ) )
 		return '';
 
 	// the content is a URL
 	$trimmed = trim( $content );
 	if ( 0 === stripos( $trimmed, 'http' ) && ! preg_match( '#\s#', $trimmed ) ) {
-		if ( $remove )
+		if ( $args['content'] )
 			$content = '';
 
 		return $trimmed;
@@ -800,7 +838,7 @@
 
 	// the content is a URL followed by content
 	if ( 0 === stripos( $line, 'http' ) ) {
-		if ( $remove )
+		if ( $args['remove'] )
 			$content = trim( join( "\n", $lines ) );
 
 		return esc_url_raw( $line );
Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(revision 24177)
+++ wp-includes/media.php	(working copy)
@@ -1897,33 +1897,48 @@
 /**
  * Extract and parse {media type} shortcodes or srcs from the passed content
  *
+ * $args contents:
+ * - type - Type of media: audio or video.
+ * - return -  Whether to return HTML or URLs.
+ * - remove - Whether to remove the found URL from the passed content.
+ * - limit - The number of medias to return.
+ *
  * @since 3.6.0
  *
- * @param string $type Type of media: audio or video
  * @param string $content A string which might contain media data.
- * @param boolean $html Whether to return HTML or URLs
- * @param boolean $remove Whether to remove the found URL from the passed content.
- * @param int $limit Optional. The number of medias to return
+ * @param array $args An array of arguments.
  * @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( &$content, $args ) {
+	$defaults = array(
+		'type'   => null,
+		'html'   => true,
+		'remove' => false,
+		'limit'  => 0,
+	);
+
+	$args = wp_parse_args( $args, $defaults );
+
+	if ( empty( $args['type'] ) )
+		return;
+
 	$items = array();
 
 	if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $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'] )
+					$content = str_replace( $shortcode[0], '', $content, $count );
 
 				$items[] = do_shortcode_tag( $shortcode );
-				if ( $limit > 0 && count( $items ) >= $limit )
+				if ( $args['limit'] > 0 && count( $items ) >= $args['limit'] )
 					break;
 			}
 		}
 	}
 
-	if ( $html )
+	if ( $args['html'] )
 		return $items;
 
 	$data = array();
@@ -1946,35 +1961,49 @@
  * Check the content blob for an <{media type}>, <object>, <embed>, or <iframe>, in that order
  * If no HTML tag is found, check the first line of the post for a URL
  *
+ * $args contents:
+ * - type - Type of media: audio or video.
+ * - remove - Whether to remove the found URL from the passed content.
+ * - limit - The number of medias to return.
+ *
  * @since 3.6.0
  *
- * @param string $type Type of media: audio or video
  * @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
+ * @param array $args An array of arguments.
  * @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( &$content, $args ) {
+	$defaults = array(
+		'type'   => null,
+		'remove' => false,
+		'limit'  => 0,
+	);
+
+	$args = wp_parse_args( $args, $defaults );
+
+	if ( empty( $args['type'] ) )
+		return;
+
 	$html = array();
 
-	foreach ( array( $type, 'object', 'embed', 'iframe' ) as $tag ) {
+	foreach ( array( $args['type'], 'object', 'embed', 'iframe' ) as $tag ) {
 		if ( preg_match( '#' . get_tag_regex( $tag ) . '#', $content, $matches ) ) {
 			$html[] = $matches[0];
-			if ( $remove )
+			if ( $args['remove'] )
 				$content = str_replace( $matches[0], '', $content );
 
-			if ( $limit > 0 && count( $html ) >= $limit )
+			if ( $args['limit'] > 0 && count( $html ) >= $args['limit'] )
 				break;
 		}
 	}
 
-	if ( ! empty( $html ) && count( $html ) >= $limit )
+	if ( ! empty( $html ) && count( $html ) >= $args['limit'] )
 		return $html;
 
 	$lines = explode( "\n", trim( $content ) );
 	$line = trim( array_shift( $lines  ) );
 	if ( 0 === stripos( $line, 'http' ) ) {
-		if ( $remove )
+		if ( $args['remove'] )
 			$content = join( "\n", $lines );
 
 		$html[] = $line;
@@ -1987,14 +2016,15 @@
  *
  * @since 3.6.0
  *
+ * @uses get_content_media()
+ *
  * @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.
+ * @param array $args (optional) An array of arguments.
  * @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( &$content, $args = array() ) {
+	return get_content_media( $content, array_merge( $args, array( 'type' => 'audio' ) ) );
 }
 
 /**
@@ -2003,12 +2033,14 @@
  *
  * @since 3.6.0
  *
+ * @uses get_embedded_media()
+ *
  * @param string $content A string which might contain audio data.
- * @param boolean $remove Whether to remove the found URL from the passed content.
+ * @param array $args (optional) An array of arguments.
  * @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( &$content, $args = array() ) {
+	return get_embedded_media( $content, array_merge( $args, array( 'type' => 'audio' ) ) );
 }
 
 /**
@@ -2016,14 +2048,15 @@
  *
  * @since 3.6.0
  *
+ * @uses get_content_media()
+ *
  * @param string $content A string which might contain video data.
- * @param boolean $html Whether to return HTML or URLs
- * @param boolean $remove Whether to remove the found URL from the passed content.
+ * @param array $args (optional) An array of arguments.
  * @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( &$content, $args = array() ) {
+	return get_content_media( $content, array_merge( $args, array( 'type' => 'video' ) ) );
 }
 
 /**
@@ -2032,12 +2065,14 @@
  *
  * @since 3.6.0
  *
+ * @uses get_embedded_media()
+ *
  * @param string $content A string which might contain video data.
- * @param boolean $remove Whether to remove the found URL from the passed content.
+ * @param array $args (optional) An array of arguments.
  * @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( &$content, $args = array() ) {
+	return get_embedded_media( $content, array_merge( $args, array( 'type' => 'video' ) ) );
 }
 
 /**
@@ -2046,6 +2081,9 @@
  *
  * @since 3.6.0
  *
+ * @uses get_content_media()
+ * @uses get_embedded_media()
+ *
  * @param string $type Required. 'audio' or 'video'
  * @param WP_Post $post Optional. Used instead of global $post when passed.
  * @param int $limit Optional. The number of medias to remove if content is scanned.
@@ -2102,7 +2140,13 @@
 	// 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( $content, array(
+		'type'   => $type,
+		'html'   => true,
+		'remove' => true,
+		'limit'  => $limit,
+	) );
+
 	if ( ! empty( $htmls ) ) {
 		$html = reset( $htmls );
 		$post->split_content = $content;
@@ -2110,7 +2154,12 @@
 		return $post->format_content[ $cache_key ];
 	}
 
-	$embeds = get_embedded_media( $type, $content, true, 1 );
+	$embeds = get_embedded_media( $content, array(
+		'type'   => $type,
+		'remove' => true,
+		'limit'  => 1,
+	) );
+
 	if ( ! empty( $embeds ) ) {
 		$embed = reset( $embeds );
 		$post->split_content = $content;
@@ -2194,15 +2243,26 @@
 /**
  * Check the content blob for images or image srcs
  *
+ * $args contents:
+ * - html - Whether to return HTML or URLs.
+ * - remove - Whether to remove the found URL from the passed content.
+ * - limit - The number of medias to return.
+ *
  * @since 3.6.0
  *
  * @param string $content A string which might contain image data.
- * @param boolean $html Whether to return HTML or URLs
- * @param boolean $remove Whether to remove the found data from the passed content.
- * @param int $limit Optional. The number of image srcs to return
+ * @param array $args (optional) An array of arguments.
  * @return array The found images or srcs
  */
-function get_content_images( &$content, $html = true, $remove = false, $limit = 0 ) {
+function get_content_images( &$content, $args = array() ) {
+	$defaults = array(
+		'html'   => true,
+		'remove' => false,
+		'limit'  => 0,
+	);
+
+	$args = wp_parse_args( $args, $defaults );
+
 	$tags = array();
 	$captions = array();
 
@@ -2210,11 +2270,11 @@
 		foreach ( $matches as $shortcode ) {
 			if ( 'caption' === $shortcode[2] ) {
 				$captions[] = $shortcode[0];
-				if ( $html )
+				if ( $args['html'] )
 					$tags[] = do_shortcode( $shortcode[0] );
 			}
 
-			if ( $limit > 0 && count( $tags ) >= $limit )
+			if ( $args['limit'] > 0 && count( $tags ) >= $args['limit'] )
 				break;
 		}
 	}
@@ -2231,24 +2291,24 @@
 				foreach ( $captions as $caption ) {
 					if ( strstr( $caption, $node[0] ) ) {
 						$found = true;
-						if ( $remove )
+						if ( $args['remove'] )
 							$content = str_replace( $caption, '', $content, $count );
 					}
 				}
 
-				if ( $remove )
+				if ( $args['remove'] )
 					$content = str_replace( $node[0], '', $content, $count );
 
 				if ( ! $found )
 					$tags[] = $node[0];
 
-				if ( $limit > 0 && count( $tags ) >= $limit )
+				if ( $args['limit'] > 0 && count( $tags ) >= $args['limit'] )
 					break 2;
 			}
 		}
 	}
 
-	if ( $html )
+	if ( $args['html'] )
 		return $tags;
 
 	$srcs = array();
@@ -2257,7 +2317,7 @@
 		preg_match( '#src=[\'"](.+?)[\'"]#is', $tag, $src );
 		if ( ! empty( $src[1] ) ) {
 			$srcs[] = $src[1];
-			if ( $limit > 0 && count( $srcs ) >= $limit )
+			if ( $args['limit'] > 0 && count( $srcs ) >= $args['limit'] )
 				break;
 		}
 	}
@@ -2268,15 +2328,20 @@
 /**
  * Check the content blob for images or srcs and return the first
  *
+ * $args contents:
+ * - html - Whether to return HTML or URLs.
+ * - remove - Whether to remove the found URL from the passed content.
+ *
  * @since 3.6.0
  *
+ * @uses get_content_images()
+ *
  * @param string $content A string which might contain image data.
- * @param boolean $html Whether to return HTML or URLs
- * @param boolean $remove Whether to remove the found data from the passed content.
+ * @param array $args (optional) An array of arguments.
  * @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( &$content, $args = array() ) {
+	$srcs = get_content_images( array_merge( $args, array( 'limit' => 1 ) ) );
 	if ( empty( $srcs ) )
 		return '';
 
@@ -2286,15 +2351,25 @@
 /**
  * Check the content blob for galleries and return their image srcs
  *
+ * $args contents:
+ * - html - Whether to return HTML or URLs.
+ * - remove - Whether to remove the found URL from the passed content.
+ * - limit - The number of galleries to return.
+ *
  * @since 3.6.0
  *
- * @param string $content A string which might contain image data.
- * @param boolean $html Whether to return HTML or data
- * @param boolean $remove Optional. Whether to remove the found data from the passed content.
- * @param int $limit Optional. The number of galleries to return
+ * @param array $args (optional) An array of arguments.
  * @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( &$content, $args = array() ) {
+	$defaults = array(
+		'html'   => true,
+		'remove' => false,
+		'limit'  => 0,
+	);
+
+	$args = wp_parse_args( $args, $defaults );
+
 	$galleries = array();
 
 	if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
@@ -2302,12 +2377,12 @@
 			if ( 'gallery' === $shortcode[2] ) {
 				$srcs = array();
 				$count = 1;
-				if ( $remove )
+				if ( $args['remove'] )
 					$content = str_replace( $shortcode[0], '', $content, $count );
 
 				$data = shortcode_parse_atts( $shortcode[3] );
 				$gallery = do_shortcode_tag( $shortcode );
-				if ( $html ) {
+				if ( $args['html'] ) {
 					$galleries[] = $gallery;
 				} else {
 					preg_match_all( '#src=[\'"](.+?)[\'"]#is', $gallery, $src, PREG_SET_ORDER );
@@ -2320,7 +2395,7 @@
 					$galleries[] = $data;
 				}
 
-				if ( $limit > 0 && count( $galleries ) >= $limit )
+				if ( $args['limit'] > 0 && count( $galleries ) >= $args['limit'] )
 					break;
 			}
 		}
@@ -2332,19 +2407,35 @@
 /**
  * Retrieve galleries from the passed post's content
  *
+ * $args contents:
+ * - post_id - The post id.
+ * - html - Whether to return HTML or data.
+ *
  * @since 3.6.0
  *
- * @param int $post_id Optional. Post ID.
- * @param boolean $html Whether to return HTML or data
+ * @uses get_content_galleries()
+ *
+ * @param array $args (optional) An array of arguments.
  * @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(
+		'post_id' => 0,
+		'html'    => true,
+	);
+
+	$args = wp_parse_args( $args, $defaults );
+
+	$post = 0 == $args['post_id'] ? clone get_post() : get_post( $args['post_id'] );
 	if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' )  )
 		return array();
 
-	return get_content_galleries( $post->post_content, $html );
+	$galleries = get_content_galleries( $post->post_content, array(
+		'html' => $args['html'],
+	) );
+
+	return $galleries;
 }
 
 /**
@@ -2352,7 +2443,9 @@
  *
  * @since 3.6.0
  *
- * @param int $post_id Optional. Post ID.
+ * @uses get_content_galleries()
+ *
+ * @param int $post_id (optional) The post id.
  * @return array A list of lists, each containing image srcs parsed
  *		from an expanded shortcode
  */
@@ -2361,25 +2454,44 @@
 	if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' )  )
 		return array();
 
-	$data = get_content_galleries( $post->post_content, false );
+	$data = get_content_galleries( $post->post_content, array(
+		'html' => false,
+	) );
+
 	return wp_list_pluck( $data, 'src' );
 }
 
 /**
  * Check a specified post's content for gallery and, if present, return the first
  *
+ * $args contents:
+ * - post_id - The post id.
+ * - html - Whether to return HTML or URLs.
+ *
  * @since 3.6.0
  *
- * @param int $post_id Optional. Post ID.
- * @param boolean $html Whether to return HTML or data
+ * @uses get_content_galleries()
+ *
+ * @param array $args (optional) An array of arguments.
  * @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(
+		'post_id' => 0,
+		'html'    => true,
+	);
+
+	$args = wp_parse_args( $args, $defaults );
+
+	$post = 0 == $args['post_id'] ? clone get_post() : get_post( $args['post_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( $post->post_content, array(
+		'html'  => $args['html'],
+		'limit' => 1,
+	) );
+
 	return reset( $data );
 }
 
@@ -2401,7 +2513,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(
+		'post_id' => $post_id,
+		'html'    => false,
+	) );
+
 	if ( empty( $gallery['src'] ) )
 		return array();
 
@@ -2413,6 +2529,8 @@
  *
  * @since 3.6.0
  *
+ * @uses get_content_images()
+ *
  * @param string $attached_size If an attached image is found, the size to display it.
  * @param WP_Post $post Optional. Used instead of global $post when passed.
  */
@@ -2529,7 +2647,12 @@
 	}
 
 	$content = $post->post_content;
-	$htmls = get_content_images( $content, true, true, 1 );
+	$htmls = get_content_images( $content, array(
+		'html'   => true,
+		'remove' => true,
+		'limit'  => 1,
+	) );
+
 	if ( ! empty( $htmls ) ) {
 		$html = reset( $htmls );
 		$post->split_content = $content;
