Make WordPress Core


Ignore:
Timestamp:
03/05/2012 07:31:31 AM (13 years ago)
Author:
azaozz
Message:

Based on the current UX feedback, remove the "Insert Link" UI from under the caption fields, see #18311

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/media.php

    r19999 r20114  
    150150    $width = $matches[1];
    151151
    152     $caption = preg_replace_callback( '/<[a-zA-Z][^<>]+>/', '_cleanup_image_add_caption', $caption );
     152    // look only for html tags with attributes
     153    $caption = preg_replace_callback( '/<[a-zA-Z0-9]+ [^<>]+>/', '_cleanup_image_add_caption', $caption );
    153154    $caption = str_replace( '"', '&quot;', $caption );
    154155
     
    166167// Private, preg_replace callback used in image_add_caption()
    167168function _cleanup_image_add_caption($str) {
    168     if ( isset($str[0]) )
    169         return str_replace( '"', "'", $str[0] );
     169    if ( isset($str[0]) ) {
     170        // look for single quotes inside html attributes (for example in title)
     171        $s = preg_replace_callback( '/="[^"]+"/', '_cleanup_image_add_caption2', $str[0] );
     172        return str_replace( '"', "'", $s );
     173    }
    170174
    171175    return '';
     176}
     177
     178// Private, preg_replace callback used in image_add_caption()
     179function _cleanup_image_add_caption2($str) {
     180    return str_replace( "'", '&#39;', $str );
    172181}
    173182
     
    796805    $name = "attachments[{$edit_post->ID}][post_excerpt]";
    797806
    798     return '
    799     <textarea class="code" name="' . $name . '" id="' . $name . '">' . $edit_post->post_excerpt . '</textarea>
    800     <div class="edit-caption-controls hide-if-no-js">
    801     <input type="button" class="button caption-insert-link" value="' . esc_attr__('Insert Link') . '" />
    802     <div class="caption-insert-link-wrap hidden">
    803     <label><span>' . __('Link URL') . '</span>
    804     <input type="text" value="" class="caption-insert-link-url" /></label>
    805     <label><span>' . __('Linked text') . '</span>
    806     <input type="text" value="" class="caption-insert-link-text" /></label>
    807     <div class="caption-insert-link-buttons">
    808     <input type="button" class="button caption-cancel" value="' . esc_attr__('Cancel') . '" />
    809     <input type="button" class="button-primary caption-save" value="' . esc_attr__('Insert') . '" />
    810     <br class="clear" />
    811     </div></div></div>
    812     ';
     807    return '<textarea class="code" name="' . $name . '" id="' . $name . '">' . $edit_post->post_excerpt . '</textarea>';
    813808}
    814809
     
    15481543<?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?>
    15491544        if ( f.caption.value ) {
    1550             caption = f.caption.value.replace(/<[a-z][^<>]+>/g, function(a){
     1545            caption = f.caption.value.replace(/<[a-zA-Z0-9]+ [^<>]+>/g, function(a){
     1546                a = a.replace(/="[^"]+"/, function(b){
     1547                    return b.replace(/'/g, '&#39;');
     1548                });
    15511549                return a.replace(/"/g, "'");
    15521550            });
     
    19551953                <span class="alignleft"><label for="caption">' . __('Image Caption') . '</label></span>
    19561954            </th>
    1957             <td class="field"><input id="caption" name="caption" value="" type="text" /></td>
     1955            <td class="field"><textarea id="caption" class="code" name="caption"></textarea></td>
    19581956        </tr>
    19591957';
Note: See TracChangeset for help on using the changeset viewer.