mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-03 04:04:35 +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:
@@ -4,10 +4,10 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<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>
|
||||
|
||||
<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" />
|
||||
<script type="text/javascript">
|
||||
if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') )
|
||||
@@ -85,7 +85,7 @@ if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') )
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<tr id="cap_field">
|
||||
<th valign="top" scope="row" class="label">
|
||||
<label for="img_cap">
|
||||
<span class="alignleft">{#wpeditimage.caption}</span>
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
},
|
||||
|
||||
_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, '"');
|
||||
c = c.replace(/\\'|\\'/g, ''').replace(/\\"/g, '"');
|
||||
var id = b.match(/id=['"]([^'"]+)/i), cls = b.match(/align=['"]([^'"]+)/i);
|
||||
@@ -101,8 +101,8 @@
|
||||
|
||||
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))+
|
||||
'px"><dt class="wp_caption_dt">'+c+'</dt><dd class="wp_caption_dd">'+cap+'</dd></dl></div>';
|
||||
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>';
|
||||
});
|
||||
},
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
cls = cls.match(/align[^ '"]+/) || 'alignnone';
|
||||
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() {
|
||||
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','');
|
||||
|
||||
if ( ! tinyMCEPopup.editor.getParam('wpeditimage_do_captions', true) )
|
||||
t.I('cap_field').style.display = 'none';
|
||||
|
||||
tinyMCEPopup.restoreSelection();
|
||||
el = ed.selection.getNode();
|
||||
if (el.nodeName != 'IMG') return;
|
||||
@@ -265,7 +269,7 @@ var wpImage = {
|
||||
}
|
||||
|
||||
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;
|
||||
return;
|
||||
}
|
||||
@@ -423,14 +427,14 @@ var wpImage = {
|
||||
|
||||
if ( DL ) {
|
||||
ed.dom.setAttribs(DL, {
|
||||
'class' : 'wp_caption '+t.align,
|
||||
'class' : 'wp-caption '+t.align,
|
||||
style : 'width: '+cap_width+'px;'
|
||||
});
|
||||
|
||||
if ( DIV )
|
||||
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);
|
||||
|
||||
} else {
|
||||
@@ -448,8 +452,8 @@ var wpImage = {
|
||||
}
|
||||
} else html = ed.dom.getOuterHTML(el);
|
||||
|
||||
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>';
|
||||
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>';
|
||||
|
||||
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 = implode($mce_buttons_4, ',');
|
||||
|
||||
$do_captions = ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF ) ? false : true;
|
||||
|
||||
// TinyMCE init settings
|
||||
$initArray = array (
|
||||
'mode' => 'none',
|
||||
@@ -163,6 +165,7 @@ $initArray = array (
|
||||
'tab_focus' => ':next',
|
||||
'content_css' => "$mce_css",
|
||||
'save_callback' => 'switchEditors.saveCallback',
|
||||
'wpeditimage_do_captions' => $do_captions,
|
||||
'plugins' => "$plugins",
|
||||
// pass-through the settings for compression and caching, so they can be changed with "tiny_mce_before_init"
|
||||
'disk_cache' => true,
|
||||
@@ -222,7 +225,7 @@ if ( $compress && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
|
||||
// Setup cache info
|
||||
if ( $disk_cache ) {
|
||||
|
||||
$cacheKey = apply_filters('tiny_mce_version', '20080709');
|
||||
$cacheKey = apply_filters('tiny_mce_version', '20080710');
|
||||
|
||||
foreach ( $initArray as $v )
|
||||
$cacheKey .= $v;
|
||||
|
||||
@@ -15,7 +15,7 @@ dl.aligncenter {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.wp_caption {
|
||||
.wp-caption {
|
||||
border: 1px solid #ddd;
|
||||
text-align: center;
|
||||
background-color: #f3f3f3;
|
||||
@@ -27,13 +27,13 @@ dl.aligncenter {
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.wp_caption img {
|
||||
.wp-caption img {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0 none;
|
||||
}
|
||||
|
||||
.wp_caption_dd {
|
||||
.wp-caption-dd {
|
||||
font-size: 11px;
|
||||
line-height: 17px;
|
||||
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('caption', 'img_caption_shortcode');
|
||||
|
||||
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.
|
||||
$output = apply_filters('img_caption_shortcode', '', $attr, $content);
|
||||
if ( $output != '' )
|
||||
|
||||
@@ -34,10 +34,10 @@ function wp_default_scripts( &$scripts ) {
|
||||
$visual_editor = apply_filters('visual_editor', array('tiny_mce'));
|
||||
$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.
|
||||
$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( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');
|
||||
@@ -159,7 +159,7 @@ function wp_default_scripts( &$scripts ) {
|
||||
'edit' => __('Edit'),
|
||||
) );
|
||||
$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(
|
||||
'browseTitle' => attribute_escape(__('Browse your files')),
|
||||
'back' => __('« Back'),
|
||||
|
||||
Reference in New Issue
Block a user