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
191       * Filters whether to disable captions.
192       *
193       * Prevents image captions from being appended to image HTML when inserted into the editor.
194       *
195       * @since 2.6.0
196       *
197       * @param bool $bool Whether to disable appending captions. Returning true to the filter
198       *                   will disable captions. Default empty string.
199       */
200      if ( empty($caption) || apply_filters( 'disable_captions', '' ) )
201           return $html;
202
203      $id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
204
205      if ( ! preg_match( '/width=["\']([0-9]+)/', $html, $matches ) )
206           return $html;
207
208      $width = $matches[1];
209
 
Line Code
2091
2092           if ( '' == f.src.value || '' == t.width )
2093                return false;
2094
2095           if ( f.alt.value )
2096                alt = f.alt.value.replace(/'/g, '&#039;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
2097
2098 <?php
2099      /** This filter is documented in wp-admin/includes/media.php */
2100      if ( ! apply_filters( 'disable_captions', '' ) ) {
2101           ?>
2102           if ( f.caption.value ) {
2103                caption = f.caption.value.replace(/\r\n|\r/g, '\n');
2104                caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){
2105                     return a.replace(/[\r\n\t]+/, ' ');
2106                });
2107
2108                caption = caption.replace(/\s*\n\s*/g, '<br />');
2109           }
 
Line Code
2530  * Creates the form for external url
2531  *
2532  * @since 2.7.0
2533  *
2534  * @param string $default_view
2535  * @return string the form html
2536  */
2537 function wp_media_insert_url_form( $default_view = 'image' ) {
2538      /** This filter is documented in wp-admin/includes/media.php */
2539      if ( ! apply_filters( 'disable_captions', '' ) ) {
2540           $caption = '
2541           <tr class="image-only">
2542                <th scope="row" class="label">
2543                     <label for="caption"><span class="alignleft">' . __('Image Caption') . '</span></label>
2544                </th>
2545                <td class="field"><textarea id="caption" name="caption"></textarea></td>
2546           </tr>
2547 ';
2548      } else {