: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if ( viewportWidth <= 782 ) {
menuState = 'responsive';
} else if ( $body.hasClass( 'folded' ) || ( $body.hasClass( 'auto-fold' ) && viewportWidth <= 960 && viewportWidth > 782 ) ) {
$document.trigger( 'wp-menu-state-set', { state: menuState } );
// Set the menu state when the window gets resized.
$document.on( 'wp-window-resized.set-menu-state', setMenuState );
* Sets ARIA attributes on the collapse/expand menu button.
* When the admin menu is open or folded, updates the `aria-expanded` and
* `aria-label` attributes of the button to give feedback to assistive
* technologies. In the responsive view, the button is always hidden.
$document.on( 'wp-menu-state-set wp-collapse-menu', function( event, eventData ) {
var $collapseButton = $( '#collapse-button' ),
ariaExpanded, ariaLabelText;
if ( 'folded' === eventData.state ) {
ariaLabelText = __( 'Expand Main menu' );
ariaLabelText = __( 'Collapse Main menu' );
'aria-expanded': ariaExpanded,
'aria-label': ariaLabelText
window.wpResponsive.init();
makeNoticesDismissible();
$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' ).trigger( 'focus' );
// Toggle update details on update-core.php.
$body.on( 'click', '.js-update-details-toggle', function() {
var $updateNotice = $( this ).closest( '.js-update-details' ),
$progressDiv = $( '#' + $updateNotice.data( 'update-details' ) );
* When clicking on "Show details" move the progress div below the update
* notice. Make sure it gets moved just the first time.
if ( ! $progressDiv.hasClass( 'update-details-moved' ) ) {
$progressDiv.insertAfter( $updateNotice ).addClass( 'update-details-moved' );
// Toggle the progress div visibility.
// Toggle the Show Details button expanded state.
$( this ).attr( 'aria-expanded', $progressDiv.is( ':visible' ) );
* Hides the update button for expired plugin or theme uploads.
* On the "Update plugin/theme from uploaded zip" screen, once the upload has expired,
* hides the "Replace current with uploaded" button and displays a warning.
var $overwrite, $warning;
if ( ! $body.hasClass( 'update-php' ) ) {
$overwrite = $( 'a.update-from-upload-overwrite' );
$warning = $( '.update-from-upload-expired' );
if ( ! $overwrite.length || ! $warning.length ) {
$warning.removeClass( 'hidden' );
if ( window.wp && window.wp.a11y ) {
window.wp.a11y.speak( $warning.text() );
7140000 // 119 minutes. The uploaded file is deleted after 2 hours.
// Fire a custom jQuery event at the end of window resize.
* Triggers the WP window-resize event.
function triggerEvent() {
$document.trigger( 'wp-window-resized' );
* Fires the trigger event again after 200 ms.
window.clearTimeout( timeout );
timeout = window.setTimeout( triggerEvent, 200 );
$window.on( 'resize.wp-fire-once', fireOnce );
// Make Windows 8 devices play along nicely.
if ( '-ms-user-select' in document.documentElement.style && navigator.userAgent.match(/IEMobile\/10\.0/) ) {
var msViewportStyle = document.createElement( 'style' );
msViewportStyle.appendChild(
document.createTextNode( '@-ms-viewport{width:auto!important}' )
document.getElementsByTagName( 'head' )[0].appendChild( msViewportStyle );
* Freeze animated plugin icons when reduced motion is enabled.
* When the user has enabled the 'prefers-reduced-motion' setting, this module
* stops animations for all GIFs on the page with the class 'plugin-icon' or
* plugin icon images in the update plugins table.
// Private variables and methods.
// Initialize pauseAll to false; it will be set to true if reduced motion is preferred.
if ( window.matchMedia ) {
mediaQuery = window.matchMedia( '(prefers-reduced-motion: reduce)' );
if ( ! mediaQuery || mediaQuery.matches ) {
// Method to replace animated GIFs with a static frame.
priv.freezeAnimatedPluginIcons = function( img ) {
var coverImage = function() {
var canvas = document.createElement( 'canvas' );
// Set canvas dimensions.
// Copy classes from the image to the canvas.
canvas.className = img.className;
// Check if the image is inside a specific table.
var isInsideUpdateTable = img.closest( '#update-plugins-table' );
if ( isInsideUpdateTable ) {
// Transfer computed styles from image to canvas.
var computedStyles = window.getComputedStyle( img ),
for ( i = 0, max = computedStyles.length; i < max; i++ ) {
var propName = computedStyles[ i ];
var propValue = computedStyles.getPropertyValue( propName );
canvas.style[ propName ] = propValue;
// Draw the image onto the canvas.
canvas.getContext( '2d' ).drawImage( img, 0, 0, width, height );
// Set accessibility attributes on canvas.
canvas.setAttribute( 'aria-hidden', 'true' );
canvas.setAttribute( 'role', 'presentation' );
// Insert canvas before the image and set the image to be near-invisible.
var parent = img.parentNode;
parent.insertBefore( canvas, img );
img.style.opacity = 0.01;
img.style.height = '0px';
// If the image is already loaded, apply the coverImage function.
// Otherwise, wait for the image to load.
img.addEventListener( 'load', coverImage, true );
// Public method to freeze all relevant GIFs on the page.
pub.freezeAll = function() {
var images = document.querySelectorAll( '.plugin-icon, #update-plugins-table img' );
for ( var x = 0; x < images.length; x++ ) {
if ( /\.gif(?:\?|$)/i.test( images[ x ].src ) ) {
priv.freezeAnimatedPluginIcons( images[ x ] );
// Only run the freezeAll method if the user prefers reduced motion.
if ( true === priv.pauseAll ) {
// Listen for jQuery AJAX events.
if ( window.pagenow === 'plugin-install' ) {
// Only listen for ajaxComplete if this is the plugin-install.php page.
$( document ).ajaxComplete( function( event, xhr, settings ) {
// Check if this is the 'search-install-plugins' request.
if ( settings.data && typeof settings.data === 'string' && settings.data.includes( 'action=search-install-plugins' ) ) {
// Recheck if the user prefers reduced motion.
if ( window.matchMedia ) {
var mediaQuery = window.matchMedia( '(prefers-reduced-motion: reduce)' );
if ( mediaQuery.matches ) {
// Fallback for browsers that don't support matchMedia.
if ( true === priv.pauseAll ) {
// Expose public methods.