Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-smush.../_src/js/smush
File: media.js
/* global smush_vars */
[0] Fix | Delete
/* global _ */
[1] Fix | Delete
[2] Fix | Delete
/**
[3] Fix | Delete
* Adds a Smush Now button and displays stats in Media Attachment Details Screen
[4] Fix | Delete
*/
[5] Fix | Delete
(function ($, _) {
[6] Fix | Delete
'use strict';
[7] Fix | Delete
[8] Fix | Delete
// Local reference to the WordPress media namespace.
[9] Fix | Delete
const smushMedia = wp.media,
[10] Fix | Delete
sharedTemplate =
[11] Fix | Delete
"<span class='setting smush-stats' data-setting='smush'>" +
[12] Fix | Delete
"<span class='name'><%= label %></span>" +
[13] Fix | Delete
"<span class='value'><%= value %></span>" +
[14] Fix | Delete
'</span>',
[15] Fix | Delete
template = _.template(sharedTemplate);
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Create the template.
[19] Fix | Delete
*
[20] Fix | Delete
* @param {string} smushHTML
[21] Fix | Delete
* @return {Object} Template object
[22] Fix | Delete
*/
[23] Fix | Delete
const prepareTemplate = function (smushHTML) {
[24] Fix | Delete
/**
[25] Fix | Delete
* @param {Array} smush_vars.strings Localization strings.
[26] Fix | Delete
* @param {Object} smush_vars Object from wp_localize_script()
[27] Fix | Delete
*/
[28] Fix | Delete
return template({
[29] Fix | Delete
label: smush_vars.strings.stats_label,
[30] Fix | Delete
value: smushHTML,
[31] Fix | Delete
});
[32] Fix | Delete
};
[33] Fix | Delete
[34] Fix | Delete
if (
[35] Fix | Delete
'undefined' !== typeof smushMedia.view &&
[36] Fix | Delete
'undefined' !== typeof smushMedia.view.Attachment.Details.TwoColumn
[37] Fix | Delete
) {
[38] Fix | Delete
// Local instance of the Attachment Details TwoColumn used in the edit attachment modal view
[39] Fix | Delete
const smushMediaTwoColumn =
[40] Fix | Delete
smushMedia.view.Attachment.Details.TwoColumn;
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* Add Smush details to attachment.
[44] Fix | Delete
*
[45] Fix | Delete
* A similar view to media.view.Attachment.Details
[46] Fix | Delete
* for use in the Edit Attachment modal.
[47] Fix | Delete
*
[48] Fix | Delete
* @see wp-includes/js/media-grid.js
[49] Fix | Delete
*/
[50] Fix | Delete
smushMedia.view.Attachment.Details.TwoColumn = smushMediaTwoColumn.extend(
[51] Fix | Delete
{
[52] Fix | Delete
initialize() {
[53] Fix | Delete
smushMediaTwoColumn.prototype.initialize.apply(this, arguments);
[54] Fix | Delete
this.listenTo(this.model, 'change:smush', this.render);
[55] Fix | Delete
},
[56] Fix | Delete
[57] Fix | Delete
render() {
[58] Fix | Delete
// Ensure that the main attachment fields are rendered.
[59] Fix | Delete
smushMedia.view.Attachment.prototype.render.apply(
[60] Fix | Delete
this,
[61] Fix | Delete
arguments
[62] Fix | Delete
);
[63] Fix | Delete
[64] Fix | Delete
const smushHTML = this.model.get('smush');
[65] Fix | Delete
if (typeof smushHTML === 'undefined') {
[66] Fix | Delete
return this;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
this.model.fetch();
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* Detach the views, append our custom fields, make sure that our data is fully updated
[73] Fix | Delete
* and re-render the updated view.
[74] Fix | Delete
*/
[75] Fix | Delete
this.views.detach();
[76] Fix | Delete
this.$el
[77] Fix | Delete
.find('.settings')
[78] Fix | Delete
.append(prepareTemplate(smushHTML));
[79] Fix | Delete
this.views.render();
[80] Fix | Delete
[81] Fix | Delete
return this;
[82] Fix | Delete
},
[83] Fix | Delete
}
[84] Fix | Delete
);
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
// Local instance of the Attachment Details TwoColumn used in the edit attachment modal view
[88] Fix | Delete
const smushAttachmentDetails = smushMedia.view.Attachment.Details;
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* Add Smush details to attachment.
[92] Fix | Delete
*/
[93] Fix | Delete
smushMedia.view.Attachment.Details = smushAttachmentDetails.extend({
[94] Fix | Delete
initialize() {
[95] Fix | Delete
smushAttachmentDetails.prototype.initialize.apply(this, arguments);
[96] Fix | Delete
this.listenTo(this.model, 'change:smush', this.render);
[97] Fix | Delete
},
[98] Fix | Delete
[99] Fix | Delete
render() {
[100] Fix | Delete
// Ensure that the main attachment fields are rendered.
[101] Fix | Delete
smushMedia.view.Attachment.prototype.render.apply(this, arguments);
[102] Fix | Delete
[103] Fix | Delete
const smushHTML = this.model.get('smush');
[104] Fix | Delete
if (typeof smushHTML === 'undefined') {
[105] Fix | Delete
return this;
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
this.model.fetch();
[109] Fix | Delete
[110] Fix | Delete
/**
[111] Fix | Delete
* Detach the views, append our custom fields, make sure that our data is fully updated
[112] Fix | Delete
* and re-render the updated view.
[113] Fix | Delete
*/
[114] Fix | Delete
this.views.detach();
[115] Fix | Delete
this.$el.append(prepareTemplate(smushHTML));
[116] Fix | Delete
[117] Fix | Delete
return this;
[118] Fix | Delete
},
[119] Fix | Delete
});
[120] Fix | Delete
[121] Fix | Delete
/**
[122] Fix | Delete
* Create a new MediaLibraryTaxonomyFilter we later will instantiate
[123] Fix | Delete
*
[124] Fix | Delete
* @since 3.0
[125] Fix | Delete
*/
[126] Fix | Delete
const MediaLibraryTaxonomyFilter = wp.media.view.AttachmentFilters.extend({
[127] Fix | Delete
id: 'media-attachment-smush-filter',
[128] Fix | Delete
[129] Fix | Delete
createFilters() {
[130] Fix | Delete
this.filters = {
[131] Fix | Delete
all: {
[132] Fix | Delete
text: smush_vars.strings.filter_all,
[133] Fix | Delete
props: { stats: 'all' },
[134] Fix | Delete
priority: 10,
[135] Fix | Delete
},
[136] Fix | Delete
[137] Fix | Delete
unsmushed: {
[138] Fix | Delete
text: smush_vars.strings.filter_not_processed,
[139] Fix | Delete
props: { stats: 'unsmushed' },
[140] Fix | Delete
priority: 20,
[141] Fix | Delete
},
[142] Fix | Delete
[143] Fix | Delete
excluded: {
[144] Fix | Delete
text: smush_vars.strings.filter_excl,
[145] Fix | Delete
props: { stats: 'excluded' },
[146] Fix | Delete
priority: 30,
[147] Fix | Delete
},
[148] Fix | Delete
[149] Fix | Delete
failed: {
[150] Fix | Delete
text: smush_vars.strings.filter_failed,
[151] Fix | Delete
props: { stats: 'failed_processing' },
[152] Fix | Delete
priority: 40,
[153] Fix | Delete
},
[154] Fix | Delete
};
[155] Fix | Delete
},
[156] Fix | Delete
});
[157] Fix | Delete
[158] Fix | Delete
/**
[159] Fix | Delete
* Extend and override wp.media.view.AttachmentsBrowser to include our new filter.
[160] Fix | Delete
*
[161] Fix | Delete
* @since 3.0
[162] Fix | Delete
*/
[163] Fix | Delete
const AttachmentsBrowser = wp.media.view.AttachmentsBrowser;
[164] Fix | Delete
wp.media.view.AttachmentsBrowser = wp.media.view.AttachmentsBrowser.extend({
[165] Fix | Delete
createToolbar() {
[166] Fix | Delete
// Make sure to load the original toolbar
[167] Fix | Delete
AttachmentsBrowser.prototype.createToolbar.call(this);
[168] Fix | Delete
this.toolbar.set(
[169] Fix | Delete
'MediaLibraryTaxonomyFilter',
[170] Fix | Delete
new MediaLibraryTaxonomyFilter({
[171] Fix | Delete
controller: this.controller,
[172] Fix | Delete
model: this.collection.props,
[173] Fix | Delete
priority: -75,
[174] Fix | Delete
}).render()
[175] Fix | Delete
);
[176] Fix | Delete
},
[177] Fix | Delete
});
[178] Fix | Delete
})(jQuery, _);
[179] Fix | Delete
[180] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function