ru-se.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

class-kirki-output-property-font-family.php (1758B)


      1 <?php
      2 /**
      3  * Handles CSS output for font-family.
      4  *
      5  * @package     Kirki
      6  * @subpackage  Controls
      7  * @copyright   Copyright (c) 2016, Aristeides Stathopoulos
      8  * @license     http://opensource.org/licenses/https://opensource.org/licenses/MIT
      9  * @since       2.2.0
     10  */
     11 
     12 if ( ! class_exists( 'Kirki_Output_Property_Font_Family' ) ) {
     13 
     14 	/**
     15 	 * Output overrides.
     16 	 */
     17 	class Kirki_Output_Property_Font_Family extends Kirki_Output_Property {
     18 
     19 		/**
     20 		 * Modifies the value.
     21 		 *
     22 		 * @access protected
     23 		 */
     24 		protected function process_value() {
     25 
     26 			$google_fonts_array = Kirki_Fonts::get_google_fonts();
     27 			$backup_fonts       = Kirki_Fonts::get_backup_fonts();
     28 
     29 			// Make sure the value is a string.
     30 			// If not, then early exit.
     31 			if ( ! is_string( $this->value ) ) {
     32 				return;
     33 			}
     34 
     35 			// Hack for standard fonts.
     36 			$this->value = str_replace( '&quot;', '"', $this->value );
     37 
     38 			// Add backup font.
     39 			if ( Kirki_Fonts::is_google_font( $this->value ) ) {
     40 
     41 				if ( isset( $google_fonts_array[ $this->value ] ) && isset( $google_fonts_array[ $this->value ]['category'] ) ) {
     42 					if ( isset( $backup_fonts[ $google_fonts_array[ $this->value ]['category'] ] ) ) {
     43 
     44 						// Add double quotes if needed.
     45 						if ( false !== strpos( $this->value, ' ' ) && false === strpos( $this->value, '"' ) ) {
     46 							$this->value = '"' . $this->value . '", ' . $backup_fonts[ $google_fonts_array[ $this->value ]['category'] ];
     47 						} else {
     48 							$this->value .= ', ' . $backup_fonts[ $google_fonts_array[ $this->value ]['category'] ];
     49 						}
     50 					}
     51 				}
     52 			} else {
     53 
     54 				// Add double quotes if needed.
     55 				if ( false !== strpos( $this->value, ' ' ) && false === strpos( $this->value, '"' ) ) {
     56 					$this->value = '"' . $this->value . '"';
     57 				}
     58 			}
     59 		}
     60 	}
     61 }