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
202       * Filters whether to disable captions.
203       *
204       * Prevents image captions from being appended to image HTML when inserted into the editor.
205       *
206       * @since 2.6.0
207       *
208       * @param bool $bool Whether to disable appending captions. Returning true to the filter
209       *                   will disable captions. Default empty string.
210       */
211      if ( empty( $caption ) || apply_filters( 'disable_captions', '' ) ) {
212           return $html;
213      }
214
215      $id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
216
217      if ( ! preg_match( '/width=["\']([0-9]+)/', $html, $matches ) ) {
218           return $html;
219      }
220
 
Line Code
2245
2246           if ( '' == f.src.value || '' == t.width )
2247                return false;
2248
2249           if ( f.alt.value )
2250                alt = f.alt.value.replace(/'/g, '&#039;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
2251
2252      <?php
2253      /** This filter is documented in wp-admin/includes/media.php */
2254      if ( ! apply_filters( 'disable_captions', '' ) ) {
2255           ?>
2256      if ( f.caption.value ) {
2257           caption = f.caption.value.replace(/\r\n|\r/g, '\n');
2258           caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){
2259                return a.replace(/[\r\n\t]+/, ' ');
2260           });
2261
2262           caption = caption.replace(/\s*\n\s*/g, '<br />');
2263      }
 
Line Code
2724  * Creates the form for external url
2725  *
2726  * @since 2.7.0
2727  *
2728  * @param string $default_view
2729  * @return string the form html
2730  */
2731 function wp_media_insert_url_form( $default_view = 'image' ) {
2732      /** This filter is documented in wp-admin/includes/media.php */
2733      if ( ! apply_filters( 'disable_captions', '' ) ) {
2734           $caption = '
2735           <tr class="image-only">
2736                <th scope="row" class="label">
2737                     <label for="caption"><span class="alignleft">' . __( 'Image Caption' ) . '</span></label>
2738                </th>
2739                <td class="field"><textarea id="caption" name="caption"></textarea></td>
2740           </tr>
2741 ';
2742      } else {