HEX
Server: Apache
System: Linux cp4.skywebbox.com 5.14.0-503.15.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Nov 28 07:25:19 EST 2024 x86_64
User: alfouzantranspor (1054)
PHP: 8.3.23
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/alfouzantranspor/www/wp-content/themes/astra/inc/customizer/class-astra-fonts-data.php
<?php
/**
 * Helper class for font settings.
 *
 * @package     Astra
 * @link        https://wpastra.com/
 * @since       Astra 1.0.0
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Font info class for System and Google fonts.
 */
if ( ! class_exists( 'Astra_Fonts_Data' ) ) {

	/**
	 * Fonts Data
	 */
	final class Astra_Fonts_Data {
		/**
		 * Localize Fonts
		 *
		 * @param bool $skip_google_fonts Whether to skip Google Fonts loading for initial load optimization.
		 */
		public static function js( $skip_google_fonts = true ) {

			$system = wp_json_encode( Astra_Font_Families::get_system_fonts() );
			$custom = wp_json_encode( Astra_Font_Families::get_custom_fonts() );

			/** @psalm-suppress UndefinedVariable */
			if ( $skip_google_fonts ) {
				$custom = $custom ? $custom : '{}';
				/** @psalm-suppress RedundantConditionGivenDocblockType */
				if ( ! empty( $custom ) && '{}' !== $custom ) {
					return 'var AstFontFamilies = { system: ' . ( $system ?: '{}' ) . ', custom: ' . $custom . ', google: {}, googleLoaded: false };';
				}
				return 'var AstFontFamilies = { system: ' . ( $system ?: '{}' ) . ', google: {}, googleLoaded: false };';
			}

			$google = wp_json_encode( Astra_Font_Families::get_google_fonts() );
			$custom = $custom ? $custom : '{}';
			$google = $google ? $google : '{}';
			$system = $system ? $system : '{}';

			/** @psalm-suppress RedundantConditionGivenDocblockType */
			if ( ! empty( $custom ) && '{}' !== $custom ) {
				return 'var AstFontFamilies = { system: ' . $system . ', custom: ' . $custom . ', google: ' . $google . ', googleLoaded: true };';
			}

			return 'var AstFontFamilies = { system: ' . $system . ', google: ' . $google . ', googleLoaded: true };';
		}
	}

}