: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
topHeight = heights.textTopHeight;
// Return if TinyMCE is still initializing.
if ( ! visual && ! $top.length ) {
topPos = $top.parent().offset().top;
editorPos = $editor.offset().top;
editorHeight = $editor.outerHeight();
* If in visual mode, checks if the editorHeight is greater than the autoresizeMinHeight + topHeight.
* If not in visual mode, checks if the editorHeight is greater than the autoresizeMinHeight + 20.
canPin = visual ? autoresizeMinHeight + topHeight : autoresizeMinHeight + 20; // 20px from textarea padding.
canPin = editorHeight > ( canPin + 5 );
if ( visual && $menuBar.length ) {
width: contentWrapWidth - ( borderWidth * 2 )
top: heights.menuBarHeight,
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) )
$statusBar.attr( 'style', advanced ? '' : 'visibility: hidden;' );
$bottom.attr( 'style', '' );
// Check if the top is not already in a fixed position.
if ( ( ! fixedTop || resize ) &&
( windowPos >= ( topPos - heights.toolsHeight - heights.adminBarHeight ) &&
windowPos <= ( topPos - heights.toolsHeight - heights.adminBarHeight + editorHeight - buffer ) ) ) {
top: heights.adminBarHeight,
if ( visual && $menuBar.length ) {
top: heights.adminBarHeight + heights.toolsHeight,
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) )
top: heights.adminBarHeight + heights.toolsHeight + heights.menuBarHeight,
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) )
// Check if the top is already in a fixed position.
} else if ( fixedTop || resize ) {
if ( windowPos <= ( topPos - heights.toolsHeight - heights.adminBarHeight ) ) {
if ( visual && $menuBar.length ) {
width: contentWrapWidth - ( borderWidth * 2 )
top: heights.menuBarHeight,
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) )
} else if ( windowPos >= ( topPos - heights.toolsHeight - heights.adminBarHeight + editorHeight - buffer ) ) {
top: editorHeight - buffer,
if ( visual && $menuBar.length ) {
top: editorHeight - buffer,
width: contentWrapWidth - ( borderWidth * 2 )
top: editorHeight - buffer + heights.menuBarHeight,
width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) )
// Check if the bottom is not already in a fixed position.
if ( ( ! fixedBottom || ( resize && advanced ) ) &&
// Add borderWidth for the border around the .wp-editor-container.
( windowPos + heights.windowHeight ) <= ( editorPos + editorHeight + heights.bottomHeight + heights.statusBarHeight + borderWidth ) ) {
if ( event && event.deltaHeight > 0 && event.deltaHeight < 100 ) {
window.scrollBy( 0, event.deltaHeight );
} else if ( visual && advanced ) {
bottom: heights.bottomHeight,
width: contentWrapWidth - ( borderWidth * 2 )
} else if ( ( ! advanced && fixedBottom ) ||
( ( fixedBottom || resize ) &&
( windowPos + heights.windowHeight ) > ( editorPos + editorHeight + heights.bottomHeight + heights.statusBarHeight - borderWidth ) ) ) {
$statusBar.attr( 'style', advanced ? '' : 'visibility: hidden;' );
$bottom.attr( 'style', '' );
// The postbox container is positioned with @media from CSS. Ensure it is pinned on the side.
if ( $postboxContainer.width() < 300 && heights.windowWidth > 600 &&
// Check if the sidebar is not taller than the document height.
$document.height() > ( $sideSortables.height() + postBodyTop + 120 ) &&
// Check if the editor is taller than the viewport.
heights.windowHeight < editorHeight ) {
if ( ( heights.sideSortablesHeight + pinnedToolsTop + sidebarBottom ) > heights.windowHeight || fixedSideTop || fixedSideBottom ) {
// Reset the sideSortables style when scrolling to the top.
if ( windowPos + pinnedToolsTop <= postBodyTop ) {
$sideSortables.attr( 'style', '' );
fixedSideTop = fixedSideBottom = false;
if ( windowPos > lastScrollPosition ) {
sidebarTop = $sideSortables.offset().top - heights.adminBarHeight;
footerTop = $footer.offset().top;
// Don't get over the footer.
if ( footerTop < sidebarTop + heights.sideSortablesHeight + sidebarBottom ) {
sidebarTop = footerTop - heights.sideSortablesHeight - 12;
} else if ( ! fixedSideBottom && heights.sideSortablesHeight + $sideSortables.offset().top + sidebarBottom < windowPos + heights.windowHeight ) {
} else if ( windowPos < lastScrollPosition ) {
sidebarTop = $sideSortables.offset().top - sidebarBottom;
footerTop = $footer.offset().top;
// Don't get over the footer.
if ( footerTop < sidebarTop + heights.sideSortablesHeight + sidebarBottom ) {
sidebarTop = footerTop - heights.sideSortablesHeight - 12;
} else if ( ! fixedSideTop && $sideSortables.offset().top >= windowPos + pinnedToolsTop ) {
// If the sidebar container is smaller than the viewport, then pin/unpin the top when scrolling.
if ( windowPos >= ( postBodyTop - pinnedToolsTop ) ) {
$sideSortables.attr( 'style', '' );
fixedSideTop = fixedSideBottom = false;
lastScrollPosition = windowPos;
$sideSortables.attr( 'style', '' );
fixedSideTop = fixedSideBottom = false;
paddingTop: heights.toolsHeight
paddingTop: heights.visualTopHeight + heights.menuBarHeight
marginTop: heights.textTopHeight
* Resizes the editor and adjusts the toolbars.
function fullscreenHide() {
* Runs the passed function with 500ms intervals.
* @param {function} callback The function to run in the timeout.
function initialResize( callback ) {
for ( var i = 1; i < 6; i++ ) {
setTimeout( callback, 500 * i );
* Runs adjust after 100ms.
clearTimeout( scrollTimer );
scrollTimer = setTimeout( adjust, 100 );
* Binds editor expand events on elements.
* Scroll to the top when triggering this from JS.
* Ensure the toolbars are pinned properly.
if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) {
window.scrollTo( window.pageXOffset, 0 );
$wrap.addClass( 'wp-editor-expand' );
// Adjust when the window is scrolled or resized.
$window.on( 'scroll.editor-expand resize.editor-expand', function( event ) {
* Adjust when collapsing the menu, changing the columns
* or changing the body class.
$document.on( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust )
.on( 'postbox-toggled.editor-expand postbox-moved.editor-expand', function() {
if ( ! fixedSideTop && ! fixedSideBottom && window.pageYOffset > pinnedToolsTop ) {
window.scrollBy( 0, -1 );
}).on( 'wp-window-resized.editor-expand', function() {
if ( mceEditor && ! mceEditor.isHidden() ) {
mceEditor.execCommand( 'wpAutoResize' );
$textEditor.on( 'focus.editor-expand input.editor-expand propertychange.editor-expand', textEditorResize );
// Adjust when entering or exiting fullscreen mode.
fullscreen && fullscreen.pubsub.subscribe( 'hidden', fullscreenHide );
mceEditor.settings.wp_autoresize_on = true;
mceEditor.execCommand( 'wpAutoResizeOn' );
if ( ! mceEditor.isHidden() ) {
mceEditor.execCommand( 'wpAutoResize' );
if ( ! mceEditor || mceEditor.isHidden() ) {
$document.trigger( 'editor-expand-on' );
* Unbinds editor expand events.
var height = parseInt( window.getUserSetting( 'ed_size', 300 ), 10 );
} else if ( height > 5000 ) {
* Scroll to the top when triggering this from JS.
* Ensure the toolbars are reset properly.
if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) {
window.scrollTo( window.pageXOffset, 0 );
$wrap.removeClass( 'wp-editor-expand' );
$window.off( '.editor-expand' );
$document.off( '.editor-expand' );
$textEditor.off( '.editor-expand' );
// Adjust when entering or exiting fullscreen mode.
fullscreen && fullscreen.pubsub.unsubscribe( 'hidden', fullscreenHide );
$.each( [ $visualTop, $textTop, $tools, $menuBar, $bottom, $statusBar, $contentWrap, $visualEditor, $textEditor, $sideSortables ], function( i, element ) {
element && element.attr( 'style', '' );
fixedTop = fixedBottom = fixedSideTop = fixedSideBottom = false;
mceEditor.settings.wp_autoresize_on = false;
mceEditor.execCommand( 'wpAutoResizeOff' );
if ( ! mceEditor.isHidden() ) {
mceEditor.theme.resizeTo( null, height );
// If there is a height found in the user setting.
$textEditor.height( height );
$document.trigger( 'editor-expand-off' );
if ( $wrap.hasClass( 'wp-editor-expand' ) ) {
// Resize just after CSS has fully loaded and QuickTags is ready.
if ( $contentWrap.hasClass( 'html-active' ) ) {
initialResize( function() {
// Show the on/off checkbox.
$( '#adv-settings .editor-expand' ).show();
$( '#editor-expand-toggle' ).on( 'change.editor-expand', function() {
if ( $(this).prop( 'checked' ) ) {
window.setUserSetting( 'editor_expand', 'on' );
window.setUserSetting( 'editor_expand', 'off' );
// Expose on() and off().
* Handles the distraction free writing of TinyMCE.
var $body = $( document.body ),
$wrap = $( '#wpcontent' ),
$editor = $( '#post-body-content' ),
$content = $( '#content' ),
$overlay = $( document.createElement( 'DIV' ) ),
$slug = $( '#edit-slug-box' ),
$slugFocusEl = $slug.find( 'a' )
.add( $slug.find( 'button' ) )
.add( $slug.find( 'input' ) ),
$menuWrap = $( '#adminmenuwrap' ),
_isActive = window.getUserSetting( 'editor_expand', 'on' ) === 'on',
_isOn = _isActive ? window.getUserSetting( 'post_dfw' ) === 'on' : false,
faded, fadedAdminBar, fadedSlug,