dvadf
File manager - Edit - /home/centroca/public_html/wp-smushit.zip
Back
PK ;80]H��%. . _src/icon-warning.pngnu �[��� �PNG IHDR ��c pHYs % %IR$� sRGB ��� gAMA ���a �IDATx�VKR�@������H�*�p�� �� (O �@n k?��� ĝ?�����d�Ƿ��O����� ���;�D.g!��͉H*5�;�O�J$�X&��`����$���mWf"!��L1��1j�=lϯ��L�aт� ��Q�0A`0�â �!F$b[H�5x0w���ɔ�����a���^k�+M�� �L���v�=���a]�6�$���%��R4�M@B:z�W|!D6��8H��݈@X�&t`��]��/F�_4�\.���8K�n���Y\d��`/ܟ;!d��-Fl�|������}�$z>ɶ�y�*(z e��5�u�v�;�4�6���" ~&.�)��1��w�m^�z�Eβ[J�H�'Ğz��� ZoR*��Ofv:�� +D;�H�@�d��Y�4����E�oE�j�b �?�� �t����u+�� IEND�B`�PK ;80]|���� � _src/js/utils/tracker.jsnu �[��� import Fetcher from './fetcher'; /** * TODO: consolidate the two tracker classes into one */ class Tracker { /* @private */ #doingEvents = new Set(); #allowToTrack; track( event, properties = {} ) { if ( ! this.allowToTrack() || this.inProgressEvent( event ) ) { return; } this.setInProgressEvent( event ); return Fetcher.common.track( event, properties ).then( ( res ) => { setTimeout( () => { this.restoreInProgressEvent( event ); }, 1000 ); return res; } ); } inProgressEvent( event ) { return this.#doingEvents.has( event ); } setInProgressEvent( event ) { this.#doingEvents.add( event ); } restoreInProgressEvent( event ) { this.#doingEvents.delete( event ); } allowToTrack() { return this.#allowToTrack || !! ( window.wp_smush_mixpanel?.opt_in ); } setAllowToTrack( allowToTrack ) { this.#allowToTrack = allowToTrack; return this; } } const tracker = new Tracker(); export default tracker; PK ;80]8��P{ { _src/js/utils/fetcher.jsnu �[��� /* global ajaxurl */ import { getResetNonce } from '../../smush-ui/core-ui/utils/smushData'; /** * Wrapper function for ajax calls to WordPress. * * @since 3.12.0 */ function SmushFetcher() { /** * Request ajax with a promise. * Use FormData Object as data if you need to upload file * * @param {string} action * @param {Object|FormData} data * @param {string} method * @return {Promise<any>} Request results. */ function request( action, data = {}, method = 'POST' ) { const args = { url: ajaxurl, method, cache: false }; if ( data instanceof FormData ) { data.append( 'action', action ); if ( ! data.has( '_ajax_nonce' ) ) { data.append( '_ajax_nonce', window.smushUIData?.wpAjax?.nonce ); } args.contentType = false; args.processData = false; } else { data._ajax_nonce = data._ajax_nonce || window.smush_global.nonce || window.smushUIData?.wpAjax?.nonce; data.action = action; } args.data = data; return new Promise( ( resolve, reject ) => { jQuery.ajax( args ).done( resolve ).fail( reject ); } ).then( ( response ) => { if ( typeof response !== 'object' ) { response = JSON.parse( response ); } return response; } ).catch( ( error ) => { console.error( 'Error:', error ); return error; } ); } const methods = { /** * Manage ajax for background. */ background: { /** * Start background process. */ start: () => { return request( 'bulk_smush_start' ); }, /** * Cancel background process. */ cancel: () => { return request( 'bulk_smush_cancel' ); }, /** * Pause background process. */ pause: () => { return request( 'bulk_smush_pause' ); }, /** * Resume background process. */ resume: () => { return request( 'bulk_smush_resume' ); }, /** * Reset background process status. */ resetStatus: () => { return request( 'bulk_smush_reset_status' ); }, /** * Initial State - Get stats on the first time. */ initState: () => { return request( 'bulk_smush_get_status' ); }, /** * Get stats. */ getStatus: () => { return request( 'bulk_smush_get_status' ); }, backgroundHealthyCheck: () => { return request( 'smush_start_background_pre_flight_check' ); }, backgroundHealthyStatus: () => { return request( 'smush_get_background_pre_flight_status' ); } }, smush: { /** * Ignore All. * * @param type */ ignoreAll: ( type ) => { return request( 'wp_smush_ignore_all_failed_items', { type, } ); }, }, /** * Manage ajax for config operations */ configs: { /** * Get the current site settings as a config. */ save: () => { return request( 'smush_save_config', { _ajax_nonce: window.smushUIData?.configsData?.nonce || '', } ); }, /** * Apply a config by ID. * * @param {number} id Config ID. */ apply: ( id ) => { return request( 'smush_apply_config', { id, _ajax_nonce: window.smushUIData?.configsData?.nonce || '', } ); }, /** * Upload and validate a config file. * * @param {File} file The JSON config file. */ upload: ( file ) => { const formData = new FormData(); formData.append( '_ajax_nonce', window.smushUIData?.configsData?.nonce || '' ); formData.append( 'file', file ); return request( 'smush_upload_config', formData ); }, /** * Sync a config to the Hub. * * @param {Object} config Config object to sync. */ syncToHub: ( config ) => { return request( 'smush_hub_sync_config', { _ajax_nonce: window.smushUIData?.configsData?.nonce || '', config: JSON.stringify( config ), } ); }, }, /** * Manage ajax for other requests */ common: { hideUpgradeModal: () => { return request( 'hide_new_features' ); }, /** * Dismiss Notice. * * @param {string} dismissId Notification id. */ dismissNotice: ( dismissId ) => { return request( 'smush_dismiss_notice', { key: dismissId } ); }, /** * Hide the new features modal. * * @param {string} modalID Notification id. */ hideModal: ( modalID ) => request( 'hide_modal', { modal_id: modalID, } ), track: ( event, properties ) => request( 'smush_analytics_track_event', { event, properties } ), /** * Custom request. * * @param {Object} data */ request: ( data ) => data.action && request( data.action, data ), poll: () => request( 'smush_frontend_poll', {} ), }, scanMediaLibrary: { start: ( optimize_on_scan_completed = false ) => { optimize_on_scan_completed = optimize_on_scan_completed ? 1 : 0; const _ajax_nonce = window.smushUIData.scanStatus.nonce; return request( 'wp_smush_start_background_scan', { optimize_on_scan_completed, _ajax_nonce, } ); }, cancel: () => { const _ajax_nonce = window.smushUIData.scanStatus.nonce; return request( 'wp_smush_cancel_background_scan', { _ajax_nonce, } ); }, getScanStatus: () => { const _ajax_nonce = window.smushUIData.scanStatus.nonce; return request( 'wp_smush_get_background_scan_status', { _ajax_nonce, } ); }, resetStatus: () => { const _ajax_nonce = window.smushUIData.scanStatus.nonce; return request( 'wp_smush_reset_background_scan_status', { _ajax_nonce, } ); } }, webp: { switchMethod: ( method ) => { return request( 'webp_switch_method', { method } ); }, recheckStatus: () => { return request( 'smush_webp_get_status' ); }, // toggleWizard: () => { // return request( 'smush_toggle_webp_wizard' ); // }, showWizard: () => { return request( 'smush_show_webp_wizard' ); }, hideWizard: () => { return request( 'smush_hide_webp_wizard' ); }, applyHtaccessRules: () => { return request( 'smush_webp_apply_htaccess_rules' ); }, }, cdn: { /** * Toggle CDN on/off. Calls the server to set up or tear down CDN infrastructure. * * @param {boolean} enable */ toggle: ( enable ) => { return request( 'smush_toggle_cdn', { param: enable } ); }, /** * Poll the CDN provisioning status. Used while CDN is still being set up. */ getStats: () => { return request( 'get_cdn_stats' ); }, }, settings: { disconnectSite: () => { return request( 'wp_smush_disconnect_site' ); }, /** * Force-recheck the Smush API connection status. * * @return {Promise} Resolves with { isPro, status } on success. */ checkApiStatus: () => { return request( 'recheck_api_status' ); }, /** * Reset all plugin settings to factory defaults. * * @return {Promise} */ resetSettings: () => { return request( 'reset_settings', { _ajax_nonce: getResetNonce(), } ); }, }, rating: { /** * User rated the plugin. */ completed: () => { return request( 'smush_rating_completed' ); }, /** * User wants to be reminded later. */ remindLater: () => { return request( 'smush_rating_remind_later' ); }, /** * User dismissed permanently. */ dismissed: () => { return request( 'smush_rating_dismissed' ); }, /** * Mark first completion. */ firstCompletion: () => { return request( 'smush_rating_first_completion' ); } }, onboarding: { resumeWizard: () => request( 'resume_smush_setup' ), }, request: ( action, data = {}, method = 'POST' ) => { return request( action, data, method ); } }; Object.assign( this, methods ); } const SmushAjax = new SmushFetcher(); export default SmushAjax; PK ;80]�ekm� � # _src/js/smush/media-library-grid.jsnu �[��� /* global smush_global */ /* global _ */ /** * Adds a Smush Now button and displays stats in Media Attachment Details Screen */ (function ($, _) { 'use strict'; // Local reference to the WordPress media namespace. const smushMedia = wp.media, sharedTemplate = "<span class='setting smush-stats' data-setting='smush'>" + "<span class='name'><%= label %></span>" + "<span class='value'><%= value %></span>" + '</span>', template = _.template(sharedTemplate); /** * Create the template. * * @param {string} smushHTML * @return {Object} Template object */ const prepareTemplate = function (smushHTML) { /** * @param {Array} smush_global.strings Localization strings. * @param {Object} smush_global Object from wp_localize_script() */ return template({ label: smush_global.strings.stats_label, value: smushHTML, }); }; if ( 'undefined' !== typeof smushMedia.view && 'undefined' !== typeof smushMedia.view.Attachment.Details.TwoColumn ) { // Local instance of the Attachment Details TwoColumn used in the edit attachment modal view const smushMediaTwoColumn = smushMedia.view.Attachment.Details.TwoColumn; /** * Add Smush details to attachment. * * A similar view to media.view.Attachment.Details * for use in the Edit Attachment modal. * * @see wp-includes/js/media-grid.js */ smushMedia.view.Attachment.Details.TwoColumn = smushMediaTwoColumn.extend( { initialize() { smushMediaTwoColumn.prototype.initialize.apply(this, arguments); this.listenTo(this.model, 'change:smush', this.render); }, render() { // Ensure that the main attachment fields are rendered. smushMedia.view.Attachment.prototype.render.apply( this, arguments ); const smushHTML = this.model.get('smush'); if (typeof smushHTML === 'undefined') { return this; } this.model.fetch(); /** * Detach the views, append our custom fields, make sure that our data is fully updated * and re-render the updated view. */ this.views.detach(); this.$el .find('.settings') .append(prepareTemplate(smushHTML)); this.views.render(); return this; }, } ); } // Local instance of the Attachment Details TwoColumn used in the edit attachment modal view const smushAttachmentDetails = smushMedia.view.Attachment.Details; /** * Add Smush details to attachment. */ smushMedia.view.Attachment.Details = smushAttachmentDetails.extend({ initialize() { smushAttachmentDetails.prototype.initialize.apply(this, arguments); this.listenTo(this.model, 'change:smush', this.render); }, render() { // Ensure that the main attachment fields are rendered. smushMedia.view.Attachment.prototype.render.apply(this, arguments); const smushHTML = this.model.get('smush'); if (typeof smushHTML === 'undefined') { return this; } this.model.fetch(); /** * Detach the views, append our custom fields, make sure that our data is fully updated * and re-render the updated view. */ this.views.detach(); this.$el.append(prepareTemplate(smushHTML)); return this; }, }); /** * Create a new MediaLibraryTaxonomyFilter we later will instantiate * * @since 3.0 */ const MediaLibraryTaxonomyFilter = wp.media.view.AttachmentFilters.extend({ id: 'media-attachment-smush-filter', createFilters() { this.filters = { all: { text: smush_global.strings.filter_all, props: { stats: 'all' }, priority: 10, }, unsmushed: { text: smush_global.strings.filter_not_processed, props: { stats: 'unsmushed' }, priority: 20, }, excluded: { text: smush_global.strings.filter_excl, props: { stats: 'excluded' }, priority: 30, }, failed: { text: smush_global.strings.filter_failed, props: { stats: 'failed_processing' }, priority: 40, }, }; }, }); /** * Extend and override wp.media.view.AttachmentsBrowser to include our new filter. * * @since 3.0 */ const AttachmentsBrowser = wp.media.view.AttachmentsBrowser; wp.media.view.AttachmentsBrowser = wp.media.view.AttachmentsBrowser.extend({ createToolbar() { // Make sure to load the original toolbar AttachmentsBrowser.prototype.createToolbar.call(this); this.toolbar.set( 'MediaLibraryTaxonomyFilter', new MediaLibraryTaxonomyFilter({ controller: this.controller, model: this.collection.props, priority: -75, }).render() ); }, }); })(jQuery, _); PK ;80]�o!;� � ! _src/js/smush/gutenberg-blocks.jsnu �[��� /** * BLOCK: extend image block */ const { createHigherOrderComponent } = wp.compose, { Fragment } = wp.element, { InspectorControls } = wp.blockEditor, { PanelBody } = wp.components; /** * Transform bytes to human readable format. * * @param {number} bytes * @return {string} Readable size string. */ function humanFileSize( bytes ) { const thresh = 1024, units = [ 'kB', 'MB', 'GB', 'TB' ]; if ( Math.abs( bytes ) < thresh ) { return bytes + ' B'; } let u = -1; do { bytes /= thresh; ++u; } while ( Math.abs( bytes ) >= thresh && u < units.length - 1 ); return bytes.toFixed( 1 ) + ' ' + units[ u ]; } /** * Generate Smush stats table. * * @param {number} id * @param {Object} stats * @return {*} Smush stats. */ export function smushStats( id, stats ) { if ( 'undefined' === typeof stats ) { return window.smush_global.strings.gb.select_image; } else if ( 'string' === typeof stats ) { return stats; } return ( <div id="smush-stats" className="sui-smush-media smush-stats-wrapper hidden" style={ { display: 'block' } } > <table className="wp-smush-stats-holder"> <thead> <tr> <th className="smush-stats-header"> { window.smush_global.strings.gb.size } </th> <th className="smush-stats-header"> { window.smush_global.strings.gb.savings } </th> </tr> </thead> <tbody> { Object.keys( stats.sizes ) .filter( ( item ) => 0 < stats.sizes[ item ].percent ) .map( ( item, i ) => ( <tr key={ i }> <td>{ item.toUpperCase() }</td> <td> { humanFileSize( stats.sizes[ item ].bytes ) }{ ' ' } ( { stats.sizes[ item ].percent }% ) </td> </tr> ) ) } </tbody> </table> </div> ); } /** * Fetch image data. If image is Smushing, update in 3 seconds. * * TODO: this could be optimized not to query so much. * * @param {Object} props */ export function fetchProps( props ) { const image = new wp.api.models.Media( { id: props.attributes.id } ), smushData = props.attributes.smush; image.fetch( { attribute: 'smush' } ).done( function( img ) { if ( 'string' === typeof img.smush ) { props.setAttributes( { smush: img.smush } ); //setTimeout( () => fetch( props ), 3000 ); } else if ( 'undefined' !== typeof img.smush && ( 'undefined' === typeof smushData || JSON.stringify( smushData ) !== JSON.stringify( img.smush ) ) ) { props.setAttributes( { smush: img.smush } ); } } ); } /** * Modify the block’s edit component. * Receives the original block BlockEdit component and returns a new wrapped component. */ const smushStatsControl = createHigherOrderComponent( ( BlockEdit ) => { return ( props ) => { // If not image block or not selected, return unmodified block. if ( 'core/image' !== props.name || ! props.isSelected || 'undefined' === typeof props.attributes.id ) { return ( <Fragment> <BlockEdit { ...props } /> </Fragment> ); } const smushData = props.attributes.smush; fetchProps( props ); return ( <Fragment> <BlockEdit { ...props } /> <InspectorControls> <PanelBody title={ window.smush_global.strings.gb.stats }> { smushStats( props.attributes.id, smushData ) } </PanelBody> </InspectorControls> </Fragment> ); }; }, 'withInspectorControl' ); wp.hooks.addFilter( 'editor.BlockEdit', 'wp-smush/smush-data-control', smushStatsControl ); PK ;80]�y=�� � _src/js/smush/media-admin.jsnu �[��� /* global smush_vars */ (function ( $ ) { $( function() { /** * Disable the action links * * * @param c_element */ const disable_links = function (c_element) { const parent = c_element.parent(); //reduce parent opacity parent.css({ opacity: '0.5' }); //Disable Links parent.find('a').prop('disabled', true); }; /** * Enable the Action Links * * * @param c_element */ const enable_links = function (c_element) { const parent = c_element.parent(); //reduce parent opacity parent.css({ opacity: '1' }); //Disable Links parent.find('a').prop('disabled', false); }; /** * Update image size in attachment info panel. * * @param {number} newSize */ const updateImageStats = ( newSize ) => { if ( 0 === newSize ) { return; } const attachmentSize = jQuery( '.attachment-info .file-size' ); const currentSize = attachmentSize .contents() .filter( function() { return this.nodeType === 3; } ) .text(); // There is a space before the size. if ( currentSize !== ' ' + newSize ) { const sizeStrongEl = attachmentSize .contents() .filter( function() { return this.nodeType === 1; } ) .text(); attachmentSize.html( '<strong>' + sizeStrongEl + '</strong> ' + newSize ); } } /** * Restore image request with a specified action for Media Library / NextGen Gallery * * @param {Object} e * @param {string} currentButton * @param {string} smushAction * @param {string} action */ const process_smush_action = function ( e, currentButton, smushAction, action ) { e.preventDefault(); // If disabled. if ( currentButton.attr( 'disabled' ) ) { return; } // Remove Error. $('.wp-smush-error').remove(); // Hide stats. $('.smush-stats-wrapper').hide(); let mode = 'grid'; if ('smush_restore_image' === smushAction) { if ($(document).find('div.media-modal.wp-core-ui').length > 0) { mode = 'grid'; } else { mode = window.location.search.indexOf('item') > -1 ? 'grid' : 'list'; } } // Get the image ID and nonce. const params = { action: smushAction, attachment_id: currentButton.data('id'), mode, _nonce: currentButton.data('nonce') || wp_smush_msgs.nonce, }; // Reduce the opacity of stats and disable the click. disable_links(currentButton); const oldLabel = currentButton.html(); currentButton.html( '<span class="spinner wp-smush-progress">' + wp_smush_msgs[action] + '</span>' ); // Restore the image. $.post(ajaxurl, params, function (r) { // Reset all functionality. enable_links(currentButton); if (r.success && 'undefined' !== typeof r.data) { // Replace in immediate parent for NextGEN. if ('restore' === action) { // Show the smush button, and remove stats and restore option. currentButton.parents().eq(1).html(r.data.stats); } else { const wrapper = currentButton.parents().eq(1); if ( wp_smush_msgs.failed_item_smushed && wrapper.hasClass('smush-failed-processing') ) { wrapper.html( '<p class="smush-status smush-success">' + wp_smush_msgs.failed_item_smushed + '</p>' ); setTimeout(function(){ wrapper.html( r.data ); }, 2000); } else { wrapper.html(r.data); } } if ('undefined' !== typeof r.data && 'restore' === action) { updateImageStats(r.data.new_size); } } else if (r.data && r.data.error_msg) { if ( r.data.html_stats ) { currentButton.closest( '.smush-status-links' ).parent().html( r.data.html_stats ); } else { currentButton.closest( '.smush-status-links' ).prev('.smush-status').addClass('smush-warning').html(r.data.error_msg); } // Reset label and disable button on error. currentButton.attr('disabled', true); currentButton.html( oldLabel ); } }); }; /** Handle smush button click **/ $('body').on( 'click', '.wp-smush-send:not(.wp-smush-resmush)', function (e) { process_smush_action( e, $(this), 'optimize_attachment', 'smush' ); } ); /** * Ignore file from bulk Smush. */ $( 'body' ).on( 'click', '.smush-ignore-image', function( e ) { e.preventDefault(); const self = $( this ); self.prop( 'disabled', true ); self.attr( 'data-tooltip' ); self.removeClass( 'sui-tooltip' ); $.post( ajaxurl, { action: 'ignore_bulk_image', id: self.attr( 'data-id' ), _ajax_nonce: wp_smush_msgs.nonce, } ).done( ( response ) => { if ( self.is( 'a' ) && response.success && 'undefined' !== typeof response.data.html ) { if ( e.target.closest( '.smush-status-links' ) ) { self.closest( '.smush-status-links' ).parent().html( response.data.html ); } else if ( e.target.closest( '.smush-bulk-error-row' ) ) { self.addClass( 'disabled' ); e.target.closest( '.smush-bulk-error-row' ).style.opacity = 0.5; } } } ); } ); /** * Handle show in bulk smush button click. */ $( 'body' ).on( 'click', '.wp-smush-remove-skipped', function( e ) { e.preventDefault(); const self = $( this ); // Send ajax request to remove the image from the skip list. $.post( ajaxurl, { action: 'remove_from_skip_list', id: self.attr( 'data-id' ), _ajax_nonce: self.attr( 'data-nonce' ), } ).done( ( response ) => { if ( response.success && 'undefined' !== typeof response.data.html ) { self.parent().parent().html( response.data.html ); } } ); } ); /** Restore: Media Library **/ $('body').on('click', '.wp-smush-action.wp-smush-restore', function (e) { const current_button = $(this); current_button.removeClass('sui-tooltip'); process_smush_action( e, current_button, 'smush_restore_image', 'restore' ); }); /** Resmush: Media Library **/ $('body').on('click', '.wp-smush-action.wp-smush-resmush', function (e) { process_smush_action(e, $(this), 'optimize_attachment', 'resmush'); }); /** * Handle the Smush Stats link click */ $( 'body' ).on( 'click', 'a.smush-stats-details', function ( e ) { // If disabled if ( $( this ).prop( 'disabled' ) ) { return false; } e.preventDefault(); const $link = $( this ); const $wrapper = $link.parents().eq( 1 ).find( '.smush-stats-wrapper' ); // Toggle expanded state $link.toggleClass( 'smush-stats-expanded' ); $wrapper.slideToggle(); } ); }); })(window.jQuery); PK ;80]��p!�8 �8 "