is_block_editor() ) { // Gutenberg page on 5+. return true; } return false; } public static function get_google_fonts(){ if ( false === ( $gutenify_google_fonts = get_transient( 'gutenify_google_fonts' ) ) ) { $response = wp_remote_get( 'https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyBwIX97bVWr3-6AIUvGkcNnmFgirefZ6Sw', array( 'timeout' => 120, 'httpversion' => '1.1', ) ); $gutenify_google_fonts = self::load_request( $response); set_transient( 'gutenify_google_fonts', $gutenify_google_fonts, 12 * HOUR_IN_SECONDS ); } return $gutenify_google_fonts; } public static function load_request($response) { try { $json = json_decode( $response['body'] ); } catch ( Exception $ex ) { $json = null; } return $json; } public static function typography_style($typography, $screen='desktop'){ $style = ''; $style .= ! empty( $typography['fontFamily'] ) ? 'font-family:' . $typography['fontFamily'] . ', sans-serif;' : ''; $style .= ! empty( $typography['weight'] ) ? 'font-weight:' . $typography['weight'] . ';' : ''; $style .= ! empty( $typography['transform'] ) ? 'text-transform:' . $typography['transform'] . ';' : ''; $style .= ! empty( $typography['style'] ) ? 'font-style:' . $typography['style'] . ';' : ''; $style .= ! empty( $typography['decoration'] ) ? 'text-decoration:' . $typography['decoration'] . ';' : ''; $style .= ! empty( $typography['size'][$screen]['value'] ) ? 'font-size:' . $typography['size'][$screen]['value'].$typography['size'][$screen]['unit'] . ';' : ''; $style .= ! empty( $typography['lineHeight'][$screen]['value'] ) ? 'line-height:' . $typography['lineHeight'][$screen]['value'].$typography['lineHeight'][$screen]['unit'] . ';' : ''; $style .= ! empty( $typography['letterSpacing'][$screen]['value'] ) ? 'letter-spacing:' . $typography['letterSpacing'][$screen]['value'] . 'px;' : ''; return $style; } }