array(
'https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.woff',
),
'font-awesome-5' => array(),
);
foreach ( array_unique( FLBuilderFonts::$preload_fa5 ) as $type ) {
switch ( $type ) {
case 'fas':
$icons['font-awesome-5'][] = FL_BUILDER_URL . 'fonts/fontawesome/' . $fa_version . '/webfonts/fa-solid-900.woff2';
break;
case 'far':
$icons['font-awesome-5'][] = FL_BUILDER_URL . 'fonts/fontawesome/' . $fa_version . '/webfonts/fa-regular-400.woff2';
break;
case 'fab':
$icons['font-awesome-5'][] = FL_BUILDER_URL . 'fonts/fontawesome/' . $fa_version . '/webfonts/fa-brands-400.woff2';
break;
}
}
// if using pro cdn do not preload as we have no idea what the url will be.
if ( get_option( '_fl_builder_enable_fa_pro', false ) || apply_filters( 'fl_enable_fa5_pro', false ) || empty( $icons['font-awesome-5'] ) ) {
unset( $icons['font-awesome-5'] );
}
foreach ( $icons as $key => $preloads ) {
if ( wp_style_is( $key, 'enqueued' ) ) {
foreach ( $preloads as $url ) {
printf( '' . "\n", $url );
}
}
}
}
/**
* Renders the JavasCript variable for font settings dropdowns.
*
* @since 1.6.3
* @return void
*/
static public function js() {
/**
* @see fl_builder_font_families_default
*/
$default = json_encode( apply_filters( 'fl_builder_font_families_default', FLBuilderFontFamilies::$default ) );
/**
* @see fl_builder_font_families_system
*/
$system = json_encode( apply_filters( 'fl_builder_font_families_system', FLBuilderFontFamilies::$system ) );
/**
* @see fl_builder_font_families_google
*/
$google = json_encode( apply_filters( 'fl_builder_font_families_google', self::prepare_google_fonts( FLBuilderFontFamilies::google() ) ) );
echo 'var FLBuilderFontFamilies = { default: ' . $default . ', system: ' . $system . ', google: ' . $google . ' };';
}
static public function prepare_google_fonts( $fonts ) {
foreach ( $fonts as $family => $variants ) {
foreach ( $variants as $k => $variant ) {
if ( 'italic' == $variant || 'i' == substr( $variant, -1 ) ) {
unset( $fonts[ $family ][ $k ] );
}
}
}
return $fonts;
}
/**
* Renders a list of all available fonts.
*
* @since 1.6.3
* @param string $font The current selected font.
* @return void
*/
static public function display_select_font( $font ) {
$system_fonts = apply_filters( 'fl_builder_font_families_system', FLBuilderFontFamilies::$system );
$google_fonts = apply_filters( 'fl_builder_font_families_google', FLBuilderFontFamilies::google() );
$recent_fonts = get_option( 'fl_builder_recent_fonts', array() );
// Check if font is valid
foreach ( $recent_fonts as $name => $variants ) {
if ( ! array_key_exists( $name, $google_fonts ) && ! array_key_exists( $name, $system_fonts ) ) {
unset( $recent_fonts[ $name ] );
}
}
echo '';
if ( is_array( $recent_fonts ) && ! empty( $recent_fonts ) ) {
echo '