....................................../////.===Shadow-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 51.91.236.193  /  Your IP : 216.73.216.177
Web Server : Apache
System : Linux webm019.cluster128.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User : thillelirn ( 8290)
PHP Version : 8.0.30
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/thillelirn/www/wp-content/plugins/imagify/inc/deprecated/classes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/thillelirn/www/wp-content/plugins/imagify/inc/deprecated/classes/class-imagify-attachment.php
<?php
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );

/**
 * Imagify Attachment class.
 *
 * @since 1.0
 * @since 1.9 Deprecated
 * @deprecated
 */
class Imagify_Attachment extends Imagify_Abstract_Attachment {

	/**
	 * Class version.
	 *
	 * @var string
	 */
	const VERSION = '1.2';

	/**
	 * The constructor.
	 *
	 * @since  1.2
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @param int|object $id The attachment ID or the attachment itself.
	 *                       If an integer, make sure the attachment exists.
	 */
	public function __construct( $id = 0 ) {
		imagify_deprecated_class( get_class( $this ), '1.9', '\\Imagify\\Optimization\\Process\\WP( $id )' );

		parent::__construct();
	}

	/**
	 * Get the attachment backup file path, even if the file doesn't exist.
	 *
	 * @since  1.6.13
	 * @author Grégory Viguier
	 * @access public
	 *
	 * @return string|bool The file path. False on failure.
	 */
	public function get_raw_backup_path() {
		return get_imagify_attachment_backup_path( $this->get_original_path() );
	}

	/**
	 * Get the attachment optimization data.
	 *
	 * @since 1.0
	 * @access public
	 *
	 * @return array
	 */
	public function get_data() {
		$data = get_post_meta( $this->id, '_imagify_data', true );
		return is_array( $data ) ? $data : array();
	}

	/**
	 * Get the attachment optimization level.
	 *
	 * @since 1.0
	 * @access public
	 *
	 * @return int
	 */
	public function get_optimization_level() {
		$level = get_post_meta( $this->id, '_imagify_optimization_level', true );
		return false !== $level ? (int) $level : false;
	}

	/**
	 * Get the attachment optimization status (success or error).
	 *
	 * @since 1.0
	 * @access public
	 *
	 * @return string
	 */
	public function get_status() {
		$status = get_post_meta( $this->id, '_imagify_status', true );
		return is_string( $status ) ? $status : '';
	}

	/**
	 * Get the original attachment path.
	 *
	 * @since 1.0
	 * @access public
	 *
	 * @return string
	 */
	public function get_original_path() {
		return get_attached_file( $this->id );
	}

	/**
	 * Get the original attachment URL.
	 *
	 * @since 1.0
	 * @access public
	 *
	 * @return string
	 */
	public function get_original_url() {
		return wp_get_attachment_url( $this->id );
	}

	/**
	 * Get width and height of the original image.
	 *
	 * @since  1.7
	 * @author Grégory Viguier
	 * @access public
	 *
	 * @return array
	 */
	public function get_dimensions() {
		if ( ! $this->is_image() ) {
			return parent::get_dimensions();
		}

		$values = wp_get_attachment_image_src( $this->id, 'full' );

		return array(
			'width'  => $values[1],
			'height' => $values[2],
		);
	}

	/**
	 * Update the metadata size of the attachment.
	 *
	 * @since 1.2
	 * @access public
	 *
	 * @return bool
	 */
	public function update_metadata_size() {
		// Check if the attachment extension is allowed.
		if ( ! $this->is_extension_supported() || ! $this->is_image() ) {
			return false;
		}

		$size = $this->filesystem->get_image_size( $this->get_original_path() );

		if ( ! $size ) {
			return false;
		}

		/**
		 * Triggered before updating an image width and height into its metadata.
		 *
		 * @since  1.8.4
		 * @see    Imagify_Filesystem->get_image_size()
		 * @author Grégory Viguier
		 *
		 * @param int   $attachment_id The attachment ID.
		 * @param array $size          {
		 *     An array with, among other data:
		 *
		 *     @type int $width  The image width.
		 *     @type int $height The image height.
		 * }
		 */
		do_action( 'before_imagify_update_metadata_size', $this->id, $size );

		$metadata           = wp_get_attachment_metadata( $this->id );
		$metadata['width']  = $size['width'];
		$metadata['height'] = $size['height'];

		wp_update_attachment_metadata( $this->id, $metadata );

		/**
		 * Triggered after updating an image width and height into its metadata.
		 *
		 * @since  1.8.4
		 * @see    Imagify_Filesystem->get_image_size()
		 * @author Grégory Viguier
		 *
		 * @param int   $attachment_id The attachment ID.
		 * @param array $size          {
		 *     An array with, among other data:
		 *
		 *     @type int $width  The image width.
		 *     @type int $height The image height.
		 * }
		 */
		do_action( 'after_imagify_update_metadata_size', $this->id, $size );

		return true;
	}

