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
187       * Filter whether to disable captions.
188       *
189       * Prevents image captions from being appended to image HTML when inserted into the editor.
190       *
191       * @since 2.6.0
192       *
193       * @param bool $bool Whether to disable appending captions. Returning true to the filter
194       *                   will disable captions. Default empty string.
195       */
196      if ( empty($caption) || apply_filters( 'disable_captions', '' ) )
197           return $html;
198
199      $id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
200
201      if ( ! preg_match( '/width=["\']([0-9]+)/', $html, $matches ) )
202           return $html;
203
204      $width = $matches[1];
205
 
Line Code
2070
2071           if ( '' == f.src.value || '' == t.width )
2072                return false;
2073
2074           if ( f.alt.value )
2075                alt = f.alt.value.replace(/'/g, '&#039;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
2076
2077 <?php
2078      /** This filter is documented in wp-admin/includes/media.php */
2079      if ( ! apply_filters( 'disable_captions', '' ) ) {
2080           ?>
2081           if ( f.caption.value ) {
2082                caption = f.caption.value.replace(/\r\n|\r/g, '\n');
2083                caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){
2084                     return a.replace(/[\r\n\t]+/, ' ');
2085                });
2086
2087                caption = caption.replace(/\s*\n\s*/g, '<br />');
2088           }
 
Line Code
2509  * Creates the form for external url
2510  *
2511  * @since 2.7.0
2512  *
2513  * @param string $default_view
2514  * @return string the form html
2515  */
2516 function wp_media_insert_url_form( $default_view = 'image' ) {
2517      /** This filter is documented in wp-admin/includes/media.php */
2518      if ( ! apply_filters( 'disable_captions', '' ) ) {
2519           $caption = '
2520           <tr class="image-only">
2521                <th scope="row" class="label">
2522                     <label for="caption"><span class="alignleft">' . __('Image Caption') . '</span></label>
2523                </th>
2524                <td class="field"><textarea id="caption" name="caption"></textarea></td>
2525           </tr>
2526 ';
2527      } else {