From 9c90fe1198d0b3957a14e2fef54e6bb1985c5b11 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 31 Aug 2015 22:06:11 +0000 Subject: [PATCH] TinyMCE: fix replacing the image caption HTML with the shortcode when saving the content. Fixes #33477. git-svn-id: https://develop.svn.wordpress.org/trunk@33834 602fd350-edb4-49c9-b593-d223f7449a82 --- .../js/tinymce/plugins/wpeditimage/plugin.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js index 2779cd39dd..11f8a7954c 100644 --- a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js @@ -159,13 +159,13 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } function getShortcode( content ) { - return content.replace( /
]*>([\s\S]+?)<\/div>/g, function( a, b ) { + return content.replace( /(?:
]+mceTemp[^>]+>)?\s*(
]+wp-caption[^>]+>[\s\S]+?<\/dl>)\s*(?:<\/div>)?/g, function( all, dl ) { var out = ''; - if ( b.indexOf(']+>([\s\S]+?)<\/dd>/i ); + out = dl.match( /
]+>([\s\S]+?)<\/dd>/i ); if ( out && out[1] ) { return '

' + out[1] + '

'; @@ -174,7 +174,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { return ''; } - out = b.replace( /\s*
]+)>\s*
]+>([\s\S]+?)<\/dt>\s*
]+>([\s\S]*?)<\/dd>\s*<\/dl>\s*/gi, function( a, b, c, caption ) { + out = dl.replace( /\s*
]+)>\s*
]+>([\s\S]+?)<\/dt>\s*
]+>([\s\S]*?)<\/dd>\s*<\/dl>\s*/gi, function( a, b, c, caption ) { var id, classes, align, width; width = c.match( /width="([0-9]*)"/ ); @@ -214,7 +214,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { if ( out.indexOf('[caption') === -1 ) { // the caption html seems broken, try to find the image that may be wrapped in a link // and may be followed by

with the caption text. - out = b.replace( /[\s\S]*?((?:]+>)?]+>(?:<\/a>)?)(

[\s\S]*<\/p>)?[\s\S]*/gi, '

$1

$2' ); + out = dl.replace( /[\s\S]*?((?:]+>)?]+>(?:<\/a>)?)(

[\s\S]*<\/p>)?[\s\S]*/gi, '

$1

$2' ); } return out;