	/**
	 * Fills statistics data with values from $data array.
	 *
	 * @since  1.0
	 * @since  1.6.5 Not static anymore.
	 * @since  1.6.6 Removed the attachment ID parameter.
	 * @since  1.7   Removed the image URL parameter.
	 * @access public
	 *
	 * @param  array  $data      The statistics data.
	 * @param  object $response  The API response.
	 * @param  string $size      The attachment size key.
	 * @return bool|array        False if the original size has an error or an array contains the data for other result.
	 */
	public function fill_data( $data, $response, $size = 'full' ) {
		$data          = is_array( $data ) ? $data : array();
		$data['sizes'] = ! empty( $data['sizes'] ) && is_array( $data['sizes'] ) ? $data['sizes'] : array();

		if ( empty( $data['stats'] ) ) {
			$data['stats'] = array(
				'original_size'  => 0,
				'optimized_size' => 0,
				'percent'        => 0,
			);
		}

		if ( is_wp_error( $response ) ) {
			$error        = $response->get_error_message();
			$error_status = 'error';

			$data['sizes'][ $size ] = array(
				'success' => false,
				'error'   => $error,
			);

			// Update the error status for the original size.
			if ( 'full' === $size ) {
				update_post_meta( $this->id, '_imagify_data', $data );

				if ( false !== strpos( $error, 'This image is already compressed' ) ) {
					$error_status = 'already_optimized';
				}

				update_post_meta( $this->id, '_imagify_status', $error_status );

				return false;
			}
		} else {
			$response = (object) array_merge( array(
				'original_size' => 0,
				'new_size'      => 0,
				'percent'       => 0,
			), (array) $response );

			$data['sizes'][ $size ] = array(
				'success'        => true,
				'original_size'  => $response->original_size,
				'optimized_size' => $response->new_size,
				'percent'        => $response->percent,
			);

			$data['stats']['original_size']  += $response->original_size;
			$data['stats']['optimized_size'] += $response->new_size;
		} // End if().

		return $data;
	}

	/**
	 * Create a thumbnail if it doesn't exist.
	 *
	 * @since  1.6.10
	 * @access protected
	 * @author Grégory Viguier
	 *
	 * @param  array $thumbnail_data The thumbnail data (width, height, crop, name, file).
	 * @return bool|array|object     True if the file exists. An array of thumbnail data if the file has just been created (width, height, crop, file). A WP_Error object on error.
	 */
	protected function create_thumbnail( $thumbnail_data ) {
		$thumbnail_size = $thumbnail_data['name'];
		$metadata       = wp_get_attachment_metadata( $this->id );
		$metadata_sizes = ! empty( $metadata['sizes'] ) && is_array( $metadata['sizes'] ) ? $metadata['sizes'] : array();

		$original_dirname = $this->filesystem->dir_path( $this->get_original_path() );
		$thumbnail_path   = $original_dirname . $thumbnail_data['file'];

		if ( ! empty( $metadata_sizes[ $thumbnail_size ] ) && $this->filesystem->exists( $thumbnail_path ) ) {
			$this->filesystem->chmod_file( $thumbnail_path );
			return true;
		}

		// Get the editor.
		$editor = $this->get_editor( $this->get_backup_path() );

		if ( is_wp_error( $editor ) ) {
			return $editor;
		}

		// Create the file.
		$result = $editor->multi_resize( array( $thumbnail_size => $thumbnail_data ) );

		if ( ! $result ) {
			return new WP_Error( 'image_resize_error' );
		}

		// The file name can change from what we expected (1px wider, etc).
		$backup_dirname    = $this->filesystem->dir_path( $this->get_backup_path() );
		$backup_thumb_path = $backup_dirname . $result[ $thumbnail_size ]['file'];
		$thumbnail_path    = $original_dirname . $result[ $thumbnail_size ]['file'];

		// Since we used the backup image as source, the new image is still in the backup folder, we need to move it.
		$moved = $this->filesystem->move( $backup_thumb_path, $thumbnail_path, true );

		if ( ! $moved ) {
			return new WP_Error( 'image_resize_error' );
		}

		return reset( $result );
	}

