array( 'label' => _x( 'Georgia', 'font style', 'amble' ), 'stack' => 'georgia-serif', ), 'palatino-serif' => array( 'label' => _x( 'Palatino Linotype, Book Antiqua, Palatino', 'font style', 'amble' ), 'stack' => 'palatino-serif', ), 'times-serif' => array( 'label' => _x( 'Times New Roman, Times', 'font style', 'amble' ), 'stack' => 'times-serif', ), 'arial-helvetica' => array( 'label' => _x( 'Arial, Helvetica', 'font style', 'amble' ), 'stack' => 'arial-helvetica', ), 'arial-gadget' => array( 'label' => _x( 'Arial Black, Gadget', 'font style', 'amble' ), 'stack' => 'arial-gadget', ), 'comic-cursive' => array( 'label' => _x( 'Comic Sans MS, cursive', 'font style', 'amble' ), 'stack' => 'comic-cursive', ), 'impact-charcoal' => array( 'label' => _x( 'Impact, Charcoal', 'font style', 'amble' ), 'stack' => 'impact-charcoal', ), 'lucida' => array( 'label' => _x( 'Lucida Sans Unicode, Lucida Grande', 'font style', 'amble' ), 'stack' => 'lucida', ), 'tahoma-geneva' => array( 'label' => _x( 'Tahoma, Geneva', 'font style', 'amble' ), 'stack' => 'tahoma-geneva', ), 'trebuchet-helvetica' => array( 'label' => _x( 'Trebuchet MS, Helvetica', 'font style', 'amble' ), 'stack' => 'trebuchet-helvetica', ), 'verdana-geneva' => array( 'label' => _x( 'Verdana, Geneva', 'font style', 'amble' ), 'stack' => 'verdana-geneva', ), 'courier' => array( 'label' => _x( 'Courier New, Courier', 'font style', 'amble' ), 'stack' => 'courier', ), 'lucida-monaco' => array( 'label' => _x( 'Lucida Console, Monaco', 'font style', 'amble' ), 'stack' => 'lucida-monaco', ) ) ); } /** * Return an array of all available Google Fonts. * * @return array All Google Fonts. */ public static function get_google_fonts() { if ( null === self::$google_fonts || empty( self::$google_fonts ) ) { $fonts = array( 'body' => '' ); // If the Google Fonts API key is set, then pull data direct from Google. if ( defined( 'GOOGLE_FONTS_API_KEY' ) && GOOGLE_FONTS_API_KEY ) { // Cache the data from Google.(NEED TO CHK) if ( false === ( $fonts = get_transient( self::$transient_key ) ) || false === self::$cache ) { $google_api = 'https://www.googleapis.com/webfonts/v1/webfonts?sort=alpha&key=' . GOOGLE_FONTS_API_KEY; $fonts = wp_remote_get( $google_api, array( 'sslverify' => false ) ); set_transient( self::$transient_key, $fonts, self::$cache_time ); } } else { $fonts = include wp_normalize_path( get_template_directory() . '/inc/customizer/custom-controls/typography/webfonts.php' ); } $google_fonts = array(); if ( is_array( $fonts ) ) { foreach ( $fonts['items'] as $font ) { $google_fonts[ $font['family'] ] = array( 'label' => $font['family'], 'variants' => $font['variants'], 'category' => $font['category'], ); } } self::$google_fonts = apply_filters( 'amble-fonts/fonts/google_fonts', $google_fonts ); } return self::$google_fonts; } /** * Google Font Variants * * @return array */ public static function get_all_variants() { return apply_filters( 'amble-fonts/fonts/font_variants', array( '100' => esc_attr__( 'Ultra-Light 100', 'amble' ), '100italic' => esc_attr__( 'Ultra-Light 100 Italic', 'amble' ), '200' => esc_attr__( 'Light 200', 'amble' ), '200italic' => esc_attr__( 'Light 200 Italic', 'amble' ), '300' => esc_attr__( 'Book 300', 'amble' ), '300italic' => esc_attr__( 'Book 300 Italic', 'amble' ), 'regular' => esc_attr__( 'Normal 400', 'amble' ), 'italic' => esc_attr__( 'Normal 400 Italic', 'amble' ), '500' => esc_attr__( 'Medium 500', 'amble' ), '500italic' => esc_attr__( 'Medium 500 Italic', 'amble' ), '600' => esc_attr__( 'Semi-Bold 600', 'amble' ), '600italic' => esc_attr__( 'Semi-Bold 600 Italic', 'amble' ), '700' => esc_attr__( 'Bold 700', 'amble' ), '700italic' => esc_attr__( 'Bold 700 Italic', 'amble' ), '800' => esc_attr__( 'Extra-Bold 800', 'amble' ), '800italic' => esc_attr__( 'Extra-Bold 800 Italic', 'amble' ), '900' => esc_attr__( 'Ultra-Bold 900', 'amble' ), '900italic' => esc_attr__( 'Ultra-Bold 900 Italic', 'amble' ), ) ); } /** * Is Google Font * * @param string $fontname */ public static function is_google_font( $fontname ) { return ( array_key_exists( $fontname, self::$google_fonts ) ); } /** * Returns an array of all font choices * * @return array */ public static function get_font_choices() { $fonts = self::get_all_fonts(); $fonts_array = array(); foreach ( $fonts as $key => $args ) { $fonts_array[ $key ] = $key; } return $fonts_array; } /** * Sanitize Typography Control * * @param array $value * * @access public * @return array */ public static function sanitize_typography( $value ) { if ( ! is_array( $value ) ) { return array(); } $sanitized_value = array(); // Sanitize font family. if ( isset( $value['font-family'] ) ) { $sanitized_value['font-family'] = esc_attr( $value['font-family'] ); } // Use a valid variant. if ( isset( $value['variant'] ) ) { $valid_variants = array( 'regular', 'italic', '100', '200', '300', '500', '600', '700', '700italic', '900', '900italic', '100italic', '300italic', '500italic', '800', '800italic', '600italic', '200italic', ); $sanitized_value['variant'] = ( in_array( $value['variant'], $valid_variants ) ) ? sanitize_text_field( $value['variant'] ) : 'regular'; } return $sanitized_value; } }