-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathdefaults.php
199 lines (186 loc) · 5.66 KB
/
defaults.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
/**
* Set our block attribute defaults.
*
* @package GenerateBlocks
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Set our block defaults.
*
* @since 0.1
*
* @return array
*/
function generateblocks_get_block_defaults() {
$use_cache = apply_filters( 'generateblocks_use_block_defaults_cache', false );
if ( $use_cache ) {
$cached_data = wp_cache_get(
'generateblocks_defaults_cache',
'generateblocks_cache_group'
);
if ( $cached_data ) {
return $cached_data;
}
}
$defaults = apply_filters(
'generateblocks_defaults',
[
'container' => generateblocks_with_global_defaults( GenerateBlocks_Block_Container::defaults() ),
'buttonContainer' => generateblocks_with_global_defaults( GenerateBlocks_Block_Button_Container::defaults() ),
'button' => generateblocks_with_global_defaults( GenerateBlocks_Block_Button::defaults() ),
'gridContainer' => generateblocks_with_global_defaults( GenerateBlocks_Block_Grid::defaults() ),
'headline' => generateblocks_with_global_defaults( GenerateBlocks_Block_Headline::defaults() ),
'image' => generateblocks_with_global_defaults( GenerateBlocks_Block_Image::defaults() ),
]
);
if ( $use_cache ) {
wp_cache_set(
'generateblocks_defaults_cache',
$defaults,
'generateblocks_cache_group'
);
}
return $defaults;
}
/**
* Get defaults for our general options.
*
* @since 0.1
*/
function generateblocks_get_option_defaults() {
return apply_filters(
'generateblocks_option_defaults',
array(
'container_width' => 1100,
'css_print_method' => 'file',
'sync_responsive_previews' => true,
'disable_google_fonts' => true,
)
);
}
/**
* Styles to use in the editor/font-end when needed.
*
* @since 1.0
*/
function generateblocks_get_default_styles() {
$defaults = generateblocks_get_block_defaults();
$defaultBlockStyles = array(
'button' => array(
'backgroundColor' => $defaults['button']['backgroundColor'] ? $defaults['button']['backgroundColor'] : '#0366d6',
'textColor' => $defaults['button']['textColor'] ? $defaults['button']['textColor'] : '#ffffff',
'backgroundColorHover' => $defaults['button']['backgroundColorHover'] ? $defaults['button']['backgroundColorHover'] : '#222222',
'textColorHover' => $defaults['button']['textColorHover'] ? $defaults['button']['textColorHover'] : '#ffffff',
'spacing' => [
'paddingTop' => $defaults['button']['paddingTop'] ? $defaults['button']['paddingTop'] : '15px',
'paddingRight' => $defaults['button']['paddingRight'] ? $defaults['button']['paddingRight'] : '20px',
'paddingBottom' => $defaults['button']['paddingBottom'] ? $defaults['button']['paddingBottom'] : '15px',
'paddingLeft' => $defaults['button']['paddingLeft'] ? $defaults['button']['paddingLeft'] : '20px',
],
'display' => 'inline-flex',
),
'container' => array(
'gridItemPaddingTop' => '',
'gridItemPaddingRight' => '',
'gridItemPaddingBottom' => '',
'gridItemPaddingLeft' => '',
'bgImageSize' => 'full',
'shapeDividers' => array(
'shape' => 'gb-waves-1',
'location' => 'bottom',
'height' => 200,
'heightTablet' => '',
'heightMobile' => '',
'width' => 100,
'widthTablet' => '',
'widthMobile' => '',
'flipHorizontally' => false,
'zindex' => '',
'color' => '#000000',
'colorOpacity' => 1,
),
),
);
if ( function_exists( 'generate_get_default_fonts' ) ) {
$font_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_default_fonts()
);
$defaultBlockStyles['headline'] = array(
'p' => array(
'marginBottom' => $font_settings['paragraph_margin'],
'marginBottomTablet' => '',
'marginBottomMobile' => '',
'marginUnit' => 'em',
'fontSize' => $font_settings['body_font_size'],
'fontSizeTablet' => '',
'fontSizeMobile' => '',
'fontSizeUnit' => 'px',
),
'h1' => array(
'marginBottom' => $font_settings['heading_1_margin_bottom'],
'marginBottomTablet' => '',
'marginBottomMobile' => '',
'marginUnit' => 'px',
'fontSize' => $font_settings['heading_1_font_size'],
'fontSizeTablet' => '',
'fontSizeMobile' => $font_settings['mobile_heading_1_font_size'],
'fontSizeUnit' => 'px',
),
'h2' => array(
'marginBottom' => $font_settings['heading_2_margin_bottom'],
'marginBottomTablet' => '',
'marginBottomMobile' => '',
'marginUnit' => 'px',
'fontSize' => $font_settings['heading_2_font_size'],
'fontSizeTablet' => '',
'fontSizeMobile' => $font_settings['mobile_heading_1_font_size'],
'fontSizeUnit' => 'px',
),
'h3' => array(
'marginBottom' => $font_settings['heading_3_margin_bottom'],
'marginBottomTablet' => '',
'marginBottomMobile' => '',
'marginUnit' => 'px',
'fontSize' => $font_settings['heading_3_font_size'],
'fontSizeTablet' => '',
'fontSizeMobile' => '',
'fontSizeUnit' => 'px',
),
'h4' => array(
'marginBottom' => '20',
'marginBottomTablet' => '',
'marginBottomMobile' => '',
'marginUnit' => 'px',
'fontSize' => '',
'fontSizeTablet' => '',
'fontSizeMobile' => '',
'fontSizeUnit' => 'px',
),
'h5' => array(
'marginBottom' => '20',
'marginBottomTablet' => '',
'marginBottomMobile' => '',
'marginUnit' => 'px',
'fontSize' => '',
'fontSizeTablet' => '',
'fontSizeMobile' => '',
'fontSizeUnit' => 'px',
),
'h6' => array(
'marginBottom' => '20',
'marginBottomTablet' => '',
'marginBottomMobile' => '',
'marginUnit' => 'px',
'fontSize' => '',
'fontSizeTablet' => '',
'fontSizeMobile' => '',
'fontSizeUnit' => 'px',
),
);
}
return apply_filters( 'generateblocks_default_block_styles', $defaultBlockStyles );
}