	/**
	 * Create all missing thumbnails if they don't exist and update the attachment metadata.
	 *
	 * @since  1.6.10
	 * @access protected
	 * @author Grégory Viguier
	 *
	 * @param  array $missing_sizes An array of thumbnail data (width, height, crop, name, file) for each thumbnail size.
	 * @return array                An array of thumbnail data (width, height, crop, file).
	 */
	protected function create_missing_thumbnails( $missing_sizes ) {
		if ( ! $missing_sizes || ! $this->is_image() ) {
			return array();
		}

		$metadata            = wp_get_attachment_metadata( $this->id );
		$metadata['sizes']   = ! empty( $metadata['sizes'] ) && is_array( $metadata['sizes'] ) ? $metadata['sizes'] : array();
		$thumbnail_new_datas = array();
		$thumbnail_metadatas = array();

		// Create the missing thumbnails.
		foreach ( $missing_sizes as $size_name => $thumbnail_data ) {
			$result = $this->create_thumbnail( $thumbnail_data );

			if ( is_array( $result ) ) {
				// New file.
				$thumbnail_new_datas[ $size_name ] = $result;
				unset( $thumbnail_new_datas[ $size_name ]['name'] );
			} elseif ( true === $result ) {
				// The file already exists.
				$thumbnail_metadatas[ $size_name ] = $metadata['sizes'][ $size_name ];
			}
		}

		// Save the new data into the attachment metadata.
		if ( $thumbnail_new_datas ) {
			$metadata['sizes'] = array_merge( $metadata['sizes'], $thumbnail_new_datas );

			/**
			 * Here we don't use wp_update_attachment_metadata() to prevent triggering unwanted hooks.
			 */
			update_post_meta( $this->id, '_wp_attachment_metadata', $metadata );
		}

		return array_merge( $thumbnail_metadatas, $thumbnail_new_datas );
	}

