Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: disable_captions

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 3 times in this file.

Line Code
162       * Filter whether to disable captions.
163       *
164       * Prevents image captions from being appended to image HTML when inserted into the editor.
165       *
166       * @since 2.6.0
167       *
168       * @param bool $bool Whether to disable appending captions. Returning true to the filter
169       *                   will disable captions. Default empty string.
170       */
171      if ( empty($caption) || apply_filters( 'disable_captions', '' ) )
172           return $html;
173
174      $id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
175
176      if ( ! preg_match( '/width=["\']([0-9]+)/', $html, $matches ) )
177           return $html;
178
179      $width = $matches[1];
180
 
Line Code
1987
1988           if ( '' == f.src.value || '' == t.width )
1989                return false;
1990
1991           if ( f.alt.value )
1992                alt = f.alt.value.replace(/'/g, '&#039;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
1993
1994 <?php
1995      /** This filter is documented in wp-admin/includes/media.php */
1996      if ( ! apply_filters( 'disable_captions', '' ) ) {
1997           ?>
1998           if ( f.caption.value ) {
1999                caption = f.caption.value.replace(/\r\n|\r/g, '\n');
2000                caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){
2001                     return a.replace(/[\r\n\t]+/, ' ');
2002                });
2003
2004                caption = caption.replace(/\s*\n\s*/g, '<br />');
2005           }
 
Line Code
2417  * Creates the form for external url
2418  *
2419  * @since 2.7.0
2420  *
2421  * @param string $default_view
2422  * @return string the form html
2423  */
2424 function wp_media_insert_url_form( $default_view = 'image' ) {
2425      /** This filter is documented in wp-admin/includes/media.php */
2426      if ( ! apply_filters( 'disable_captions', '' ) ) {
2427           $caption = '
2428           <tr class="image-only">
2429                <th scope="row" class="label">
2430                     <label for="caption"><span class="alignleft">' . __('Image Caption') . '</span></label>
2431                </th>
2432                <td class="field"><textarea id="caption" name="caption"></textarea></td>
2433           </tr>
2434 ';
2435      } else {