mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 10:44:26 +00:00
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: https://develop.svn.wordpress.org/trunk@8313 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -64,7 +64,7 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' );
|
||||
?>
|
||||
{
|
||||
"betaManifestVersion" : 1,
|
||||
"version" : "<?php echo $man_version; ?>_20080710",
|
||||
"version" : "<?php echo $man_version; ?>_20080710a",
|
||||
"entries" : [
|
||||
<?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/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" },
|
||||
|
||||
|
||||
@@ -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, '');
|
||||
<?php if ( ! defined('CAPTIONS_OFF') || true != CAPTIONS_OFF ) { ?>
|
||||
caption = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
||||
<?php } ?>
|
||||
}
|
||||
|
||||
cls = caption ? '' : ' class="'+t.align+'"';
|
||||
@@ -1018,7 +1031,7 @@ var addExtImage = {
|
||||
html = '<a href="'+f.url.value+'">'+html+'</a>';
|
||||
|
||||
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 = '
|
||||
<table class="describe"><tbody>
|
||||
<tr>
|
||||
<th valign="top" scope="row" class="label" style="width:120px;">
|
||||
@@ -1279,7 +1292,20 @@ function type_form_image() {
|
||||
</th>
|
||||
<td class="field"><p><input id="title" name="title" value="" type="text" aria-required="true" /></p></td>
|
||||
</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>
|
||||
<th valign="top" scope="row" class="label">
|
||||
<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" />
|
||||
<p class="help">' . __('Also used as alternate text for the image') . '</p></td>
|
||||
</tr>
|
||||
|
||||
';
|
||||
}
|
||||
$form .= '
|
||||
<tr class="align">
|
||||
<th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th>
|
||||
<td class="field">
|
||||
@@ -1321,6 +1349,8 @@ function type_form_image() {
|
||||
</tr>
|
||||
</tbody></table>
|
||||
';
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function type_form_audio() {
|
||||
|
||||
@@ -52,8 +52,8 @@ switchEditors = {
|
||||
// Fix some block element newline issues
|
||||
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('\\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'), "<br />\n");
|
||||
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('(?:<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 ');
|
||||
|
||||
// Fix the pre|script tags
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user