	/**
	 * Optimize all sizes with Imagify.
	 *
	 * @since 1.0
	 * @access public
	 *
	 * @param  int   $optimization_level  The optimization level (2=ultra, 1=aggressive, 0=normal).
	 * @param  array $metadata            The attachment meta data.
	 * @return array $optimized_data      The optimization data.
	 */
	public function optimize( $optimization_level = null, $metadata = array() ) {
		// Check if the attachment extension is allowed.
		if ( ! $this->is_extension_supported() ) {
			return;
		}

		$optimization_level = isset( $optimization_level ) ? (int) $optimization_level : get_imagify_option( 'optimization_level' );
		$metadata           = $metadata ? $metadata : wp_get_attachment_metadata( $this->id );
		$sizes              = ! empty( $metadata['sizes'] ) && is_array( $metadata['sizes'] ) && $this->is_image() ? $metadata['sizes'] : array();

		// To avoid issue with "original_size" at 0 in "_imagify_data".
		if ( 0 === (int) $this->get_stats_data( 'original_size' ) ) {
			$this->delete_imagify_data();
		}

		// Check if the full size is already optimized.
		if ( $this->is_optimized() && $this->get_optimization_level() === $optimization_level ) {
			return;
		}

		// Get file path & URL for original image.
		$attachment_path          = $this->get_original_path();
		$attachment_url           = $this->get_original_url();
		$attachment_original_size = $this->get_original_size( false );

		/**
		 * Fires before optimizing an attachment.
		 *
		 * @since 1.0
		 *
		 * @param int $id The attachment ID.
		 */
		do_action( 'before_imagify_optimize_attachment', $this->id );

		$this->set_running_status();

		// Get the resize values for the original size.
		$resized   = false;
		$do_resize = $this->is_image() && get_imagify_option( 'resize_larger' );

		if ( $do_resize ) {
			$resize_width    = get_imagify_option( 'resize_larger_w' );
			$attachment_size = $this->filesystem->get_image_size( $attachment_path );

			if ( $attachment_size && $resize_width < $attachment_size['width'] ) {
				$resized_attachment_path = $this->resize( $attachment_path, $attachment_size, $resize_width );

				if ( ! is_wp_error( $resized_attachment_path ) ) {
					// TODO (@Greg): Send an error message if the backup fails.
					imagify_backup_file( $attachment_path );

					$this->filesystem->move( $resized_attachment_path, $attachment_path, true );

					$resized = true;
				}
			}
		}

		// Optimize the original size.
		$response = do_imagify( $attachment_path, array(
			'optimization_level' => $optimization_level,
			'context'            => $this->get_context(),
			'resized'            => $resized,
			'original_size'      => $attachment_original_size,
		) );

		$data = $this->fill_data( null, $response );

		/**
		 * Filter the optimization data of the full size.
		 *
		 * @since  1.8
		 * @author Grégory Viguier
		 *
		 * @param array  $data               The statistics data.
		 * @param object $response           The API response.
		 * @param int    $id                 The attachment ID.
		 * @param string $attachment_path    The attachment path.
		 * @param string $attachment_url     The attachment URL.
		 * @param string $size_key           The attachment size key. The value is obviously 'full' but it's kept for concistancy with other filters.
		 * @param int    $optimization_level The optimization level.
		 * @param array  $metadata           WP metadata.
		 */
		$data = apply_filters( 'imagify_fill_full_size_data', $data, $response, $this->id, $attachment_path, $attachment_url, 'full', $optimization_level, $metadata );

		// Save the optimization level.
		update_post_meta( $this->id, '_imagify_optimization_level', $optimization_level );

		// If we resized the original with success, we have to update the attachment metadata.
		// If not, WordPress keeps the old attachment size.
		if ( $resized ) {
			$this->update_metadata_size();
		}

		if ( ! $data ) {
			$this->delete_running_status();
			return;
		}

		// Optimize all thumbnails.
		if ( $sizes ) {
			$disallowed_sizes        = get_imagify_option( 'disallowed-sizes' );
			$is_active_for_network   = imagify_is_active_for_network();
			$attachment_path_dirname = $this->filesystem->dir_path( $attachment_path );
			$attachment_url_dirname  = $this->filesystem->dir_path( $attachment_url );

			foreach ( $sizes as $size_key => $size_data ) {
				$thumbnail_path = $attachment_path_dirname . $size_data['file'];
				$thumbnail_url  = $attachment_url_dirname . $size_data['file'];

				// Check if this size has to be optimized.
				if ( ! $is_active_for_network && isset( $disallowed_sizes[ $size_key ] ) ) {
					$data['sizes'][ $size_key ] = array(
						'success' => false,
						'error'   => __( 'This size is not authorized to be optimized. Update your Imagify settings if you want to optimize it.', 'imagify' ),
					);

					/**
					 * Filter the optimization data of an unauthorized thumbnail.
					 *
					 * @since  1.8
					 * @author Grégory Viguier
					 *
					 * @param array  $data               The statistics data.
					 * @param int    $id                 The attachment ID.
					 * @param string $thumbnail_path     The thumbnail path.
					 * @param string $thumbnail_url      The thumbnail URL.
					 * @param string $size_key           The thumbnail size key.
					 * @param int    $optimization_level The optimization level.
					 * @param array  $metadata           WP metadata.
					 */
					$data = apply_filters( 'imagify_fill_unauthorized_thumbnail_data', $data, $this->id, $thumbnail_path, $thumbnail_url, $size_key, $optimization_level, $metadata );
					continue;
				}

				// Optimize the thumbnail size.
				$response = do_imagify( $thumbnail_path, array(
					'backup'             => false,
					'optimization_level' => $optimization_level,
					'context'            => $this->get_context(),
				) );

				$data = $this->fill_data( $data, $response, $size_key );

				/**
				 * Filter the optimization data of a specific thumbnail.
				 *
				 * @since 1.0
				 * @since 1.8 Added $metadata.
				 *
				 * @param array  $data               The statistics data.
				 * @param object $response           The API response.
				 * @param int    $id                 The attachment ID.
				 * @param string $thumbnail_path     The thumbnail path.
				 * @param string $thumbnail_url      The thumbnail URL.
				 * @param string $size_key           The thumbnail size key.
				 * @param int    $optimization_level The optimization level.
				 * @param array  $metadata           WP metadata.
				 */
				$data = apply_filters( 'imagify_fill_thumbnail_data', $data, $response, $this->id, $thumbnail_path, $thumbnail_url, $size_key, $optimization_level, $metadata );
			} // End foreach().
		} // End if().

		$data['stats']['percent'] = round( ( ( $data['stats']['original_size'] - $data['stats']['optimized_size'] ) / $data['stats']['original_size'] ) * 100, 2 );

		update_post_meta( $this->id, '_imagify_data', $data );
		update_post_meta( $this->id, '_imagify_status', 'success' );

		$optimized_data = $this->get_data();

		/**
		 * Fires after optimizing an attachment.
		 *
		 * @since 1.0
		 *
		 * @param int   $id              The attachment ID.
		 * @param array $optimized_data  The optimization data.
		 */
		do_action( 'after_imagify_optimize_attachment', $this->id, $optimized_data );

		$this->delete_running_status();

		return $optimized_data;
	}

