Diff: STRATO-apps/wordpress_03/app/wp-content/themes/blocksy/inc/components/hero-section.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
3
+
if (! function_exists('blocksy_is_page_title_default')) {
4
+
function blocksy_is_page_title_default() {
5
+
if (blocksy_is_page() || is_single()) {
6
+
$post_options = blocksy_get_post_options();
7
+
8
+
$mode = blocksy_akg('has_hero_section', $post_options, 'default');
9
+
10
+
if ($mode !== 'default') {
11
+
return false;
12
+
}
13
+
}
14
+
15
+
return true;
16
+
}
17
+
}
18
+
19
+
if (! function_exists('blocksy_get_page_title_source')) {
20
+
function blocksy_get_page_title_source() {
21
+
static $result = null;
22
+
23
+
if (! is_null($result)) {
24
+
if (! is_customize_preview()) {
25
+
return $result;
26
+
}
27
+
}
28
+
29
+
$maybe_custom_source = apply_filters(
30
+
'blocksy:hero:custom-source',
31
+
null
32
+
);
33
+
34
+
if ($maybe_custom_source !== null) {
35
+
$result = $maybe_custom_source;
36
+
return $result;
37
+
}
38
+
39
+
$prefix = blocksy_manager()->screen->get_prefix();
40
+
41
+
if ($prefix === 'ct_content_block_single') {
42
+
$result = false;
43
+
return $result;
44
+
}
45
+
46
+
if ($prefix === 'ct_product_tab_single') {
47
+
$result = false;
48
+
return $result;
49
+
}
50
+
51
+
if ($prefix === 'ct_size_guide_single') {
52
+
$result = false;
53
+
return $result;
54
+
}
55
+
56
+
if ($prefix === 'ct_thank_you_page_single') {
57
+
$result = false;
58
+
return $result;
59
+
}
60
+
61
+
if ($prefix === 'jet-woo-builder_single') {
62
+
$result = false;
63
+
return $result;
64
+
}
65
+
66
+
if ($prefix && strpos($prefix, 'single') !== false || (
67
+
function_exists('is_shop') && is_shop()
68
+
) && ! is_search()) {
69
+
$post_options = blocksy_get_post_options();
70
+
71
+
$mode = blocksy_akg('has_hero_section', $post_options, 'default');
72
+
73
+
if ($mode === 'disabled') {
74
+
$result = false;
75
+
return $result;
76
+
}
77
+
78
+
if ($mode === 'enabled') {
79
+
$result = [
80
+
'strategy' => $post_options
81
+
];
82
+
return $result;
83
+
}
84
+
}
85
+
86
+
$default_value = 'yes';
87
+
88
+
if (
89
+
$prefix === 'blog'
90
+
||
91
+
$prefix === 'tribe_events_single'
92
+
) {
93
+
$default_value = 'no';
94
+
}
95
+
96
+
if (blocksy_get_theme_mod($prefix . '_hero_enabled', $default_value) === 'no') {
97
+
$result = false;
98
+
return $result;
99
+
}
100
+
101
+
$result = [
102
+
'strategy' => 'customizer',
103
+
'prefix' => $prefix
104
+
];
105
+
106
+
return $result;
107
+
}
108
+
}
109
+
110
+
if (! function_exists('blocksy_first_level_deep_link')) {
111
+
function blocksy_first_level_deep_link($prefix) {
112
+
if ($prefix === 'blog') {
113
+
return 'blog_posts';
114
+
}
115
+
116
+
if ($prefix === 'author') {
117
+
return 'author_page';
118
+
}
119
+
120
+
if ($prefix === 'search') {
121
+
return 'search_page';
122
+
}
123
+
124
+
if ($prefix === 'woo_categories') {
125
+
return 'woocommerce_posts_archives';
126
+
}
127
+
128
+
if ($prefix === 'categories') {
129
+
return 'archive_blog_posts_categories';
130
+
}
131
+
132
+
if ($prefix === 'single_page') {
133
+
return 'single_pages';
134
+
}
135
+
136
+
if ($prefix === 'single_blog_post') {
137
+
return 'single_blog_posts';
138
+
}
139
+
140
+
if ($prefix === 'product') {
141
+
return 'woocommerce_single';
142
+
}
143
+
144
+
if ($prefix && strpos($prefix, '_archive') !== false) {
145
+
return 'post_type_archive_' . str_replace(
146
+
'_archive', '', $prefix
147
+
);
148
+
}
149
+
150
+
if ($prefix && strpos($prefix, '_single') !== false) {
151
+
return 'post_type_single_' . str_replace(
152
+
'_single', '', $prefix
153
+
);
154
+
}
155
+
156
+
return null;
157
+
}
158
+
}
159
+
160
+
if (! function_exists('blocksy_hero_get_deep_link')) {
161
+
function blocksy_hero_get_deep_link($source) {
162
+
if (! $source) {
163
+
return null;
164
+
}
165
+
166
+
if (! isset($source['prefix'])) {
167
+
return null;
168
+
}
169
+
170
+
$first_level = blocksy_first_level_deep_link($source['prefix']);
171
+
172
+
if (! $first_level) {
173
+
return null;
174
+
}
175
+
176
+
return $first_level . ':' . $source['prefix'] . '_hero_enabled';
177
+
}
178
+
}
179
+
180
+
if (! function_exists('blocksy_output_hero_section')) {
181
+
function blocksy_output_hero_section($args = []) {
182
+
$args = wp_parse_args($args, [
183
+
'type' => 'type-1',
184
+
'source' => false,
185
+
'elements' => null
186
+
]);
187
+
188
+
$type = $args['type'];
189
+
190
+
if (! blocksy_get_page_title_source()) {
191
+
return '';
192
+
}
193
+
194
+
$default_type = 'type-1';
195
+
196
+
if (
197
+
blocksy_get_page_title_source()['strategy'] === 'customizer'
198
+
&& (
199
+
blocksy_get_page_title_source()['prefix'] === 'woo_categories'
200
+
||
201
+
blocksy_get_page_title_source()['prefix'] === 'author'
202
+
)
203
+
) {
204
+
$default_type = 'type-2';
205
+
}
206
+
207
+
$actual_type = blocksy_akg_or_customizer(
208
+
'hero_section',
209
+
blocksy_get_page_title_source(),
210
+
$default_type
211
+
);
212
+
213
+
if (! $type) {
214
+
$type = $actual_type;
215
+
}
216
+
217
+
if ($type !== $actual_type) {
218
+
return '';
219
+
}
220
+
221
+
$post_id = blocksy_get_special_post_id();
222
+
223
+
$elements = $args['elements'];
224
+
225
+
if (! $elements) {
226
+
$elements = blocksy_render_view(
227
+
dirname(__FILE__) . '/hero/elements.php',
228
+
[
229
+
'type' => $type,
230
+
'post_id' => $post_id
231
+
]
232
+
);
233
+
}
234
+
235
+
if ($type !== 'type-1' && $type !== 'type-2') {
236
+
return '';
237
+
}
238
+
239
+
ob_start();
240
+
241
+
do_action('blocksy:hero:before', $type);
242
+
243
+
$attr = [
244
+
'class' => 'hero-section',
245
+
'data-type' => $type
246
+
];
247
+
248
+
if ($type === 'type-1') {
249
+
$attr['class'] .= ' is-width-constrained';
250
+
}
251
+
252
+
if (
253
+
is_customize_preview()
254
+
&&
255
+
blocksy_is_page_title_default()
256
+
&&
257
+
blocksy_hero_get_deep_link(blocksy_get_page_title_source())
258
+
) {
259
+
$attr['data-shortcut'] = 'border';
260
+
$attr['data-shortcut-location'] = blocksy_hero_get_deep_link(blocksy_get_page_title_source());
261
+
}
262
+
263
+
echo blocksy_render_view(
264
+
dirname(__FILE__) . '/hero/' . $type . '.php',
265
+
[
266
+
'type' => $type,
267
+
'elements' => $elements,
268
+
'attr' => $attr,
269
+
'post_id' => $post_id,
270
+
]
271
+
);
272
+
273
+
do_action('blocksy:hero:after', $type);
274
+
275
+
return ob_get_clean();
276
+
}
277
+
}
278
+
279
+