PluginProbe
Gutenify – Visual Site Builder Blocks & Starter Templates / 1.8.0
Gutenify – Visual Site Builder Blocks & Starter Templates v1.8.0
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 / core / inc / depricated / styles.php

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

111 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Function to add style variables.
4 *
5 * [TODO: Depricate this file.]
6 *
7 * @return void
8 */
9 if ( ! defined( 'ABSPATH' ) ) exit;
10
11 function gutenify_get_color_value( $value ) {
12 if ( strpos( $value, 'var:' ) !== false ) {
13 // var:preset|color|vivid-red
14 $value = str_replace( 'var:', '', $value );
15 $value = str_replace( '|', '--', $value );
16 return 'var( --wp--' . $value . ')';
17 }
18 return $value;
19 }
20 function gutenify_global_styles_vars() {
21 $transient_name = 'gutenify_global_styles_vars';
22 $cached = get_transient( $transient_name );
23 if ( $cached ) {
24 wp_add_inline_style( 'global-styles', $cached );
25 return false;
26 }
27
28 $styles = wp_get_global_styles();
29
30 if ( ! empty( $styles['elements']['button'] ) ) {
31 $core_button_styles = $styles['elements']['button'];
32 } else {
33 $core_button_styles = wp_get_global_styles(
34 array(),
35 array( 'elements' => 'button' )
36 );
37 }
38
39 $css_styles = '';
40 $element_css_styles = '';
41 if ( ! empty( $core_button_styles['spacing']['padding'] ) ) {
42 if ( ! empty( $core_button_styles['spacing']['padding']['left'] ) ) {
43 $element_css_styles .= '--wp--custom--core-button--spacing--padding--left: ' . $core_button_styles['spacing']['padding']['left'] . ';';
44 }
45 if ( ! empty( $core_button_styles['spacing']['padding']['right'] ) ) {
46 $element_css_styles .= '--wp--custom--core-button--spacing--padding--right: ' . $core_button_styles['spacing']['padding']['right'] . ';';
47 }
48 if ( ! empty( $core_button_styles['spacing']['padding']['top'] ) ) {
49 $element_css_styles .= '--wp--custom--core-button--spacing--padding--top: ' . $core_button_styles['spacing']['padding']['top'] . ';';
50 }
51 if ( ! empty( $core_button_styles['spacing']['padding']['bottom'] ) ) {
52 $element_css_styles .= '--wp--custom--core-button--spacing--padding--bottom: ' . $core_button_styles['spacing']['padding']['bottom'] . ';';
53 }
54 }
55
56 if ( ! empty( $core_button_styles['color']['background'] ) ) {
57 $element_css_styles .= '--wp--custom--core-button--color--background: ' . gutenify_get_color_value( $core_button_styles['color']['background'] ) . ';';
58 }
59
60 if ( ! empty( $core_button_styles['color']['text'] ) ) {
61 $element_css_styles .= '--wp--custom--core-button--color: ' . gutenify_get_color_value( $core_button_styles['color']['text'] ) . ';';
62 }
63
64 if ( isset( $core_button_styles['border']['width'] ) ) {
65 $element_css_styles .= '--wp--custom--core-button--border--width: ' . $core_button_styles['border']['width'] . ';';
66 }
67
68 if ( isset( $core_button_styles['border']['radius'] ) ) {
69 $top_left = is_array( $core_button_styles['border']['radius'] ) ? $core_button_styles['border']['radius']['topLeft'] : $core_button_styles['border']['radius'];
70 $top_right = is_array( $core_button_styles['border']['radius'] ) ? $core_button_styles['border']['radius']['topRight'] : $core_button_styles['border']['radius'];
71 $bottom_left = is_array( $core_button_styles['border']['radius'] ) ? $core_button_styles['border']['radius']['bottomLeft'] : $core_button_styles['border']['radius'];
72 $bottom_right = is_array( $core_button_styles['border']['radius'] ) ? $core_button_styles['border']['radius']['bottomRight'] : $core_button_styles['border']['radius'];
73 if ( '' !== $top_left ) {
74 $element_css_styles .= '--wp--custom--core-button--border-radius--top-left: ' . $top_left . ';';
75 }
76 if ( '' !== ( $top_right ) ) {
77 $element_css_styles .= '--wp--custom--core-button--border-radius--top-right: ' . $top_right . ';';
78 }
79 if ( '' !== ( $bottom_left ) ) {
80 $element_css_styles .= '--wp--custom--core-button--border-radius--bottom-left: ' . $bottom_left . ';';
81 }
82 if ( '' !== ( $bottom_right ) ) {
83 $element_css_styles .= '--wp--custom--core-button--border-radius--bottom-right: ' . $bottom_right . ';';
84 }
85 }
86
87 if ( isset( $core_button_styles['typography']['fontSize'] ) ) {
88 $element_css_styles .= '--wp--custom--core-button--typography--font-size: ' . $core_button_styles['typography']['fontSize'] . ';';
89 }
90
91 if ( isset( $core_button_styles['typography']['fontWeight'] ) ) {
92 $element_css_styles .= '--wp--custom--core-button--typography--font-weight: ' . $core_button_styles['typography']['fontWeight'] . ';';
93 }
94
95 if ( ! empty( $core_button_styles[':hover']['color']['background'] ) ) {
96 $element_css_styles .= '--wp--custom--core-button--hover--color--background: ' . gutenify_get_color_value( $core_button_styles[':hover']['color']['background'] ) . ';';
97 }
98
99 if ( ! empty( $core_button_styles[':hover']['color']['text'] ) ) {
100 $element_css_styles .= '--wp--custom--core-button--hover--color: ' . gutenify_get_color_value( $core_button_styles[':hover']['color']['text'] ) . ';';
101 }
102
103 if ( ! empty( $element_css_styles ) ) {
104 $css_styles .= 'body{' . $element_css_styles . '}';
105 }
106
107 set_transient( $transient_name, $css_styles, MINUTE_IN_SECONDS );
108 wp_add_inline_style( 'global-styles', $css_styles );
109 }
110 add_action( 'wp_enqueue_scripts', 'gutenify_global_styles_vars', 200 );
111