	/**
	 * Optimize missing thumbnail sizes with Imagify.
	 *
	 * @since  1.6.10
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @param  int $optimization_level The optimization level (2=ultra, 1=aggressive, 0=normal).
	 * @return array|object            An array of thumbnail data, size by size. A WP_Error object on failure.
	 */
	public function optimize_missing_thumbnails( $optimization_level = null ) {
		// Check if the attachment extension is allowed.
		if ( ! $this->is_extension_supported() || ! $this->is_image() ) {
			return new WP_Error( 'mime_type_not_supported', __( 'This type of file is not supported.', 'imagify' ) );
		}

		$optimization_level = isset( $optimization_level ) ? (int) $optimization_level : get_imagify_option( 'optimization_level' );
		$missing_sizes      = $this->get_unoptimized_sizes();

		if ( ! $missing_sizes ) {
			// We have everything we need.
			return array();
		}

		// Stop the process if there is no backup file to use.
		if ( ! $this->has_backup() ) {
			return new WP_Error( 'no_backup', __( 'This file has no backup file.', 'imagify' ) );
		}

		/**
		 * Fires before optimizing the missing thumbnails.
		 *
		 * @since  1.6.10
		 * @author Grégory Viguier
		 * @see    $this->get_unoptimized_sizes()
		 *
		 * @param int   $id            The attachment ID.
		 * @param array $missing_sizes An array of the missing sizes.
		*/
		do_action( 'before_imagify_optimize_missing_thumbnails', $this->id, $missing_sizes );

		$this->set_running_status();

		$errors = new WP_Error();

		// Create the missing thumbnails.
		$result_sizes = $this->create_missing_thumbnails( $missing_sizes );
		$failed_sizes = array_diff_key( $missing_sizes, $result_sizes );

		if ( $failed_sizes ) {
			$failed_count  = count( $failed_sizes );
			/* translators: %d is a number of thumbnails. */
			$error_message = _n( '%d thumbnail failed to be created', '%d thumbnails failed to be created', $failed_count, 'imagify' );
			$error_message = sprintf( $error_message, $failed_count );

			$errors->add( 'image_resize_error', $error_message, array(
				'nbr_failed'      => $failed_count,
				'sizes_failed'    => $failed_sizes,
				'sizes_succeeded' => $result_sizes,
			) );
		}

		if ( ! $result_sizes ) {
			$this->delete_running_status();
			return $errors;
		}

		// Optimize.
		$imagify_data     = $this->get_data();
		$original_dirname = $this->filesystem->dir_path( $this->get_original_path() );
		$orig_url_dirname = $this->filesystem->dir_path( $this->get_original_url() );

		foreach ( $result_sizes as $size_name => $thumbnail_data ) {
			$thumbnail_path = $original_dirname . $thumbnail_data['file'];
			$thumbnail_url  = $orig_url_dirname . $thumbnail_data['file'];

			// Optimize the thumbnail size.
			$response = do_imagify( $thumbnail_path, array(
				'backup'             => false,
				'optimization_level' => $optimization_level,
				'context'            => $this->get_context(),
			) );

			$imagify_data = $this->fill_data( $imagify_data, $response, $size_name );
			$metadata     = wp_get_attachment_metadata( $this->id );

			/** This filter is documented in inc/classes/class-imagify-attachment.php. */
			$imagify_data = apply_filters( 'imagify_fill_thumbnail_data', $imagify_data, $response, $this->id, $thumbnail_path, $thumbnail_url, $size_name, $optimization_level, $metadata );
		}

		// Save Imagify data.
		$imagify_data['stats']['percent'] = round( ( ( $imagify_data['stats']['original_size'] - $imagify_data['stats']['optimized_size'] ) / $imagify_data['stats']['original_size'] ) * 100, 2 );

		update_post_meta( $this->id, '_imagify_data', $imagify_data );

		/**
		 * Fires after optimizing the missing thumbnails.
		 *
		 * @since  1.6.10
		 * @author Grégory Viguier
		 * @see    $this->create_missing_thumbnails()
		 *
		 * @param int    $id           The attachment ID.
		 * @param array  $result_sizes An array of created thumbnails.
		 * @param object $errors       A WP_Error object that stores thumbnail creation failures.
		 */
		do_action( 'after_imagify_optimize_missing_thumbnails', $this->id, $result_sizes, $errors );

		$this->delete_running_status();

		// Return the result.
		if ( $errors->get_error_codes() ) {
			return $errors;
		}

		return $result_sizes;
	}

