Make WordPress Core

Changeset 8313


Ignore:
Timestamp:
07/11/2008 03:59:14 PM (16 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

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/gears-manifest.php

    r8307 r8313  
    6565{
    6666"betaManifestVersion" : 1,
    67 "version" : "<?php echo $man_version; ?>_20080710",
     67"version" : "<?php echo $man_version; ?>_20080710a",
    6868"entries" : [
    6969<?php echo $defaults; ?>
     
    132132{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/source_editor.js?ver=311" },
    133133{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/anchor.js?ver=311" },
    134 { "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js?ver=311c" },
     134{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js?ver=311d" },
    135135{ "url" : "../wp-includes/js/tinymce/tiny_mce.js?ver=311" },
    136136{ "url" : "../wp-includes/js/tinymce/themes/advanced/editor_template.js?ver=311" },
     
    149149{ "url" : "../wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm?ver=311" },
    150150{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/template.htm?ver=311" },
    151 { "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/editimage.html?ver=311c" },
     151{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/editimage.html?ver=311d" },
    152152{ "url" : "../wp-includes/js/tinymce/wp-mce-help.php?ver=311" },
    153153
     
    162162{ "url" : "../wp-includes/js/tinymce/plugins/paste/css/pasteword.css?ver=311" },
    163163{ "url" : "../wp-includes/js/tinymce/plugins/paste/css/blank.css?ver=311" },
    164 { "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css?ver=311c" },
     164{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css?ver=311d" },
    165165{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage-rtl.css?ver=311" },
    166166{ "url" : "../wp-includes/js/tinymce/wordpress.css?ver=311" },
  • 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
  • trunk/wp-admin/js/editor.js

    r8260 r8313  
    5353        content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div');
    5454        content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\n');
    55         content = content.replace(new RegExp('\\s*\\[wp_caption([^\\[]+)\\[/wp_caption\\]\\s*', 'gi'), '\n\n[wp_caption$1[/wp_caption]\n\n');
    56         content = content.replace(new RegExp('wp_caption\\]\\n\\n+\\[wp_caption', 'g'), 'wp_caption]\n\n[wp_caption');
     55        content = content.replace(new RegExp('\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*', 'gi'), '\n\n[caption$1[/caption]\n\n');
     56        content = content.replace(new RegExp('caption\\]\\n\\n+\\[caption', 'g'), 'caption]\n\n[caption');
    5757
    5858        var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre';
     
    167167        pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1");
    168168        pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1');
    169         pee = pee.replace(new RegExp('(?:<p>|<br ?/?>)*\\s*\\[wp_caption([^\\[]+)\\[/wp_caption\\]\\s*(?:</p>|<br ?/?>)*', 'gi'), '[wp_caption$1[/wp_caption]');
     169        pee = pee.replace(new RegExp('(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*', 'gi'), '[caption$1[/caption]');
    170170        // pee = pee.replace(new RegExp('^((?:&nbsp;)*)\\s', 'mg'), '$1&nbsp;');
    171171
  • trunk/wp-admin/js/media-upload.js

    r8245 r8313  
    66            ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark);
    77
    8         if ( h.indexOf('[wp_caption') != -1 )
     8        if ( h.indexOf('[caption') != -1 )
    99            h = ed.plugins.wpeditimage._do_shcode(h);
    1010       
  • trunk/wp-includes/js/tinymce/plugins/wpeditimage/editimage.html

    r8307 r8313  
    55<title></title>
    66
    7 <script type="text/javascript" src="js/editimage.js?ver=311c"></script>
     7<script type="text/javascript" src="js/editimage.js?ver=311d"></script>
    88<script type="text/javascript" src="../../utils/form_utils.js?ver=311"></script>
    99
    10 <link rel="stylesheet" href="css/editimage.css?ver=311c" type="text/css" media="all" />
     10<link rel="stylesheet" href="css/editimage.css?ver=311d" type="text/css" media="all" />
    1111<link rel="stylesheet" href="../../../../../wp-admin/css/media.css?ver=2.6-beta3" type="text/css" media="all" />
    1212<script type="text/javascript">
     
    8686        </tr>
    8787
    88         <tr>
     88        <tr id="cap_field">
    8989            <th valign="top" scope="row" class="label">
    9090                <label for="img_cap">
  • trunk/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js

    r8307 r8313  
    8888
    8989        _do_shcode : function(co) {
    90             return co.replace(/\[wp_caption([^\]]+)\]([\s\S]+?)\[\/wp_caption\][\s\u00a0]*/g, function(a,b,c){
     90            return co.replace(/\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\][\s\u00a0]*/g, function(a,b,c){
    9191                b = b.replace(/\\'|\\&#39;|\\&#039;/g, '&#39;').replace(/\\"|\\&quot;/g, '&quot;');
    9292                c = c.replace(/\\&#39;|\\&#039;/g, '&#39;').replace(/\\&quot;/g, '&quot;');
     
    102102                var div_cls = (cls == 'aligncenter') ? 'mceTemp mceIEcenter' : 'mceTemp';
    103103
    104                 return '<div class="'+div_cls+'"><dl id="'+id+'" class="wp_caption '+cls+'" style="width: '+(10+parseInt(w))+
    105                 'px"><dt class="wp_caption_dt">'+c+'</dt><dd class="wp_caption_dd">'+cap+'</dd></dl></div>';
     104                return '<div class="'+div_cls+'"><dl id="'+id+'" class="wp-caption '+cls+'" style="width: '+(10+parseInt(w))+
     105                'px"><dt class="wp-caption-dt">'+c+'</dt><dd class="wp-caption-dd">'+cap+'</dd></dl></div>';
    106106            });
    107107        },
     
    120120                cap = cap.replace(/<\S[^<>]*>/gi, '').replace(/'/g, '&#39;').replace(/"/g, '&quot;');
    121121
    122                 return '[wp_caption id="'+id+'" align="'+cls+'" width="'+w+'" caption="'+cap+'"]'+c+'[/wp_caption]';
     122                return '[caption id="'+id+'" align="'+cls+'" width="'+w+'" caption="'+cap+'"]'+c+'[/caption]';
    123123            });
    124124        },
  • trunk/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js

    r8307 r8313  
    248248        var t = this, h, c, el, id, link, fname, f = document.forms[0], ed = tinyMCEPopup.editor, d = t.I('img_demo'), dom = tinyMCEPopup.dom, DL, caption = null;
    249249        document.dir = tinyMCEPopup.editor.getParam('directionality','');
     250
     251        if ( ! tinyMCEPopup.editor.getParam('wpeditimage_do_captions', true) )
     252            t.I('cap_field').style.display = 'none';
     253
    250254        tinyMCEPopup.restoreSelection();
    251255        el = ed.selection.getNode();
     
    266270
    267271            tinymce.each(DL.childNodes, function(e) {
    268                 if ( e.nodeName == 'DD' && dom.hasClass(e, 'wp_caption_dd') ) {
     272                if ( e.nodeName == 'DD' && dom.hasClass(e, 'wp-caption-dd') ) {
    269273                    caption = e.innerHTML;
    270274                    return;
     
    424428            if ( DL ) {
    425429                ed.dom.setAttribs(DL, {
    426                     'class' : 'wp_caption '+t.align,
     430                    'class' : 'wp-caption '+t.align,
    427431                    style : 'width: '+cap_width+'px;'
    428432                });
     
    431435                    ed.dom.setAttrib(DIV, 'class', div_cls);
    432436
    433                 if ( (DT = ed.dom.getParent(el, 'dt')) && (DD = DT.nextSibling) && ed.dom.hasClass(DD, 'wp_caption_dd') )
     437                if ( (DT = ed.dom.getParent(el, 'dt')) && (DD = DT.nextSibling) && ed.dom.hasClass(DD, 'wp-caption-dd') )
    434438                    ed.dom.setHTML(DD, f.img_cap.value);
    435439
     
    449453                } else html = ed.dom.getOuterHTML(el);
    450454
    451                 html = '<dl id="'+cap_id+'" class="wp_caption '+t.align+'" style="width: '+cap_width+
    452                 'px"><dt class="wp_caption_dt">'+html+'</dt><dd class="wp_caption_dd">'+f.img_cap.value+'</dd></dl>';
     455                html = '<dl id="'+cap_id+'" class="wp-caption '+t.align+'" style="width: '+cap_width+
     456                'px"><dt class="wp-caption-dt">'+html+'</dt><dd class="wp-caption-dd">'+f.img_cap.value+'</dd></dl>';
    453457
    454458                cap = ed.dom.create('div', {'class': div_cls}, html);
  • trunk/wp-includes/js/tinymce/tiny_mce_config.php

    r8307 r8313  
    130130$mce_buttons_4 = apply_filters('mce_buttons_4', array());
    131131$mce_buttons_4 = implode($mce_buttons_4, ',');
     132
     133$do_captions = ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF ) ? false : true;
    132134
    133135// TinyMCE init settings
     
    164166    'content_css' => "$mce_css",
    165167    'save_callback' => 'switchEditors.saveCallback',
     168    'wpeditimage_do_captions' => $do_captions,
    166169    'plugins' => "$plugins",
    167170    // pass-through the settings for compression and caching, so they can be changed with "tiny_mce_before_init"
     
    223226if ( $disk_cache ) {
    224227
    225     $cacheKey = apply_filters('tiny_mce_version', '20080709');
     228    $cacheKey = apply_filters('tiny_mce_version', '20080710');
    226229
    227230    foreach ( $initArray as $v )
  • trunk/wp-includes/js/tinymce/wordpress.css

    r8239 r8313  
    1616}
    1717
    18 .wp_caption {
     18.wp-caption {
    1919    border: 1px solid #ddd;
    2020    text-align: center;
     
    2828}
    2929
    30 .wp_caption img {
     30.wp-caption img {
    3131    margin: 0;
    3232    padding: 0;
     
    3434}
    3535
    36 .wp_caption_dd {
     36.wp-caption-dd {
    3737    font-size: 11px;
    3838    line-height: 17px;
  • trunk/wp-includes/media.php

    r8289 r8313  
    352352
    353353add_shortcode('wp_caption', 'img_caption_shortcode');
     354add_shortcode('caption', 'img_caption_shortcode');
    354355
    355356function img_caption_shortcode($attr, $content = null) {
    356    
     357
     358    if ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF )
     359        return $content;
     360
    357361    // Allow plugins/themes to override the default caption template.
    358362    $output = apply_filters('img_caption_shortcode', '', $attr, $content);
  • trunk/wp-includes/script-loader.php

    r8307 r8313  
    3535    $scripts->add( 'editor', false, $visual_editor, '20080321' );
    3636
    37     $scripts->add( 'editor_functions', '/wp-admin/js/editor.js', false, '20080706' );
     37    $scripts->add( 'editor_functions', '/wp-admin/js/editor.js', false, '20080710' );
    3838
    3939    // Modify this version when tinyMCE plugins are changed.
    40     $mce_version = apply_filters('tiny_mce_version', '20080709');
     40    $mce_version = apply_filters('tiny_mce_version', '20080710');
    4141    $scripts->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('editor_functions'), $mce_version );
    4242
     
    160160        ) );
    161161        $scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20080709' );
    162         $scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20080702' );
     162        $scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20080710' );
    163163        $scripts->localize( 'upload', 'uploadL10n', array(
    164164            'browseTitle' => attribute_escape(__('Browse your files')),
Note: See TracChangeset for help on using the changeset viewer.