PluginProbe
Gutenify – Visual Site Builder Blocks & Starter Templates / 1.0.8
Gutenify – Visual Site Builder Blocks & Starter Templates v1.0.8
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 / styles.php

styles.php in Gutenify – Visual Site Builder Blocks & Starter Templates 1.0.8, at inc/styles.php

79 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 function gutenify_global_styles_vars() {
3 $transient_name = 'gutenify_global_styles_vars';
4 $cached = get_transient( $transient_name );
5 if ( $cached ) {
6 wp_add_inline_style( 'global-styles', $cached );
7 return false;
8 }
9
10 $core_button_styles = wp_get_global_styles(
11 array(),
12 array( 'block_name' => 'core/button' )
13 );
14 $css_styles = '';
15 $element_css_styles = '';
16 if ( ! empty( $core_button_styles['spacing']['padding'] ) ) {
17 if ( ! empty( $core_button_styles['spacing']['padding']['left'] ) ) {
18 $element_css_styles .= '--wp--custom--core-button--spacing--padding--left: ' . $core_button_styles['spacing']['padding']['left'] . ';';
19 }
20 if ( ! empty( $core_button_styles['spacing']['padding']['right'] ) ) {
21 $element_css_styles .= '--wp--custom--core-button--spacing--padding--right: ' . $core_button_styles['spacing']['padding']['right'] . ';';
22 }
23 if ( ! empty( $core_button_styles['spacing']['padding']['top'] ) ) {
24 $element_css_styles .= '--wp--custom--core-button--spacing--padding--top: ' . $core_button_styles['spacing']['padding']['top'] . ';';
25 }
26 if ( ! empty( $core_button_styles['spacing']['padding']['bottom'] ) ) {
27 $element_css_styles .= '--wp--custom--core-button--spacing--padding--bottom: ' . $core_button_styles['spacing']['padding']['bottom'] . ';';
28 }
29 }
30
31 if ( ! empty( $core_button_styles['color']['background'] ) ) {
32 $element_css_styles .= '--wp--custom--core-button--color--background: ' . $core_button_styles['color']['background'] . ';';
33 }
34
35 if ( ! empty( $core_button_styles['color']['text'] ) ) {
36 $element_css_styles .= '--wp--custom--core-button--color: ' . $core_button_styles['color']['text'] . ';';
37 }
38
39 if ( isset( $core_button_styles['border']['width'] ) ) {
40 $element_css_styles .= '--wp--custom--core-button--border--width: ' . $core_button_styles['border']['width'] . ';';
41 }
42
43 if ( isset( $core_button_styles['border']['radius'] ) ) {
44 $top_left = is_array( $core_button_styles['border']['radius'] ) ? $core_button_styles['border']['radius']['topLeft'] : $core_button_styles['border']['radius'];
45 $top_right = is_array( $core_button_styles['border']['radius'] ) ? $core_button_styles['border']['radius']['topRight'] : $core_button_styles['border']['radius'];
46 $bottom_left = is_array( $core_button_styles['border']['radius'] ) ? $core_button_styles['border']['radius']['bottomLeft'] : $core_button_styles['border']['radius'];
47 $bottom_right = is_array( $core_button_styles['border']['radius'] ) ? $core_button_styles['border']['radius']['bottomRight'] : $core_button_styles['border']['radius'];
48 if ( '' !== $top_left ) {
49 $element_css_styles .= '--wp--custom--core-button--border-radius--top-left: ' . $top_left . ';';
50 }
51 if ( '' !== ( $top_right ) ) {
52 $element_css_styles .= '--wp--custom--core-button--border-radius--top-right: ' . $top_right . ';';
53 }
54 if ( '' !== ( $bottom_left ) ) {
55 $element_css_styles .= '--wp--custom--core-button--border-radius--bottom-left: ' . $bottom_left . ';';
56 }
57 if ( '' !== ( $bottom_right ) ) {
58 $element_css_styles .= '--wp--custom--core-button--border-radius--bottom-right: ' . $bottom_right . ';';
59 }
60 }
61
62 if ( isset( $core_button_styles['typography']['fontSize'] ) ) {
63 $element_css_styles .= '--wp--custom--core-button--typography--font-size: ' . $core_button_styles['typography']['fontSize'] . ';';
64 }
65
66 if ( isset( $core_button_styles['typography']['fontWeight'] ) ) {
67 $element_css_styles .= '--wp--custom--core-button--typography--font-weight: ' . $core_button_styles['typography']['fontWeight'] . ';';
68 }
69
70 if ( ! empty( $element_css_styles ) ) {
71 $css_styles .= 'body{' . $element_css_styles . '}';
72 }
73
74 set_transient( $transient_name, $css_styles, MINUTE_IN_SECONDS );
75 wp_add_inline_style( 'global-styles', $css_styles );
76
77 }
78 add_action( 'wp_enqueue_scripts', 'gutenify_global_styles_vars', 200 );
79