Make WordPress Core


Ignore:
Timestamp:
07/11/2008 03:59:14 PM (17 years ago)
Author:
ryan
Message:

Rename wp_caption shortcode to caption. Allow themes to disable captioning. Use dashes instead of underscores in class names. Props azaozz. see #6812

File:
1 edited

Legend:

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

    r8312 r8313  
    6868function image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) {
    6969
    70     if ( empty($alt) ) return $html;
     70    if ( empty($alt) || ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF ) ) return $html;
    7171    $id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
    7272
     
    7878    if ( empty($align) ) $align = 'none';
    7979
    80     $shcode = '[wp_caption id="' . $id . '" align="align' . $align
    81     . '" width="' . $width . '" caption="' . $alt . '"]' . $html . '[/wp_caption]';
     80    $shcode = '[caption id="' . $id . '" align="align' . $align
     81    . '" width="' . $width . '" caption="' . $alt . '"]' . $html . '[/caption]';
    8282
    8383    return apply_filters( 'image_add_caption_shortcode', $shcode, $html );
     
    509509    if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
    510510        $form_fields['post_title']['required'] = true;
    511         $form_fields['post_excerpt']['label'] = __('Caption');
    512         $form_fields['post_excerpt']['helps'][] = __('Alternate text, e.g. "The Mona Lisa"');
     511
     512        if ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF ) {
     513            $form_fields['post_excerpt']['label'] = __('Alternate Text');
     514            $form_fields['post_excerpt']['helps'][] = __('Alt text for the image, e.g. "The Mona Lisa"');
     515        } else {
     516            $form_fields['post_excerpt']['label'] = __('Caption');
     517            $form_fields['post_excerpt']['helps'][] = __('Also used as alternate text for the image');
     518        }
    513519
    514520        $form_fields['post_content']['label'] = __('Description');
     
    599605    $link = get_attachment_link($post->ID);
    600606
     607    if ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF )
     608        $alt = __('Alternate Text');
     609    else
     610        $alt = __('Caption');
     611
    601612    $form_fields = array(
    602613        'post_title'   => array(
     
    605616        ),
    606617        'post_excerpt' => array(
    607             'label'      => __('Caption'),
     618            'label'      => $alt,
    608619            'value'      => $edit_post->post_excerpt,
    609620        ),
     
    10081019        if ( f.alt.value ) {
    10091020            alt = f.alt.value.replace(/['"<>]+/g, '');
     1021<?php if ( ! defined('CAPTIONS_OFF') || true != CAPTIONS_OFF ) { ?>
    10101022            caption = f.alt.value.replace(/'/g, '&#39;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
     1023<?php } ?>
    10111024        }
    10121025
     
    10191032
    10201033        if ( caption )
    1021             html = '[wp_caption id="" align="'+t.align+'" width="'+t.width+'" caption="'+caption+'"]'+html+'[/wp_caption]';
     1034            html = '[caption id="" align="'+t.align+'" width="'+t.width+'" caption="'+caption+'"]'+html+'[/caption]';
    10221035
    10231036        var win = window.dialogArguments || opener || parent || top;
     
    12631276
    12641277function type_form_image() {
    1265     return '
     1278    $form = '
    12661279    <table class="describe"><tbody>
    12671280        <tr>
     
    12801293            <td class="field"><p><input id="title" name="title" value="" type="text" aria-required="true" /></p></td>
    12811294        </tr>
    1282 
     1295';
     1296    if ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF ) {
     1297        $form .= '
     1298        <tr>
     1299            <th valign="top" scope="row" class="label">
     1300                <span class="alignleft"><label for="alt">' . __('Alternate Text') . '</label></span>
     1301            </th>
     1302            <td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" />
     1303            <p class="help">' . __('Alt text for the image, e.g. "The Mona Lisa"') . '</p></td>
     1304        </tr>
     1305';
     1306
     1307    } else {
     1308        $form .= '
    12831309        <tr>
    12841310            <th valign="top" scope="row" class="label">
     
    12881314            <p class="help">' . __('Also used as alternate text for the image') . '</p></td>
    12891315        </tr>
    1290 
     1316';
     1317    }
     1318        $form .= '
    12911319        <tr class="align">
    12921320            <th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th>
     
    13221350    </tbody></table>
    13231351';
     1352
     1353    return $form;
    13241354}
    13251355
Note: See TracChangeset for help on using the changeset viewer.