Edit File by line
/home/barbar84/public_h.../wp-admin/js
File: custom-background.js
/**
[0] Fix | Delete
* @output wp-admin/js/custom-background.js
[1] Fix | Delete
*/
[2] Fix | Delete
[3] Fix | Delete
/* global ajaxurl */
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Registers all events for customizing the background.
[7] Fix | Delete
*
[8] Fix | Delete
* @since 3.0.0
[9] Fix | Delete
*
[10] Fix | Delete
* @requires jQuery
[11] Fix | Delete
*/
[12] Fix | Delete
(function($) {
[13] Fix | Delete
$(document).ready(function() {
[14] Fix | Delete
var frame,
[15] Fix | Delete
bgImage = $( '#custom-background-image' );
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Instantiates the WordPress color picker and binds the change and clear events.
[19] Fix | Delete
*
[20] Fix | Delete
* @since 3.5.0
[21] Fix | Delete
*
[22] Fix | Delete
* @return {void}
[23] Fix | Delete
*/
[24] Fix | Delete
$('#background-color').wpColorPicker({
[25] Fix | Delete
change: function( event, ui ) {
[26] Fix | Delete
bgImage.css('background-color', ui.color.toString());
[27] Fix | Delete
},
[28] Fix | Delete
clear: function() {
[29] Fix | Delete
bgImage.css('background-color', '');
[30] Fix | Delete
}
[31] Fix | Delete
});
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* Alters the background size CSS property whenever the background size input has changed.
[35] Fix | Delete
*
[36] Fix | Delete
* @since 4.7.0
[37] Fix | Delete
*
[38] Fix | Delete
* @return {void}
[39] Fix | Delete
*/
[40] Fix | Delete
$( 'select[name="background-size"]' ).on( 'change', function() {
[41] Fix | Delete
bgImage.css( 'background-size', $( this ).val() );
[42] Fix | Delete
});
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* Alters the background position CSS property whenever the background position input has changed.
[46] Fix | Delete
*
[47] Fix | Delete
* @since 4.7.0
[48] Fix | Delete
*
[49] Fix | Delete
* @return {void}
[50] Fix | Delete
*/
[51] Fix | Delete
$( 'input[name="background-position"]' ).on( 'change', function() {
[52] Fix | Delete
bgImage.css( 'background-position', $( this ).val() );
[53] Fix | Delete
});
[54] Fix | Delete
[55] Fix | Delete
/**
[56] Fix | Delete
* Alters the background repeat CSS property whenever the background repeat input has changed.
[57] Fix | Delete
*
[58] Fix | Delete
* @since 3.0.0
[59] Fix | Delete
*
[60] Fix | Delete
* @return {void}
[61] Fix | Delete
*/
[62] Fix | Delete
$( 'input[name="background-repeat"]' ).on( 'change', function() {
[63] Fix | Delete
bgImage.css( 'background-repeat', $( this ).is( ':checked' ) ? 'repeat' : 'no-repeat' );
[64] Fix | Delete
});
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Alters the background attachment CSS property whenever the background attachment input has changed.
[68] Fix | Delete
*
[69] Fix | Delete
* @since 4.7.0
[70] Fix | Delete
*
[71] Fix | Delete
* @return {void}
[72] Fix | Delete
*/
[73] Fix | Delete
$( 'input[name="background-attachment"]' ).on( 'change', function() {
[74] Fix | Delete
bgImage.css( 'background-attachment', $( this ).is( ':checked' ) ? 'scroll' : 'fixed' );
[75] Fix | Delete
});
[76] Fix | Delete
[77] Fix | Delete
/**
[78] Fix | Delete
* Binds the event for opening the WP Media dialog.
[79] Fix | Delete
*
[80] Fix | Delete
* @since 3.5.0
[81] Fix | Delete
*
[82] Fix | Delete
* @return {void}
[83] Fix | Delete
*/
[84] Fix | Delete
$('#choose-from-library-link').on( 'click', function( event ) {
[85] Fix | Delete
var $el = $(this);
[86] Fix | Delete
[87] Fix | Delete
event.preventDefault();
[88] Fix | Delete
[89] Fix | Delete
// If the media frame already exists, reopen it.
[90] Fix | Delete
if ( frame ) {
[91] Fix | Delete
frame.open();
[92] Fix | Delete
return;
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
// Create the media frame.
[96] Fix | Delete
frame = wp.media.frames.customBackground = wp.media({
[97] Fix | Delete
// Set the title of the modal.
[98] Fix | Delete
title: $el.data('choose'),
[99] Fix | Delete
[100] Fix | Delete
// Tell the modal to show only images.
[101] Fix | Delete
library: {
[102] Fix | Delete
type: 'image'
[103] Fix | Delete
},
[104] Fix | Delete
[105] Fix | Delete
// Customize the submit button.
[106] Fix | Delete
button: {
[107] Fix | Delete
// Set the text of the button.
[108] Fix | Delete
text: $el.data('update'),
[109] Fix | Delete
/*
[110] Fix | Delete
* Tell the button not to close the modal, since we're
[111] Fix | Delete
* going to refresh the page when the image is selected.
[112] Fix | Delete
*/
[113] Fix | Delete
close: false
[114] Fix | Delete
}
[115] Fix | Delete
});
[116] Fix | Delete
[117] Fix | Delete
/**
[118] Fix | Delete
* When an image is selected, run a callback.
[119] Fix | Delete
*
[120] Fix | Delete
* @since 3.5.0
[121] Fix | Delete
*
[122] Fix | Delete
* @return {void}
[123] Fix | Delete
*/
[124] Fix | Delete
frame.on( 'select', function() {
[125] Fix | Delete
// Grab the selected attachment.
[126] Fix | Delete
var attachment = frame.state().get('selection').first();
[127] Fix | Delete
var nonceValue = $( '#_wpnonce' ).val() || '';
[128] Fix | Delete
[129] Fix | Delete
// Run an Ajax request to set the background image.
[130] Fix | Delete
$.post( ajaxurl, {
[131] Fix | Delete
action: 'set-background-image',
[132] Fix | Delete
attachment_id: attachment.id,
[133] Fix | Delete
_ajax_nonce: nonceValue,
[134] Fix | Delete
size: 'full'
[135] Fix | Delete
}).done( function() {
[136] Fix | Delete
// When the request completes, reload the window.
[137] Fix | Delete
window.location.reload();
[138] Fix | Delete
});
[139] Fix | Delete
});
[140] Fix | Delete
[141] Fix | Delete
// Finally, open the modal.
[142] Fix | Delete
frame.open();
[143] Fix | Delete
});
[144] Fix | Delete
});
[145] Fix | Delete
})(jQuery);
[146] Fix | Delete
[147] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function