array( 'fallback' => '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif', 'weights' => array( '100', '200', '300', '400', '500', '600', '700', '800', ), ), 'Helvetica' => array( 'fallback' => 'Verdana, Arial, sans-serif', 'weights' => array( '300', '400', '700', ), ), 'Verdana' => array( 'fallback' => 'Helvetica, Arial, sans-serif', 'weights' => array( '300', '400', '700', ), ), 'Arial' => array( 'fallback' => 'Helvetica, Verdana, sans-serif', 'weights' => array( '300', '400', '700', ), ), 'Times' => array( 'fallback' => 'Georgia, serif', 'weights' => array( '300', '400', '700', ), ), 'Georgia' => array( 'fallback' => 'Times, serif', 'weights' => array( '300', '400', '700', ), ), 'Courier' => array( 'fallback' => 'monospace', 'weights' => array( '300', '400', '700', ), ), ); } return apply_filters( 'baltic_system_fonts', self::$system_fonts ); } /** * Custom Fonts * * @since 1.0.19 * * @return Array All the custom fonts in Astra */ public static function get_custom_fonts() { $custom_fonts = array(); return apply_filters( 'baltic_custom_fonts', $custom_fonts ); } /** * Google Fonts used in baltic. * Array is generated from the google-fonts.json file. * * @since 1.0.19 * * @return Array Array of Google Fonts. */ public static function get_google_fonts() { if ( empty( self::$google_fonts ) ) { $google_fonts_file = apply_filters( 'baltic_google_fonts_json_file', BALTIC_DIR . '/assets/google-fonts.json' ); if ( ! file_exists( BALTIC_DIR . '/assets/google-fonts.json' ) ) { return array(); } global $wp_filesystem; if ( empty( $wp_filesystem ) ) { require_once( ABSPATH . '/wp-admin/includes/file.php' ); WP_Filesystem(); } $file_contants = $wp_filesystem->get_contents( $google_fonts_file ); $google_fonts_json = json_decode( $file_contants, 1 ); foreach ( $google_fonts_json as $key => $font ) { $name = key( $font ); foreach ( $font[ $name ] as $font_key => $single_font ) { if ( 'variants' === $font_key ) { foreach ( $single_font as $variant_key => $variant ) { if ( stristr( $variant, 'italic' ) ) { unset( $font[ $name ][ $font_key ][ $variant_key ] ); } if ( 'regular' == $variant ) { $font[ $name ][ $font_key ][ $variant_key ] = '400'; } } } self::$google_fonts[ $name ] = array_values( $font[ $name ] ); } } } return apply_filters( 'baltic_google_fonts', self::$google_fonts ); } public static function is_google_fonts( $fontname ) { return ( array_key_exists( $fontname, self::$get_google_fonts ) ); } public static function get_font_fallback( $font ) { $system_fonts = self::get_system_fonts(); $google_fonts = self::get_google_fonts(); $output = ''; if ( isset( $system_fonts[$font]['fallback'] ) ) { $output = $system_fonts[$font]['fallback']; } elseif( isset( $google_fonts[$font][1] ) ) { $output = $google_fonts[$font][1]; } return $output; } public static function get_font_family( $font ) { $system_fonts = self::get_system_fonts(); $google_fonts = self::get_google_fonts(); $output = ''; if ( isset( $system_fonts[$font] ) && isset( $system_fonts[$font]['fallback'] ) ) { if ( 'System' === $font ) { $output = $system_fonts[$font]['fallback']; } else { $output = $font .','. $system_fonts[$font]['fallback']; } } elseif( isset( $google_fonts[$font] ) && isset( $google_fonts[$font][1] ) ) { $output = sprintf( '\'%1$s\', %2$s', $font, $google_fonts[$font][1] ); } elseif( 'inherit' === $font ) { $output = 'inherit'; } return $output; } public static function get_text_transform( $transform ) { if ( empty( $transform ) ) { return; } else { return 'text-transform:' . esc_attr( $transform ) . ';'; } } }