PluginProbe
Gutenify – Visual Site Builder Blocks & Starter Templates / 0.0.1
Gutenify – Visual Site Builder Blocks & Starter Templates v0.0.1
1.9.0 1.8.0 1.7.0 1.6.6 1.6.5 1.6.4 trunk 0.0.1 0.0.2 0.0.3 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 All 74 releases
gutenify / inc / class-helpers.php

class-helpers.php in Gutenify – Visual Site Builder Blocks & Starter Templates 0.0.1, at inc/class-helpers.php

65 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Gutenify Helper file.
4 *
5 * @package Gutenify
6 */
7
8 // Exit if accessed directly.
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12 class Gutenify_Helpers{
13 public static function is_gutenberg_page() {
14 if ( function_exists( 'is_gutenberg_page' ) &&
15 is_gutenberg_page()
16 ) {
17 // The Gutenberg plugin is on.
18 return true;
19 }
20 $current_screen = get_current_screen();
21 if ( method_exists( $current_screen, 'is_block_editor' ) &&
22 $current_screen->is_block_editor()
23 ) {
24 // Gutenberg page on 5+.
25 return true;
26 }
27 return false;
28 }
29 public static function get_google_fonts(){
30 if ( false === ( $gutenify_google_fonts = get_transient( 'gutenify_google_fonts' ) ) ) {
31 $response = wp_remote_get( 'https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyBwIX97bVWr3-6AIUvGkcNnmFgirefZ6Sw',
32 array(
33 'timeout' => 120,
34 'httpversion' => '1.1',
35 )
36 );
37 $gutenify_google_fonts = self::load_request( $response);
38 set_transient( 'gutenify_google_fonts', $gutenify_google_fonts, 12 * HOUR_IN_SECONDS );
39 }
40
41 return $gutenify_google_fonts;
42 }
43
44 public static function load_request($response) {
45 try {
46 $json = json_decode( $response['body'] );
47 } catch ( Exception $ex ) {
48 $json = null;
49 }
50 return $json;
51 }
52
53 public static function typography_style($typography, $screen='desktop'){
54 $style = '';
55 $style .= ! empty( $typography['fontFamily'] ) ? 'font-family:' . $typography['fontFamily'] . ', sans-serif;' : '';
56 $style .= ! empty( $typography['weight'] ) ? 'font-weight:' . $typography['weight'] . ';' : '';
57 $style .= ! empty( $typography['transform'] ) ? 'text-transform:' . $typography['transform'] . ';' : '';
58 $style .= ! empty( $typography['style'] ) ? 'font-style:' . $typography['style'] . ';' : '';
59 $style .= ! empty( $typography['decoration'] ) ? 'text-decoration:' . $typography['decoration'] . ';' : '';
60 $style .= ! empty( $typography['size'][$screen]['value'] ) ? 'font-size:' . $typography['size'][$screen]['value'].$typography['size'][$screen]['unit'] . ';' : '';
61 $style .= ! empty( $typography['lineHeight'][$screen]['value'] ) ? 'line-height:' . $typography['lineHeight'][$screen]['value'].$typography['lineHeight'][$screen]['unit'] . ';' : '';
62 $style .= ! empty( $typography['letterSpacing'][$screen]['value'] ) ? 'letter-spacing:' . $typography['letterSpacing'][$screen]['value'] . 'px;' : '';
63 return $style;
64 }
65 }