<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[28128] trunk/src/wp-includes/media.php: Inline documentation for hooks in wp-includes/media.php.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/28128">28128</a></dd>
<dt>Author</dt> <dd>DrewAPicture</dd>
<dt>Date</dt> <dd>2014-04-15 01:35:49 +0000 (Tue, 15 Apr 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Inline documentation for hooks in wp-includes/media.php.
Props scottlee for the initial patch. Props kpdesign, DrewAPicture.
Fixes <a href="http://core.trac.wordpress.org/ticket/27718">#27718</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesmediaphp">trunk/src/wp-includes/media.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/media.php (28127 => 28128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/media.php 2014-04-15 01:30:36 UTC (rev 28127)
+++ trunk/src/wp-includes/media.php 2014-04-15 01:35:49 UTC (rev 28128)
</span><span class="lines">@@ -78,6 +78,18 @@
</span><span class="cx"> $max_height = $height;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Filter the maximum image size dimensions for the editor.
+ *
+ * @since 2.5.0
+ *
+ * @param array $max_image_size An array with the width as the first element,
+ * and the height as the second element.
+ * @param string|array $size Size of what the result image should be.
+ * @param string $context The context the image is being resized for.
+ * Possible values are 'display' (like in a theme)
+ * or 'edit' (like inserting into an editor).
+ */
</ins><span class="cx"> list( $max_width, $max_height ) = apply_filters( 'editor_max_image_size', array( $max_width, $max_height ), $size, $context );
</span><span class="cx">
</span><span class="cx"> return wp_constrain_dimensions( $width, $height, $max_width, $max_height );
</span><span class="lines">@@ -126,8 +138,6 @@
</span><span class="cx"> * to the new image that was resized.
</span><span class="cx"> *
</span><span class="cx"> * @since 2.5.0
</span><del>- * @uses apply_filters() Calls 'image_downsize' on $id and $size to provide
- * resize services.
</del><span class="cx"> *
</span><span class="cx"> * @param int $id Attachment ID for image.
</span><span class="cx"> * @param array|string $size Optional, default is 'medium'. Size of image, either array or string.
</span><span class="lines">@@ -138,9 +148,21 @@
</span><span class="cx"> if ( !wp_attachment_is_image($id) )
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- // plugins can use this to provide resize services
- if ( $out = apply_filters( 'image_downsize', false, $id, $size ) )
</del><ins>+ /**
+ * Filter whether to preempt the output of image_downsize().
+ *
+ * Passing a truthy value to the filter will effectively short-circuit
+ * down-sizing the image, returning that value as output instead.
+ *
+ * @since 2.5.0
+ *
+ * @param bool $downsize Whether to short-circuit the image downsize. Default false.
+ * @param int $id Attachment ID for image.
+ * @param array|string $size Size of image, either array or string. Default 'medium'.
+ */
+ if ( $out = apply_filters( 'image_downsize', false, $id, $size ) ) {
</ins><span class="cx"> return $out;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> $img_url = wp_get_attachment_url($id);
</span><span class="cx"> $meta = wp_get_attachment_metadata($id);
</span><span class="lines">@@ -273,11 +295,6 @@
</span><span class="cx"> *
</span><span class="cx"> * @since 2.5.0
</span><span class="cx"> *
</span><del>- * @uses apply_filters() The 'get_image_tag_class' filter is the IMG element
- * class attribute.
- * @uses apply_filters() The 'get_image_tag' filter is the full IMG element with
- * all attributes.
- *
</del><span class="cx"> * @param int $id Attachment ID.
</span><span class="cx"> * @param string $alt Image Description for the alt attribute.
</span><span class="cx"> * @param string $title Image Description for the title attribute.
</span><span class="lines">@@ -293,10 +310,33 @@
</span><span class="cx"> $title = $title ? 'title="' . esc_attr( $title ) . '" ' : '';
</span><span class="cx">
</span><span class="cx"> $class = 'align' . esc_attr($align) .' size-' . esc_attr($size) . ' wp-image-' . $id;
</span><del>- $class = apply_filters('get_image_tag_class', $class, $id, $align, $size);
</del><span class="cx">
</span><ins>+ /**
+ * Filter the value of the attachment's image tag class attribute.
+ *
+ * @since 2.6.0
+ *
+ * @param string $class CSS class name or space-separated list of classes.
+ * @param int $id Attachment ID.
+ * @param string $align Part of the class name for aligning the image.
+ * @param string $size Optional. Default is 'medium'.
+ */
+ $class = apply_filters( 'get_image_tag_class', $class, $id, $align, $size );
+
</ins><span class="cx"> $html = '<img src="' . esc_attr($img_src) . '" alt="' . esc_attr($alt) . '" ' . $title . $hwstring . 'class="' . $class . '" />';
</span><span class="cx">
</span><ins>+ /**
+ * Filter the HTML content for the image tag.
+ *
+ * @since 2.6.0
+ *
+ * @param string $html HTML content for the image.
+ * @param int $id Attachment ID.
+ * @param string $alt Alternate text.
+ * @param string $title Attachment title.
+ * @param string $align Part of the class name for aligning the image.
+ * @param string $size Optional. Default is 'medium'.
+ */
</ins><span class="cx"> $html = apply_filters( 'get_image_tag', $html, $id, $alt, $title, $align, $size );
</span><span class="cx">
</span><span class="cx"> return $html;
</span><span class="lines">@@ -374,8 +414,6 @@
</span><span class="cx"> * 3. If true, images will be cropped to the specified dimensions using center positions.
</span><span class="cx"> *
</span><span class="cx"> * @since 2.5.0
</span><del>- * @uses apply_filters() Calls 'image_resize_dimensions' on $orig_w, $orig_h, $dest_w,
- * $dest_h and $crop to provide custom resize dimensions.
</del><span class="cx"> *
</span><span class="cx"> * @param int $orig_w Original width in pixels.
</span><span class="cx"> * @param int $orig_h Original height in pixels.
</span><span class="lines">@@ -393,7 +431,22 @@
</span><span class="cx"> if ($dest_w <= 0 && $dest_h <= 0)
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- // plugins can use this to provide custom resize dimensions
</del><ins>+ /**
+ * Filter whether to preempt calculating the image resize dimensions.
+ *
+ * Passing a non-null value to the filter will effectively short-circuit
+ * image_resize_dimensions(), returning that value instead.
+ *
+ * @since 3.4.0
+ *
+ * @param null|mixed $null Whether to preempt output of the resize dimensions.
+ * @param int $orig_w Original width in pixels.
+ * @param int $orig_h Original height in pixels.
+ * @param int $dest_w New width in pixels.
+ * @param int $dest_h New height in pixels.
+ * @param bool|array $crop Whether to crop image to specified height and width or resize.
+ * An array can specify positioning of the crop area. Default false.
+ */
</ins><span class="cx"> $output = apply_filters( 'image_resize_dimensions', null, $orig_w, $orig_h, $dest_w, $dest_h, $crop );
</span><span class="cx"> if ( null !== $output )
</span><span class="cx"> return $output;
</span><span class="lines">@@ -578,6 +631,14 @@
</span><span class="cx"> if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) )
</span><span class="cx"> $image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) );
</span><span class="cx">
</span><ins>+ /**
+ * Filter the list of intermediate image sizes.
+ *
+ * @since 2.5.0
+ *
+ * @param array $image_sizes An array of intermediate image sizes. Defaults
+ * are 'thumbnail', 'medium', 'large'.
+ */
</ins><span class="cx"> return apply_filters( 'intermediate_image_sizes', $image_sizes );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -602,6 +663,7 @@
</span><span class="cx"> $src = false;
</span><span class="cx">
</span><span class="cx"> if ( $icon && $src = wp_mime_type_icon($attachment_id) ) {
</span><ins>+ /** This filter is documented in wp-includes/post.php */
</ins><span class="cx"> $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' );
</span><span class="cx"> $src_file = $icon_dir . '/' . wp_basename($src);
</span><span class="cx"> @list($width, $height) = getimagesize($src_file);
</span><span class="lines">@@ -619,10 +681,10 @@
</span><span class="cx"> * efficient than having to find the closest-sized image and then having the
</span><span class="cx"> * browser scale down the image.
</span><span class="cx"> *
</span><ins>+ * @since 2.5.0
+ *
</ins><span class="cx"> * @see add_image_size()
</span><del>- * @uses apply_filters() Calls 'wp_get_attachment_image_attributes' hook on attributes array
</del><span class="cx"> * @uses wp_get_attachment_image_src() Gets attachment file URL and dimensions
</span><del>- * @since 2.5.0
</del><span class="cx"> *
</span><span class="cx"> * @param int $attachment_id Image attachment ID.
</span><span class="cx"> * @param string $size Optional, default is 'thumbnail'.
</span><span class="lines">@@ -651,6 +713,15 @@
</span><span class="cx"> $default_attr['alt'] = trim(strip_tags( $attachment->post_title )); // Finally, use the title
</span><span class="cx">
</span><span class="cx"> $attr = wp_parse_args($attr, $default_attr);
</span><ins>+
+ /**
+ * Filter the list of attachment image attributes.
+ *
+ * @since 2.8.0
+ *
+ * @param mixed $attr Attributes for the image markup.
+ * @param int $attachment_id Image attachment ID.
+ */
</ins><span class="cx"> $attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment );
</span><span class="cx"> $attr = array_map( 'esc_attr', $attr );
</span><span class="cx"> $html = rtrim("<img $hwstring");
</span><span class="lines">@@ -963,6 +1034,15 @@
</span><span class="cx">
</span><span class="cx"> $size_class = sanitize_html_class( $size );
</span><span class="cx"> $gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
</span><ins>+
+ /**
+ * Filter the default gallery shortcode CSS styles.
+ *
+ * @since 2.5.0
+ *
+ * @param string $gallery_style Default gallery shortcode CSS styles.
+ * @param string $gallery_div Opening HTML div container for the gallery shortcode output.
+ */
</ins><span class="cx"> $output = apply_filters( 'gallery_style', $gallery_style . $gallery_div );
</span><span class="cx">
</span><span class="cx"> $i = 0;
</span><span class="lines">@@ -1098,8 +1178,7 @@
</span><span class="cx"> * @since 3.9.0
</span><span class="cx"> *
</span><span class="cx"> * @param string $output Playlist output. Default empty.
</span><del>- * @param array $attr Array of shortcode attributes.
- * @param string $type Type of playlist to generate output for.
</del><ins>+ * @param array $attr An array of shortcode attributes.
</ins><span class="cx"> */
</span><span class="cx"> $output = apply_filters( 'post_playlist', '', $attr );
</span><span class="cx"> if ( $output != '' ) {
</span><span class="lines">@@ -1256,7 +1335,7 @@
</span><span class="cx">
</span><span class="cx"> if ( 1 === $instance ) {
</span><span class="cx"> /**
</span><del>- * Hook to print and enqueue playlist scripts, styles, and JavaScript templates.
</del><ins>+ * Print and enqueue playlist scripts, styles, and JavaScript templates.
</ins><span class="cx"> *
</span><span class="cx"> * @since 3.9.0
</span><span class="cx"> *
</span><span class="lines">@@ -1299,16 +1378,32 @@
</span><span class="cx"> * @return string Fallback HTML
</span><span class="cx"> */
</span><span class="cx"> function wp_mediaelement_fallback( $url ) {
</span><ins>+ /**
+ * Filter the Mediaelement fallback output for no-JS.
+ *
+ * @since 3.6.0
+ *
+ * @param string $output Fallback output for no-JS.
+ * @param string $url Media file URL.
+ */
</ins><span class="cx"> return apply_filters( 'wp_mediaelement_fallback', sprintf( '<a href="%1$s">%1$s</a>', esc_url( $url ) ), $url );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Return a filtered list of WP-supported audio formats
</del><ins>+ * Return a filtered list of WP-supported audio formats.
</ins><span class="cx"> *
</span><span class="cx"> * @since 3.6.0
</span><span class="cx"> * @return array
</span><span class="cx"> */
</span><span class="cx"> function wp_get_audio_extensions() {
</span><ins>+ /**
+ * Filter the list of supported audio formats.
+ *
+ * @since 3.6.0
+ *
+ * @param array $extensions An array of support audio formats. Defaults are
+ * 'mp3', 'ogg', 'wma', 'm4a', 'wav'.
+ */
</ins><span class="cx"> return apply_filters( 'wp_audio_extensions', array( 'mp3', 'ogg', 'wma', 'm4a', 'wav' ) );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1334,12 +1429,13 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Filter the editable list of keys to lookup data from an attachment's metadata.
</del><ins>+ * Filter the editable list of keys to look up data from an attachment's metadata.
</ins><span class="cx"> *
</span><span class="cx"> * @since 3.9.0
</span><span class="cx"> *
</span><span class="cx"> * @param array $fields Key/value pairs of field keys to labels.
</span><span class="cx"> * @param WP_Post $attachment Attachment object.
</span><ins>+ * @param string $context The context. Accepts 'edit', 'display'. Default 'display'.
</ins><span class="cx"> */
</span><span class="cx"> return apply_filters( 'wp_get_attachment_id3_keys', $fields, $attachment, $context );
</span><span class="cx"> }
</span><span class="lines">@@ -1383,8 +1479,7 @@
</span><span class="cx"> * @param string $content Shortcode content.
</span><span class="cx"> * @param int $instances Unique numeric ID of this audio shortcode instance.
</span><span class="cx"> */
</span><del>- $html = '';
- $html = apply_filters( 'wp_audio_shortcode_override', $html, $attr, $content, $instances );
</del><ins>+ $html = apply_filters( 'wp_audio_shortcode_override', '', $attr, $content, $instances );
</ins><span class="cx"> if ( '' !== $html )
</span><span class="cx"> return $html;
</span><span class="cx">
</span><span class="lines">@@ -1433,12 +1528,26 @@
</span><span class="cx"> array_unshift( $default_types, 'src' );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Filter the media library used for the audio shortcode.
+ *
+ * @since 3.6.0
+ *
+ * @param string $library Media library used for the audio shortcode.
+ */
</ins><span class="cx"> $library = apply_filters( 'wp_audio_shortcode_library', 'mediaelement' );
</span><span class="cx"> if ( 'mediaelement' === $library && did_action( 'init' ) ) {
</span><span class="cx"> wp_enqueue_style( 'wp-mediaelement' );
</span><span class="cx"> wp_enqueue_script( 'wp-mediaelement' );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Filter the class attribute for the audio shortcode output container.
+ *
+ * @since 3.6.0
+ *
+ * @param string $class CSS class or list of space-separated classes.
+ */
</ins><span class="cx"> $atts = array(
</span><span class="cx"> 'class' => apply_filters( 'wp_audio_shortcode_class', 'wp-audio-shortcode' ),
</span><span class="cx"> 'id' => sprintf( 'audio-%d-%d', $post_id, $instances ),
</span><span class="lines">@@ -1480,6 +1589,17 @@
</span><span class="cx"> $html .= wp_mediaelement_fallback( $fileurl );
</span><span class="cx"> $html .= '</audio>';
</span><span class="cx">
</span><ins>+ /**
+ * Filter the audio shortcode output.
+ *
+ * @since 3.6.0
+ *
+ * @param string $html Audio shortcode HTML output.
+ * @param array $atts Array of audio shortcode attributes.
+ * @param string $audio Audio file.
+ * @param int $post_id Post ID.
+ * @param string $library Media library used for the audio shortcode.
+ */
</ins><span class="cx"> return apply_filters( 'wp_audio_shortcode', $html, $atts, $audio, $post_id, $library );
</span><span class="cx"> }
</span><span class="cx"> add_shortcode( 'audio', 'wp_audio_shortcode' );
</span><span class="lines">@@ -1491,6 +1611,14 @@
</span><span class="cx"> * @return array
</span><span class="cx"> */
</span><span class="cx"> function wp_get_video_extensions() {
</span><ins>+ /**
+ * Filter the list of supported video formats.
+ *
+ * @since 3.6.0
+ *
+ * @param array $extensions An array of support video formats. Defaults are
+ * 'mp4', 'm4v', 'webm', 'ogv', 'wmv', 'flv'.
+ */
</ins><span class="cx"> return apply_filters( 'wp_video_extensions', array( 'mp4', 'm4v', 'webm', 'ogv', 'wmv', 'flv' ) );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1615,12 +1743,26 @@
</span><span class="cx"> array_unshift( $default_types, 'src' );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Filter the media library used for the video shortcode.
+ *
+ * @since 3.6.0
+ *
+ * @param string $library Media library used for the video shortcode.
+ */
</ins><span class="cx"> $library = apply_filters( 'wp_video_shortcode_library', 'mediaelement' );
</span><span class="cx"> if ( 'mediaelement' === $library && did_action( 'init' ) ) {
</span><span class="cx"> wp_enqueue_style( 'wp-mediaelement' );
</span><span class="cx"> wp_enqueue_script( 'wp-mediaelement' );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Filter the class attribute for the video shortcode output container.
+ *
+ * @since 3.6.0
+ *
+ * @param string $class CSS class or list of space-separated classes.
+ */
</ins><span class="cx"> $atts = array(
</span><span class="cx"> 'class' => apply_filters( 'wp_video_shortcode_class', 'wp-video-shortcode' ),
</span><span class="cx"> 'id' => sprintf( 'video-%d-%d', $post_id, $instances ),
</span><span class="lines">@@ -1677,6 +1819,18 @@
</span><span class="cx"> $html .= '</video>';
</span><span class="cx">
</span><span class="cx"> $html = sprintf( '<div style="width: %dpx; max-width: 100%%;" class="wp-video">%s</div>', $width, $html );
</span><ins>+
+ /**
+ * Filter the output of the video shortcode.
+ *
+ * @since 3.6.0
+ *
+ * @param string $html Video shortcode HTML output.
+ * @param array $atts Array of video shortcode attributes.
+ * @param string $video Video file.
+ * @param int $post_id Post ID.
+ * @param string $library Media library used for the video shortcode.
+ */
</ins><span class="cx"> return apply_filters( 'wp_video_shortcode', $html, $atts, $video, $post_id, $library );
</span><span class="cx"> }
</span><span class="cx"> add_shortcode( 'video', 'wp_video_shortcode' );
</span><span class="lines">@@ -1731,6 +1885,20 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $adjacent = $prev ? 'previous' : 'next';
</span><ins>+
+ /**
+ * Filter the adjacent image link.
+ *
+ * The dynamic portion of the hook name, $adjacent, refers to the type of adjacency,
+ * either 'next', or 'previous'.
+ *
+ * @since 3.5.0
+ *
+ * @param string $output Adjacent image HTML markup.
+ * @param int $attachment_id Attachment ID
+ * @param string $size Image size.
+ * @param string $text Link text.
+ */
</ins><span class="cx"> echo apply_filters( "{$adjacent}_image_link", $output, $attachment_id, $size, $text );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1866,6 +2034,14 @@
</span><span class="cx">
</span><span class="cx"> $height = min( ceil( $width * 1.5 ), 1000 );
</span><span class="cx">
</span><ins>+ /**
+ * Filter the default array of embed dimensions.
+ *
+ * @since 2.9.0
+ *
+ * @param int $width Width of the embed in pixels.
+ * @param int $height Height of the embed in pixels.
+ */
</ins><span class="cx"> return apply_filters( 'embed_defaults', compact( 'width', 'height' ) );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1959,10 +2135,37 @@
</span><span class="cx"> * @since 2.9.0
</span><span class="cx"> */
</span><span class="cx"> function wp_maybe_load_embeds() {
</span><del>- if ( ! apply_filters( 'load_default_embeds', true ) )
</del><ins>+ /**
+ * Filter whether to load the default embed handlers.
+ *
+ * Returning a falsey value will prevent loading the default embed handlers.
+ *
+ * @since 2.9.0
+ *
+ * @param bool $maybe_load_embeds Whether to load the embeds library. Default true.
+ */
+ if ( ! apply_filters( 'load_default_embeds', true ) ) {
</ins><span class="cx"> return;
</span><ins>+ }
+
</ins><span class="cx"> wp_embed_register_handler( 'googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo' );
</span><ins>+
+ /**
+ * Filter the audio embed handler callback.
+ *
+ * @since 3.6.0
+ *
+ * @param callback $handler Audio embed handler callback function.
+ */
</ins><span class="cx"> wp_embed_register_handler( 'audio', '#^https?://.+?\.(' . join( '|', wp_get_audio_extensions() ) . ')$#i', apply_filters( 'wp_audio_embed_handler', 'wp_embed_handler_audio' ), 9999 );
</span><ins>+
+ /**
+ * Filter the video embed handler callback.
+ *
+ * @since 3.6.0
+ *
+ * @param callback $handler Video embed handler callback function.
+ */
</ins><span class="cx"> wp_embed_register_handler( 'video', '#^https?://.+?\.(' . join( '|', wp_get_video_extensions() ) . ')$#i', apply_filters( 'wp_video_embed_handler', 'wp_embed_handler_video' ), 9999 );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1987,6 +2190,17 @@
</span><span class="cx"> list( $width, $height ) = wp_expand_dimensions( 425, 344, $attr['width'], $attr['height'] );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Filter the Google Video embed output.
+ *
+ * @since 2.9.0
+ *
+ * @param string $html Google Video HTML embed markup.
+ * @param array $matches The regex matches from the provided regex.
+ * @param array $attr An array of embed attributes.
+ * @param string $url The original URL that was matched by the regex.
+ * @param array $rawattr The original unmodified attributes.
+ */
</ins><span class="cx"> return apply_filters( 'embed_googlevideo', '<embed type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docid=' . esc_attr($matches[2]) . '&hl=en&fs=true" style="width:' . esc_attr($width) . 'px;height:' . esc_attr($height) . 'px" allowFullScreen="true" allowScriptAccess="always" />', $matches, $attr, $url, $rawattr );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2003,6 +2217,17 @@
</span><span class="cx"> */
</span><span class="cx"> function wp_embed_handler_audio( $matches, $attr, $url, $rawattr ) {
</span><span class="cx"> $audio = sprintf( '[audio src="%s" /]', esc_url( $url ) );
</span><ins>+
+ /**
+ * Filter the audio embed output.
+ *
+ * @since 3.6.0
+ *
+ * @param string $audio Audio embed output.
+ * @param array $attr An array of embed attributes.
+ * @param string $url The original URL that was matched by the regex.
+ * @param array $rawattr The original unmodified attributes.
+ */
</ins><span class="cx"> return apply_filters( 'wp_embed_handler_audio', $audio, $attr, $url, $rawattr );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2024,6 +2249,17 @@
</span><span class="cx"> $dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] );
</span><span class="cx"> }
</span><span class="cx"> $video = sprintf( '[video %s src="%s" /]', $dimensions, esc_url( $url ) );
</span><ins>+
+ /**
+ * Filter the video embed output.
+ *
+ * @since 3.6.0
+ *
+ * @param string $video Video embed output.
+ * @param array $attr An array of embed attributes.
+ * @param string $url The original URL that was matched by the regex.
+ * @param array $rawattr The original unmodified attributes.
+ */
</ins><span class="cx"> return apply_filters( 'wp_embed_handler_video', $video, $attr, $url, $rawattr );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2057,8 +2293,17 @@
</span><span class="cx"> function wp_max_upload_size() {
</span><span class="cx"> $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
</span><span class="cx"> $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
</span><del>- $bytes = apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes );
- return $bytes;
</del><ins>+
+ /**
+ * Filter the maximum upload size allowed in php.ini.
+ *
+ * @since 2.5.0
+ *
+ * @param int $size Max upload size limit in bytes.
+ * @param int $u_bytes Maximum upload filesize in bytes.
+ * @param int $p_bytes Maximum size of POST data in bytes.
+ */
+ return apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -2125,8 +2370,15 @@
</span><span class="cx"> require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
</span><span class="cx"> require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php';
</span><span class="cx">
</span><del>- $implementations = apply_filters( 'wp_image_editors',
- array( 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD' ) );
</del><ins>+ /**
+ * Filter the list of image editing library classes.
+ *
+ * @since 3.5.0
+ *
+ * @param array $image_editors List of available image editors. Defaults are
+ * 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'.
+ */
+ $implementations = apply_filters( 'wp_image_editors', array( 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD' ) );
</ins><span class="cx">
</span><span class="cx"> foreach ( $implementations as $implementation ) {
</span><span class="cx"> if ( ! call_user_func( array( $implementation, 'test' ), $args ) )
</span><span class="lines">@@ -2180,12 +2432,26 @@
</span><span class="cx"> if ( wp_is_mobile() )
</span><span class="cx"> $defaults['multi_selection'] = false;
</span><span class="cx">
</span><ins>+ /**
+ * Filter the Plupload default settings.
+ *
+ * @since 3.4.0
+ *
+ * @param array $defaults Default Plupload settings array.
+ */
</ins><span class="cx"> $defaults = apply_filters( 'plupload_default_settings', $defaults );
</span><span class="cx">
</span><span class="cx"> $params = array(
</span><span class="cx"> 'action' => 'upload-attachment',
</span><span class="cx"> );
</span><span class="cx">
</span><ins>+ /**
+ * Filter the Plupload default parameters.
+ *
+ * @since 3.4.0
+ *
+ * @param array $params Default Plupload parameters array.
+ */
</ins><span class="cx"> $params = apply_filters( 'plupload_default_params', $params );
</span><span class="cx"> $params['_wpnonce'] = wp_create_nonce( 'media-form' );
</span><span class="cx"> $defaults['multipart_params'] = $params;
</span><span class="lines">@@ -2272,6 +2538,7 @@
</span><span class="cx">
</span><span class="cx"> if ( $meta && 'image' === $type ) {
</span><span class="cx"> $sizes = array();
</span><ins>+
</ins><span class="cx"> /** This filter is documented in wp-admin/includes/media.php */
</span><span class="cx"> $possible_sizes = apply_filters( 'image_size_names_choose', array(
</span><span class="cx"> 'thumbnail' => __('Thumbnail'),
</span><span class="lines">@@ -2286,6 +2553,8 @@
</span><span class="cx"> // If the filter does not return something, then image_downsize() is just an expensive
</span><span class="cx"> // way to check the image metadata, which we do second.
</span><span class="cx"> foreach ( $possible_sizes as $size => $label ) {
</span><ins>+
+ /** This filter is documented in wp-includes/media.php */
</ins><span class="cx"> if ( $downsize = apply_filters( 'image_downsize', false, $attachment->ID, $size ) ) {
</span><span class="cx"> if ( ! $downsize[3] )
</span><span class="cx"> continue;
</span><span class="lines">@@ -2360,6 +2629,15 @@
</span><span class="cx"> if ( function_exists('get_compat_media_markup') )
</span><span class="cx"> $response['compat'] = get_compat_media_markup( $attachment->ID, array( 'in_modal' => true ) );
</span><span class="cx">
</span><ins>+ /**
+ * Filter the attachment data prepared for JavaScript.
+ *
+ * @since 3.5.0
+ *
+ * @param array $response Array of prepared attachment data.
+ * @param int|object $attachment Attachment ID or object.
+ * @param array $meta Array of attachment meta data.
+ */
</ins><span class="cx"> return apply_filters( 'wp_prepare_attachment_for_js', $response, $attachment, $meta );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2392,6 +2670,7 @@
</span><span class="cx"> 'library' => '',
</span><span class="cx"> );
</span><span class="cx">
</span><ins>+ /** This filter is documented in wp-admin/includes/media.php */
</ins><span class="cx"> $tabs = apply_filters( 'media_upload_tabs', $tabs );
</span><span class="cx"> unset( $tabs['type'], $tabs['type_url'], $tabs['gallery'], $tabs['library'] );
</span><span class="cx">
</span><span class="lines">@@ -2427,6 +2706,7 @@
</span><span class="cx"> 'tabs' => $tabs,
</span><span class="cx"> 'tabUrl' => add_query_arg( array( 'chromeless' => true ), admin_url('media-upload.php') ),
</span><span class="cx"> 'mimeTypes' => wp_list_pluck( get_post_mime_types(), 0 ),
</span><ins>+ /** This filter is documented in wp-admin/includes/media.php */
</ins><span class="cx"> 'captions' => ! apply_filters( 'disable_captions', '' ),
</span><span class="cx"> 'nonce' => array(
</span><span class="cx"> 'sendToEditor' => wp_create_nonce( 'media-send-to-editor' ),
</span><span class="lines">@@ -2572,9 +2852,26 @@
</span><span class="cx"> 'addToVideoPlaylistTitle' => __( 'Add to Video Playlist' ),
</span><span class="cx"> );
</span><span class="cx">
</span><ins>+ /**
+ * Filter the media view settings.
+ *
+ * @since 3.5.0
+ *
+ * @param array $settings List of media view settings.
+ * @param WP_Post $post Post object.
+ */
</ins><span class="cx"> $settings = apply_filters( 'media_view_settings', $settings, $post );
</span><del>- $strings = apply_filters( 'media_view_strings', $strings, $post );
</del><span class="cx">
</span><ins>+ /**
+ * Filter the media view strings.
+ *
+ * @since 3.5.0
+ *
+ * @param array $strings List of media view strings.
+ * @param WP_Post $post Post object.
+ */
+ $strings = apply_filters( 'media_view_strings', $strings, $post );
+
</ins><span class="cx"> $strings['settings'] = $settings;
</span><span class="cx">
</span><span class="cx"> wp_localize_script( 'media-views', '_wpMediaViewsL10n', $strings );
</span><span class="lines">@@ -2594,11 +2891,16 @@
</span><span class="cx"> add_action( 'wp_footer', 'wp_print_media_templates' );
</span><span class="cx"> add_action( 'customize_controls_print_footer_scripts', 'wp_print_media_templates' );
</span><span class="cx">
</span><ins>+ /**
+ * Fires at the conclusion of wp_enqueue_media().
+ *
+ * @since 3.5.0
+ */
</ins><span class="cx"> do_action( 'wp_enqueue_media' );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Retrieve media attached to the passed post
</del><ins>+ * Retrieve media attached to the passed post.
</ins><span class="cx"> *
</span><span class="cx"> * @since 3.6.0
</span><span class="cx"> *
</span><span class="lines">@@ -2619,10 +2921,28 @@
</span><span class="cx"> 'order' => 'ASC',
</span><span class="cx"> );
</span><span class="cx">
</span><ins>+ /**
+ * Filter arguments used to retrieve media attached to the given post.
+ *
+ * @since 3.6.0
+ *
+ * @param array $args Post query arguments.
+ * @param string $type Mime type of the desired media.
+ * @param mixed $post Post ID or object.
+ */
</ins><span class="cx"> $args = apply_filters( 'get_attached_media_args', $args, $type, $post );
</span><span class="cx">
</span><span class="cx"> $children = get_children( $args );
</span><span class="cx">
</span><ins>+ /**
+ * Filter the
+ *
+ * @since 3.6.0
+ *
+ * @param array $children Associative array of media attached to the given post.
+ * @param string $type Mime type of the media desired.
+ * @param mixed $post Post ID or object.
+ */
</ins><span class="cx"> return (array) apply_filters( 'get_attached_media', $children, $type, $post );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2654,14 +2974,14 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Retrieve galleries from the passed post's content
</del><ins>+ * Retrieve galleries from the passed post's content.
</ins><span class="cx"> *
</span><span class="cx"> * @since 3.6.0
</span><span class="cx"> *
</span><del>- * @param mixed $post Optional. Post ID or object.
- * @param boolean $html Whether to return HTML or data in the array
</del><ins>+ * @param int|WP_Post $post Optional. Post ID or object.
+ * @param bool $html Whether to return HTML or data in the array.
</ins><span class="cx"> * @return array A list of arrays, each containing gallery data and srcs parsed
</span><del>- * from the expanded shortcode
</del><ins>+ * from the expanded shortcode.
</ins><span class="cx"> */
</span><span class="cx"> function get_post_galleries( $post, $html = true ) {
</span><span class="cx"> if ( ! $post = get_post( $post ) )
</span><span class="lines">@@ -2695,6 +3015,14 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Filter the list of all found galleries in the given post.
+ *
+ * @since 3.6.0
+ *
+ * @param array $galleries Associative array of all found post galleries.
+ * @param WP_Post $post Post object.
+ */
</ins><span class="cx"> return apply_filters( 'get_post_galleries', $galleries, $post );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2703,14 +3031,23 @@
</span><span class="cx"> *
</span><span class="cx"> * @since 3.6.0
</span><span class="cx"> *
</span><del>- * @param mixed $post Optional. Post ID or object.
- * @param boolean $html Whether to return HTML or data
- * @return string|array Gallery data and srcs parsed from the expanded shortcode
</del><ins>+ * @param int|WP_Post $post Optional. Post ID or object.
+ * @param bool $html Whether to return HTML or data.
+ * @return string|array Gallery data and srcs parsed from the expanded shortcode.
</ins><span class="cx"> */
</span><span class="cx"> function get_post_gallery( $post = 0, $html = true ) {
</span><span class="cx"> $galleries = get_post_galleries( $post, $html );
</span><span class="cx"> $gallery = reset( $galleries );
</span><span class="cx">
</span><ins>+ /**
+ * Filter the first-found post gallery.
+ *
+ * @since 3.6.0
+ *
+ * @param array $gallery The first-found post gallery.
+ * @param int|WP_Post $post Post ID or object.
+ * @param array $galleries Associative array of all found post galleries.
+ */
</ins><span class="cx"> return apply_filters( 'get_post_gallery', $gallery, $post, $galleries );
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>