From 752b0eb45b9cc67a9c2c14b4b483ee9aa3cb88ef Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 11 Jul 2008 15:59:14 +0000 Subject: [PATCH] Rename wp_caption shortcode to caption. Allow themes to disable captioning. Use dashes instead of underscores in class names. Props azaozz. see #6812 git-svn-id: http://svn.automattic.com/wordpress/trunk@8313 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/gears-manifest.php | 8 ++-- wp-admin/includes/media.php | 48 +++++++++++++++---- wp-admin/js/editor.js | 6 +-- wp-admin/js/media-upload.js | 2 +- .../plugins/wpeditimage/editimage.html | 6 +-- .../plugins/wpeditimage/editor_plugin.js | 8 ++-- .../plugins/wpeditimage/js/editimage.js | 14 ++++-- wp-includes/js/tinymce/tiny_mce_config.php | 5 +- wp-includes/js/tinymce/wordpress.css | 6 +-- wp-includes/media.php | 6 ++- wp-includes/script-loader.php | 6 +-- 11 files changed, 78 insertions(+), 37 deletions(-) diff --git a/wp-admin/gears-manifest.php b/wp-admin/gears-manifest.php index 961fdb23f3..ba965a4e05 100644 --- a/wp-admin/gears-manifest.php +++ b/wp-admin/gears-manifest.php @@ -64,7 +64,7 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' ); ?> { "betaManifestVersion" : 1, -"version" : "_20080710", +"version" : "_20080710a", "entries" : [ @@ -131,7 +131,7 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' ); { "url" : "../wp-includes/js/tinymce/themes/advanced/js/link.js?ver=311" }, { "url" : "../wp-includes/js/tinymce/themes/advanced/js/source_editor.js?ver=311" }, { "url" : "../wp-includes/js/tinymce/themes/advanced/js/anchor.js?ver=311" }, -{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js?ver=311c" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js?ver=311d" }, { "url" : "../wp-includes/js/tinymce/tiny_mce.js?ver=311" }, { "url" : "../wp-includes/js/tinymce/themes/advanced/editor_template.js?ver=311" }, { "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js?ver=311" }, @@ -148,7 +148,7 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' ); { "url" : "../wp-includes/js/tinymce/plugins/paste/pastetext.htm?ver=311" }, { "url" : "../wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm?ver=311" }, { "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/template.htm?ver=311" }, -{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/editimage.html?ver=311c" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/editimage.html?ver=311d" }, { "url" : "../wp-includes/js/tinymce/wp-mce-help.php?ver=311" }, { "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css?ver=311" }, @@ -161,7 +161,7 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' ); { "url" : "../wp-includes/js/tinymce/plugins/media/css/media.css?ver=311" }, { "url" : "../wp-includes/js/tinymce/plugins/paste/css/pasteword.css?ver=311" }, { "url" : "../wp-includes/js/tinymce/plugins/paste/css/blank.css?ver=311" }, -{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css?ver=311c" }, +{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css?ver=311d" }, { "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage-rtl.css?ver=311" }, { "url" : "../wp-includes/js/tinymce/wordpress.css?ver=311" }, diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index fe9eb265ea..0cb7e373f3 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -67,7 +67,7 @@ function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = fal function image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) { - if ( empty($alt) ) return $html; + if ( empty($alt) || ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF ) ) return $html; $id = ( 0 < (int) $id ) ? 'attachment_' . $id : ''; preg_match( '/width="([0-9]+)/', $html, $matches ); @@ -77,8 +77,8 @@ function image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) { $html = preg_replace( '/align[^\s\'"]+\s?/', '', $html ); if ( empty($align) ) $align = 'none'; - $shcode = '[wp_caption id="' . $id . '" align="align' . $align - . '" width="' . $width . '" caption="' . $alt . '"]' . $html . '[/wp_caption]'; + $shcode = '[caption id="' . $id . '" align="align' . $align + . '" width="' . $width . '" caption="' . $alt . '"]' . $html . '[/caption]'; return apply_filters( 'image_add_caption_shortcode', $shcode, $html ); } @@ -508,8 +508,14 @@ function media_upload_library() { function image_attachment_fields_to_edit($form_fields, $post) { if ( substr($post->post_mime_type, 0, 5) == 'image' ) { $form_fields['post_title']['required'] = true; - $form_fields['post_excerpt']['label'] = __('Caption'); - $form_fields['post_excerpt']['helps'][] = __('Alternate text, e.g. "The Mona Lisa"'); + + if ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF ) { + $form_fields['post_excerpt']['label'] = __('Alternate Text'); + $form_fields['post_excerpt']['helps'][] = __('Alt text for the image, e.g. "The Mona Lisa"'); + } else { + $form_fields['post_excerpt']['label'] = __('Caption'); + $form_fields['post_excerpt']['helps'][] = __('Also used as alternate text for the image'); + } $form_fields['post_content']['label'] = __('Description'); @@ -598,13 +604,18 @@ function get_attachment_fields_to_edit($post, $errors = null) { $file = wp_get_attachment_url($post->ID); $link = get_attachment_link($post->ID); + if ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF ) + $alt = __('Alternate Text'); + else + $alt = __('Caption'); + $form_fields = array( 'post_title' => array( 'label' => __('Title'), 'value' => $edit_post->post_title, ), 'post_excerpt' => array( - 'label' => __('Caption'), + 'label' => $alt, 'value' => $edit_post->post_excerpt, ), 'post_content' => array( @@ -1007,7 +1018,9 @@ var addExtImage = { if ( f.alt.value ) { alt = f.alt.value.replace(/['"<>]+/g, ''); + caption = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(//g, '>'); + } cls = caption ? '' : ' class="'+t.align+'"'; @@ -1018,7 +1031,7 @@ var addExtImage = { html = ''+html+''; if ( caption ) - html = '[wp_caption id="" align="'+t.align+'" width="'+t.width+'" caption="'+caption+'"]'+html+'[/wp_caption]'; + html = '[caption id="" align="'+t.align+'" width="'+t.width+'" caption="'+caption+'"]'+html+'[/caption]'; var win = window.dialogArguments || opener || parent || top; win.send_to_editor(html); @@ -1262,7 +1275,7 @@ jQuery(function($){ } function type_form_image() { - return ' + $form = ' +'; + if ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF ) { + $form .= ' + + + + +'; + } else { + $form .= ' - +'; + } + $form .= '
@@ -1279,7 +1292,20 @@ function type_form_image() {

+ + +

' . __('Alt text for the image, e.g. "The Mona Lisa"') . '

@@ -1287,7 +1313,9 @@ function type_form_image() {

' . __('Also used as alternate text for the image') . '

@@ -1321,6 +1349,8 @@ function type_form_image() {
'; + + return $form; } function type_form_audio() { diff --git a/wp-admin/js/editor.js b/wp-admin/js/editor.js index 7f5875ad08..4b32f1b101 100644 --- a/wp-admin/js/editor.js +++ b/wp-admin/js/editor.js @@ -52,8 +52,8 @@ switchEditors = { // Fix some block element newline issues content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); - content = content.replace(new RegExp('\\s*\\[wp_caption([^\\[]+)\\[/wp_caption\\]\\s*', 'gi'), '\n\n[wp_caption$1[/wp_caption]\n\n'); - content = content.replace(new RegExp('wp_caption\\]\\n\\n+\\[wp_caption', 'g'), 'wp_caption]\n\n[wp_caption'); + content = content.replace(new RegExp('\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*', 'gi'), '\n\n[caption$1[/caption]\n\n'); + content = content.replace(new RegExp('caption\\]\\n\\n+\\[caption', 'g'), 'caption]\n\n[caption'); var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre'; content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); @@ -166,7 +166,7 @@ switchEditors = { pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "
\n"); pee = pee.replace(new RegExp('(]*>)\\s*
', 'gi'), "$1"); pee = pee.replace(new RegExp('
(\\s*)', 'gi'), '$1'); - pee = pee.replace(new RegExp('(?:

|
)*\\s*\\[wp_caption([^\\[]+)\\[/wp_caption\\]\\s*(?:

|
)*', 'gi'), '[wp_caption$1[/wp_caption]'); + pee = pee.replace(new RegExp('(?:

|
)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:

|
)*', 'gi'), '[caption$1[/caption]'); // pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 '); // Fix the pre|script tags diff --git a/wp-admin/js/media-upload.js b/wp-admin/js/media-upload.js index 3a034ac9fc..4d4065bc1a 100644 --- a/wp-admin/js/media-upload.js +++ b/wp-admin/js/media-upload.js @@ -5,7 +5,7 @@ function send_to_editor(h) { if (tinymce.isIE) ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark); - if ( h.indexOf('[wp_caption') != -1 ) + if ( h.indexOf('[caption') != -1 ) h = ed.plugins.wpeditimage._do_shcode(h); ed.execCommand('mceInsertContent', false, h); diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/editimage.html b/wp-includes/js/tinymce/plugins/wpeditimage/editimage.html index 49b82c81cc..a9f1c1556d 100644 --- a/wp-includes/js/tinymce/plugins/wpeditimage/editimage.html +++ b/wp-includes/js/tinymce/plugins/wpeditimage/editimage.html @@ -4,10 +4,10 @@ - + - +