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
This commit is contained in:
parent
35e593c3ab
commit
752b0eb45b
|
@ -64,7 +64,7 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' );
|
||||||
?>
|
?>
|
||||||
{
|
{
|
||||||
"betaManifestVersion" : 1,
|
"betaManifestVersion" : 1,
|
||||||
"version" : "<?php echo $man_version; ?>_20080710",
|
"version" : "<?php echo $man_version; ?>_20080710a",
|
||||||
"entries" : [
|
"entries" : [
|
||||||
<?php echo $defaults; ?>
|
<?php echo $defaults; ?>
|
||||||
|
|
||||||
|
@ -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/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/source_editor.js?ver=311" },
|
||||||
{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/anchor.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/tiny_mce.js?ver=311" },
|
||||||
{ "url" : "../wp-includes/js/tinymce/themes/advanced/editor_template.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" },
|
{ "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/paste/pastetext.htm?ver=311" },
|
||||||
{ "url" : "../wp-includes/js/tinymce/plugins/fullscreen/fullscreen.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/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/wp-mce-help.php?ver=311" },
|
||||||
|
|
||||||
{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css?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/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/pasteword.css?ver=311" },
|
||||||
{ "url" : "../wp-includes/js/tinymce/plugins/paste/css/blank.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/plugins/wpeditimage/css/editimage-rtl.css?ver=311" },
|
||||||
{ "url" : "../wp-includes/js/tinymce/wordpress.css?ver=311" },
|
{ "url" : "../wp-includes/js/tinymce/wordpress.css?ver=311" },
|
||||||
|
|
||||||
|
|
|
@ -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 ) {
|
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 : '';
|
$id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
|
||||||
|
|
||||||
preg_match( '/width="([0-9]+)/', $html, $matches );
|
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 );
|
$html = preg_replace( '/align[^\s\'"]+\s?/', '', $html );
|
||||||
if ( empty($align) ) $align = 'none';
|
if ( empty($align) ) $align = 'none';
|
||||||
|
|
||||||
$shcode = '[wp_caption id="' . $id . '" align="align' . $align
|
$shcode = '[caption id="' . $id . '" align="align' . $align
|
||||||
. '" width="' . $width . '" caption="' . $alt . '"]' . $html . '[/wp_caption]';
|
. '" width="' . $width . '" caption="' . $alt . '"]' . $html . '[/caption]';
|
||||||
|
|
||||||
return apply_filters( 'image_add_caption_shortcode', $shcode, $html );
|
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) {
|
function image_attachment_fields_to_edit($form_fields, $post) {
|
||||||
if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
|
if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
|
||||||
$form_fields['post_title']['required'] = true;
|
$form_fields['post_title']['required'] = true;
|
||||||
|
|
||||||
|
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']['label'] = __('Caption');
|
||||||
$form_fields['post_excerpt']['helps'][] = __('Alternate text, e.g. "The Mona Lisa"');
|
$form_fields['post_excerpt']['helps'][] = __('Also used as alternate text for the image');
|
||||||
|
}
|
||||||
|
|
||||||
$form_fields['post_content']['label'] = __('Description');
|
$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);
|
$file = wp_get_attachment_url($post->ID);
|
||||||
$link = get_attachment_link($post->ID);
|
$link = get_attachment_link($post->ID);
|
||||||
|
|
||||||
|
if ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF )
|
||||||
|
$alt = __('Alternate Text');
|
||||||
|
else
|
||||||
|
$alt = __('Caption');
|
||||||
|
|
||||||
$form_fields = array(
|
$form_fields = array(
|
||||||
'post_title' => array(
|
'post_title' => array(
|
||||||
'label' => __('Title'),
|
'label' => __('Title'),
|
||||||
'value' => $edit_post->post_title,
|
'value' => $edit_post->post_title,
|
||||||
),
|
),
|
||||||
'post_excerpt' => array(
|
'post_excerpt' => array(
|
||||||
'label' => __('Caption'),
|
'label' => $alt,
|
||||||
'value' => $edit_post->post_excerpt,
|
'value' => $edit_post->post_excerpt,
|
||||||
),
|
),
|
||||||
'post_content' => array(
|
'post_content' => array(
|
||||||
|
@ -1007,7 +1018,9 @@ var addExtImage = {
|
||||||
|
|
||||||
if ( f.alt.value ) {
|
if ( f.alt.value ) {
|
||||||
alt = f.alt.value.replace(/['"<>]+/g, '');
|
alt = f.alt.value.replace(/['"<>]+/g, '');
|
||||||
|
<?php if ( ! defined('CAPTIONS_OFF') || true != CAPTIONS_OFF ) { ?>
|
||||||
caption = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
caption = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
||||||
|
<?php } ?>
|
||||||
}
|
}
|
||||||
|
|
||||||
cls = caption ? '' : ' class="'+t.align+'"';
|
cls = caption ? '' : ' class="'+t.align+'"';
|
||||||
|
@ -1018,7 +1031,7 @@ var addExtImage = {
|
||||||
html = '<a href="'+f.url.value+'">'+html+'</a>';
|
html = '<a href="'+f.url.value+'">'+html+'</a>';
|
||||||
|
|
||||||
if ( caption )
|
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;
|
var win = window.dialogArguments || opener || parent || top;
|
||||||
win.send_to_editor(html);
|
win.send_to_editor(html);
|
||||||
|
@ -1262,7 +1275,7 @@ jQuery(function($){
|
||||||
}
|
}
|
||||||
|
|
||||||
function type_form_image() {
|
function type_form_image() {
|
||||||
return '
|
$form = '
|
||||||
<table class="describe"><tbody>
|
<table class="describe"><tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th valign="top" scope="row" class="label" style="width:120px;">
|
<th valign="top" scope="row" class="label" style="width:120px;">
|
||||||
|
@ -1279,7 +1292,20 @@ function type_form_image() {
|
||||||
</th>
|
</th>
|
||||||
<td class="field"><p><input id="title" name="title" value="" type="text" aria-required="true" /></p></td>
|
<td class="field"><p><input id="title" name="title" value="" type="text" aria-required="true" /></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
';
|
||||||
|
if ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF ) {
|
||||||
|
$form .= '
|
||||||
|
<tr>
|
||||||
|
<th valign="top" scope="row" class="label">
|
||||||
|
<span class="alignleft"><label for="alt">' . __('Alternate Text') . '</label></span>
|
||||||
|
</th>
|
||||||
|
<td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" />
|
||||||
|
<p class="help">' . __('Alt text for the image, e.g. "The Mona Lisa"') . '</p></td>
|
||||||
|
</tr>
|
||||||
|
';
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$form .= '
|
||||||
<tr>
|
<tr>
|
||||||
<th valign="top" scope="row" class="label">
|
<th valign="top" scope="row" class="label">
|
||||||
<span class="alignleft"><label for="alt">' . __('Image Caption') . '</label></span>
|
<span class="alignleft"><label for="alt">' . __('Image Caption') . '</label></span>
|
||||||
|
@ -1287,7 +1313,9 @@ function type_form_image() {
|
||||||
<td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" />
|
<td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" />
|
||||||
<p class="help">' . __('Also used as alternate text for the image') . '</p></td>
|
<p class="help">' . __('Also used as alternate text for the image') . '</p></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
$form .= '
|
||||||
<tr class="align">
|
<tr class="align">
|
||||||
<th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th>
|
<th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th>
|
||||||
<td class="field">
|
<td class="field">
|
||||||
|
@ -1321,6 +1349,8 @@ function type_form_image() {
|
||||||
</tr>
|
</tr>
|
||||||
</tbody></table>
|
</tbody></table>
|
||||||
';
|
';
|
||||||
|
|
||||||
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
function type_form_audio() {
|
function type_form_audio() {
|
||||||
|
|
|
@ -52,8 +52,8 @@ switchEditors = {
|
||||||
// Fix some block element newline issues
|
// Fix some block element newline issues
|
||||||
content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div');
|
content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div');
|
||||||
content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\n');
|
content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\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('\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*', 'gi'), '\n\n[caption$1[/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('caption\\]\\n\\n+\\[caption', 'g'), 'caption]\n\n[caption');
|
||||||
|
|
||||||
var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre';
|
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>');
|
content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
|
||||||
|
@ -166,7 +166,7 @@ switchEditors = {
|
||||||
pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "<br />\n");
|
pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "<br />\n");
|
||||||
pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1");
|
pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1");
|
||||||
pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1');
|
pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1');
|
||||||
pee = pee.replace(new RegExp('(?:<p>|<br ?/?>)*\\s*\\[wp_caption([^\\[]+)\\[/wp_caption\\]\\s*(?:</p>|<br ?/?>)*', 'gi'), '[wp_caption$1[/wp_caption]');
|
pee = pee.replace(new RegExp('(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*', 'gi'), '[caption$1[/caption]');
|
||||||
// pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 ');
|
// pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 ');
|
||||||
|
|
||||||
// Fix the pre|script tags
|
// Fix the pre|script tags
|
||||||
|
|
|
@ -5,7 +5,7 @@ function send_to_editor(h) {
|
||||||
if (tinymce.isIE)
|
if (tinymce.isIE)
|
||||||
ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark);
|
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);
|
h = ed.plugins.wpeditimage._do_shcode(h);
|
||||||
|
|
||||||
ed.execCommand('mceInsertContent', false, h);
|
ed.execCommand('mceInsertContent', false, h);
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
<title></title>
|
<title></title>
|
||||||
|
|
||||||
<script type="text/javascript" src="js/editimage.js?ver=311c"></script>
|
<script type="text/javascript" src="js/editimage.js?ver=311d"></script>
|
||||||
<script type="text/javascript" src="../../utils/form_utils.js?ver=311"></script>
|
<script type="text/javascript" src="../../utils/form_utils.js?ver=311"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" href="css/editimage.css?ver=311c" type="text/css" media="all" />
|
<link rel="stylesheet" href="css/editimage.css?ver=311d" type="text/css" media="all" />
|
||||||
<link rel="stylesheet" href="../../../../../wp-admin/css/media.css?ver=2.6-beta3" type="text/css" media="all" />
|
<link rel="stylesheet" href="../../../../../wp-admin/css/media.css?ver=2.6-beta3" type="text/css" media="all" />
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') )
|
if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') )
|
||||||
|
@ -85,7 +85,7 @@ if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') )
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr id="cap_field">
|
||||||
<th valign="top" scope="row" class="label">
|
<th valign="top" scope="row" class="label">
|
||||||
<label for="img_cap">
|
<label for="img_cap">
|
||||||
<span class="alignleft">{#wpeditimage.caption}</span>
|
<span class="alignleft">{#wpeditimage.caption}</span>
|
||||||
|
|
|
@ -87,7 +87,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
_do_shcode : function(co) {
|
_do_shcode : function(co) {
|
||||||
return co.replace(/\[wp_caption([^\]]+)\]([\s\S]+?)\[\/wp_caption\][\s\u00a0]*/g, function(a,b,c){
|
return co.replace(/\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\][\s\u00a0]*/g, function(a,b,c){
|
||||||
b = b.replace(/\\'|\\'|\\'/g, ''').replace(/\\"|\\"/g, '"');
|
b = b.replace(/\\'|\\'|\\'/g, ''').replace(/\\"|\\"/g, '"');
|
||||||
c = c.replace(/\\'|\\'/g, ''').replace(/\\"/g, '"');
|
c = c.replace(/\\'|\\'/g, ''').replace(/\\"/g, '"');
|
||||||
var id = b.match(/id=['"]([^'"]+)/i), cls = b.match(/align=['"]([^'"]+)/i);
|
var id = b.match(/id=['"]([^'"]+)/i), cls = b.match(/align=['"]([^'"]+)/i);
|
||||||
|
@ -101,8 +101,8 @@
|
||||||
|
|
||||||
var div_cls = (cls == 'aligncenter') ? 'mceTemp mceIEcenter' : 'mceTemp';
|
var div_cls = (cls == 'aligncenter') ? 'mceTemp mceIEcenter' : 'mceTemp';
|
||||||
|
|
||||||
return '<div class="'+div_cls+'"><dl id="'+id+'" class="wp_caption '+cls+'" style="width: '+(10+parseInt(w))+
|
return '<div class="'+div_cls+'"><dl id="'+id+'" class="wp-caption '+cls+'" style="width: '+(10+parseInt(w))+
|
||||||
'px"><dt class="wp_caption_dt">'+c+'</dt><dd class="wp_caption_dd">'+cap+'</dd></dl></div>';
|
'px"><dt class="wp-caption-dt">'+c+'</dt><dd class="wp-caption-dd">'+cap+'</dd></dl></div>';
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
cls = cls.match(/align[^ '"]+/) || 'alignnone';
|
cls = cls.match(/align[^ '"]+/) || 'alignnone';
|
||||||
cap = cap.replace(/<\S[^<>]*>/gi, '').replace(/'/g, ''').replace(/"/g, '"');
|
cap = cap.replace(/<\S[^<>]*>/gi, '').replace(/'/g, ''').replace(/"/g, '"');
|
||||||
|
|
||||||
return '[wp_caption id="'+id+'" align="'+cls+'" width="'+w+'" caption="'+cap+'"]'+c+'[/wp_caption]';
|
return '[caption id="'+id+'" align="'+cls+'" width="'+w+'" caption="'+cap+'"]'+c+'[/caption]';
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -247,6 +247,10 @@ var wpImage = {
|
||||||
setup : function() {
|
setup : function() {
|
||||||
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;
|
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;
|
||||||
document.dir = tinyMCEPopup.editor.getParam('directionality','');
|
document.dir = tinyMCEPopup.editor.getParam('directionality','');
|
||||||
|
|
||||||
|
if ( ! tinyMCEPopup.editor.getParam('wpeditimage_do_captions', true) )
|
||||||
|
t.I('cap_field').style.display = 'none';
|
||||||
|
|
||||||
tinyMCEPopup.restoreSelection();
|
tinyMCEPopup.restoreSelection();
|
||||||
el = ed.selection.getNode();
|
el = ed.selection.getNode();
|
||||||
if (el.nodeName != 'IMG') return;
|
if (el.nodeName != 'IMG') return;
|
||||||
|
@ -265,7 +269,7 @@ var wpImage = {
|
||||||
}
|
}
|
||||||
|
|
||||||
tinymce.each(DL.childNodes, function(e) {
|
tinymce.each(DL.childNodes, function(e) {
|
||||||
if ( e.nodeName == 'DD' && dom.hasClass(e, 'wp_caption_dd') ) {
|
if ( e.nodeName == 'DD' && dom.hasClass(e, 'wp-caption-dd') ) {
|
||||||
caption = e.innerHTML;
|
caption = e.innerHTML;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -423,14 +427,14 @@ var wpImage = {
|
||||||
|
|
||||||
if ( DL ) {
|
if ( DL ) {
|
||||||
ed.dom.setAttribs(DL, {
|
ed.dom.setAttribs(DL, {
|
||||||
'class' : 'wp_caption '+t.align,
|
'class' : 'wp-caption '+t.align,
|
||||||
style : 'width: '+cap_width+'px;'
|
style : 'width: '+cap_width+'px;'
|
||||||
});
|
});
|
||||||
|
|
||||||
if ( DIV )
|
if ( DIV )
|
||||||
ed.dom.setAttrib(DIV, 'class', div_cls);
|
ed.dom.setAttrib(DIV, 'class', div_cls);
|
||||||
|
|
||||||
if ( (DT = ed.dom.getParent(el, 'dt')) && (DD = DT.nextSibling) && ed.dom.hasClass(DD, 'wp_caption_dd') )
|
if ( (DT = ed.dom.getParent(el, 'dt')) && (DD = DT.nextSibling) && ed.dom.hasClass(DD, 'wp-caption-dd') )
|
||||||
ed.dom.setHTML(DD, f.img_cap.value);
|
ed.dom.setHTML(DD, f.img_cap.value);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -448,8 +452,8 @@ var wpImage = {
|
||||||
}
|
}
|
||||||
} else html = ed.dom.getOuterHTML(el);
|
} else html = ed.dom.getOuterHTML(el);
|
||||||
|
|
||||||
html = '<dl id="'+cap_id+'" class="wp_caption '+t.align+'" style="width: '+cap_width+
|
html = '<dl id="'+cap_id+'" class="wp-caption '+t.align+'" style="width: '+cap_width+
|
||||||
'px"><dt class="wp_caption_dt">'+html+'</dt><dd class="wp_caption_dd">'+f.img_cap.value+'</dd></dl>';
|
'px"><dt class="wp-caption-dt">'+html+'</dt><dd class="wp-caption-dd">'+f.img_cap.value+'</dd></dl>';
|
||||||
|
|
||||||
cap = ed.dom.create('div', {'class': div_cls}, html);
|
cap = ed.dom.create('div', {'class': div_cls}, html);
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,8 @@ $mce_buttons_3 = implode($mce_buttons_3, ',');
|
||||||
$mce_buttons_4 = apply_filters('mce_buttons_4', array());
|
$mce_buttons_4 = apply_filters('mce_buttons_4', array());
|
||||||
$mce_buttons_4 = implode($mce_buttons_4, ',');
|
$mce_buttons_4 = implode($mce_buttons_4, ',');
|
||||||
|
|
||||||
|
$do_captions = ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF ) ? false : true;
|
||||||
|
|
||||||
// TinyMCE init settings
|
// TinyMCE init settings
|
||||||
$initArray = array (
|
$initArray = array (
|
||||||
'mode' => 'none',
|
'mode' => 'none',
|
||||||
|
@ -163,6 +165,7 @@ $initArray = array (
|
||||||
'tab_focus' => ':next',
|
'tab_focus' => ':next',
|
||||||
'content_css' => "$mce_css",
|
'content_css' => "$mce_css",
|
||||||
'save_callback' => 'switchEditors.saveCallback',
|
'save_callback' => 'switchEditors.saveCallback',
|
||||||
|
'wpeditimage_do_captions' => $do_captions,
|
||||||
'plugins' => "$plugins",
|
'plugins' => "$plugins",
|
||||||
// pass-through the settings for compression and caching, so they can be changed with "tiny_mce_before_init"
|
// pass-through the settings for compression and caching, so they can be changed with "tiny_mce_before_init"
|
||||||
'disk_cache' => true,
|
'disk_cache' => true,
|
||||||
|
@ -222,7 +225,7 @@ if ( $compress && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
|
||||||
// Setup cache info
|
// Setup cache info
|
||||||
if ( $disk_cache ) {
|
if ( $disk_cache ) {
|
||||||
|
|
||||||
$cacheKey = apply_filters('tiny_mce_version', '20080709');
|
$cacheKey = apply_filters('tiny_mce_version', '20080710');
|
||||||
|
|
||||||
foreach ( $initArray as $v )
|
foreach ( $initArray as $v )
|
||||||
$cacheKey .= $v;
|
$cacheKey .= $v;
|
||||||
|
|
|
@ -15,7 +15,7 @@ dl.aligncenter {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wp_caption {
|
.wp-caption {
|
||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background-color: #f3f3f3;
|
background-color: #f3f3f3;
|
||||||
|
@ -27,13 +27,13 @@ dl.aligncenter {
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wp_caption img {
|
.wp-caption img {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: 0 none;
|
border: 0 none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wp_caption_dd {
|
.wp-caption-dd {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
line-height: 17px;
|
line-height: 17px;
|
||||||
padding: 0 4px 5px;
|
padding: 0 4px 5px;
|
||||||
|
|
|
@ -351,9 +351,13 @@ function wp_get_attachment_image($attachment_id, $size='thumbnail', $icon = fals
|
||||||
}
|
}
|
||||||
|
|
||||||
add_shortcode('wp_caption', 'img_caption_shortcode');
|
add_shortcode('wp_caption', 'img_caption_shortcode');
|
||||||
|
add_shortcode('caption', 'img_caption_shortcode');
|
||||||
|
|
||||||
function img_caption_shortcode($attr, $content = null) {
|
function img_caption_shortcode($attr, $content = null) {
|
||||||
|
|
||||||
|
if ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF )
|
||||||
|
return $content;
|
||||||
|
|
||||||
// Allow plugins/themes to override the default caption template.
|
// Allow plugins/themes to override the default caption template.
|
||||||
$output = apply_filters('img_caption_shortcode', '', $attr, $content);
|
$output = apply_filters('img_caption_shortcode', '', $attr, $content);
|
||||||
if ( $output != '' )
|
if ( $output != '' )
|
||||||
|
|
|
@ -34,10 +34,10 @@ function wp_default_scripts( &$scripts ) {
|
||||||
$visual_editor = apply_filters('visual_editor', array('tiny_mce'));
|
$visual_editor = apply_filters('visual_editor', array('tiny_mce'));
|
||||||
$scripts->add( 'editor', false, $visual_editor, '20080321' );
|
$scripts->add( 'editor', false, $visual_editor, '20080321' );
|
||||||
|
|
||||||
$scripts->add( 'editor_functions', '/wp-admin/js/editor.js', false, '20080706' );
|
$scripts->add( 'editor_functions', '/wp-admin/js/editor.js', false, '20080710' );
|
||||||
|
|
||||||
// Modify this version when tinyMCE plugins are changed.
|
// Modify this version when tinyMCE plugins are changed.
|
||||||
$mce_version = apply_filters('tiny_mce_version', '20080709');
|
$mce_version = apply_filters('tiny_mce_version', '20080710');
|
||||||
$scripts->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('editor_functions'), $mce_version );
|
$scripts->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('editor_functions'), $mce_version );
|
||||||
|
|
||||||
$scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');
|
$scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');
|
||||||
|
@ -159,7 +159,7 @@ function wp_default_scripts( &$scripts ) {
|
||||||
'edit' => __('Edit'),
|
'edit' => __('Edit'),
|
||||||
) );
|
) );
|
||||||
$scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20080709' );
|
$scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20080709' );
|
||||||
$scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20080702' );
|
$scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20080710' );
|
||||||
$scripts->localize( 'upload', 'uploadL10n', array(
|
$scripts->localize( 'upload', 'uploadL10n', array(
|
||||||
'browseTitle' => attribute_escape(__('Browse your files')),
|
'browseTitle' => attribute_escape(__('Browse your files')),
|
||||||
'back' => __('« Back'),
|
'back' => __('« Back'),
|
||||||
|
|
Loading…
Reference in New Issue