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
207       * Filters whether to disable captions.
208       *
209       * Prevents image captions from being appended to image HTML when inserted into the editor.
210       *
211       * @since 2.6.0
212       *
213       * @param bool $bool Whether to disable appending captions. Returning true from the filter
214       *                   will disable captions. Default empty string.
215       */
216      if ( empty( $caption ) || apply_filters( 'disable_captions', '' ) ) {
217           return $html;
218      }
219
220      $id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
221
222      if ( ! preg_match( '/width=["\']([0-9]+)/', $html, $matches ) ) {
223           return $html;
224      }
225
 
Line Code
2434
2435           if ( '' === f.src.value || '' === t.width )
2436                return false;
2437
2438           if ( f.alt.value )
2439                alt = f.alt.value.replace(/'/g, '&#039;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
2440
2441           <?php
2442           /** This filter is documented in wp-admin/includes/media.php */
2443           if ( ! apply_filters( 'disable_captions', '' ) ) {
2444                ?>
2445                if ( f.caption.value ) {
2446                     caption = f.caption.value.replace(/\r\n|\r/g, '\n');
2447                     caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){
2448                          return a.replace(/[\r\n\t]+/, ' ');
2449                     });
2450
2451                     caption = caption.replace(/\s*\n\s*/g, '<br />');
2452                }
 
Line Code
2918  * Creates the form for external url.
2919  *
2920  * @since 2.7.0
2921  *
2922  * @param string $default_view
2923  * @return string HTML content of the form.
2924  */
2925 function wp_media_insert_url_form( $default_view = 'image' ) {
2926      /** This filter is documented in wp-admin/includes/media.php */
2927      if ( ! apply_filters( 'disable_captions', '' ) ) {
2928           $caption = '
2929           <tr class="image-only">
2930                <th scope="row" class="label">
2931                     <label for="caption"><span class="alignleft">' . __( 'Image Caption' ) . '</span></label>
2932                </th>
2933                <td class="field"><textarea id="caption" name="caption"></textarea></td>
2934           </tr>';
2935      } else {
2936           $caption = '';