....................................../////.===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 : 172.67.169.23  /  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/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /sites/xo-fab.com/www/graphmailerwp/wp-content_old/plugins/breeze/inc/breeze-admin.php
<?php
/**
 * @copyright 2017  Cloudways  https://www.cloudways.com
 *
 *  This plugin is inspired from WP Speed of Light by JoomUnited.
 *
 *  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
 */
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );

/**
 * Load the required resources.
 *
 * Class Breeze_Admin
 */
class Breeze_Admin {
	public function __construct() {
		add_action(
			'init',
			function () {
				load_plugin_textdomain( 'breeze', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
			}
		);

		// Load the Javascript for Lazy load.
		add_action( 'wp_enqueue_scripts', array( $this, 'breeze_lazy_load' ) );

		// Add our custom action to clear cache
		add_action( 'breeze_clear_all_cache', array( $this, 'breeze_clear_all_cache' ) );
		add_action( 'breeze_clear_varnish', array( $this, 'breeze_clear_varnish' ) );

		// Check the status change of excluded ecommerce pages.
		add_action( 'transition_post_status', array( $this, 'on_all_status_transitions' ), 10, 3 );
		// Check if woocommerce exists
		if ( function_exists( 'is_woocommerce_active' ) && is_woocommerce_active() ) {
			// Clear all cache on bulk update
			add_action( 'woocommerce_after_product_object_save', array( $this, 'clear_cache_if_changed_api' ), 10, 2 );
		}

		if ( is_admin() || 'cli' === php_sapi_name() ) {
			add_action( 'admin_init', array( $this, 'admin_init' ) );

			// register menu
			add_action( 'admin_menu', array( $this, 'register_menu_page' ) );
			add_action( 'network_admin_menu', array( $this, 'register_network_menu_page' ) );

			// Add notice when installing plugin
			$first_install = get_option( 'breeze_first_install' );
			if ( false === $first_install ) {
				add_option( 'breeze_first_install', 'yes' );
			}
			if ( 'yes' === $first_install ) {
				add_action( 'admin_notices', array( $this, 'installing_notices' ) );
			}

			$breeze_display_clean = Breeze_Options_Reader::get_option_value( 'breeze-display-clean' );

			if ( isset( $breeze_display_clean ) && $breeze_display_clean ) {
				// register top bar menu
				add_action( 'admin_bar_menu', array( $this, 'register_admin_bar_menu' ), 999 );
			}
			/** Load admin js * */
			add_action( 'admin_enqueue_scripts', array( $this, 'load_admin_scripts' ) );

			add_action( 'wp_head', array( $this, 'define_ajaxurl' ) );
			$this->ajax_handle();

			// Add setting buttons to plugins list page
			add_filter( 'plugin_action_links_' . BREEZE_BASENAME, array( $this, 'breeze_add_action_links' ) );
			add_filter(
				'network_admin_plugin_action_links_' . BREEZE_BASENAME,
				array(
					$this,
					'breeze_add_action_links_network',
				)
			);
			add_action( 'wpmu_new_blog', array( &$this, 'create_new_blog_items' ), 10, 6 );
		}

		add_action(
			'admin_init',
			function () {
				// When permalinks are reset, we also reset the config files.
				if ( isset( $_POST['permalink_structure'] ) || isset( $_POST['category_base'] ) ) {
					$to_action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'permalink';
					if ( 'permalink' !== $to_action ) {
						check_admin_referer( 'options-options' );
					} else {
						check_admin_referer( 'update-permalink' );
					}
					Breeze_Upgrade::refresh_config_files();
				}
			},
			99
		);

		add_action(
			'wp_login',
			function ( $user_login, $user ) {
				if ( in_array( 'administrator', (array) $user->roles, true ) ) {
					Breeze_Upgrade::refresh_config_files();
				}
			},
			10,
			2
		);
	}

	/**
	 * Check the page status and if the current page is
	 * in the excluded ecommerce pages list.
	 *
	 * Clears the cache when a scheduled post get's published.
	 *
	 * @param string $new_status
	 * @param string $old_status
	 * @param object $post
	 *
	 * @return void
	 */
	public function on_all_status_transitions( $new_status, $old_status, $post ) {

		// Make sure the Breeze_Ecommerce_Cache class is available.
		require_once BREEZE_PLUGIN_DIR . 'inc/cache/ecommerce-cache.php';

		if ( $new_status != $old_status && Breeze_Ecommerce_Cache::is_excluded_ecom_page( $post->ID ) ) {
			Breeze_ConfigCache::write_config_cache();
		}
		// Clear cache when a scheduled post get's published.
		if ( 'future' === $old_status && 'publish' === $new_status ) {
			do_action( 'breeze_clear_varnish' );
			Breeze_PurgeCache::breeze_cache_flush();
			Breeze_MinificationCache::clear_minification();
		}
	}

	public function create_new_blog_items( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {

		if ( ! is_multisite() ) {
			return;
		}
		$blog_id        = intval( $blog_id );
		$default_option = self::breeze_default_options_value();

		$basic     = $default_option['basic'];
		$file      = $default_option['file'];
		$heartbeat = $default_option['heartbeat'];
		$cdn       = $default_option['cdn'];
		$advanced  = $default_option['advanced'];
		$preload   = $default_option['preload'];
		$varnish   = $default_option['varnish'];

		$is_inherit_already = get_blog_option( $blog_id, 'breeze_inherit_settings', '' );
		if ( '' === $is_inherit_already ) {
			update_blog_option( $blog_id, 'breeze_inherit_settings', '1' );
		}

		$blog_basic = get_blog_option( $blog_id, 'breeze_basic_settings', '' );
		if ( empty( $blog_basic ) ) {
			update_blog_option( $blog_id, 'breeze_basic_settings', $basic );
		}

		$blog_advanced = get_blog_option( $blog_id, 'breeze_advanced_settings', '' );
		if ( empty( $blog_advanced ) ) {
			update_blog_option( $blog_id, 'breeze_advanced_settings', $advanced );
		}

		$blog_heartbeat = get_blog_option( $blog_id, 'breeze_heartbeat_settings', '' );
		if ( empty( $blog_heartbeat ) ) {
			update_blog_option( $blog_id, 'breeze_heartbeat_settings', $heartbeat );
		}

		$blog_preload = get_blog_option( $blog_id, 'breeze_preload_settings', '' );
		if ( empty( $blog_preload ) ) {
			update_blog_option( $blog_id, 'breeze_preload_settings', $preload );
		}

		$blog_file = get_blog_option( $blog_id, 'breeze_file_settings', '' );
		if ( empty( $blog_file ) || empty( $is_advanced ) ) {
			$save_file = $file;

			if ( isset( $breeze_delay_js_scripts ) ) {
				if ( empty( $blog_file ) ) {
					$save_file['breeze-delay-js-scripts'] = $breeze_delay_js_scripts;
				} else {
					$save_file                            = $blog_file;
					$save_file['breeze-delay-js-scripts'] = $breeze_delay_js_scripts;
				}
			}
			update_blog_option( $blog_id, 'breeze_file_settings', $save_file );
		}

		$blog_cdn = get_blog_option( $blog_id, 'breeze_cdn_integration', '' );
		if ( empty( $blog_cdn ) ) {
			update_blog_option( $blog_id, 'breeze_cdn_integration', $cdn );
		}

		$blog_varnish = get_blog_option( $blog_id, 'breeze_varnish_cache', '' );
		if ( empty( $blog_varnish ) ) {
			update_blog_option( $blog_id, 'breeze_varnish_cache', $varnish );
		}
	}


	/**
	 * Clear cache if products are changed trough API
	 *
	 * @param $product
	 * @param $data_store
	 *
	 * @return void
	 */
	public function clear_cache_if_changed_api( $product, $data_store ) {
		// Check if this is a REST API update and clear the cache only if this is the first time hook is called.
		if ( defined( 'REST_REQUEST' ) && REST_REQUEST && did_action( 'woocommerce_after_product_object_save' ) === 1 ) {
			$this->breeze_clear_all_cache();
		}
	}

	/**
	 * Load Lazy Load library
	 *
	 * @since 1.2.0
	 * @access public
	 */
	public function breeze_lazy_load() {

		$is_lazy_load_enabled = false;
		$is_lazy_load_native  = false;
		$is_lazy_load_videos  = false;

		$option_breeze_lazy_load        = Breeze_Options_Reader::get_option_value( 'breeze-lazy-load' );
		$option_breeze_lazy_load_native = Breeze_Options_Reader::get_option_value( 'breeze-lazy-load-native' );
		$option_breeze_lazy_load_videos = Breeze_Options_Reader::get_option_value( 'breeze-lazy-load-videos' );

		if ( isset( $option_breeze_lazy_load ) ) {
			$is_lazy_load_enabled = filter_var( $option_breeze_lazy_load, FILTER_VALIDATE_BOOLEAN );
		}
		if ( isset( $option_breeze_lazy_load_native ) ) {
			$is_lazy_load_native = filter_var( $option_breeze_lazy_load_native, FILTER_VALIDATE_BOOLEAN );
		}
		if ( isset( $option_breeze_lazy_load_videos ) ) {
			$is_lazy_load_videos = filter_var( $option_breeze_lazy_load_videos, FILTER_VALIDATE_BOOLEAN );
		}

		if ( $is_lazy_load_enabled ) {
			// Load breeze lazy load only for videos if the native lazy load is enabled. If the lazy load native is not activated, load the breeze lazy load
			if ( ! $is_lazy_load_native || $is_lazy_load_videos ) {
				if ( ! wp_script_is( 'jquery', 'enqueued' ) ) {
					wp_enqueue_script( 'jquery' );
				}

				wp_enqueue_script( 'breeze-lazy', plugins_url( 'assets/js/js-front-end/breeze-lazy-load.min.js', __DIR__ ), array(), BREEZE_VERSION, true );

				$data = 'document.addEventListener("DOMContentLoaded", function () {
							window.lazyLoadInstance = new LazyLoad({
						    elements_selector: ".br-lazy",
						    data_src: "breeze",
						    data_srcset: "brsrcset",
						    data_sizes: "brsizes",
						    class_loaded: "br-loaded",
						    threshold: 300,
								    });
						});';
				wp_add_inline_script( 'breeze-lazy', $data, 'after' );
			}

			if ( $is_lazy_load_native ) {
				$inline_js = <<<INLINEJS
window.addEventListener("DOMContentLoaded",(e=>{document.querySelectorAll('img[loading="lazy"]').forEach((e=>{e.getBoundingClientRect().top<=window.innerHeight&&(e.loading="eager")}))}));
INLINEJS;

				add_action(
					'wp_footer',
					function () use ( $inline_js ) {
						printf( '<script type="text/javascript">%s</script>', $inline_js );
					},
					99
				);
			}
		}
	}

