Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../public_h.../wp-admin/js
File: editor.js
var markedText = textArea.value.slice( htmlModeCursorStartPosition, htmlModeCursorEndPosition ),
[500] Fix | Delete
bookMarkEnd = cursorMarkerSkeleton.clone().addClass( 'mce_SELRES_end' );
[501] Fix | Delete
[502] Fix | Delete
selectedText = [
[503] Fix | Delete
markedText,
[504] Fix | Delete
bookMarkEnd[0].outerHTML
[505] Fix | Delete
].join( '' );
[506] Fix | Delete
}
[507] Fix | Delete
[508] Fix | Delete
textArea.value = [
[509] Fix | Delete
textArea.value.slice( 0, htmlModeCursorStartPosition ), // Text until the cursor/selection position.
[510] Fix | Delete
cursorMarkerSkeleton.clone() // Cursor/selection start marker.
[511] Fix | Delete
.addClass( 'mce_SELRES_start' )[0].outerHTML,
[512] Fix | Delete
selectedText, // Selected text with end cursor/position marker.
[513] Fix | Delete
textArea.value.slice( htmlModeCursorEndPosition ) // Text from last cursor/selection position to end.
[514] Fix | Delete
].join( '' );
[515] Fix | Delete
}
[516] Fix | Delete
[517] Fix | Delete
/**
[518] Fix | Delete
* Focuses the selection markers in Visual mode.
[519] Fix | Delete
*
[520] Fix | Delete
* The method checks for existing selection markers inside the editor DOM (Visual mode)
[521] Fix | Delete
* and create a selection between the two nodes using the DOM `createRange` selection API
[522] Fix | Delete
*
[523] Fix | Delete
* If there is only a single node, select only the single node through TinyMCE's selection API
[524] Fix | Delete
*
[525] Fix | Delete
* @param {Object} editor TinyMCE editor instance.
[526] Fix | Delete
*/
[527] Fix | Delete
function focusHTMLBookmarkInVisualEditor( editor ) {
[528] Fix | Delete
var startNode = editor.$( '.mce_SELRES_start' ).attr( 'data-mce-bogus', 1 ),
[529] Fix | Delete
endNode = editor.$( '.mce_SELRES_end' ).attr( 'data-mce-bogus', 1 );
[530] Fix | Delete
[531] Fix | Delete
if ( startNode.length ) {
[532] Fix | Delete
editor.focus();
[533] Fix | Delete
[534] Fix | Delete
if ( ! endNode.length ) {
[535] Fix | Delete
editor.selection.select( startNode[0] );
[536] Fix | Delete
} else {
[537] Fix | Delete
var selection = editor.getDoc().createRange();
[538] Fix | Delete
[539] Fix | Delete
selection.setStartAfter( startNode[0] );
[540] Fix | Delete
selection.setEndBefore( endNode[0] );
[541] Fix | Delete
[542] Fix | Delete
editor.selection.setRng( selection );
[543] Fix | Delete
}
[544] Fix | Delete
}
[545] Fix | Delete
[546] Fix | Delete
if ( editor.getParam( 'wp_keep_scroll_position' ) ) {
[547] Fix | Delete
scrollVisualModeToStartElement( editor, startNode );
[548] Fix | Delete
}
[549] Fix | Delete
[550] Fix | Delete
removeSelectionMarker( startNode );
[551] Fix | Delete
removeSelectionMarker( endNode );
[552] Fix | Delete
[553] Fix | Delete
editor.save();
[554] Fix | Delete
}
[555] Fix | Delete
[556] Fix | Delete
/**
[557] Fix | Delete
* Removes selection marker and the parent node if it is an empty paragraph.
[558] Fix | Delete
*
[559] Fix | Delete
* By default TinyMCE wraps loose inline tags in a `<p>`.
[560] Fix | Delete
* When removing selection markers an empty `<p>` may be left behind, remove it.
[561] Fix | Delete
*
[562] Fix | Delete
* @param {Object} $marker The marker to be removed from the editor DOM, wrapped in an instance of `editor.$`
[563] Fix | Delete
*/
[564] Fix | Delete
function removeSelectionMarker( $marker ) {
[565] Fix | Delete
var $markerParent = $marker.parent();
[566] Fix | Delete
[567] Fix | Delete
$marker.remove();
[568] Fix | Delete
[569] Fix | Delete
//Remove empty paragraph left over after removing the marker.
[570] Fix | Delete
if ( $markerParent.is( 'p' ) && ! $markerParent.children().length && ! $markerParent.text() ) {
[571] Fix | Delete
$markerParent.remove();
[572] Fix | Delete
}
[573] Fix | Delete
}
[574] Fix | Delete
[575] Fix | Delete
/**
[576] Fix | Delete
* Scrolls the content to place the selected element in the center of the screen.
[577] Fix | Delete
*
[578] Fix | Delete
* Takes an element, that is usually the selection start element, selected in
[579] Fix | Delete
* `focusHTMLBookmarkInVisualEditor()` and scrolls the screen so the element appears roughly
[580] Fix | Delete
* in the middle of the screen.
[581] Fix | Delete
*
[582] Fix | Delete
* I order to achieve the proper positioning, the editor media bar and toolbar are subtracted
[583] Fix | Delete
* from the window height, to get the proper viewport window, that the user sees.
[584] Fix | Delete
*
[585] Fix | Delete
* @param {Object} editor TinyMCE editor instance.
[586] Fix | Delete
* @param {Object} element HTMLElement that should be scrolled into view.
[587] Fix | Delete
*/
[588] Fix | Delete
function scrollVisualModeToStartElement( editor, element ) {
[589] Fix | Delete
var elementTop = editor.$( element ).offset().top,
[590] Fix | Delete
TinyMCEContentAreaTop = editor.$( editor.getContentAreaContainer() ).offset().top,
[591] Fix | Delete
[592] Fix | Delete
toolbarHeight = getToolbarHeight( editor ),
[593] Fix | Delete
[594] Fix | Delete
edTools = $( '#wp-content-editor-tools' ),
[595] Fix | Delete
edToolsHeight = 0,
[596] Fix | Delete
edToolsOffsetTop = 0,
[597] Fix | Delete
[598] Fix | Delete
$scrollArea;
[599] Fix | Delete
[600] Fix | Delete
if ( edTools.length ) {
[601] Fix | Delete
edToolsHeight = edTools.height();
[602] Fix | Delete
edToolsOffsetTop = edTools.offset().top;
[603] Fix | Delete
}
[604] Fix | Delete
[605] Fix | Delete
var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
[606] Fix | Delete
[607] Fix | Delete
selectionPosition = TinyMCEContentAreaTop + elementTop,
[608] Fix | Delete
visibleAreaHeight = windowHeight - ( edToolsHeight + toolbarHeight );
[609] Fix | Delete
[610] Fix | Delete
// There's no need to scroll if the selection is inside the visible area.
[611] Fix | Delete
if ( selectionPosition < visibleAreaHeight ) {
[612] Fix | Delete
return;
[613] Fix | Delete
}
[614] Fix | Delete
[615] Fix | Delete
/**
[616] Fix | Delete
* The minimum scroll height should be to the top of the editor, to offer a consistent
[617] Fix | Delete
* experience.
[618] Fix | Delete
*
[619] Fix | Delete
* In order to find the top of the editor, we calculate the offset of `#wp-content-editor-tools` and
[620] Fix | Delete
* subtracting the height. This gives the scroll position where the top of the editor tools aligns with
[621] Fix | Delete
* the top of the viewport (under the Master Bar)
[622] Fix | Delete
*/
[623] Fix | Delete
var adjustedScroll;
[624] Fix | Delete
if ( editor.settings.wp_autoresize_on ) {
[625] Fix | Delete
$scrollArea = $( 'html,body' );
[626] Fix | Delete
adjustedScroll = Math.max( selectionPosition - visibleAreaHeight / 2, edToolsOffsetTop - edToolsHeight );
[627] Fix | Delete
} else {
[628] Fix | Delete
$scrollArea = $( editor.contentDocument ).find( 'html,body' );
[629] Fix | Delete
adjustedScroll = elementTop;
[630] Fix | Delete
}
[631] Fix | Delete
[632] Fix | Delete
$scrollArea.animate( {
[633] Fix | Delete
scrollTop: parseInt( adjustedScroll, 10 )
[634] Fix | Delete
}, 100 );
[635] Fix | Delete
}
[636] Fix | Delete
[637] Fix | Delete
/**
[638] Fix | Delete
* This method was extracted from the `SaveContent` hook in
[639] Fix | Delete
* `wp-includes/js/tinymce/plugins/wordpress/plugin.js`.
[640] Fix | Delete
*
[641] Fix | Delete
* It's needed here, since the method changes the content a bit, which confuses the cursor position.
[642] Fix | Delete
*
[643] Fix | Delete
* @param {Object} event TinyMCE event object.
[644] Fix | Delete
*/
[645] Fix | Delete
function fixTextAreaContent( event ) {
[646] Fix | Delete
// Keep empty paragraphs :(
[647] Fix | Delete
event.content = event.content.replace( /<p>(?:<br ?\/?>|\u00a0|\uFEFF| )*<\/p>/g, '<p>&nbsp;</p>' );
[648] Fix | Delete
}
[649] Fix | Delete
[650] Fix | Delete
/**
[651] Fix | Delete
* Finds the current selection position in the Visual editor.
[652] Fix | Delete
*
[653] Fix | Delete
* Find the current selection in the Visual editor by inserting marker elements at the start
[654] Fix | Delete
* and end of the selection.
[655] Fix | Delete
*
[656] Fix | Delete
* Uses the standard DOM selection API to achieve that goal.
[657] Fix | Delete
*
[658] Fix | Delete
* Check the notes in the comments in the code below for more information on some gotchas
[659] Fix | Delete
* and why this solution was chosen.
[660] Fix | Delete
*
[661] Fix | Delete
* @param {Object} editor The editor where we must find the selection.
[662] Fix | Delete
* @return {(null|Object)} The selection range position in the editor.
[663] Fix | Delete
*/
[664] Fix | Delete
function findBookmarkedPosition( editor ) {
[665] Fix | Delete
// Get the TinyMCE `window` reference, since we need to access the raw selection.
[666] Fix | Delete
var TinyMCEWindow = editor.getWin(),
[667] Fix | Delete
selection = TinyMCEWindow.getSelection();
[668] Fix | Delete
[669] Fix | Delete
if ( ! selection || selection.rangeCount < 1 ) {
[670] Fix | Delete
// no selection, no need to continue.
[671] Fix | Delete
return;
[672] Fix | Delete
}
[673] Fix | Delete
[674] Fix | Delete
/**
[675] Fix | Delete
* The ID is used to avoid replacing user generated content, that may coincide with the
[676] Fix | Delete
* format specified below.
[677] Fix | Delete
* @type {string}
[678] Fix | Delete
*/
[679] Fix | Delete
var selectionID = 'SELRES_' + Math.random();
[680] Fix | Delete
[681] Fix | Delete
/**
[682] Fix | Delete
* Create two marker elements that will be used to mark the start and the end of the range.
[683] Fix | Delete
*
[684] Fix | Delete
* The elements have hardcoded style that makes them invisible. This is done to avoid seeing
[685] Fix | Delete
* random content flickering in the editor when switching between modes.
[686] Fix | Delete
*/
[687] Fix | Delete
var spanSkeleton = getCursorMarkerSpan( editor.$, selectionID ),
[688] Fix | Delete
startElement = spanSkeleton.clone().addClass( 'mce_SELRES_start' ),
[689] Fix | Delete
endElement = spanSkeleton.clone().addClass( 'mce_SELRES_end' );
[690] Fix | Delete
[691] Fix | Delete
/**
[692] Fix | Delete
* Inspired by:
[693] Fix | Delete
* @link https://stackoverflow.com/a/17497803/153310
[694] Fix | Delete
*
[695] Fix | Delete
* Why do it this way and not with TinyMCE's bookmarks?
[696] Fix | Delete
*
[697] Fix | Delete
* TinyMCE's bookmarks are very nice when working with selections and positions, BUT
[698] Fix | Delete
* there is no way to determine the precise position of the bookmark when switching modes, since
[699] Fix | Delete
* TinyMCE does some serialization of the content, to fix things like shortcodes, run plugins, prettify
[700] Fix | Delete
* HTML code and so on. In this process, the bookmark markup gets lost.
[701] Fix | Delete
*
[702] Fix | Delete
* If we decide to hook right after the bookmark is added, we can see where the bookmark is in the raw HTML
[703] Fix | Delete
* in TinyMCE. Unfortunately this state is before the serialization, so any visual markup in the content will
[704] Fix | Delete
* throw off the positioning.
[705] Fix | Delete
*
[706] Fix | Delete
* To avoid this, we insert two custom `span`s that will serve as the markers at the beginning and end of the
[707] Fix | Delete
* selection.
[708] Fix | Delete
*
[709] Fix | Delete
* Why not use TinyMCE's selection API or the DOM API to wrap the contents? Because if we do that, this creates
[710] Fix | Delete
* a new node, which is inserted in the dom. Now this will be fine, if we worked with fixed selections to
[711] Fix | Delete
* full nodes. Unfortunately in our case, the user can select whatever they like, which means that the
[712] Fix | Delete
* selection may start in the middle of one node and end in the middle of a completely different one. If we
[713] Fix | Delete
* wrap the selection in another node, this will create artifacts in the content.
[714] Fix | Delete
*
[715] Fix | Delete
* Using the method below, we insert the custom `span` nodes at the start and at the end of the selection.
[716] Fix | Delete
* This helps us not break the content and also gives us the option to work with multi-node selections without
[717] Fix | Delete
* breaking the markup.
[718] Fix | Delete
*/
[719] Fix | Delete
var range = selection.getRangeAt( 0 ),
[720] Fix | Delete
startNode = range.startContainer,
[721] Fix | Delete
startOffset = range.startOffset,
[722] Fix | Delete
boundaryRange = range.cloneRange();
[723] Fix | Delete
[724] Fix | Delete
/**
[725] Fix | Delete
* If the selection is on a shortcode with Live View, TinyMCE creates a bogus markup,
[726] Fix | Delete
* which we have to account for.
[727] Fix | Delete
*/
[728] Fix | Delete
if ( editor.$( startNode ).parents( '.mce-offscreen-selection' ).length > 0 ) {
[729] Fix | Delete
startNode = editor.$( '[data-mce-selected]' )[0];
[730] Fix | Delete
[731] Fix | Delete
/**
[732] Fix | Delete
* Marking the start and end element with `data-mce-object-selection` helps
[733] Fix | Delete
* discern when the selected object is a Live Preview selection.
[734] Fix | Delete
*
[735] Fix | Delete
* This way we can adjust the selection to properly select only the content, ignoring
[736] Fix | Delete
* whitespace inserted around the selected object by the Editor.
[737] Fix | Delete
*/
[738] Fix | Delete
startElement.attr( 'data-mce-object-selection', 'true' );
[739] Fix | Delete
endElement.attr( 'data-mce-object-selection', 'true' );
[740] Fix | Delete
[741] Fix | Delete
editor.$( startNode ).before( startElement[0] );
[742] Fix | Delete
editor.$( startNode ).after( endElement[0] );
[743] Fix | Delete
} else {
[744] Fix | Delete
boundaryRange.collapse( false );
[745] Fix | Delete
boundaryRange.insertNode( endElement[0] );
[746] Fix | Delete
[747] Fix | Delete
boundaryRange.setStart( startNode, startOffset );
[748] Fix | Delete
boundaryRange.collapse( true );
[749] Fix | Delete
boundaryRange.insertNode( startElement[0] );
[750] Fix | Delete
[751] Fix | Delete
range.setStartAfter( startElement[0] );
[752] Fix | Delete
range.setEndBefore( endElement[0] );
[753] Fix | Delete
selection.removeAllRanges();
[754] Fix | Delete
selection.addRange( range );
[755] Fix | Delete
}
[756] Fix | Delete
[757] Fix | Delete
/**
[758] Fix | Delete
* Now the editor's content has the start/end nodes.
[759] Fix | Delete
*
[760] Fix | Delete
* Unfortunately the content goes through some more changes after this step, before it gets inserted
[761] Fix | Delete
* in the `textarea`. This means that we have to do some minor cleanup on our own here.
[762] Fix | Delete
*/
[763] Fix | Delete
editor.on( 'GetContent', fixTextAreaContent );
[764] Fix | Delete
[765] Fix | Delete
var content = removep( editor.getContent() );
[766] Fix | Delete
[767] Fix | Delete
editor.off( 'GetContent', fixTextAreaContent );
[768] Fix | Delete
[769] Fix | Delete
startElement.remove();
[770] Fix | Delete
endElement.remove();
[771] Fix | Delete
[772] Fix | Delete
var startRegex = new RegExp(
[773] Fix | Delete
'<span[^>]*\\s*class="mce_SELRES_start"[^>]+>\\s*' + selectionID + '[^<]*<\\/span>(\\s*)'
[774] Fix | Delete
);
[775] Fix | Delete
[776] Fix | Delete
var endRegex = new RegExp(
[777] Fix | Delete
'(\\s*)<span[^>]*\\s*class="mce_SELRES_end"[^>]+>\\s*' + selectionID + '[^<]*<\\/span>'
[778] Fix | Delete
);
[779] Fix | Delete
[780] Fix | Delete
var startMatch = content.match( startRegex ),
[781] Fix | Delete
endMatch = content.match( endRegex );
[782] Fix | Delete
[783] Fix | Delete
if ( ! startMatch ) {
[784] Fix | Delete
return null;
[785] Fix | Delete
}
[786] Fix | Delete
[787] Fix | Delete
var startIndex = startMatch.index,
[788] Fix | Delete
startMatchLength = startMatch[0].length,
[789] Fix | Delete
endIndex = null;
[790] Fix | Delete
[791] Fix | Delete
if (endMatch) {
[792] Fix | Delete
/**
[793] Fix | Delete
* Adjust the selection index, if the selection contains a Live Preview object or not.
[794] Fix | Delete
*
[795] Fix | Delete
* Check where the `data-mce-object-selection` attribute is set above for more context.
[796] Fix | Delete
*/
[797] Fix | Delete
if ( startMatch[0].indexOf( 'data-mce-object-selection' ) !== -1 ) {
[798] Fix | Delete
startMatchLength -= startMatch[1].length;
[799] Fix | Delete
}
[800] Fix | Delete
[801] Fix | Delete
var endMatchIndex = endMatch.index;
[802] Fix | Delete
[803] Fix | Delete
if ( endMatch[0].indexOf( 'data-mce-object-selection' ) !== -1 ) {
[804] Fix | Delete
endMatchIndex -= endMatch[1].length;
[805] Fix | Delete
}
[806] Fix | Delete
[807] Fix | Delete
// We need to adjust the end position to discard the length of the range start marker.
[808] Fix | Delete
endIndex = endMatchIndex - startMatchLength;
[809] Fix | Delete
}
[810] Fix | Delete
[811] Fix | Delete
return {
[812] Fix | Delete
start: startIndex,
[813] Fix | Delete
end: endIndex
[814] Fix | Delete
};
[815] Fix | Delete
}
[816] Fix | Delete
[817] Fix | Delete
/**
[818] Fix | Delete
* Selects text in the TinyMCE `textarea`.
[819] Fix | Delete
*
[820] Fix | Delete
* Selects the text in TinyMCE's textarea that's between `selection.start` and `selection.end`.
[821] Fix | Delete
*
[822] Fix | Delete
* For `selection` parameter:
[823] Fix | Delete
* @link findBookmarkedPosition
[824] Fix | Delete
*
[825] Fix | Delete
* @param {Object} editor TinyMCE's editor instance.
[826] Fix | Delete
* @param {Object} selection Selection data.
[827] Fix | Delete
*/
[828] Fix | Delete
function selectTextInTextArea( editor, selection ) {
[829] Fix | Delete
// Only valid in the text area mode and if we have selection.
[830] Fix | Delete
if ( ! selection ) {
[831] Fix | Delete
return;
[832] Fix | Delete
}
[833] Fix | Delete
[834] Fix | Delete
var textArea = editor.getElement(),
[835] Fix | Delete
start = selection.start,
[836] Fix | Delete
end = selection.end || selection.start;
[837] Fix | Delete
[838] Fix | Delete
if ( textArea.focus ) {
[839] Fix | Delete
// Wait for the Visual editor to be hidden, then focus and scroll to the position.
[840] Fix | Delete
setTimeout( function() {
[841] Fix | Delete
textArea.setSelectionRange( start, end );
[842] Fix | Delete
if ( textArea.blur ) {
[843] Fix | Delete
// Defocus before focusing.
[844] Fix | Delete
textArea.blur();
[845] Fix | Delete
}
[846] Fix | Delete
textArea.focus();
[847] Fix | Delete
}, 100 );
[848] Fix | Delete
}
[849] Fix | Delete
}
[850] Fix | Delete
[851] Fix | Delete
// Restore the selection when the editor is initialized. Needed when the Text editor is the default.
[852] Fix | Delete
$( document ).on( 'tinymce-editor-init.keep-scroll-position', function( event, editor ) {
[853] Fix | Delete
if ( editor.$( '.mce_SELRES_start' ).length ) {
[854] Fix | Delete
focusHTMLBookmarkInVisualEditor( editor );
[855] Fix | Delete
}
[856] Fix | Delete
} );
[857] Fix | Delete
[858] Fix | Delete
/**
[859] Fix | Delete
* Replaces <p> tags with two line breaks. "Opposite" of wpautop().
[860] Fix | Delete
*
[861] Fix | Delete
* Replaces <p> tags with two line breaks except where the <p> has attributes.
[862] Fix | Delete
* Unifies whitespace.
[863] Fix | Delete
* Indents <li>, <dt> and <dd> for better readability.
[864] Fix | Delete
*
[865] Fix | Delete
* @since 2.5.0
[866] Fix | Delete
*
[867] Fix | Delete
* @memberof switchEditors
[868] Fix | Delete
*
[869] Fix | Delete
* @param {string} html The content from the editor.
[870] Fix | Delete
* @return {string} The content with stripped paragraph tags.
[871] Fix | Delete
*/
[872] Fix | Delete
function removep( html ) {
[873] Fix | Delete
var blocklist = 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset|figure',
[874] Fix | Delete
blocklist1 = blocklist + '|div|p',
[875] Fix | Delete
blocklist2 = blocklist + '|pre',
[876] Fix | Delete
preserve_linebreaks = false,
[877] Fix | Delete
preserve_br = false,
[878] Fix | Delete
preserve = [];
[879] Fix | Delete
[880] Fix | Delete
if ( ! html ) {
[881] Fix | Delete
return '';
[882] Fix | Delete
}
[883] Fix | Delete
[884] Fix | Delete
// Protect script and style tags.
[885] Fix | Delete
if ( html.indexOf( '<script' ) !== -1 || html.indexOf( '<style' ) !== -1 ) {
[886] Fix | Delete
html = html.replace( /<(script|style)[^>]*>[\s\S]*?<\/\1>/g, function( match ) {
[887] Fix | Delete
preserve.push( match );
[888] Fix | Delete
return '<wp-preserve>';
[889] Fix | Delete
} );
[890] Fix | Delete
}
[891] Fix | Delete
[892] Fix | Delete
// Protect pre tags.
[893] Fix | Delete
if ( html.indexOf( '<pre' ) !== -1 ) {
[894] Fix | Delete
preserve_linebreaks = true;
[895] Fix | Delete
html = html.replace( /<pre[^>]*>[\s\S]+?<\/pre>/g, function( a ) {
[896] Fix | Delete
a = a.replace( /<br ?\/?>(\r\n|\n)?/g, '<wp-line-break>' );
[897] Fix | Delete
a = a.replace( /<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp-line-break>' );
[898] Fix | Delete
return a.replace( /\r?\n/g, '<wp-line-break>' );
[899] Fix | Delete
});
[900] Fix | Delete
}
[901] Fix | Delete
[902] Fix | Delete
// Remove line breaks but keep <br> tags inside image captions.
[903] Fix | Delete
if ( html.indexOf( '[caption' ) !== -1 ) {
[904] Fix | Delete
preserve_br = true;
[905] Fix | Delete
html = html.replace( /\[caption[\s\S]+?\[\/caption\]/g, function( a ) {
[906] Fix | Delete
return a.replace( /<br([^>]*)>/g, '<wp-temp-br$1>' ).replace( /[\r\n\t]+/, '' );
[907] Fix | Delete
});
[908] Fix | Delete
}
[909] Fix | Delete
[910] Fix | Delete
// Normalize white space characters before and after block tags.
[911] Fix | Delete
html = html.replace( new RegExp( '\\s*</(' + blocklist1 + ')>\\s*', 'g' ), '</$1>\n' );
[912] Fix | Delete
html = html.replace( new RegExp( '\\s*<((?:' + blocklist1 + ')(?: [^>]*)?)>', 'g' ), '\n<$1>' );
[913] Fix | Delete
[914] Fix | Delete
// Mark </p> if it has any attributes.
[915] Fix | Delete
html = html.replace( /(<p [^>]+>.*?)<\/p>/g, '$1</p#>' );
[916] Fix | Delete
[917] Fix | Delete
// Preserve the first <p> inside a <div>.
[918] Fix | Delete
html = html.replace( /<div( [^>]*)?>\s*<p>/gi, '<div$1>\n\n' );
[919] Fix | Delete
[920] Fix | Delete
// Remove paragraph tags.
[921] Fix | Delete
html = html.replace( /\s*<p>/gi, '' );
[922] Fix | Delete
html = html.replace( /\s*<\/p>\s*/gi, '\n\n' );
[923] Fix | Delete
[924] Fix | Delete
// Normalize white space chars and remove multiple line breaks.
[925] Fix | Delete
html = html.replace( /\n[\s\u00a0]+\n/g, '\n\n' );
[926] Fix | Delete
[927] Fix | Delete
// Replace <br> tags with line breaks.
[928] Fix | Delete
html = html.replace( /(\s*)<br ?\/?>\s*/gi, function( match, space ) {
[929] Fix | Delete
if ( space && space.indexOf( '\n' ) !== -1 ) {
[930] Fix | Delete
return '\n\n';
[931] Fix | Delete
}
[932] Fix | Delete
[933] Fix | Delete
return '\n';
[934] Fix | Delete
});
[935] Fix | Delete
[936] Fix | Delete
// Fix line breaks around <div>.
[937] Fix | Delete
html = html.replace( /\s*<div/g, '\n<div' );
[938] Fix | Delete
html = html.replace( /<\/div>\s*/g, '</div>\n' );
[939] Fix | Delete
[940] Fix | Delete
// Fix line breaks around caption shortcodes.
[941] Fix | Delete
html = html.replace( /\s*\[caption([^\[]+)\[\/caption\]\s*/gi, '\n\n[caption$1[/caption]\n\n' );
[942] Fix | Delete
html = html.replace( /caption\]\n\n+\[caption/g, 'caption]\n\n[caption' );
[943] Fix | Delete
[944] Fix | Delete
// Pad block elements tags with a line break.
[945] Fix | Delete
html = html.replace( new RegExp('\\s*<((?:' + blocklist2 + ')(?: [^>]*)?)\\s*>', 'g' ), '\n<$1>' );
[946] Fix | Delete
html = html.replace( new RegExp('\\s*</(' + blocklist2 + ')>\\s*', 'g' ), '</$1>\n' );
[947] Fix | Delete
[948] Fix | Delete
// Indent <li>, <dt> and <dd> tags.
[949] Fix | Delete
html = html.replace( /<((li|dt|dd)[^>]*)>/g, ' \t<$1>' );
[950] Fix | Delete
[951] Fix | Delete
// Fix line breaks around <select> and <option>.
[952] Fix | Delete
if ( html.indexOf( '<option' ) !== -1 ) {
[953] Fix | Delete
html = html.replace( /\s*<option/g, '\n<option' );
[954] Fix | Delete
html = html.replace( /\s*<\/select>/g, '\n</select>' );
[955] Fix | Delete
}
[956] Fix | Delete
[957] Fix | Delete
// Pad <hr> with two line breaks.
[958] Fix | Delete
if ( html.indexOf( '<hr' ) !== -1 ) {
[959] Fix | Delete
html = html.replace( /\s*<hr( [^>]*)?>\s*/g, '\n\n<hr$1>\n\n' );
[960] Fix | Delete
}
[961] Fix | Delete
[962] Fix | Delete
// Remove line breaks in <object> tags.
[963] Fix | Delete
if ( html.indexOf( '<object' ) !== -1 ) {
[964] Fix | Delete
html = html.replace( /<object[\s\S]+?<\/object>/g, function( a ) {
[965] Fix | Delete
return a.replace( /[\r\n]+/g, '' );
[966] Fix | Delete
});
[967] Fix | Delete
}
[968] Fix | Delete
[969] Fix | Delete
// Unmark special paragraph closing tags.
[970] Fix | Delete
html = html.replace( /<\/p#>/g, '</p>\n' );
[971] Fix | Delete
[972] Fix | Delete
// Pad remaining <p> tags whit a line break.
[973] Fix | Delete
html = html.replace( /\s*(<p [^>]+>[\s\S]*?<\/p>)/g, '\n$1' );
[974] Fix | Delete
[975] Fix | Delete
// Trim.
[976] Fix | Delete
html = html.replace( /^\s+/, '' );
[977] Fix | Delete
html = html.replace( /[\s\u00a0]+$/, '' );
[978] Fix | Delete
[979] Fix | Delete
if ( preserve_linebreaks ) {
[980] Fix | Delete
html = html.replace( /<wp-line-break>/g, '\n' );
[981] Fix | Delete
}
[982] Fix | Delete
[983] Fix | Delete
if ( preserve_br ) {
[984] Fix | Delete
html = html.replace( /<wp-temp-br([^>]*)>/g, '<br$1>' );
[985] Fix | Delete
}
[986] Fix | Delete
[987] Fix | Delete
// Restore preserved tags.
[988] Fix | Delete
if ( preserve.length ) {
[989] Fix | Delete
html = html.replace( /<wp-preserve>/g, function() {
[990] Fix | Delete
return preserve.shift();
[991] Fix | Delete
} );
[992] Fix | Delete
}
[993] Fix | Delete
[994] Fix | Delete
return html;
[995] Fix | Delete
}
[996] Fix | Delete
[997] Fix | Delete
/**
[998] Fix | Delete
* Replaces two line breaks with a paragraph tag and one line break with a <br>.
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function