....................................../////.===Hehe-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 : 104.21.27.90  /  Your IP : 216.73.217.46
Web Server : nginx/1.28.3
System : Linux 4e27b89abc44 6.8.0-147-generic #147-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 24 11:33:16 UTC 2026 x86_64
User :  ( 1000)
PHP Version : 8.2.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /sites/xo-fab.com/www/graphmailerwp/wp-content_old/plugins/breeze/inc/cache/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /sites/xo-fab.com/www/graphmailerwp/wp-content_old/plugins/breeze/inc/cache//purge-cache.php
<?php
/**
 * @copyright 2017  Cloudways  https://www.cloudways.com
 *
 *  Original development of this plugin by JoomUnited https://www.joomunited.com/
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class Breeze_PurgeCache {

	/**
	 * Temporary page/post/cpt ID list of already cache cleared.
	 */
	private array $cleared_extra_items = array();

	public function set_action() {
		add_action( 'pre_post_update', array( $this, 'purge_post_on_update' ), 10, 1 );
		add_action( 'save_post', array( $this, 'purge_post_on_update' ), 10, 1 );
		add_action( 'save_post', array( $this, 'purge_post_on_update_content' ), 9, 3 );

		add_action( 'edited_term', array( $this, 'purge_term_on_update' ), 9, 3 );
		add_action( 'wp_trash_post', array( $this, 'purge_post_on_update' ), 10, 1 );
		add_action( 'wp_trash_post', array( $this, 'purge_post_on_trash' ), 9, 1 );
		add_action( 'comment_post', array( $this, 'purge_post_on_new_comment' ), 10, 3 );
		add_action( 'wp_set_comment_status', array( $this, 'purge_post_on_comment_status_change' ), 10, 2 );
		add_action( 'spammed_comment', array( $this, 'purge_post_on_comment_status_change' ), 10, 2 );
		add_action( 'trashed_comment', array( $this, 'purge_post_on_comment_status_change' ), 10, 2 );
		add_action( 'edit_comment', array( $this, 'purge_post_on_comment_status_change' ), 10, 2 );
		add_action( 'set_comment_cookies', array( $this, 'set_comment_cookie_exceptions' ), 10, 2 );

		add_action( 'switch_theme', array( &$this, 'clear_local_cache_on_switch' ), 9, 3 );
		add_action( 'customize_save_after', array( &$this, 'clear_customizer_cache' ), 11, 1 );
	}

	/**
	 * Detects pages with the latest comments block and clears their cache.
	 *
	 * This method scans the content of published posts to find pages that contain
	 * the latest comments block (`<!-- wp:latest-comments -->`). If such pages are found,
	 * it purges their Cloudflare cache and removes local cache files.
	 *
	 * @return void
	 */
	private function detect_comments_page_clear_cache(): void {
		global $wpdb;

		$query = "SELECT ID
			FROM `$wpdb->posts`
			WHERE post_content LIKE '%<!-- wp:latest-comments %>'
			AND post_status = 'publish'";

		$results = $wpdb->get_results( $query ); // phpcs:ignore

		$pages_list = array();

		if ( $results ) {
			foreach ( $results as $result ) {
				$page_id       = $result->ID;
				$get_permalink = get_permalink( $page_id );
				if ( false !== $get_permalink && ! in_array( $page_id, $this->cleared_extra_items, true ) ) {
					$pages_list[]                = $get_permalink;
					$this->cleared_extra_items[] = $page_id;
				}
			}
		}

		if ( ! empty( $pages_list ) ) {
			// CLear Cloudflare, if enabled.
			Breeze_CloudFlare_Helper::purge_cloudflare_cache_urls( $pages_list );

			// Remove local cache file.
			foreach ( $pages_list as $url_path ) {
				$this->clear_local_cache_for_urls( array( $url_path ) );

				$main     = new Breeze_PurgeVarnish();
				$item_url = untrailingslashit( $url_path ) . '/?breeze';
				$main->purge_cache( $item_url );
			}
		}
	}

	/**
	 * When customizer settings are saved ( Publish button is clicked ), clear all cache.
	 *
	 * @param $element
	 *
	 * @return void
	 */
	public function clear_customizer_cache( $element ) {

		do_action( 'breeze_clear_all_cache' );
	}

	/**
	 * Clear local cache on theme switch.
	 *
	 * @param $new_name
	 * @param $new_theme
	 * @param $old_theme
	 *
	 * @return void
	 */
	public function clear_local_cache_on_switch( $new_name, $new_theme, $old_theme ) {
		//delete minify
		Breeze_MinificationCache::clear_minification();
		//clear normal cache
		Breeze_PurgeCache::breeze_cache_flush( true, true, true );
		//do_action( 'breeze_clear_all_cache' );
	}

	/**
	 * When user posts a comment, set a cookie so we don't show them page cache
	 *
	 * @param WP_Comment $comment
	 * @param WP_User $user
	 *
	 * @since  1.3
	 */
	public function set_comment_cookie_exceptions( $comment, $user ) {
		// File based caching only
		if ( ! empty( Breeze_Options_Reader::get_option_value( 'breeze-active' ) ) ) {

			$post_id = $comment->comment_post_ID;

			setcookie( 'breeze_commented_posts[' . $post_id . ']', parse_url( get_permalink( $post_id ), PHP_URL_PATH ), ( time() + HOUR_IN_SECONDS * 24 * 7 ) );
		}
	}

	//    Automatically purge all file based page cache on post changes
	public function purge_post_on_update( $post_id ) {

		$post_type = get_post_type( $post_id );

		if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || 'revision' === $post_type ) {
			return;
		} elseif ( ! current_user_can( 'edit_post', $post_id ) && ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) ) {
			return;
		}

		$do_cache_reset = true;
		if ( 'tribe_events' === $post_type ) {
			$do_cache_reset = false;
		}
		$clear_wp_cache = true;

		if ( true === self::is_pro_plugin_ob_cache_enabled() ) {
			$clear_wp_cache = false;
		}

		if ( did_action( 'edit_post' ) ) {
			return;
		}

		// File based caching only
		if ( ! empty( Breeze_Options_Reader::get_option_value( 'breeze-active' ) ) ) {
			self::breeze_cache_flush( $do_cache_reset, $clear_wp_cache );
		}
	}

	/**
	 * Purges cache related to a term when it is updated.
	 *
	 * This method handles clearing object cache and file-based caching mechanisms
	 * for the specified term. It ensures cache consistency across term updates
	 * based on plugin configuration and active caching mechanisms.
	 *
	 * @param int $term_id The ID of the term being updated.
	 * @param int $tt_id The term taxonomy ID associated with the term.
	 * @param string $taxonomy The taxonomy name of the term being updated.
	 *
	 * @return void
	 */
	public function purge_term_on_update( int $term_id, int $tt_id, string $taxonomy ) {

		$clear_wp_cache = true;
		if ( true === self::is_pro_plugin_ob_cache_enabled() ) {
			$clear_wp_cache = false;
		}

		// File based caching only
		if ( ! empty( Breeze_Options_Reader::get_option_value( 'breeze-active' ) ) ) {
			self::clear_op_cache_for_terms( $term_id, $tt_id, $taxonomy );
			self::breeze_cache_flush( true, $clear_wp_cache );
		}
	}

	/**
	 * Purge Cloudflare data on post/page/cpt update.
	 *
	 * @param int $post_id Post ID.
	 * @param WP_Post $post Post object.
	 * @param bool $update Whether this is an existing post being updated.
	 *
	 * @return void
	 * @access public
	 * @since 2.0.15
	 */
	public function purge_post_on_update_content( int $post_id, WP_Post $post, bool $update ) {
		if ( true === $update ) {

			$post_type = get_post_type( $post_id );

			if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || 'revision' === $post_type ) {
				return;
			} elseif ( ! current_user_can( 'edit_post', $post_id ) && ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) ) {
				return;
			}

			$list_of_urls = self::collect_urls_for_cache_purge( $post_id );

			if ( ! empty( $list_of_urls ) ) {
				// Purge local cache for the URLs list.
				$this->clear_local_cache_for_urls( $list_of_urls );
				// Purge CF cache.
				Breeze_CloudFlare_Helper::purge_cloudflare_cache_urls( $list_of_urls );
			}
		}
	}

	/**
	 * Clear cloudflare cache on post/page/cpt delete action.
	 *
	 * @param int $post_id Post ID.
	 *
	 * @return void
	 */
	public function purge_post_on_trash( int $post_id ) {
		$list_of_urls = self::collect_urls_for_cache_purge( $post_id );

		if ( ! empty( $list_of_urls ) ) {
			// Purge local cache for the URLs list.
			$this->clear_local_cache_for_urls( $list_of_urls );
			// Purge CF cache.
			Breeze_CloudFlare_Helper::purge_cloudflare_cache_urls( $list_of_urls );
		}
	}

	public static function collect_urls_for_cache_purge( $post_id ): array {

		if ( false === get_permalink( $post_id ) ) {
			return array();
		}
		// Reset CloudFlare cache.
		$get_permalink = get_permalink( $post_id );
		// On delete action, the permalink has "__trashed" added to the permalink.
		// We need to remove that.
		$get_permalink  = str_replace( '__trashed', '', $get_permalink );
		$list_of_urls   = array();
		$list_of_urls[] = $get_permalink;

		$noarchive_post_type = array( 'post', 'page' );
		$this_post_status    = get_post_status( $post_id );
		$this_post_type      = get_post_type( $post_id );
		$rest_api_route      = 'wp/v2';
		$valid_post_status   = array( 'publish', 'private', 'trash' );

		$post_type_object = get_post_type_object( $this_post_type );
		if ( isset( $post_type_object->rest_base ) && ! empty( $post_type_object->rest_base ) ) {
			$rest_permalink = get_rest_url() . $rest_api_route . '/' . $post_type_object->rest_base . '/' . $post_id . '/';
		} elseif ( 'post' === $this_post_type ) {
			$rest_permalink = get_rest_url() . $rest_api_route . '/posts/' . $post_id . '/';
		} elseif ( 'page' === $this_post_type ) {
			$rest_permalink = get_rest_url() . $rest_api_route . '/views/' . $post_id . '/';
		}
		if ( isset( $rest_permalink ) ) {
			$list_of_urls[] = $rest_permalink;
		}

		// Add in AMP permalink if Automattic's AMP is installed
		if ( function_exists( 'amp_get_permalink' ) ) {
			$list_of_urls[] = amp_get_permalink( $post_id );
			// Regular AMP url for posts
			$list_of_urls[] = get_permalink( $post_id ) . 'amp/';
		}
		if ( 'trash' === $this_post_status ) {
			$list_of_urls[] = $get_permalink . 'feed/';
		}

		$author_id = get_post_field( 'post_author', $post_id );
		array_push(
			$list_of_urls,
			get_author_posts_url( $author_id ),
			get_author_feed_link( $author_id ),
			get_rest_url() . $rest_api_route . '/users/' . $author_id . '/'
		);

		$categories = get_the_category( $post_id );
		if ( $categories ) {
			foreach ( $categories as $cat ) {
				$category_link        = get_category_link( $cat->term_id );
				$category_link_no_cat = str_replace( 'category/', '', $category_link );
				if ( ! empty( $category_link ) && $category_link !== $category_link_no_cat ) {
					array_push( $list_of_urls, $category_link_no_cat );
				}

				array_push(
					$list_of_urls,
					$category_link,
					get_rest_url() . $rest_api_route . '/categories/' . $cat->term_id . '/'
				);
				$category_link = '';
			}
		}

		$tags = get_the_tags( $post_id );
		if ( $tags ) {
			foreach ( $tags as $tag ) {
				array_push(
					$list_of_urls,
					get_tag_link( $tag->term_id ),
					get_rest_url() . $rest_api_route . '/tags/' . $tag->term_id . '/'
				);
			}
		}

		// Archives and their feeds
		if ( $this_post_type && ! in_array( $this_post_type, $noarchive_post_type, true ) ) {
			$get_archive_link = get_post_type_archive_link( get_post_type( $post_id ) );

			$get_archive_feed_link = get_post_type_archive_feed_link( get_post_type( $post_id ) );
			if ( ! empty( $get_archive_link ) ) {
				$list_of_urls[] = $get_archive_link;
			}
			if ( ! empty( $get_archive_feed_link ) ) {
				$list_of_urls[] = $get_archive_feed_link;
			}
		}

		// Feeds
		array_push(
			$list_of_urls,
			get_bloginfo_rss( 'rdf_url' ),
			get_bloginfo_rss( 'rss_url' ),
			get_bloginfo_rss( 'rss2_url' ),
			get_bloginfo_rss( 'atom_url' ),
			get_bloginfo_rss( 'comments_rss2_url' ),
			get_post_comments_feed_link( $post_id )
		);
		// Home Pages and (if used) posts page
		array_push(
			$list_of_urls,
			get_rest_url(),
		);
		if ( 'page' === get_option( 'show_on_front' ) ) {
			// Ensure we have a page_for_posts setting to avoid empty URL
			if ( get_option( 'page_for_posts' ) ) {
				$list_of_urls[] = get_permalink( get_option( 'page_for_posts' ) );
			}
		}

		// Trim all URLs in the list to ensure clean output
		$list_of_urls = array_map( 'trim', $list_of_urls );

		$homepage = trailingslashit( home_url() );
		if ( ! in_array( $homepage, $list_of_urls, true ) ) {
			// Clear the cache for homepage
			array_push(
				$list_of_urls,
				$homepage
			);
		}

		return $list_of_urls;
	}

	/**
	 * Clears the local cache for the specified URLs.
	 *
	 * @param array $list_of_urls An array of URLs for which the local cache should be cleared.
	 *
	 * @return void
	 */
	private function clear_local_cache_for_urls( array $list_of_urls ) {
		$wp_filesystem = breeze_get_filesystem();

		if ( ! empty( $list_of_urls ) ) {
			foreach ( $list_of_urls as $local_url ) {
				if ( $wp_filesystem->exists( breeze_get_cache_base_path() . hash( 'sha512', $local_url ) ) ) {
					$wp_filesystem->rmdir( breeze_get_cache_base_path() . hash( 'sha512', $local_url ), true );
				}
			}
		}
	}

	/**
	 * Purges the cache for a post associated with a newly approved comment.
	 *
	 * This method is triggered when a new comment is added and approved, handling cache
	 * clearing for the related post using file-based caching and Cloudflare integration.
	 *
	 * @param int $comment_ID The ID of the new comment.
	 * @param int|string $approved Approval status of the comment. Non-zero value indicates approval.
	 * @param array $commentdata An array of comment data including the ID of the associated post.
	 *
	 * @return void
	 */
	public function purge_post_on_new_comment( $comment_ID, $approved, $commentdata ) {
		if ( 1 !== $approved ) {
			return;
		}
		// File based caching only
		if ( ! empty( Breeze_Options_Reader::get_option_value( 'breeze-active' ) ) ) {
			$post_id = $commentdata['comment_post_ID'];

			Breeze_CloudFlare_Helper::purge_cloudflare_cache_urls( array( get_permalink( $post_id ) ) );

			$url_path = get_permalink( $post_id );
			// Purge local cache for the URLs list.
			$this->clear_local_cache_for_urls( array( $url_path ) );

			$this->detect_comments_page_clear_cache();
			$this->clear_op_cache_for_comments( $comment_ID );
		}
	}

	/**
	 * Purges the post associated with a comment when the comment's status changes.
	 *
	 * This method is triggered to handle cache clearing for posts related to comments,
	 * based on file-based caching settings and configurations specific to Breeze.
	 *
	 * @param int $comment_ID The ID of the comment whose status has changed.
	 * @param mixed $comment_status The new status of the comment.
	 *
	 * @return void
	 */
	public function purge_post_on_comment_status_change( int $comment_ID, $comment_status ) {
		// File based caching only
		if ( ! empty( Breeze_Options_Reader::get_option_value( 'breeze-active' ) ) ) {
			$comment = get_comment( $comment_ID );
			if ( ! empty( $comment ) ) {
				$post_id = $comment->comment_post_ID;

				$url_path = get_permalink( $post_id );
				Breeze_CloudFlare_Helper::purge_cloudflare_cache_urls( array( $url_path ) );
				$this->clear_local_cache_for_urls( array( $url_path ) );
			}

			$this->detect_comments_page_clear_cache();
			$this->clear_op_cache_for_comments( $comment_ID );
		}
	}

	/**
	 * Clear Breeze & WordPress Cache
	 *
	 * @param $flush_cache
	 * @param $clear_ocp
	 *
	 * @return void
	 */
	public static function breeze_cache_flush( $flush_cache = true, $clear_ocp = true, $purge_all_html_folder = false ) {
		global $post;

		$post_id = null;
		if ( $post instanceof WP_Post ) {
			$post_id = $post->ID;
		}

		if ( true === Breeze_CloudFlare_Helper::is_log_enabled() ) {
			error_log( '######### PURGE LOCAL CACHE HTML ###: ' . var_export( 'true', true ) );
		}

		if ( true === $purge_all_html_folder ) {
			$wp_filesystem = breeze_get_filesystem();

			$cache_path = breeze_get_cache_base_path( is_network_admin() );
			$wp_filesystem->rmdir( untrailingslashit( $cache_path ), true );
		}

		if ( true === $flush_cache && ! empty( $post ) && is_object( $post ) ) {
			$post_type = get_post_type( $post->ID );

			$flush_cache         = true;
			$ignore_object_cache = array(
				'tribe_events',
				'shop_order',
			);
			if ( in_array( $post_type, $ignore_object_cache, true ) ) {
				$flush_cache = false;
			}
		}

		if ( true === $flush_cache && isset( $_GET['post_type'] ) && 'tribe_events' === $_GET['post_type'] ) {
			$flush_cache = false;
		}

		if ( ! empty( $post_id ) && true === $flush_cache && true === $clear_ocp ) {
			if ( true === Breeze_CloudFlare_Helper::is_log_enabled() ) {
				error_log( '######### PURGE OBJECT CACHE ###: ' . var_export( 'true', true ) );
			}
			self::clear_op_cache_for_posts( $post_id );
		}
	}

	//delete file for clean up

	public function clean_up() {

		$wp_filesystem = breeze_get_filesystem();
		$file          = untrailingslashit( WP_CONTENT_DIR ) . '/advanced-cache.php';

		$ret = true;

		if ( ! $wp_filesystem->delete( $file ) ) {
			$ret = false;
		}

		$folder = untrailingslashit( breeze_get_cache_base_path() );

		if ( ! $wp_filesystem->delete( $folder, true ) ) {
			$ret = false;
		}

		return $ret;
	}

	/**
	 * Return an instance of the current class, create one if it doesn't exist
	 * @return object
	 * @since  1.0
	 */
	public static function factory() {

		static $instance;

		if ( ! $instance ) {
			$instance = new self();
			$instance->set_action();
		}

		return $instance;
	}


	/**
	 * Flushes the entire object cache for the current context.
	 *
	 * This method resets the object cache, clearing all stored data. When executed
	 * on a network admin screen, it will handle any additional logic specific to
	 * network context (if required). Otherwise, it flushes the cache for the current
	 * instance or site.
	 *
	 * @return bool True on success, false on failure.
	 */
	public static function __flush_object_cache() {
		set_as_network_screen();

		if ( is_network_admin() ) {
			// in case we need to add something specific for network.
			return wp_cache_flush();
		}

		return wp_cache_flush();
	}

	/**
	 * Clears the object cache associated with a specific post or custom post type.
	 *
	 * This method removes cached data for the given post ID, including post metadata
	 * and any related term cache associated with the post.
	 *
	 * @param int $object_id The ID of the post or custom post type for which the cache should be cleared.
	 *
	 * @return void
	 */
	public static function clear_op_cache_for_posts( int $object_id ) {
		if ( true === self::is_pro_plugin_ob_cache_enabled() ) {
			return;
		}

		// POST/PAGE/CPT
		// $object_id is $post_id
		wp_cache_delete( $object_id, 'posts' );
		wp_cache_delete( $object_id, 'post_meta' ); // If needed
		wp_cache_delete( 'post_terms_' . $object_id, 'terms' ); //for term related to post
	}

	/**
	 * Clears the object cache related to specific terms and their taxonomy.
	 *
	 * This method removes cached data for the given term, term taxonomy, and associated taxonomy
	 * data, ensuring that outdated cached information is invalidated and updated.
	 *
	 * @param int $object_id The ID of the term for which the cache should be cleared.
	 * @param int $tt_id The term taxonomy ID associated with the term.
	 * @param string $taxonomy The taxonomy name related to the term.
	 *
	 * @return void
	 */
	private static function clear_op_cache_for_terms( int $object_id, int $tt_id, string $taxonomy ) {
		if ( true === self::is_pro_plugin_ob_cache_enabled() ) {
			return;
		}

		// TAXONOMY
		// $object_id is term_id
		wp_cache_delete( $object_id, 'terms' );
		wp_cache_delete( $tt_id, 'term_taxonomy' );
		#delete_transient( 'all_terms' ); //for all terms, if needed
		$tax_cache_key = "{$taxonomy}_terms"; //dynamic based on current taxonomy
		wp_cache_delete( $tax_cache_key, 'terms' ); //clear cache for taxonomy
	}

	/**
	 * Clears the object cache related to a specific comment and its associated post.
	 *
	 * This method removes cached data for the given comment, resets queries related
	 * to comments, clears the comment count cache, and clears the cache for the post
	 * associated with the given comment.
	 *
	 * @param int $comment_id The ID of the comment for which the cache should be cleared.
	 *
	 * @return void
	 */
	private static function clear_op_cache_for_comments( int $comment_id ) {
		if ( true === self::is_pro_plugin_ob_cache_enabled() ) {
			return;
		}
		error_log( '$comment_id: ' . var_export( $comment_id, true ) );
		wp_cache_delete( $comment_id, 'comment' );
		wp_cache_delete( 'comment_query_1_' . get_the_ID(), 'comment' );
		wp_cache_delete( 'get_comments_by_post_id_' . get_the_ID(), 'comment' );
		//Clear all comments count cache, as it has changed
		wp_cache_delete( 'comments-per-page', 'counts' );

		// Clear the cache for the post the comment belongs to
		$post_id = get_comment( $comment_id )->comment_post_ID;
		wp_cache_delete( $post_id, 'posts' );
		wp_cache_delete( $post_id, 'post_meta' ); // If needed
	}

	/**
	 * Checks if object cache support is enabled by a Pro plugin.
	 *
	 * This method verifies the presence of object caching functionality typically provided
	 * by Pro-level caching plugins, such as Redis Cache Pro or similar plugins.
	 *
	 * @return bool Returns true if a Pro plugin enabling object cache is detected, otherwise false.
	 */
	private static function is_pro_plugin_ob_cache_enabled(): bool {
		// If Redis Pro is found, leave the object cache clear to it.
		if ( defined( 'RedisCachePro\Version' ) || defined( 'WP_REDIS_VERSION' ) ) {
			return true;
		}

		// if the function does not exist, block the calling of it.
		if ( ! function_exists( 'wp_cache_delete' ) ) {
			return true;
		}
		// Go ahead and clear the object cache.
		return false;
	}
}

$breeze_basic_settings = Breeze_Options_Reader::get_option_value( 'breeze-active' );

if ( isset( $breeze_basic_settings ) && $breeze_basic_settings ) {
	Breeze_PurgeCache::factory();
}

Youez - 2016 - github.com/yon3zu
LinuXploit