From 69c17f9c1942fd0d6a5ea941636e87723b8a6fe2 Mon Sep 17 00:00:00 2001 From: Zach van Rijn Date: Wed, 21 Jul 2021 16:19:29 -0500 Subject: dos2unix on all .php files, begin paring down admin page and site branding. --- inc/customizer/class-astra-fonts.php | 400 +++++++++++++++++------------------ 1 file changed, 200 insertions(+), 200 deletions(-) (limited to 'inc/customizer/class-astra-fonts.php') diff --git a/inc/customizer/class-astra-fonts.php b/inc/customizer/class-astra-fonts.php index fc2ae34..925f95a 100644 --- a/inc/customizer/class-astra-fonts.php +++ b/inc/customizer/class-astra-fonts.php @@ -1,200 +1,200 @@ - (array) $variants, - ); - } - } - - /** - * Get Fonts - */ - public static function get_fonts() { - - do_action( 'astra_get_fonts' ); - return apply_filters( 'astra_add_fonts', self::$fonts ); - } - - /** - * Renders the tag for all fonts in the $fonts array. - * - * @since 1.0.16 Added the filter 'astra_render_fonts' to support custom fonts. - * @since 1.0.0 - * @return void - */ - public static function render_fonts() { - - $font_list = apply_filters( 'astra_render_fonts', self::get_fonts() ); - - $google_fonts = array(); - $font_subset = array(); - - $system_fonts = Astra_Font_Families::get_system_fonts(); - - foreach ( $font_list as $name => $font ) { - if ( ! empty( $name ) && ! isset( $system_fonts[ $name ] ) ) { - - // Add font variants. - $google_fonts[ $name ] = $font['variants']; - - // Add Subset. - $subset = apply_filters( 'astra_font_subset', '', $name ); - if ( ! empty( $subset ) ) { - $font_subset[] = $subset; - } - } - } - - $google_font_url = self::google_fonts_url( $google_fonts, $font_subset ); - - // Do not load Google font remote or local font asset if not any font selected. - if ( '' === $google_font_url ) { - return; - } - - /** - * Support self hosted Google Fonts. - * - * @since 3.6.0 - */ - if ( astra_get_option( 'load-google-fonts-locally' ) && ! is_customize_preview() && ! is_admin() ) { - if ( astra_get_option( 'preload-local-fonts' ) ) { - ast_load_preload_local_fonts( $google_font_url ); - } - wp_enqueue_style( 'astra-google-fonts', ast_get_webfont_url( $google_font_url ), array(), ASTRA_THEME_VERSION, 'all' ); - } else { - wp_enqueue_style( 'astra-google-fonts', $google_font_url, array(), ASTRA_THEME_VERSION, 'all' ); - } - } - - /** - * Google Font URL - * Combine multiple google font in one URL - * - * @link https://shellcreeper.com/?p=1476 - * @param array $fonts Google Fonts array. - * @param array $subsets Font's Subsets array. - * - * @return string - */ - public static function google_fonts_url( $fonts, $subsets = array() ) { - - /* URL */ - $base_url = 'https://fonts.googleapis.com/css'; - $font_args = array(); - $family = array(); - - // This is deprecated filter hook. - $fonts = apply_filters( 'astra_google_fonts', $fonts ); - - $fonts = apply_filters( 'astra_google_fonts_selected', $fonts ); - - /* Format Each Font Family in Array */ - foreach ( $fonts as $font_name => $font_weight ) { - $font_name = str_replace( ' ', '+', $font_name ); - if ( ! empty( $font_weight ) ) { - if ( is_array( $font_weight ) ) { - $font_weight = implode( ',', $font_weight ); - } - $font_family = explode( ',', $font_name ); - $font_family = str_replace( "'", '', astra_get_prop( $font_family, 0 ) ); - $family[] = trim( $font_family . ':' . rawurlencode( trim( $font_weight ) ) ); - } else { - $family[] = trim( $font_name ); - } - } - - /* Only return URL if font family defined. */ - if ( ! empty( $family ) ) { - - /* Make Font Family a String */ - $family = implode( '|', $family ); - - /* Add font family in args */ - $font_args['family'] = $family; - - /* Add font subsets in args */ - if ( ! empty( $subsets ) ) { - - /* format subsets to string */ - if ( is_array( $subsets ) ) { - $subsets = implode( ',', $subsets ); - } - - $font_args['subset'] = rawurlencode( trim( $subsets ) ); - } - - $font_args['display'] = astra_get_fonts_display_property(); - - return add_query_arg( $font_args, $base_url ); - } - - return ''; - } -} + (array) $variants, + ); + } + } + + /** + * Get Fonts + */ + public static function get_fonts() { + + do_action( 'astra_get_fonts' ); + return apply_filters( 'astra_add_fonts', self::$fonts ); + } + + /** + * Renders the tag for all fonts in the $fonts array. + * + * @since 1.0.16 Added the filter 'astra_render_fonts' to support custom fonts. + * @since 1.0.0 + * @return void + */ + public static function render_fonts() { + + $font_list = apply_filters( 'astra_render_fonts', self::get_fonts() ); + + $google_fonts = array(); + $font_subset = array(); + + $system_fonts = Astra_Font_Families::get_system_fonts(); + + foreach ( $font_list as $name => $font ) { + if ( ! empty( $name ) && ! isset( $system_fonts[ $name ] ) ) { + + // Add font variants. + $google_fonts[ $name ] = $font['variants']; + + // Add Subset. + $subset = apply_filters( 'astra_font_subset', '', $name ); + if ( ! empty( $subset ) ) { + $font_subset[] = $subset; + } + } + } + + $google_font_url = self::google_fonts_url( $google_fonts, $font_subset ); + + // Do not load Google font remote or local font asset if not any font selected. + if ( '' === $google_font_url ) { + return; + } + + /** + * Support self hosted Google Fonts. + * + * @since 3.6.0 + */ + if ( astra_get_option( 'load-google-fonts-locally' ) && ! is_customize_preview() && ! is_admin() ) { + if ( astra_get_option( 'preload-local-fonts' ) ) { + ast_load_preload_local_fonts( $google_font_url ); + } + wp_enqueue_style( 'astra-google-fonts', ast_get_webfont_url( $google_font_url ), array(), ASTRA_THEME_VERSION, 'all' ); + } else { + wp_enqueue_style( 'astra-google-fonts', $google_font_url, array(), ASTRA_THEME_VERSION, 'all' ); + } + } + + /** + * Google Font URL + * Combine multiple google font in one URL + * + * @link https://shellcreeper.com/?p=1476 + * @param array $fonts Google Fonts array. + * @param array $subsets Font's Subsets array. + * + * @return string + */ + public static function google_fonts_url( $fonts, $subsets = array() ) { + + /* URL */ + $base_url = 'https://fonts.googleapis.com/css'; + $font_args = array(); + $family = array(); + + // This is deprecated filter hook. + $fonts = apply_filters( 'astra_google_fonts', $fonts ); + + $fonts = apply_filters( 'astra_google_fonts_selected', $fonts ); + + /* Format Each Font Family in Array */ + foreach ( $fonts as $font_name => $font_weight ) { + $font_name = str_replace( ' ', '+', $font_name ); + if ( ! empty( $font_weight ) ) { + if ( is_array( $font_weight ) ) { + $font_weight = implode( ',', $font_weight ); + } + $font_family = explode( ',', $font_name ); + $font_family = str_replace( "'", '', astra_get_prop( $font_family, 0 ) ); + $family[] = trim( $font_family . ':' . rawurlencode( trim( $font_weight ) ) ); + } else { + $family[] = trim( $font_name ); + } + } + + /* Only return URL if font family defined. */ + if ( ! empty( $family ) ) { + + /* Make Font Family a String */ + $family = implode( '|', $family ); + + /* Add font family in args */ + $font_args['family'] = $family; + + /* Add font subsets in args */ + if ( ! empty( $subsets ) ) { + + /* format subsets to string */ + if ( is_array( $subsets ) ) { + $subsets = implode( ',', $subsets ); + } + + $font_args['subset'] = rawurlencode( trim( $subsets ) ); + } + + $font_args['display'] = astra_get_fonts_display_property(); + + return add_query_arg( $font_args, $base_url ); + } + + return ''; + } +} -- cgit v1.2.3-60-g2f50