	/**
	 * Admin Init.
	 */
	public function admin_init() {
		// Check plugin requirements
		if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
			if ( current_user_can( 'activate_plugins' ) && is_plugin_active( plugin_basename( __FILE__ ) ) ) {
				deactivate_plugins( __FILE__ );
				add_action( 'admin_notices', array( $this, 'breeze_show_error' ) );
				unset( $_GET['activate'] );
			}
		}

		// Do not load anything more
		return;
	}

	/**
	 * define Ajax URL.
	 */
	function define_ajaxurl() {
		if ( current_user_can( 'manage_options' ) ) {
			echo '<script type="text/javascript">
           var ajaxurl = "' . admin_url( 'admin-ajax.php' ) . '";
             </script>';
		}
	}

	/**
	 * Add notice message when install plugin.
	 */
	public function installing_notices() {
		if ( get_option( 'breeze_first_install' ) === 'no' ) {
			return;
		}
		if ( is_user_logged_in() && ( is_super_admin() || current_user_can( 'administrator' ) ) ) {
			$class = 'notice notice-success';

			$message = __( 'Thanks for installing Breeze. It is always recommended not to use more than one caching plugin at the same time. We recommend you to purge cache if necessary.', 'breeze' );

			printf( '<div class="%1$s"><p>%2$s <button class="button" id="breeze-hide-install-msg">' . __( 'Hide message', 'breeze' ) . '</button></p></div>', esc_attr( $class ), esc_html( $message ) );
			update_option( 'breeze_first_install', 'no' );
		}
	}

	/**
	 * Enqueue CSS and JS files required for the plugin functionality.
	 */
	function load_admin_scripts() {
		if ( ! wp_script_is( 'jquery', 'enqueued' ) ) {
			wp_enqueue_script( 'jquery' );
		}
		$min = '.min';
		if ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) {
			$min = '';
		}
		wp_enqueue_script( 'breeze-backend', plugins_url( 'assets/js/breeze-main' . $min . '.js', __DIR__ ), array( 'jquery' ), BREEZE_VERSION, true ); // BREEZE_VERSION
		wp_enqueue_style( 'breeze-notice', plugins_url( 'assets/css/breeze-admin-global.css', __DIR__ ), array(), BREEZE_VERSION );
		$current_screen = get_current_screen();
		if ( $current_screen->base == 'settings_page_breeze' || $current_screen->base == 'settings_page_breeze-network' ) {
			// add css
			wp_enqueue_style( 'breeze-fonts', plugins_url( 'assets/css/breeze-fonts.css', __DIR__ ), array(), BREEZE_VERSION ); // BREEZE_VERSION
			wp_enqueue_style( 'breeze-style', plugins_url( 'assets/css/breeze-admin.css', __DIR__ ), array( 'breeze-fonts' ), BREEZE_VERSION ); // BREEZE_VERSION

			// js
			// wp_enqueue_script( 'breeze-configuration', plugins_url( 'assets/js/breeze-configuration.js', dirname( __FILE__ ) ), array( 'jquery' ), BREEZE_VERSION, true );

			// Include the required jQuery UI Core & Libraries
			wp_enqueue_script( 'jquery-ui-core' );
			wp_enqueue_script( 'jquery-ui-tabs' );
			wp_enqueue_script( 'jquery-ui-accordion' );
			wp_enqueue_script( 'jquery-ui-sortable' );
			wp_enqueue_script( 'jquery-ui-widget' );

		}

		$token_name = array(
			'breeze_purge_varnish'   => '',
			'breeze_purge_database'  => '',
			'breeze_purge_cache'     => '',
			'breeze_save_options'    => '',
			'breeze_purge_opcache'   => '',
			'breeze_import_settings' => '',
			'breeze_reset_default'   => '',
			'breeze_check_cdn_url'   => '',
		);

		// Only create the security nonce if the user has manage_options ( administrator capabilities ).
		if ( false === breeze_is_restricted_access( true ) ) {
			$token_name = array(
				'breeze_purge_varnish'    => wp_create_nonce( '_breeze_purge_varnish' ),
				'breeze_purge_database'   => wp_create_nonce( '_breeze_purge_database' ),
				'breeze_purge_cache'      => wp_create_nonce( '_breeze_purge_cache' ),
				'breeze_save_options'     => wp_create_nonce( '_breeze_save_options' ),
				'breeze_purge_opcache'    => wp_create_nonce( '_breeze_purge_opcache' ),
				'breeze_import_settings'  => wp_create_nonce( '_breeze_import_settings' ),
				'breeze_reset_default'    => wp_create_nonce( '_breeze_reset_default' ),
				'breeze_check_cdn_url'    => wp_create_nonce( '_breeze_check_cdn_url' ),
				'breeze_check_compat'     => wp_create_nonce( '_breeze_check_compat' ),
				'breeze_check_permission' => wp_create_nonce( '_breeze_check_permission' ),
				'breeze_export_json'      => wp_create_nonce( '_breeze_export_json' ),
			);
		}

		wp_localize_script( 'breeze-backend', 'breeze_token_name', $token_name );
	}

	/**
	 * Register menu.
	 */
	function register_menu_page() {
		// add submenu for Cloudways
		add_submenu_page(
			'options-general.php',
			__( 'Breeze', 'breeze' ),
			__( 'Breeze', 'breeze' ),
			'manage_options',
			'breeze',
			array(
				$this,
				'breeze_load_page',
			)
		);
	}

	/**
	 * Register menu for multisite.
	 */
	function register_network_menu_page() {
		// add submenu for multisite network
		add_submenu_page(
			'settings.php',
			__( 'Breeze', 'breeze' ),
			__( 'Breeze', 'breeze' ),
			'manage_options',
			'breeze',
			array(
				$this,
				'breeze_load_page',
			)
		);
	}


	/**
	 * Register bar menu.
	 *
	 * @param WP_Admin_Bar $wp_admin_bar
	 */
	function register_admin_bar_menu( WP_Admin_Bar $wp_admin_bar ) {

		if ( ! ( current_user_can( 'manage_options' ) || current_user_can( 'editor' ) )
			&& ! ( is_plugin_active( 'woocommerce/woocommerce.php' ) && current_user_can( 'manage_woocommerce' ) ) ) {
			return;
		}

		$is_network = is_multisite() && is_network_admin();

		// add parent item
		$args = array(
			'id'    => 'breeze-topbar',
			'title' => esc_html__( 'Breeze', 'breeze' ),
			'meta'  => array(
				'classname' => 'breeze',
			),
		);
		$wp_admin_bar->add_node( $args );

		// Recreate the current URL in order to redirect to the same page on cache purge.
		$current_protocol                 = is_ssl() ? 'https' : 'http';
		$current_host                     = $_SERVER['HTTP_HOST'];
		$current_script                   = $_SERVER['SCRIPT_NAME'];
		$current_params                   = $_SERVER['QUERY_STRING'];
		$current_params ? $current_params = '?' . $current_params : $current_params = '';
		$current_screen_base              = get_current_screen()->base;

		if ( is_multisite() && ! is_subdomain_install() ) {
			$blog_details = get_blog_details();
			if ( ! empty( $blog_details->path ) ) {
				$blog_details->path = '';
			}

			$current_host .= rtrim( $blog_details->path, '/' );
		}

		// $current_screen_url = $current_protocol . '://' . $current_host . $current_script . '?' . $current_params;
		$current_script = str_replace( '/wp-admin/', '', $current_script );
		if ( $current_screen_base == 'dashboard' ) {
			$current_screen_url = admin_url() . $current_params;
		} else {
			$current_screen_url = admin_url( basename( $_SERVER['REQUEST_URI'] ) );
		}

		if ( true === $is_network ) {
			$current_screen_url = network_admin_url( basename( $_SERVER['REQUEST_URI'] ) );
			// particular fix when network is found twice in the url.
			$current_screen_url = str_replace( 'network/network', 'network/', $current_screen_url );
		}

		$current_screen_url = remove_query_arg(
			array(
				'breeze_purge',
				'_wpnonce',
				'breeze_purge_cloudflare',
				'breeze_purge_cache_cloudflare',
			),
			$current_screen_url
		);

		$purge_site_cache_url       = esc_url( wp_nonce_url( add_query_arg( 'breeze_purge', 1, $current_screen_url ), 'breeze_purge_cache' ) );
		$purge_cloudflare_cache_url = esc_url( wp_nonce_url( add_query_arg( 'breeze_purge_cloudflare', 1, $current_screen_url ), 'breeze_purge_cache_cloudflare' ) );

		// add purge all item
		$args = array(
			'id'     => ( ! is_multisite() || $is_network ) ? 'breeze-purge-all' : 'breeze-purge-site',
			'title'  => ( ! is_multisite() || $is_network ) ? esc_html__( 'Purge All Cache', 'breeze' ) : esc_html__( 'Purge Site Cache', 'breeze' ),
			'parent' => 'breeze-topbar',
			'href'   => $purge_site_cache_url,
			'meta'   => array( 'class' => 'breeze-toolbar-group' ),
		);
		$wp_admin_bar->add_node( $args );

		// Only admin can purge cache per module.
		if ( ! current_user_can( 'manage_options' ) ) {
			return;
		}

		// add purge modules group
		$args = array(
			'id'     => 'breeze-purge-modules',
			'title'  => esc_html__( 'Purge Modules', 'breeze' ),
			'parent' => 'breeze-topbar',
			'meta'   => array( 'class' => 'breeze-toolbar-group' ),
		);
		$wp_admin_bar->add_node( $args );

		if ( true === Breeze_CloudFlare_Helper::is_cloudflare_enabled() ) {
			$args = array(
				'id'     => 'breeze-purge-cloudflare',
				'title'  => esc_html__( 'Purge Cloudflare Cache', 'breeze' ),
				'parent' => 'breeze-purge-modules',
				'href'   => $purge_cloudflare_cache_url,
				'meta'   => array(
					'class' => 'breeze-toolbar-group',
				),
			);
			$wp_admin_bar->add_node( $args );
		}

		if ( true === is_varnish_cache_started() ) {
			// add child item (Purge Modules)
			$args = array(
				'id'     => 'breeze-purge-varnish-group',
				'title'  => esc_html__( 'Purge Varnish Cache', 'breeze' ),
				'parent' => 'breeze-purge-modules',
			);
			$wp_admin_bar->add_node( $args );
		}

		// add child item (Purge Modules)
		$args = array(
			'id'     => 'breeze-purge-file-group',
			'title'  => esc_html__( 'Purge Internal Cache', 'breeze' ),
			'parent' => 'breeze-purge-modules',
		);
		$wp_admin_bar->add_node( $args );

		// add child item (Purge Modules)
		$args = array(
			'id'     => 'breeze-purge-object-cache-group',
			'title'  => esc_html__( 'Purge Object Cache', 'breeze' ),
			'parent' => 'breeze-purge-modules',
		);
		$wp_admin_bar->add_node( $args );

		// add settings item
		$args = array(
			'id'     => 'breeze-settings',
			'title'  => esc_html__( 'Settings', 'breeze' ),
			'parent' => 'breeze-topbar',
			'href'   => $is_network ? network_admin_url( 'settings.php?page=breeze' ) : admin_url( 'options-general.php?page=breeze' ),
			'meta'   => array( 'class' => 'breeze-toolbar-group' ),
		);
		$wp_admin_bar->add_node( $args );

		// add support item
		$args = array(
			'id'     => 'breeze-support',
			'title'  => esc_html__( 'Support', 'breeze' ),
			'href'   => 'https://support.cloudways.com/breeze-wordpress-cache-configuration',
			'parent' => 'breeze-topbar',
			'meta'   => array(
				'class'  => 'breeze-toolbar-group',
				'target' => '_blank',
			),
		);
		$wp_admin_bar->add_node( $args );
	}

	/**
	 * Load plugin settings page for back-end.
	 */
	function breeze_load_page() {
		if ( isset( $_GET['page'] ) && 'breeze' === $_GET['page'] ) {
			require_once BREEZE_PLUGIN_DIR . 'views/breeze-setting-views.php';
		}
	}

	/**
	 * Error displayed of the PHP version is to low.
	 */
	public function breeze_show_error() {
		echo '<div class="error"><p><strong>Breeze</strong> need at least PHP 5.3 version, please update php before installing the plugin.</p></div>';
	}

	/**
	 * Admin ajax actions.
	 */
	public function ajax_handle() {
		add_action(
			'wp_ajax_breeze_purge_varnish',
			function () {
				Breeze_Configuration::purge_varnish_action( $this );
			}
		);

		add_action( 'wp_ajax_breeze_purge_file', array( 'Breeze_Configuration', 'breeze_ajax_clean_cache' ) );
		add_action( 'wp_ajax_breeze_purge_database', array( 'Breeze_Configuration', 'breeze_ajax_purge_database' ) );
		add_action( 'wp_ajax_breeze_purge_opcache', array( 'Breeze_Configuration', 'breeze_ajax_purge_opcache' ) );
		add_action( 'wp_ajax_breeze_reset_default', array( 'Breeze_Configuration', 'reset_to_default_ajax' ) );
		add_action( 'wp_ajax_breeze_check_cdn_url', array( 'Breeze_Configuration', 'breeze_ajax_check_cdn_url' ) );
	}

	/**
	 * Default Breeze settings.
	 *
	 * @return array
	 * @throws \Random\RandomException
	 */
	private static function breeze_default_options_value(): array {
		$default_data = array();
		// Default basic
		$basic = breeze_get_option( 'basic_settings' );
		if ( empty( $basic ) ) {
			$basic = array();
		}

		$all_user_roles     = breeze_all_wp_user_roles();
		$active_cache_users = array();
		foreach ( $all_user_roles as $usr_role ) {
			$active_cache_users[ $usr_role ] = 0;
		}

		$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
		$token      = '';

		for ( $i = 0; $i < 12; $i++ ) {
			$token .= $characters[ random_int( 0, strlen( $characters ) - 1 ) ];
		}

		$default_basic = array(
			'breeze-active'            => '1',
			'breeze-mobile-separate'   => '1',
			'breeze-cross-origin'      => '0',
			'breeze-disable-admin'     => $active_cache_users,
			'breeze-gzip-compression'  => '1',
			'breeze-desktop-cache'     => '1',
			'breeze-mobile-cache'      => '1',
			'breeze-b-ttl'             => 1440,
			'breeze-browser-cache'     => '1',
			'breeze-lazy-load'         => '0',
			'breeze-lazy-load-native'  => '0',
			'breeze-lazy-load-iframes' => '0',
			'breeze-lazy-load-videos'  => '0',
			'breeze-display-clean'     => '1',

		);
		$default_data['basic'] = array_merge( $default_basic, $basic );

		// Default File
		$file = breeze_get_option( 'file_settings' );
		if ( empty( $file ) ) {
			$file = array();
		}
		$breeze_delay_js_scripts = array(
			'gtag',
			'document.write',
			'html5.js',
			'show_ads.js',
			'google_ad',
			'blogcatalog.com/w',
			'tweetmeme.com/i',
			'mybloglog.com/',
			'histats.com/js',
			'ads.smowtion.com/ad.js',
			'statcounter.com/counter/counter.js',
			'widgets.amung.us',
			'ws.amazon.com/widgets',
			'media.fastclick.net',
			'/ads/',
			'comment-form-quicktags/quicktags.php',
			'edToolbar',
			'intensedebate.com',
			'scripts.chitika.net/',
			'_gaq.push',
			'jotform.com/',
			'admin-bar.min.js',
			'GoogleAnalyticsObject',
			'plupload.full.min.js',
			'syntaxhighlighter',
			'adsbygoogle',
			'gist.github.com',
			'_stq',
			'nonce',
			'post_id',
			'data-noptimize',
			'googletagmanager',
		);
		$default_file            = array(
			'breeze-minify-html'       => '0',
			// --
			'breeze-minify-css'        => '0',
			'breeze-font-display-swap' => '0',
			'breeze-group-css'         => '0',
			'breeze-exclude-css'       => array(),
			// --
			'breeze-minify-js'         => '0',
			'breeze-group-js'          => '0',
			'breeze-include-inline-js' => '0',
			'breeze-exclude-js'        => array(),
			'breeze-move-to-footer-js' => array(),
			'breeze-defer-js'          => array(),
			'breeze-enable-js-delay'   => '0',
			'no-breeze-no-delay-js'    => array(),
			'breeze-delay-all-js'      => '0',
			'breeze-delay-js-scripts'  => $breeze_delay_js_scripts,
		);

		$default_data['file'] = array_merge( $default_file, $file );

		// Default Advanced
		$advanced = breeze_get_option( 'advanced_settings' );
		if ( empty( $advanced ) ) {
			$advanced = array();
		}
		$default_advanced         = array(
			'breeze-exclude-urls'                  => array(),
			'cached-query-strings'                 => array(),
			'breeze-wp-emoji'                      => '0',
			'breeze-store-googlefonts-locally'     => '0',
			'breeze-store-googleanalytics-locally' => '0',
			'breeze-store-facebookpixel-locally'   => '0',
			'breeze-store-gravatars-locally'       => '0',
			'breeze-enable-api'                    => '0',
			'breeze-secure-api'                    => '0',
			'breeze-api-token'                     => $token,
		);
		$default_data['advanced'] = array_merge( $default_advanced, $advanced );

		$heartbeat = breeze_get_option( 'heartbeat_settings' );
		if ( empty( $heartbeat ) ) {
			$heartbeat = array();
		}

		$default_heartbeat         = array(
			'breeze-control-heartbeat'  => '0',
			'breeze-heartbeat-front'    => '',
			'breeze-heartbeat-postedit' => '',
			'breeze-heartbeat-backend'  => '',
		);
		$default_data['heartbeat'] = array_merge( $default_heartbeat, $heartbeat );

		// CDN default
		$cdn = breeze_get_option( 'cdn_integration' );
		if ( empty( $cdn ) ) {
			$cdn = array();
		}
		$wp_content          = substr( WP_CONTENT_DIR, strlen( ABSPATH ) );
		$default_cdn         = array(
			'cdn-active'          => '0',
			'cdn-url'             => '',
			'cdn-content'         => array( 'wp-includes', $wp_content ),
			'cdn-exclude-content' => array( '.php' ),
			'cdn-relative-path'   => '1',
		);
		$default_data['cdn'] = array_merge( $default_cdn, $cdn );

		// Preload default
		$preload = breeze_get_option( 'preload_settings' );
		if ( empty( $preload ) ) {
			$preload = array();
		}
		$default_preload         = array(
			'breeze-preload-fonts' => array(),
			'breeze-preload-links' => '1',
			'breeze-prefetch-urls' => array(),
		);
		$default_data['preload'] = array_merge( $default_preload, $preload );

		// Varnish default
		$varnish = breeze_get_option( 'varnish_cache' );
		if ( empty( $varnish ) ) {
			$varnish = array();
		}
		$default_varnish         = array(
			'auto-purge-varnish'       => '1',
			'breeze-varnish-server-ip' => '127.0.0.1',
			'breeze-ttl'               => 1440,
		);
		$default_data['varnish'] = array_merge( $default_varnish, $varnish );

		return $default_data;
	}

	/*
	 * Register active plugin hook.
	 */
	/**
	 * @throws \Random\RandomException
	 */
	public static function plugin_active_hook( $network_wide ) {
		WP_Filesystem();
		// Include required files.
		if ( ! class_exists( 'Breeze_ConfigCache' ) ) {
			require_once BREEZE_PLUGIN_DIR . 'inc/cache/config-cache.php';
		}
		if ( ! class_exists( 'Breeze_Configuration' ) ) {
			require_once BREEZE_PLUGIN_DIR . 'inc/breeze-configuration.php';
		}
		$default_option = self::breeze_default_options_value();
		$basic          = $default_option['basic'];
		$file           = $default_option['file'];
		$heartbeat      = $default_option['heartbeat'];
		$cdn            = $default_option['cdn'];
		$advanced       = $default_option['advanced'];
		$preload        = $default_option['preload'];
		$varnish        = $default_option['varnish'];

		if ( is_multisite() ) {
			if ( ! isset( $network_wide ) ) {
				$network_wide = is_network_admin();
			}

			$blogs = get_sites();
			foreach ( $blogs as $blog ) {
				$is_inherit_already = get_blog_option( (int) $blog->blog_id, 'breeze_inherit_settings', '' );
				if ( '' === $is_inherit_already ) {
					update_blog_option( (int) $blog->blog_id, 'breeze_inherit_settings', '1' );
				}

				$blog_basic = get_blog_option( (int) $blog->blog_id, 'breeze_basic_settings', '' );
				if ( empty( $blog_basic ) ) {
					update_blog_option( (int) $blog->blog_id, 'breeze_basic_settings', $basic );
				}

				$blog_advanced = get_blog_option( (int) $blog->blog_id, 'breeze_advanced_settings', '' );
				if ( empty( $blog_advanced ) ) {
					update_blog_option( (int) $blog->blog_id, 'breeze_advanced_settings', $advanced );
				}

				$blog_heartbeat = get_blog_option( (int) $blog->blog_id, 'breeze_heartbeat_settings', '' );
				if ( empty( $blog_heartbeat ) ) {
					update_blog_option( (int) $blog->blog_id, 'breeze_heartbeat_settings', $heartbeat );
				}

				$blog_preload = get_blog_option( (int) $blog->blog_id, 'breeze_preload_settings', '' );
				if ( empty( $blog_preload ) ) {
					update_blog_option( (int) $blog->blog_id, 'breeze_preload_settings', $preload );
				}

				$blog_file = get_blog_option( (int) $blog->blog_id, 'breeze_file_settings', '' );
				if ( empty( $blog_file ) || empty( $is_advanced ) ) {
					update_blog_option( (int) $blog->blog_id, 'breeze_file_settings', $file );
				}

				$blog_cdn = get_blog_option( (int) $blog->blog_id, 'breeze_cdn_integration', '' );
				if ( empty( $blog_cdn ) ) {
					update_blog_option( (int) $blog->blog_id, 'breeze_cdn_integration', $cdn );
				}

				$blog_varnish = get_blog_option( (int) $blog->blog_id, 'breeze_varnish_cache', '' );
				if ( empty( $blog_varnish ) ) {
					update_blog_option( (int) $blog->blog_id, 'breeze_varnish_cache', $varnish );
				}
			}

			if ( $network_wide ) {
				$network_basic = breeze_get_option( 'basic_settings' );
				if ( ! $network_basic ) {
					breeze_update_option( 'basic_settings', $basic );
				}

				$network_advanced = breeze_get_option( 'advanced_settings' );
				if ( ! $network_advanced ) {
					breeze_update_option( 'advanced_settings', $advanced );
				}

				$network_heartbeat = breeze_get_option( 'heartbeat_settings' );
				if ( ! $network_heartbeat ) {
					breeze_update_option( 'heartbeat_settings', $heartbeat );
				}

				$network_preload = breeze_get_option( 'preload_settings' );
				if ( ! $network_preload ) {
					breeze_update_option( 'preload_settings', $preload );
				}

				$network_file = breeze_get_option( 'file_settings' );
				if ( ! $network_file || empty( $is_advanced ) ) {
					breeze_update_option( 'file_settings', $file, true );
				}

				$network_cdn = breeze_get_option( 'cdn_integration' );
				if ( ! $network_cdn ) {
					breeze_update_option( 'cdn_integration', $cdn );
				}

				$network_varnish = breeze_get_option( 'varnish_cache' );
				if ( ! $network_varnish ) {
					breeze_update_option( 'varnish_cache', $varnish );
				}
			}

			Breeze_ConfigCache::factory()->write_config_cache( true );
		} else {
			$singe_network_basic = breeze_get_option( 'basic_settings' );
			if ( ! $singe_network_basic ) {
				breeze_update_option( 'basic_settings', $basic );
			}

			$singe_network_advanced = breeze_get_option( 'advanced_settings' );
			if ( ! $singe_network_advanced ) {
				breeze_update_option( 'advanced_settings', $advanced );
			}

			$singe_network_heartbeat = breeze_get_option( 'heartbeat_settings' );
			if ( ! $singe_network_heartbeat ) {
				breeze_update_option( 'heartbeat_settings', $heartbeat );
			}

			$singe_network_preload = breeze_get_option( 'preload_settings' );
			if ( ! $singe_network_preload ) {
				breeze_update_option( 'preload_settings', $preload );
			}

			$singe_network_file = breeze_get_option( 'file_settings' );
			if ( ! $singe_network_file || empty( $is_advanced ) ) {
				breeze_update_option( 'file_settings', $file, true );
			}

			$singe_network_cdn = breeze_get_option( 'cdn_integration' );
			if ( ! $singe_network_cdn ) {
				breeze_update_option( 'cdn_integration', $cdn );
			}

			$singe_network_varnish = breeze_get_option( 'varnish_cache' );
			if ( ! $singe_network_varnish ) {
				breeze_update_option( 'varnish_cache', $varnish );
			}
		}

		// add header to htaccess if setting is enabled or by default if first installed
		Breeze_Configuration::update_htaccess();
		// automatic config start cache
		Breeze_ConfigCache::factory()->write();
		Breeze_ConfigCache::factory()->write_config_cache();

		if ( ! empty( $basic ) && ! empty( $basic['breeze-active'] ) ) {
			Breeze_ConfigCache::factory()->toggle_caching( true );
		}
	}

	/**
	 * Unschedules the 'breeze_purge_cache' event if it is scheduled.
	 *
	 * Identifies the next scheduled occurrence of the 'breeze_purge_cache' event
	 * and removes it from the WordPress cron schedule.
	 *
	 * @return void
	 */
	public static function unschedule_events() {
		$timestamp = wp_next_scheduled( 'breeze_purge_cache' );
		wp_unschedule_event( $timestamp, 'breeze_purge_cache' );

		// Find the timestamp with the correct parameters
		$timestamp = wp_next_scheduled( 'breeze_clear_remote_gravatar', array( 'gravatars' ) );

		// Only try to unschedule if a timestamp was found
		if ( $timestamp ) {
			wp_unschedule_event( $timestamp, 'breeze_clear_remote_gravatar', array( 'gravatars' ) );
		}
	}

	/*
	 * Register deactivate plugin hook.
	 */
	public static function plugin_deactive_hook() {
		WP_Filesystem();
		if ( ! class_exists( 'Breeze_ConfigCache' ) ) {
			require_once BREEZE_PLUGIN_DIR . 'inc/cache/config-cache.php';
		}
		if ( ! class_exists( 'Breeze_Configuration' ) ) {
			require_once BREEZE_PLUGIN_DIR . 'inc/breeze-configuration.php';
		}

		Breeze_ConfigCache::factory()->clean_up();
		self::unschedule_events();
		// Breeze_ConfigCache::factory()->clean_config();
		Breeze_ConfigCache::factory()->toggle_caching( false );
		Breeze_Configuration::update_htaccess( true );

		Breeze_Store_Files::cleanup_all_extra_folder();

		$check_varnish = is_varnish_cache_started();
		if ( $check_varnish ) {
			if ( is_multisite() ) {
				$sites = get_sites();
				foreach ( $sites as $site ) {
					switch_to_blog( $site->blog_id );
					self::unschedule_events();
					do_action( 'breeze_clear_varnish' );
					restore_current_blog();
				}
			} else {
				do_action( 'breeze_clear_varnish' );
			}
		}
	}

	/**
	 * Removed the files and the database settings when plugin is uninstalled
	 *
	 * @since 1.1.6
	 * @static
	 * @access public
	 */
	public static function plugin_uninstall_hook() {
		// Remove config files and update .htaccess.
		self::plugin_deactive_hook();
		// Remove extra cache files. (fb,google,fonts...)
		Breeze_Store_Files::cleanup_all_extra_folder();
		// Delete config file(s).
		Breeze_ConfigCache::factory()->clean_config();
		// Remove data from the database.
		self::purge_local_options();
	}

	public static function purge_local_options() {
		if ( ( is_admin() || 'cli' === php_sapi_name() ) ) {
			if ( is_multisite() ) {
				$sites = get_sites(
					array(
						'fields' => 'ids',
					)
				);

				// Delete NETWORK level options.
				delete_site_option( 'breeze_basic_settings' );
				delete_site_option( 'breeze_preload_settings' );
				delete_site_option( 'breeze_file_settings' );
				delete_site_option( 'breeze_advanced_settings' );
				delete_site_option( 'breeze_heartbeat_settings' );
				delete_site_option( 'breeze_cdn_integration' );
				delete_site_option( 'breeze_varnish_cache' );
				delete_site_option( 'breeze_inherit_settings' );
				delete_site_option( 'breeze_show_incompatibility' );
				delete_site_option( 'breeze_first_install' );
				delete_site_option( 'breeze_advanced_settings_120' );
				delete_site_option( 'breeze_new_update' );
				delete_site_option( 'breeze_ecommerce_detect' );
				delete_site_option( 'breeze_exclude_url_pages' );
				delete_site_option( 'breeze_hide_notice' );
				delete_site_option( 'breeze_version' );

				// Delete transients.
				delete_transient( 'breeze_custom_varnish_server_active' );

				// Delete options for each sub-blog.
				foreach ( $sites as $blog_id ) {
					switch_to_blog( $blog_id );
					delete_option( 'breeze_basic_settings' );
					delete_option( 'breeze_preload_settings' );
					delete_option( 'breeze_file_settings' );
					delete_option( 'breeze_advanced_settings' );
					delete_option( 'breeze_heartbeat_settings' );
					delete_option( 'breeze_cdn_integration' );
					delete_option( 'breeze_varnish_cache' );
					delete_option( 'breeze_inherit_settings' );
					delete_option( 'breeze_show_incompatibility' );
					delete_option( 'breeze_first_install' );
					delete_option( 'breeze_advanced_settings_120' );
					delete_option( 'breeze_new_update' );
					delete_option( 'breeze_ecommerce_detect' );
					delete_option( 'breeze_exclude_url_pages' );
					delete_option( 'breeze_hide_notice' );
					delete_option( 'breeze_version' );
					restore_current_blog();
				}
			} else {
				// Delete options for each sub-blog.
				delete_option( 'breeze_basic_settings' );
				delete_option( 'breeze_preload_settings' );
				delete_option( 'breeze_file_settings' );
				delete_option( 'breeze_advanced_settings' );
				delete_option( 'breeze_heartbeat_settings' );
				delete_option( 'breeze_cdn_integration' );
				delete_option( 'breeze_varnish_cache' );
				delete_option( 'breeze_inherit_settings' );
				delete_option( 'breeze_show_incompatibility' );
				delete_option( 'breeze_first_install' );
				delete_option( 'breeze_advanced_settings_120' );
				delete_option( 'breeze_new_update' );
				delete_option( 'breeze_ecommerce_detect' );
				delete_option( 'breeze_exclude_url_pages' );
				delete_option( 'breeze_hide_notice' );
				delete_option( 'breeze_version' );

				// Delete transients.
				delete_transient( 'breeze_custom_varnish_server_active' );

				// Delete Minfication hashes.
				delete_option( 'breeze_minified_hashes' );
			}
		}
	}


	/*
	 * Render tab for the settings in back-end.
	 */
	public static function render( $tab ) {
		require_once BREEZE_PLUGIN_DIR . 'views/option-tabs/' . $tab . '-tab.php';
	}

	/**
	 * Check varnish cache exist.
	 *
	 * @return bool
	 */
	public static function check_varnish() {
		if ( isset( $_SERVER['HTTP_X_VARNISH'] ) ) {
			return true;
		}

		return false;
	}

	/**
	 * Applied to the list of links to display on the plugins page.
	 *
	 * @param array $links List of links.
	 *
	 * @return array
	 */
	public function breeze_add_action_links( $links ) {
		$my_links = array(
			'<a href="' . admin_url( 'options-general.php?page=breeze' ) . '">Settings</a>',
		);

		return array_merge( $my_links, $links );
	}

	/**
	 * Applied to the list of links to display on the network plugins page
	 *
	 * @param array $links List of links.
	 *
	 * @return array
	 */
	public function breeze_add_action_links_network( $links ) {
		$my_links = array(
			'<a href="' . network_admin_url( 'settings.php?page=breeze' ) . '">Settings</a>',
		);

		return array_merge( $my_links, $links );
	}

	/**
	 * Clear all cache action.
	 */
	public function breeze_clear_all_cache() {
		set_as_network_screen();

		global $post;
		$flush_cache = false;

		if ( ! empty( $post ) ) {
			$post_type = get_post_type( $post->ID );

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

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

		if ( is_multisite() && ! is_network_admin() ) {

			// Show settings inherit option.
			$inherit_settings      = get_option( 'breeze_inherit_settings', '0' );
			$is_inherited_settings = isset( $inherit_settings ) ? filter_var( $inherit_settings, FILTER_VALIDATE_BOOLEAN ) : false;

			$url            = get_home_url();
			$list_of_urls   = array();
			$list_of_urls[] = trailingslashit( $url );

			if ( true === $is_inherited_settings ) {

				switch_to_blog( get_network()->site_id );
				// delete minify
				Breeze_MinificationCache::clear_minification();
				// clear normal cache
				Breeze_PurgeCache::breeze_cache_flush( $flush_cache, true, true );
				// clear varnish cache
				$this->breeze_clear_varnish();
				Breeze_PurgeCache::__flush_object_cache();
				$url            = get_home_url();
				$list_of_urls[] = trailingslashit( $url );
				restore_current_blog();
			}

			// for current blog.
			$current_blog_id = get_current_blog_id();
			Breeze_MinificationCache::clear_minification( $current_blog_id );
			Breeze_PurgeCache::breeze_cache_flush( $flush_cache, true, true );
			$main     = new Breeze_PurgeVarnish();
			$homepage = home_url() . '/?breeze';
			$main->purge_cache( $homepage );

			Breeze_CloudFlare_Helper::reset_all_cache( $list_of_urls );
			Breeze_PurgeCache::__flush_object_cache();

		} else {
			$current_blog_id = null;
			// delete minify
			if ( is_multisite() ) {
				$current_blog_id = get_current_blog_id();
			}
			Breeze_MinificationCache::clear_minification( $current_blog_id );
			// clear normal cache
			Breeze_PurgeCache::breeze_cache_flush( $flush_cache, true, true );
			// clear varnish cache
			$this->breeze_clear_varnish();
			$url            = get_home_url();
			$list_of_urls   = array();
			$list_of_urls[] = trailingslashit( $url );
			Breeze_CloudFlare_Helper::reset_all_cache( $list_of_urls );
			Breeze_PurgeCache::__flush_object_cache();
		}
	}

	/**
	 * Clear all varnish cache action.
	 */
	public function breeze_clear_varnish() {
		$main = new Breeze_PurgeVarnish();

		$is_network = ( is_network_admin() || ( ! empty( $_POST['is_network'] ) && 'true' === $_POST['is_network'] ) );
		$response   = null;

		if ( is_multisite() && $is_network ) {
			$sites = get_sites();
			foreach ( $sites as $site ) {
				switch_to_blog( $site->blog_id );
				$homepage = home_url() . '/?breeze';
				$response = $main->purge_cache( $homepage );
				restore_current_blog();
			}
		} else {
			$homepage = home_url() . '/?breeze';
			$response = $main->purge_cache( $homepage );
		}

		if ( is_wp_error( $response ) || 200 !== $response['response']['code'] ) {
			return false;
		} else {
			return true;
		}
	}
}

add_action(
	'init',
	function () {
		$admin = new Breeze_Admin();
	},
	0
);

Youez - 2016 - github.com/yon3zu
LinuXploit