	/**
	 * Re-optimize the given thumbnail sizes to the same level.
	 * Before doing this, the given sizes must be restored.
	 *
	 * @since  1.7.1
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @param  array $sizes The sizes to optimize.
	 * @return array|void             A WP_Error object on failure.
	 */
	public function reoptimize_thumbnails( $sizes ) {
		// Check if the attachment extension is allowed.
		if ( ! $this->is_extension_supported() || ! $this->is_image() ) {
			return new WP_Error( 'mime_type_not_supported', __( 'This type of file is not supported.', 'imagify' ) );
		}

		if ( ! $sizes || ! is_array( $sizes ) ) {
			return;
		}

		/**
		 * Fires before re-optimizing some thumbnails of an attachment.
		 *
		 * @since  1.7.1
		 * @author Grégory Viguier
		 *
		 * @param int   $id    The attachment ID.
		 * @param array $sizes The sizes to optimize.
		*/
		do_action( 'before_imagify_reoptimize_attachment_thumbnails', $this->id, $sizes );

		$this->set_running_status();

		$data = $this->get_data();

		$data['sizes'] = ! empty( $data['sizes'] ) && is_array( $data['sizes'] ) ? $data['sizes'] : array();

		foreach ( $sizes as $size_key => $size_data ) {
			// In case it's a disallowed size, fill in the new data. If it's not, it will be overwritten by $this->fill_data() later.
			$data['sizes'][ $size_key ] = array(
				'success' => false,
				'error'   => __( 'This size is not authorized to be optimized. Update your Imagify settings if you want to optimize it.', 'imagify' ),
			);
		}

		// Update global attachment stats.
		$data['stats'] = array(
			'original_size'  => 0,
			'optimized_size' => 0,
			'percent'        => 0,
		);

		foreach ( $data['sizes'] as $size_data ) {
			if ( ! empty( $size_data['original_size'] ) ) {
				$data['stats']['original_size'] += $size_data['original_size'];
			}
			if ( ! empty( $size_data['optimized_size'] ) ) {
				$data['stats']['optimized_size'] += $size_data['optimized_size'];
			}
		}

		// Remove disallowed sizes.
		if ( ! imagify_is_active_for_network() ) {
			$sizes = array_diff_key( $sizes, get_imagify_option( 'disallowed-sizes' ) );
		}

		if ( ! $sizes ) {
			$data['stats']['percent'] = $data['stats']['original_size'] ? round( ( ( $data['stats']['original_size'] - $data['stats']['optimized_size'] ) / $data['stats']['original_size'] ) * 100, 2 ) : 0;
			update_post_meta( $this->id, '_imagify_data', $data );
			$this->delete_running_status();
			return;
		}

		$optimization_level      = $this->get_optimization_level();
		$thumbnail_path          = $this->get_original_path();
		$thumbnail_url           = $this->get_original_url();
		$attachment_path_dirname = $this->filesystem->dir_path( $thumbnail_path );
		$attachment_url_dirname  = $this->filesystem->dir_path( $thumbnail_url );

		foreach ( $sizes as $size_key => $size_data ) {
			$thumbnail_path = $attachment_path_dirname . $size_data['file'];
			$thumbnail_url  = $attachment_url_dirname . $size_data['file'];

			// Optimize the thumbnail size.
			$response = do_imagify( $thumbnail_path, array(
				'backup'             => false,
				'optimization_level' => $optimization_level,
				'context'            => $this->get_context(),
			) );

			$data = $this->fill_data( $data, $response, $size_key );

			/** This filter is documented in /inc/classes/class-imagify-attachment.php. */
			$data = apply_filters( 'imagify_fill_thumbnail_data', $data, $response, $this->id, $thumbnail_path, $thumbnail_url, $size_key, $optimization_level );
		} // End foreach().

		$data['stats']['percent'] = round( ( ( $data['stats']['original_size'] - $data['stats']['optimized_size'] ) / $data['stats']['original_size'] ) * 100, 2 );

		update_post_meta( $this->id, '_imagify_data', $data );

		/**
		 * Fires after re-optimizing some thumbnails of an attachment.
		 *
		 * @since  1.7.1
		 * @author Grégory Viguier
		 *
		 * @param int   $id    The attachment ID.
		 * @param array $sizes The sizes to optimize.
		*/
		do_action( 'after_imagify_reoptimize_attachment_thumbnails', $this->id, $sizes );

		$this->delete_running_status();
	}

