Edit File by line
/home/barbar84/public_h.../wp-admin/js
File: postbox.js
/**
[0] Fix | Delete
* Contains the postboxes logic, opening and closing postboxes, reordering and saving
[1] Fix | Delete
* the state and ordering to the database.
[2] Fix | Delete
*
[3] Fix | Delete
* @since 2.5.0
[4] Fix | Delete
* @requires jQuery
[5] Fix | Delete
* @output wp-admin/js/postbox.js
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/* global ajaxurl, postboxes */
[9] Fix | Delete
[10] Fix | Delete
(function($) {
[11] Fix | Delete
var $document = $( document ),
[12] Fix | Delete
__ = wp.i18n.__;
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* This object contains all function to handle the behaviour of the post boxes. The post boxes are the boxes you see
[16] Fix | Delete
* around the content on the edit page.
[17] Fix | Delete
*
[18] Fix | Delete
* @since 2.7.0
[19] Fix | Delete
*
[20] Fix | Delete
* @namespace postboxes
[21] Fix | Delete
*
[22] Fix | Delete
* @type {Object}
[23] Fix | Delete
*/
[24] Fix | Delete
window.postboxes = {
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* Handles a click on either the postbox heading or the postbox open/close icon.
[28] Fix | Delete
*
[29] Fix | Delete
* Opens or closes the postbox. Expects `this` to equal the clicked element.
[30] Fix | Delete
* Calls postboxes.pbshow if the postbox has been opened, calls postboxes.pbhide
[31] Fix | Delete
* if the postbox has been closed.
[32] Fix | Delete
*
[33] Fix | Delete
* @since 4.4.0
[34] Fix | Delete
*
[35] Fix | Delete
* @memberof postboxes
[36] Fix | Delete
*
[37] Fix | Delete
* @fires postboxes#postbox-toggled
[38] Fix | Delete
*
[39] Fix | Delete
* @return {void}
[40] Fix | Delete
*/
[41] Fix | Delete
handle_click : function () {
[42] Fix | Delete
var $el = $( this ),
[43] Fix | Delete
p = $el.closest( '.postbox' ),
[44] Fix | Delete
id = p.attr( 'id' ),
[45] Fix | Delete
ariaExpandedValue;
[46] Fix | Delete
[47] Fix | Delete
if ( 'dashboard_browser_nag' === id ) {
[48] Fix | Delete
return;
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
p.toggleClass( 'closed' );
[52] Fix | Delete
ariaExpandedValue = ! p.hasClass( 'closed' );
[53] Fix | Delete
[54] Fix | Delete
if ( $el.hasClass( 'handlediv' ) ) {
[55] Fix | Delete
// The handle button was clicked.
[56] Fix | Delete
$el.attr( 'aria-expanded', ariaExpandedValue );
[57] Fix | Delete
} else {
[58] Fix | Delete
// The handle heading was clicked.
[59] Fix | Delete
$el.closest( '.postbox' ).find( 'button.handlediv' )
[60] Fix | Delete
.attr( 'aria-expanded', ariaExpandedValue );
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
if ( postboxes.page !== 'press-this' ) {
[64] Fix | Delete
postboxes.save_state( postboxes.page );
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
if ( id ) {
[68] Fix | Delete
if ( !p.hasClass('closed') && typeof postboxes.pbshow === 'function' ) {
[69] Fix | Delete
postboxes.pbshow( id );
[70] Fix | Delete
} else if ( p.hasClass('closed') && typeof postboxes.pbhide === 'function' ) {
[71] Fix | Delete
postboxes.pbhide( id );
[72] Fix | Delete
}
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
/**
[76] Fix | Delete
* Fires when a postbox has been opened or closed.
[77] Fix | Delete
*
[78] Fix | Delete
* Contains a jQuery object with the relevant postbox element.
[79] Fix | Delete
*
[80] Fix | Delete
* @since 4.0.0
[81] Fix | Delete
* @ignore
[82] Fix | Delete
*
[83] Fix | Delete
* @event postboxes#postbox-toggled
[84] Fix | Delete
* @type {Object}
[85] Fix | Delete
*/
[86] Fix | Delete
$document.trigger( 'postbox-toggled', p );
[87] Fix | Delete
},
[88] Fix | Delete
[89] Fix | Delete
/**
[90] Fix | Delete
* Handles clicks on the move up/down buttons.
[91] Fix | Delete
*
[92] Fix | Delete
* @since 5.5.0
[93] Fix | Delete
*
[94] Fix | Delete
* @return {void}
[95] Fix | Delete
*/
[96] Fix | Delete
handleOrder: function() {
[97] Fix | Delete
var button = $( this ),
[98] Fix | Delete
postbox = button.closest( '.postbox' ),
[99] Fix | Delete
postboxId = postbox.attr( 'id' ),
[100] Fix | Delete
postboxesWithinSortables = postbox.closest( '.meta-box-sortables' ).find( '.postbox:visible' ),
[101] Fix | Delete
postboxesWithinSortablesCount = postboxesWithinSortables.length,
[102] Fix | Delete
postboxWithinSortablesIndex = postboxesWithinSortables.index( postbox ),
[103] Fix | Delete
firstOrLastPositionMessage;
[104] Fix | Delete
[105] Fix | Delete
if ( 'dashboard_browser_nag' === postboxId ) {
[106] Fix | Delete
return;
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
// If on the first or last position, do nothing and send an audible message to screen reader users.
[110] Fix | Delete
if ( 'true' === button.attr( 'aria-disabled' ) ) {
[111] Fix | Delete
firstOrLastPositionMessage = button.hasClass( 'handle-order-higher' ) ?
[112] Fix | Delete
__( 'The box is on the first position' ) :
[113] Fix | Delete
__( 'The box is on the last position' );
[114] Fix | Delete
[115] Fix | Delete
wp.a11y.speak( firstOrLastPositionMessage );
[116] Fix | Delete
return;
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
// Move a postbox up.
[120] Fix | Delete
if ( button.hasClass( 'handle-order-higher' ) ) {
[121] Fix | Delete
// If the box is first within a sortable area, move it to the previous sortable area.
[122] Fix | Delete
if ( 0 === postboxWithinSortablesIndex ) {
[123] Fix | Delete
postboxes.handleOrderBetweenSortables( 'previous', button, postbox );
[124] Fix | Delete
return;
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
postbox.prevAll( '.postbox:visible' ).eq( 0 ).before( postbox );
[128] Fix | Delete
button.trigger( 'focus' );
[129] Fix | Delete
postboxes.updateOrderButtonsProperties();
[130] Fix | Delete
postboxes.save_order( postboxes.page );
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
// Move a postbox down.
[134] Fix | Delete
if ( button.hasClass( 'handle-order-lower' ) ) {
[135] Fix | Delete
// If the box is last within a sortable area, move it to the next sortable area.
[136] Fix | Delete
if ( postboxWithinSortablesIndex + 1 === postboxesWithinSortablesCount ) {
[137] Fix | Delete
postboxes.handleOrderBetweenSortables( 'next', button, postbox );
[138] Fix | Delete
return;
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
postbox.nextAll( '.postbox:visible' ).eq( 0 ).after( postbox );
[142] Fix | Delete
button.trigger( 'focus' );
[143] Fix | Delete
postboxes.updateOrderButtonsProperties();
[144] Fix | Delete
postboxes.save_order( postboxes.page );
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
},
[148] Fix | Delete
[149] Fix | Delete
/**
[150] Fix | Delete
* Moves postboxes between the sortables areas.
[151] Fix | Delete
*
[152] Fix | Delete
* @since 5.5.0
[153] Fix | Delete
*
[154] Fix | Delete
* @param {string} position The "previous" or "next" sortables area.
[155] Fix | Delete
* @param {Object} button The jQuery object representing the button that was clicked.
[156] Fix | Delete
* @param {Object} postbox The jQuery object representing the postbox to be moved.
[157] Fix | Delete
*
[158] Fix | Delete
* @return {void}
[159] Fix | Delete
*/
[160] Fix | Delete
handleOrderBetweenSortables: function( position, button, postbox ) {
[161] Fix | Delete
var closestSortablesId = button.closest( '.meta-box-sortables' ).attr( 'id' ),
[162] Fix | Delete
sortablesIds = [],
[163] Fix | Delete
sortablesIndex,
[164] Fix | Delete
detachedPostbox;
[165] Fix | Delete
[166] Fix | Delete
// Get the list of sortables within the page.
[167] Fix | Delete
$( '.meta-box-sortables:visible' ).each( function() {
[168] Fix | Delete
sortablesIds.push( $( this ).attr( 'id' ) );
[169] Fix | Delete
});
[170] Fix | Delete
[171] Fix | Delete
// Return if there's only one visible sortables area, e.g. in the block editor page.
[172] Fix | Delete
if ( 1 === sortablesIds.length ) {
[173] Fix | Delete
return;
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
// Find the index of the current sortables area within all the sortable areas.
[177] Fix | Delete
sortablesIndex = $.inArray( closestSortablesId, sortablesIds );
[178] Fix | Delete
// Detach the postbox to be moved.
[179] Fix | Delete
detachedPostbox = postbox.detach();
[180] Fix | Delete
[181] Fix | Delete
// Move the detached postbox to its new position.
[182] Fix | Delete
if ( 'previous' === position ) {
[183] Fix | Delete
$( detachedPostbox ).appendTo( '#' + sortablesIds[ sortablesIndex - 1 ] );
[184] Fix | Delete
}
[185] Fix | Delete
[186] Fix | Delete
if ( 'next' === position ) {
[187] Fix | Delete
$( detachedPostbox ).prependTo( '#' + sortablesIds[ sortablesIndex + 1 ] );
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
postboxes._mark_area();
[191] Fix | Delete
button.focus();
[192] Fix | Delete
postboxes.updateOrderButtonsProperties();
[193] Fix | Delete
postboxes.save_order( postboxes.page );
[194] Fix | Delete
},
[195] Fix | Delete
[196] Fix | Delete
/**
[197] Fix | Delete
* Update the move buttons properties depending on the postbox position.
[198] Fix | Delete
*
[199] Fix | Delete
* @since 5.5.0
[200] Fix | Delete
*
[201] Fix | Delete
* @return {void}
[202] Fix | Delete
*/
[203] Fix | Delete
updateOrderButtonsProperties: function() {
[204] Fix | Delete
var firstSortablesId = $( '.meta-box-sortables:visible:first' ).attr( 'id' ),
[205] Fix | Delete
lastSortablesId = $( '.meta-box-sortables:visible:last' ).attr( 'id' ),
[206] Fix | Delete
firstPostbox = $( '.postbox:visible:first' ),
[207] Fix | Delete
lastPostbox = $( '.postbox:visible:last' ),
[208] Fix | Delete
firstPostboxId = firstPostbox.attr( 'id' ),
[209] Fix | Delete
lastPostboxId = lastPostbox.attr( 'id' ),
[210] Fix | Delete
firstPostboxSortablesId = firstPostbox.closest( '.meta-box-sortables' ).attr( 'id' ),
[211] Fix | Delete
lastPostboxSortablesId = lastPostbox.closest( '.meta-box-sortables' ).attr( 'id' ),
[212] Fix | Delete
moveUpButtons = $( '.handle-order-higher' ),
[213] Fix | Delete
moveDownButtons = $( '.handle-order-lower' );
[214] Fix | Delete
[215] Fix | Delete
// Enable all buttons as a reset first.
[216] Fix | Delete
moveUpButtons
[217] Fix | Delete
.attr( 'aria-disabled', 'false' )
[218] Fix | Delete
.removeClass( 'hidden' );
[219] Fix | Delete
moveDownButtons
[220] Fix | Delete
.attr( 'aria-disabled', 'false' )
[221] Fix | Delete
.removeClass( 'hidden' );
[222] Fix | Delete
[223] Fix | Delete
// When there's only one "sortables" area (e.g. in the block editor) and only one visible postbox, hide the buttons.
[224] Fix | Delete
if ( firstSortablesId === lastSortablesId && firstPostboxId === lastPostboxId ) {
[225] Fix | Delete
moveUpButtons.addClass( 'hidden' );
[226] Fix | Delete
moveDownButtons.addClass( 'hidden' );
[227] Fix | Delete
}
[228] Fix | Delete
[229] Fix | Delete
// Set an aria-disabled=true attribute on the first visible "move" buttons.
[230] Fix | Delete
if ( firstSortablesId === firstPostboxSortablesId ) {
[231] Fix | Delete
$( firstPostbox ).find( '.handle-order-higher' ).attr( 'aria-disabled', 'true' );
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
// Set an aria-disabled=true attribute on the last visible "move" buttons.
[235] Fix | Delete
if ( lastSortablesId === lastPostboxSortablesId ) {
[236] Fix | Delete
$( '.postbox:visible .handle-order-lower' ).last().attr( 'aria-disabled', 'true' );
[237] Fix | Delete
}
[238] Fix | Delete
},
[239] Fix | Delete
[240] Fix | Delete
/**
[241] Fix | Delete
* Adds event handlers to all postboxes and screen option on the current page.
[242] Fix | Delete
*
[243] Fix | Delete
* @since 2.7.0
[244] Fix | Delete
*
[245] Fix | Delete
* @memberof postboxes
[246] Fix | Delete
*
[247] Fix | Delete
* @param {string} page The page we are currently on.
[248] Fix | Delete
* @param {Object} [args]
[249] Fix | Delete
* @param {Function} args.pbshow A callback that is called when a postbox opens.
[250] Fix | Delete
* @param {Function} args.pbhide A callback that is called when a postbox closes.
[251] Fix | Delete
* @return {void}
[252] Fix | Delete
*/
[253] Fix | Delete
add_postbox_toggles : function (page, args) {
[254] Fix | Delete
var $handles = $( '.postbox .hndle, .postbox .handlediv' ),
[255] Fix | Delete
$orderButtons = $( '.postbox .handle-order-higher, .postbox .handle-order-lower' );
[256] Fix | Delete
[257] Fix | Delete
this.page = page;
[258] Fix | Delete
this.init( page, args );
[259] Fix | Delete
[260] Fix | Delete
$handles.on( 'click.postboxes', this.handle_click );
[261] Fix | Delete
[262] Fix | Delete
// Handle the order of the postboxes.
[263] Fix | Delete
$orderButtons.on( 'click.postboxes', this.handleOrder );
[264] Fix | Delete
[265] Fix | Delete
/**
[266] Fix | Delete
* @since 2.7.0
[267] Fix | Delete
*/
[268] Fix | Delete
$('.postbox .hndle a').on( 'click', function(e) {
[269] Fix | Delete
e.stopPropagation();
[270] Fix | Delete
});
[271] Fix | Delete
[272] Fix | Delete
/**
[273] Fix | Delete
* Hides a postbox.
[274] Fix | Delete
*
[275] Fix | Delete
* Event handler for the postbox dismiss button. After clicking the button
[276] Fix | Delete
* the postbox will be hidden.
[277] Fix | Delete
*
[278] Fix | Delete
* As of WordPress 5.5, this is only used for the browser update nag.
[279] Fix | Delete
*
[280] Fix | Delete
* @since 3.2.0
[281] Fix | Delete
*
[282] Fix | Delete
* @return {void}
[283] Fix | Delete
*/
[284] Fix | Delete
$( '.postbox a.dismiss' ).on( 'click.postboxes', function( e ) {
[285] Fix | Delete
var hide_id = $(this).parents('.postbox').attr('id') + '-hide';
[286] Fix | Delete
e.preventDefault();
[287] Fix | Delete
$( '#' + hide_id ).prop('checked', false).triggerHandler('click');
[288] Fix | Delete
});
[289] Fix | Delete
[290] Fix | Delete
/**
[291] Fix | Delete
* Hides the postbox element
[292] Fix | Delete
*
[293] Fix | Delete
* Event handler for the screen options checkboxes. When a checkbox is
[294] Fix | Delete
* clicked this function will hide or show the relevant postboxes.
[295] Fix | Delete
*
[296] Fix | Delete
* @since 2.7.0
[297] Fix | Delete
* @ignore
[298] Fix | Delete
*
[299] Fix | Delete
* @fires postboxes#postbox-toggled
[300] Fix | Delete
*
[301] Fix | Delete
* @return {void}
[302] Fix | Delete
*/
[303] Fix | Delete
$('.hide-postbox-tog').on('click.postboxes', function() {
[304] Fix | Delete
var $el = $(this),
[305] Fix | Delete
boxId = $el.val(),
[306] Fix | Delete
$postbox = $( '#' + boxId );
[307] Fix | Delete
[308] Fix | Delete
if ( $el.prop( 'checked' ) ) {
[309] Fix | Delete
$postbox.show();
[310] Fix | Delete
if ( typeof postboxes.pbshow === 'function' ) {
[311] Fix | Delete
postboxes.pbshow( boxId );
[312] Fix | Delete
}
[313] Fix | Delete
} else {
[314] Fix | Delete
$postbox.hide();
[315] Fix | Delete
if ( typeof postboxes.pbhide === 'function' ) {
[316] Fix | Delete
postboxes.pbhide( boxId );
[317] Fix | Delete
}
[318] Fix | Delete
}
[319] Fix | Delete
[320] Fix | Delete
postboxes.save_state( page );
[321] Fix | Delete
postboxes._mark_area();
[322] Fix | Delete
[323] Fix | Delete
/**
[324] Fix | Delete
* @since 4.0.0
[325] Fix | Delete
* @see postboxes.handle_click
[326] Fix | Delete
*/
[327] Fix | Delete
$document.trigger( 'postbox-toggled', $postbox );
[328] Fix | Delete
});
[329] Fix | Delete
[330] Fix | Delete
/**
[331] Fix | Delete
* Changes the amount of columns based on the layout preferences.
[332] Fix | Delete
*
[333] Fix | Delete
* @since 2.8.0
[334] Fix | Delete
*
[335] Fix | Delete
* @return {void}
[336] Fix | Delete
*/
[337] Fix | Delete
$('.columns-prefs input[type="radio"]').on('click.postboxes', function(){
[338] Fix | Delete
var n = parseInt($(this).val(), 10);
[339] Fix | Delete
[340] Fix | Delete
if ( n ) {
[341] Fix | Delete
postboxes._pb_edit(n);
[342] Fix | Delete
postboxes.save_order( page );
[343] Fix | Delete
}
[344] Fix | Delete
});
[345] Fix | Delete
},
[346] Fix | Delete
[347] Fix | Delete
/**
[348] Fix | Delete
* Initializes all the postboxes, mainly their sortable behaviour.
[349] Fix | Delete
*
[350] Fix | Delete
* @since 2.7.0
[351] Fix | Delete
*
[352] Fix | Delete
* @memberof postboxes
[353] Fix | Delete
*
[354] Fix | Delete
* @param {string} page The page we are currently on.
[355] Fix | Delete
* @param {Object} [args={}] The arguments for the postbox initializer.
[356] Fix | Delete
* @param {Function} args.pbshow A callback that is called when a postbox opens.
[357] Fix | Delete
* @param {Function} args.pbhide A callback that is called when a postbox
[358] Fix | Delete
* closes.
[359] Fix | Delete
*
[360] Fix | Delete
* @return {void}
[361] Fix | Delete
*/
[362] Fix | Delete
init : function(page, args) {
[363] Fix | Delete
var isMobile = $( document.body ).hasClass( 'mobile' ),
[364] Fix | Delete
$handleButtons = $( '.postbox .handlediv' );
[365] Fix | Delete
[366] Fix | Delete
$.extend( this, args || {} );
[367] Fix | Delete
$('.meta-box-sortables').sortable({
[368] Fix | Delete
placeholder: 'sortable-placeholder',
[369] Fix | Delete
connectWith: '.meta-box-sortables',
[370] Fix | Delete
items: '.postbox',
[371] Fix | Delete
handle: '.hndle',
[372] Fix | Delete
cursor: 'move',
[373] Fix | Delete
delay: ( isMobile ? 200 : 0 ),
[374] Fix | Delete
distance: 2,
[375] Fix | Delete
tolerance: 'pointer',
[376] Fix | Delete
forcePlaceholderSize: true,
[377] Fix | Delete
helper: function( event, element ) {
[378] Fix | Delete
/* `helper: 'clone'` is equivalent to `return element.clone();`
[379] Fix | Delete
* Cloning a checked radio and then inserting that clone next to the original
[380] Fix | Delete
* radio unchecks the original radio (since only one of the two can be checked).
[381] Fix | Delete
* We get around this by renaming the helper's inputs' name attributes so that,
[382] Fix | Delete
* when the helper is inserted into the DOM for the sortable, no radios are
[383] Fix | Delete
* duplicated, and no original radio gets unchecked.
[384] Fix | Delete
*/
[385] Fix | Delete
return element.clone()
[386] Fix | Delete
.find( ':input' )
[387] Fix | Delete
.attr( 'name', function( i, currentName ) {
[388] Fix | Delete
return 'sort_' + parseInt( Math.random() * 100000, 10 ).toString() + '_' + currentName;
[389] Fix | Delete
} )
[390] Fix | Delete
.end();
[391] Fix | Delete
},
[392] Fix | Delete
opacity: 0.65,
[393] Fix | Delete
start: function() {
[394] Fix | Delete
$( 'body' ).addClass( 'is-dragging-metaboxes' );
[395] Fix | Delete
// Refresh the cached positions of all the sortable items so that the min-height set while dragging works.
[396] Fix | Delete
$( '.meta-box-sortables' ).sortable( 'refreshPositions' );
[397] Fix | Delete
},
[398] Fix | Delete
stop: function() {
[399] Fix | Delete
var $el = $( this );
[400] Fix | Delete
[401] Fix | Delete
$( 'body' ).removeClass( 'is-dragging-metaboxes' );
[402] Fix | Delete
[403] Fix | Delete
if ( $el.find( '#dashboard_browser_nag' ).is( ':visible' ) && 'dashboard_browser_nag' != this.firstChild.id ) {
[404] Fix | Delete
$el.sortable('cancel');
[405] Fix | Delete
return;
[406] Fix | Delete
}
[407] Fix | Delete
[408] Fix | Delete
postboxes.updateOrderButtonsProperties();
[409] Fix | Delete
postboxes.save_order(page);
[410] Fix | Delete
},
[411] Fix | Delete
receive: function(e,ui) {
[412] Fix | Delete
if ( 'dashboard_browser_nag' == ui.item[0].id )
[413] Fix | Delete
$(ui.sender).sortable('cancel');
[414] Fix | Delete
[415] Fix | Delete
postboxes._mark_area();
[416] Fix | Delete
$document.trigger( 'postbox-moved', ui.item );
[417] Fix | Delete
}
[418] Fix | Delete
});
[419] Fix | Delete
[420] Fix | Delete
if ( isMobile ) {
[421] Fix | Delete
$(document.body).on('orientationchange.postboxes', function(){ postboxes._pb_change(); });
[422] Fix | Delete
this._pb_change();
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
this._mark_area();
[426] Fix | Delete
[427] Fix | Delete
// Update the "move" buttons properties.
[428] Fix | Delete
this.updateOrderButtonsProperties();
[429] Fix | Delete
$document.on( 'postbox-toggled', this.updateOrderButtonsProperties );
[430] Fix | Delete
[431] Fix | Delete
// Set the handle buttons `aria-expanded` attribute initial value on page load.
[432] Fix | Delete
$handleButtons.each( function () {
[433] Fix | Delete
var $el = $( this );
[434] Fix | Delete
$el.attr( 'aria-expanded', ! $el.closest( '.postbox' ).hasClass( 'closed' ) );
[435] Fix | Delete
});
[436] Fix | Delete
},
[437] Fix | Delete
[438] Fix | Delete
/**
[439] Fix | Delete
* Saves the state of the postboxes to the server.
[440] Fix | Delete
*
[441] Fix | Delete
* It sends two lists, one with all the closed postboxes, one with all the
[442] Fix | Delete
* hidden postboxes.
[443] Fix | Delete
*
[444] Fix | Delete
* @since 2.7.0
[445] Fix | Delete
*
[446] Fix | Delete
* @memberof postboxes
[447] Fix | Delete
*
[448] Fix | Delete
* @param {string} page The page we are currently on.
[449] Fix | Delete
* @return {void}
[450] Fix | Delete
*/
[451] Fix | Delete
save_state : function(page) {
[452] Fix | Delete
var closed, hidden;
[453] Fix | Delete
[454] Fix | Delete
// Return on the nav-menus.php screen, see #35112.
[455] Fix | Delete
if ( 'nav-menus' === page ) {
[456] Fix | Delete
return;
[457] Fix | Delete
}
[458] Fix | Delete
[459] Fix | Delete
closed = $( '.postbox' ).filter( '.closed' ).map( function() { return this.id; } ).get().join( ',' );
[460] Fix | Delete
hidden = $( '.postbox' ).filter( ':hidden' ).map( function() { return this.id; } ).get().join( ',' );
[461] Fix | Delete
[462] Fix | Delete
$.post(ajaxurl, {
[463] Fix | Delete
action: 'closed-postboxes',
[464] Fix | Delete
closed: closed,
[465] Fix | Delete
hidden: hidden,
[466] Fix | Delete
closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
[467] Fix | Delete
page: page
[468] Fix | Delete
});
[469] Fix | Delete
},
[470] Fix | Delete
[471] Fix | Delete
/**
[472] Fix | Delete
* Saves the order of the postboxes to the server.
[473] Fix | Delete
*
[474] Fix | Delete
* Sends a list of all postboxes inside a sortable area to the server.
[475] Fix | Delete
*
[476] Fix | Delete
* @since 2.8.0
[477] Fix | Delete
*
[478] Fix | Delete
* @memberof postboxes
[479] Fix | Delete
*
[480] Fix | Delete
* @param {string} page The page we are currently on.
[481] Fix | Delete
* @return {void}
[482] Fix | Delete
*/
[483] Fix | Delete
save_order : function(page) {
[484] Fix | Delete
var postVars, page_columns = $('.columns-prefs input:checked').val() || 0;
[485] Fix | Delete
[486] Fix | Delete
postVars = {
[487] Fix | Delete
action: 'meta-box-order',
[488] Fix | Delete
_ajax_nonce: $('#meta-box-order-nonce').val(),
[489] Fix | Delete
page_columns: page_columns,
[490] Fix | Delete
page: page
[491] Fix | Delete
};
[492] Fix | Delete
[493] Fix | Delete
$('.meta-box-sortables').each( function() {
[494] Fix | Delete
postVars[ 'order[' + this.id.split( '-' )[0] + ']' ] = $( this ).sortable( 'toArray' ).join( ',' );
[495] Fix | Delete
} );
[496] Fix | Delete
[497] Fix | Delete
$.post(
[498] Fix | Delete
ajaxurl,
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function