diff -r 34716fd837a4 -r be944660c56a wp/wp-admin/js/custom-background.js --- a/wp/wp-admin/js/custom-background.js Tue Dec 15 15:52:01 2020 +0100 +++ b/wp/wp-admin/js/custom-background.js Wed Sep 21 18:19:35 2022 +0200 @@ -12,7 +12,7 @@ * @requires jQuery */ (function($) { - $(document).ready(function() { + $( function() { var frame, bgImage = $( '#custom-background-image' ); @@ -39,7 +39,7 @@ * * @return {void} */ - $( 'select[name="background-size"]' ).change( function() { + $( 'select[name="background-size"]' ).on( 'change', function() { bgImage.css( 'background-size', $( this ).val() ); }); @@ -50,7 +50,7 @@ * * @return {void} */ - $( 'input[name="background-position"]' ).change( function() { + $( 'input[name="background-position"]' ).on( 'change', function() { bgImage.css( 'background-position', $( this ).val() ); }); @@ -61,7 +61,7 @@ * * @return {void} */ - $( 'input[name="background-repeat"]' ).change( function() { + $( 'input[name="background-repeat"]' ).on( 'change', function() { bgImage.css( 'background-repeat', $( this ).is( ':checked' ) ? 'repeat' : 'no-repeat' ); }); @@ -72,7 +72,7 @@ * * @return {void} */ - $( 'input[name="background-attachment"]' ).change( function() { + $( 'input[name="background-attachment"]' ).on( 'change', function() { bgImage.css( 'background-attachment', $( this ).is( ':checked' ) ? 'scroll' : 'fixed' ); }); @@ -83,7 +83,7 @@ * * @return {void} */ - $('#choose-from-library-link').click( function( event ) { + $('#choose-from-library-link').on( 'click', function( event ) { var $el = $(this); event.preventDefault(); @@ -126,11 +126,13 @@ frame.on( 'select', function() { // Grab the selected attachment. var attachment = frame.state().get('selection').first(); + var nonceValue = $( '#_wpnonce' ).val() || ''; // Run an Ajax request to set the background image. $.post( ajaxurl, { action: 'set-background-image', attachment_id: attachment.id, + _ajax_nonce: nonceValue, size: 'full' }).done( function() { // When the request completes, reload the window.