	/**
	 * Process an attachment restoration from the backup file.
	 *
	 * @since 1.0
	 * @access public
	 *
	 * @return void
	 */
	public function restore() {
		// Check if the attachment extension is allowed.
		if ( ! $this->is_extension_supported() ) {
			return;
		}

		// Stop the process if there is no backup file to restore.
		if ( ! $this->has_backup() ) {
			return;
		}

		$backup_path     = $this->get_backup_path();
		$attachment_path = $this->get_original_path();

		/**
		 * Fires before restoring an attachment.
		 *
		 * @since 1.0
		 *
		 * @param int $id The attachment ID
		 */
		do_action( 'before_imagify_restore_attachment', $this->id );

		// Create the original image from the backup.
		$this->filesystem->copy( $backup_path, $attachment_path, true );
		$this->filesystem->chmod_file( $attachment_path );

		if ( $this->is_image() ) {
			if ( ! function_exists( 'wp_generate_attachment_metadata' ) ) {
				require_once ABSPATH . 'wp-admin/includes/image.php';
			}

			wp_generate_attachment_metadata( $this->id, $attachment_path );

			// Restore the original size in the metadata.
			$this->update_metadata_size();
		}

		// Remove old optimization data.
		$this->delete_imagify_data();

		/**
		 * Fires after restoring an attachment.
		 *
		 * @since 1.0
		 *
		 * @param int $id The attachment ID
		 */
		do_action( 'after_imagify_restore_attachment', $this->id );
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit