--- a/wp/wp-admin/js/common.js Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-admin/js/common.js Wed Sep 21 18:19:35 2022 +0200
@@ -55,13 +55,15 @@
* Deprecate all properties on an object.
*
* @since 5.5.1
+ * @since 5.6.0 Added the `version` parameter.
*
* @param {string} name The name of the object, i.e. commonL10n.
* @param {object} l10nObject The object to deprecate the properties on.
+ * @param {string} version The version of WordPress that deprecated the property.
*
* @return {object} The object with all its properties deprecated.
*/
-function deprecateL10nObject( name, l10nObject ) {
+function deprecateL10nObject( name, l10nObject, version ) {
var deprecatedObject = {};
Object.keys( l10nObject ).forEach( function( key ) {
@@ -70,12 +72,12 @@
if ( 'object' === typeof prop ) {
Object.defineProperty( deprecatedObject, key, { get: function() {
- deprecatedProperty( propName, '5.5.0', prop.alternative );
+ deprecatedProperty( propName, version, prop.alternative );
return prop.func();
} } );
} else {
Object.defineProperty( deprecatedObject, key, { get: function() {
- deprecatedProperty( propName, '5.5.0', 'wp.i18n' );
+ deprecatedProperty( propName, version, 'wp.i18n' );
return prop;
} } );
}
@@ -99,7 +101,7 @@
expandMenu: ''
};
-window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n );
+window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n, '5.5.0' );
/**
* Removed in 5.5.0, needed for back-compatibility.
@@ -111,7 +113,7 @@
dismiss: ''
};
-window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n );
+window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n, '5.5.0' );
/**
* Removed in 5.5.0, needed for back-compatibility.
@@ -129,7 +131,7 @@
ariaHide: ''
};
-window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n );
+window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n, '5.5.0' );
/**
* Removed in 5.5.0, needed for back-compatibility.
@@ -148,7 +150,7 @@
exportError: ''
};
-window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n );
+window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n, '5.5.0' );
/**
* Removed in 5.5.0, needed for back-compatibility.
@@ -160,7 +162,7 @@
beforeunload: ''
};
-window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n );
+window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n, '5.5.0' );
/**
* Removed in 5.5.0, needed for back-compatibility.
@@ -173,7 +175,7 @@
broken: ''
};
-window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n );
+window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n, '5.5.0' );
/**
* Removed in 5.5.0, needed for back-compatibility.
@@ -198,7 +200,7 @@
docTitleCommentsCount: ''
};
-window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n );
+window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n, '5.5.0' );
/**
* Removed in 5.5.0, needed for back-compatibility.
@@ -214,7 +216,7 @@
termRemoved: ''
};
-window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n );
+window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n, '5.5.0' );
/**
* Removed in 5.5.0, needed for back-compatibility.
@@ -231,7 +233,7 @@
defaultLabel: ''
};
-window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n );
+window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n, '5.5.0' );
/**
* Removed in 5.5.0, needed for back-compatibility.
@@ -243,7 +245,7 @@
error: ''
};
-window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n );
+window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n, '5.5.0' );
/**
* Removed in 5.5.0, needed for back-compatibility.
@@ -276,7 +278,7 @@
permalinkSaved: ''
};
-window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n );
+window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n, '5.5.0' );
/**
* Removed in 5.5.0, needed for back-compatibility.
@@ -292,7 +294,7 @@
saved: ''
};
-window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n );
+window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n, '5.5.0' );
/**
* Removed in 5.5.0, needed for back-compatibility.
@@ -306,7 +308,7 @@
ays: ''
};
-window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n );
+window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n, '5.5.0' );
/**
* Removed in 5.5.0, needed for back-compatibility.
@@ -321,7 +323,7 @@
untitled: ''
};
-window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n );
+window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n, '5.5.0' );
/**
* Removed in 5.5.0, needed for back-compatibility.
@@ -334,7 +336,7 @@
dateFormat: ''
};
-window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n );
+window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n, '5.5.0' );
/**
* Removed in 5.5.0, needed for back-compatibility.
@@ -349,7 +351,7 @@
done: ''
};
-window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n );
+window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n, '5.5.0' );
/**
* Removed in 3.3.0, needed for back-compatibility.
@@ -380,7 +382,7 @@
*/
init : function() {
var that = this;
- $('.hide-column-tog', '#adv-settings').click( function() {
+ $('.hide-column-tog', '#adv-settings').on( 'click', function() {
var $t = $(this), column = $t.val();
if ( $t.prop('checked') )
that.checked(column);
@@ -481,7 +483,7 @@
}
};
-$document.ready(function(){columns.init();});
+$( function() { columns.init(); } );
/**
* Validates that the required form fields are not empty.
@@ -498,7 +500,7 @@
.filter( function() { return $( ':input:visible', this ).val() === ''; } )
.addClass( 'form-invalid' )
.find( ':input:visible' )
- .change( function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } )
+ .on( 'change', function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } )
.length;
};
@@ -569,7 +571,7 @@
this.toggles = $( '#screen-meta-links' ).find( '.show-settings' );
this.page = $('#wpcontent');
- this.toggles.click( this.toggleEvent );
+ this.toggles.on( 'click', this.toggleEvent );
},
/**
@@ -615,7 +617,7 @@
* @return {void}
*/
panel.slideDown( 'fast', function() {
- panel.focus();
+ panel.trigger( 'focus' );
button.addClass( 'screen-meta-active' ).attr( 'aria-expanded', true );
});
@@ -657,7 +659,7 @@
*
* @return {void}
*/
-$('.contextual-help-tabs').delegate('a', 'click', function(e) {
+$('.contextual-help-tabs').on( 'click', 'a', function(e) {
var link = $(this),
panel;
@@ -796,11 +798,11 @@
if ( permalinkStructureFocused && $permalinkStructure[0].setSelectionRange ) {
newSelectionStart = ( permalinkStructureValue.substr( 0, selectionStart ) + textToAppend ).length;
$permalinkStructure[0].setSelectionRange( newSelectionStart, newSelectionStart );
- $permalinkStructure.focus();
+ $permalinkStructure.trigger( 'focus' );
}
} );
-$document.ready( function() {
+$( function() {
var checks, first, last, checked, sliced, mobileEvent, transitionTimeout, focusedRowActions,
lastClicked = false,
pageInput = $('input.current-page'),
@@ -1092,6 +1094,10 @@
var $el = $( this ),
$button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' );
+ if ( $el.find( '.notice-dismiss' ).length ) {
+ return;
+ }
+
// Ensure plain text.
$button.find( '.screen-reader-text' ).text( __( 'Dismiss this notice.' ) );
$button.on( 'click.wp-dismiss-notice', function( event ) {
@@ -1214,6 +1220,62 @@
});
/**
+ * Marries a secondary control to its primary control.
+ *
+ * @param {jQuery} topSelector The top selector element.
+ * @param {jQuery} topSubmit The top submit element.
+ * @param {jQuery} bottomSelector The bottom selector element.
+ * @param {jQuery} bottomSubmit The bottom submit element.
+ * @return {void}
+ */
+ function marryControls( topSelector, topSubmit, bottomSelector, bottomSubmit ) {
+ /**
+ * Updates the primary selector when the secondary selector is changed.
+ *
+ * @since 5.7.0
+ *
+ * @return {void}
+ */
+ function updateTopSelector() {
+ topSelector.val($(this).val());
+ }
+ bottomSelector.on('change', updateTopSelector);
+
+ /**
+ * Updates the secondary selector when the primary selector is changed.
+ *
+ * @since 5.7.0
+ *
+ * @return {void}
+ */
+ function updateBottomSelector() {
+ bottomSelector.val($(this).val());
+ }
+ topSelector.on('change', updateBottomSelector);
+
+ /**
+ * Triggers the primary submit when then secondary submit is clicked.
+ *
+ * @since 5.7.0
+ *
+ * @return {void}
+ */
+ function triggerSubmitClick(e) {
+ e.preventDefault();
+ e.stopPropagation();
+
+ topSubmit.trigger('click');
+ }
+ bottomSubmit.on('click', triggerSubmitClick);
+ }
+
+ // Marry the secondary "Bulk actions" controls to the primary controls:
+ marryControls( $('#bulk-action-selector-top'), $('#doaction'), $('#bulk-action-selector-bottom'), $('#doaction2') );
+
+ // Marry the secondary "Change role to" controls to the primary controls:
+ marryControls( $('#new_role'), $('#changeit'), $('#new_role2'), $('#changeit2') );
+
+ /**
* Shows row actions on focus of its parent container element or any other elements contained within.
*
* @return {void}
@@ -1233,14 +1295,14 @@
focusedRowActions.removeClass( 'visible' );
}, 30 );
}
- }, '.has-row-actions' );
+ }, '.table-view-list .has-row-actions' );
// Toggle list table rows on small screens.
$( 'tbody' ).on( 'click', '.toggle-row', function() {
$( this ).closest( 'tr' ).toggleClass( 'is-expanded' );
});
- $('#default-password-nag-no').click( function() {
+ $('#default-password-nag-no').on( 'click', function() {
setUserSetting('default_password_nag', 'hide');
$('div.default-password-nag').hide();
return false;
@@ -1253,7 +1315,7 @@
*
* @return {void}
*/
- $('#newcontent').bind('keydown.wpevent_InsertTab', function(e) {
+ $('#newcontent').on('keydown.wpevent_InsertTab', function(e) {
var el = e.target, selStart, selEnd, val, scroll, sel;
// After pressing escape key (keyCode: 27), the tab key should tab out of the textarea.
@@ -1312,12 +1374,11 @@
*
* @return {void}
*/
- pageInput.closest('form').submit( function() {
+ pageInput.closest('form').on( 'submit', function() {
/*
* action = bulk action dropdown at the top of the table
- * action2 = bulk action dropdow at the bottom of the table
*/
- if ( $('select[name="action"]').val() == -1 && $('select[name="action2"]').val() == -1 && pageInput.val() == currentPage )
+ if ( $('select[name="action"]').val() == -1 && pageInput.val() == currentPage )
pageInput.val('1');
});
}
@@ -1327,7 +1388,7 @@
*
* @return {void}
*/
- $('.search-box input[type="search"], .search-box input[type="submit"]').mousedown(function () {
+ $('.search-box input[type="search"], .search-box input[type="submit"]').on( 'mousedown', function () {
$('select[name^="action"]').val('-1');
});
@@ -1628,7 +1689,7 @@
$wpwrap.toggleClass( 'wp-responsive-open' );
if ( $wpwrap.hasClass( 'wp-responsive-open' ) ) {
$(this).find('a').attr( 'aria-expanded', 'true' );
- $( '#adminmenu a:first' ).focus();
+ $( '#adminmenu a:first' ).trigger( 'focus' );
} else {
$(this).find('a').attr( 'aria-expanded', 'false' );
}
@@ -1645,7 +1706,7 @@
});
self.trigger();
- $document.on( 'wp-window-resized.wp-responsive', $.proxy( this.trigger, this ) );
+ $document.on( 'wp-window-resized.wp-responsive', this.trigger.bind( this ) );
// This needs to run later as UI Sortable may be initialized later on $(document).ready().
$window.on( 'load.wp-responsive', this.maybeDisableSortables );
@@ -1828,7 +1889,7 @@
$( '.aria-button-if-js' ).attr( 'role', 'button' );
}
- $( document ).ajaxComplete( function() {
+ $( document ).on( 'ajaxComplete', function() {
aria_button_if_js();
});
@@ -1917,7 +1978,7 @@
$document.on( 'wp-pin-menu wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu wp-collapse-menu.pin-menu wp-scroll-start.pin-menu', setPinMenu );
// Set initial focus on a specific element.
- $( '.wp-initial-focus' ).focus();
+ $( '.wp-initial-focus' ).trigger( 'focus' );
// Toggle update details on update-core.php.
$body.on( 'click', '.js-update-details-toggle', function() {
@@ -1947,7 +2008,7 @@
*
* @since 5.5.0
*/
-$document.ready( function( $ ) {
+$( function( $ ) {
var $overwrite, $warning;
if ( ! $body.hasClass( 'update-php' ) ) {