Diff: STRATO-apps/wordpress_03/app/wp-content/themes/blocksy/inc/css/static-files.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
3
+
class Blocksy_Static_Css_Files {
4
+
public function all_static_files() {
5
+
$should_load_comments_css = (
6
+
is_singular()
7
+
&&
8
+
(
9
+
blocksy_has_comments()
10
+
||
11
+
is_customize_preview()
12
+
)
13
+
);
14
+
15
+
$should_load_comments_css = apply_filters(
16
+
'blocksy:static-files:ct-comments-styles',
17
+
$should_load_comments_css
18
+
);
19
+
20
+
$should_load_sidebar = (
21
+
blocksy_sidebar_position() !== 'none'
22
+
||
23
+
is_customize_preview()
24
+
||
25
+
(
26
+
function_exists('is_woocommerce')
27
+
&&
28
+
is_woocommerce()
29
+
&&
30
+
(
31
+
is_shop()
32
+
||
33
+
is_product_category()
34
+
||
35
+
is_product_tag()
36
+
||
37
+
is_product_taxonomy()
38
+
||
39
+
is_search()
40
+
)
41
+
&&
42
+
blocksy_get_theme_mod('has_woo_offcanvas_filter', 'no') === 'yes'
43
+
)
44
+
);
45
+
46
+
$static_files = [
47
+
'ct-main-styles' => [
48
+
'url' => '/static/bundle/main.min.css'
49
+
],
50
+
51
+
'ct-admin-frontend-styles' => [
52
+
'url' => '/static/bundle/admin-frontend.min.css',
53
+
'enabled' => (
54
+
current_user_can('manage_options')
55
+
||
56
+
current_user_can('edit_theme_options')
57
+
)
58
+
],
59
+
60
+
'ct-page-title-styles' => [
61
+
'url' => '/static/bundle/page-title.min.css',
62
+
'enabled' => (
63
+
is_customize_preview()
64
+
||
65
+
blocksy_get_page_title_source()
66
+
)
67
+
],
68
+
69
+
'ct-main-rtl-styles' => [
70
+
'url' => '/static/bundle/main-rtl.min.css',
71
+
'enabled' => is_rtl()
72
+
],
73
+
74
+
'ct-sidebar-styles' => [
75
+
'url' => '/static/bundle/sidebar.min.css',
76
+
'deps' => ['ct-main-styles'],
77
+
'enabled' => $should_load_sidebar
78
+
],
79
+
80
+
'ct-comments-styles' => [
81
+
'url' => '/static/bundle/comments.min.css',
82
+
'deps' => ['ct-main-styles'],
83
+
'enabled' => $should_load_comments_css
84
+
],
85
+
86
+
'ct-author-box-styles' => [
87
+
'url' => '/static/bundle/author-box.min.css',
88
+
'deps' => ['ct-main-styles'],
89
+
'enabled' => (
90
+
is_singular()
91
+
&&
92
+
(
93
+
blocksy_has_author_box()
94
+
||
95
+
is_customize_preview()
96
+
)
97
+
)
98
+
],
99
+
100
+
'ct-posts-nav-styles' => [
101
+
'url' => '/static/bundle/posts-nav.min.css',
102
+
'deps' => ['ct-main-styles'],
103
+
'enabled' => (
104
+
is_singular()
105
+
&&
106
+
(
107
+
blocksy_has_post_nav()
108
+
||
109
+
is_customize_preview()
110
+
)
111
+
)
112
+
],
113
+
114
+
// Integrations
115
+
'ct-forminator-styles' => [
116
+
'url' => '/static/bundle/forminator.min.css',
117
+
'deps' => ['ct-main-styles'],
118
+
'enabled' => class_exists('Forminator')
119
+
],
120
+
121
+
'ct-getwid-styles' => [
122
+
'url' => '/static/bundle/getwid.min.css',
123
+
'deps' => ['ct-main-styles'],
124
+
'enabled' => class_exists('Getwid\Getwid')
125
+
],
126
+
127
+
'ct-elementor-styles' => [
128
+
'url' => '/static/bundle/elementor-frontend.min.css',
129
+
'deps' => ['ct-main-styles'],
130
+
'enabled' => did_action('elementor/loaded')
131
+
],
132
+
133
+
'ct-elementor-woocommerce-styles' => [
134
+
'url' => '/static/bundle/elementor-woocommerce-frontend.min.css',
135
+
'deps' => ['ct-main-styles'],
136
+
'enabled' => (
137
+
did_action('elementor/loaded')
138
+
&&
139
+
function_exists('is_woocommerce')
140
+
)
141
+
],
142
+
143
+
'ct-tutor-styles' => [
144
+
'url' => '/static/bundle/tutor.min.css',
145
+
'deps' => ['ct-main-styles'],
146
+
'enabled' => function_exists('tutor_course_enrolled_lead_info')
147
+
],
148
+
149
+
'ct-tribe-events-styles' => [
150
+
'url' => '/static/bundle/tribe-events.min.css',
151
+
'deps' => ['ct-main-styles'],
152
+
'enabled' => class_exists('Tribe__Events__Main')
153
+
],
154
+
155
+
'ct-brizy-styles' => [
156
+
'url' => '/static/bundle/brizy.min.css',
157
+
'deps' => ['ct-main-styles'],
158
+
'enabled' => function_exists('brizy_load')
159
+
],
160
+
161
+
'ct-jet-woo-builder-styles' => [
162
+
'url' => '/static/bundle/jet-woo-builder.min.css',
163
+
'deps' => ['ct-main-styles'],
164
+
'enabled' => class_exists('Jet_Woo_Builder')
165
+
],
166
+
167
+
'ct-beaver-styles' => [
168
+
'url' => '/static/bundle/beaver.min.css',
169
+
'deps' => ['ct-main-styles'],
170
+
'enabled' => class_exists('FLBuilderLoader')
171
+
],
172
+
173
+
'ct-divi-styles' => [
174
+
'url' => '/static/bundle/divi.min.css',
175
+
'deps' => ['ct-main-styles'],
176
+
'enabled' => class_exists('ET_Builder_Plugin')
177
+
],
178
+
179
+
'ct-cf-7-styles' => [
180
+
'url' => '/static/bundle/cf-7.min.css',
181
+
'deps' => ['ct-main-styles'],
182
+
'enabled' => defined('WPCF7_VERSION')
183
+
],
184
+
185
+
'ct-stackable-styles' => [
186
+
'url' => '/static/bundle/stackable.min.css',
187
+
'deps' => ['ct-main-styles'],
188
+
'enabled' => defined('STACKABLE_VERSION')
189
+
],
190
+
191
+
'ct-qubely-styles' => [
192
+
'url' => '/static/bundle/qubely.min.css',
193
+
'deps' => ['ct-main-styles'],
194
+
'enabled' => defined('QUBELY_VERSION')
195
+
],
196
+
197
+
'ct-bbpress-styles' => [
198
+
'url' => '/static/bundle/bbpress.min.css',
199
+
'deps' => ['ct-main-styles'],
200
+
'enabled' => function_exists('is_bbpress')
201
+
],
202
+
203
+
'ct-buddypress-styles' => [
204
+
'url' => '/static/bundle/buddypress.min.css',
205
+
'deps' => ['ct-main-styles'],
206
+
'enabled' => function_exists('is_buddypress')
207
+
],
208
+
209
+
'ct-wpforms-styles' => [
210
+
'url' => '/static/bundle/wpforms.min.css',
211
+
'deps' => ['ct-main-styles'],
212
+
'enabled' => defined('WPFORMS_VERSION')
213
+
],
214
+
215
+
'ct-dokan-styles' => [
216
+
'url' => '/static/bundle/dokan.min.css',
217
+
'deps' => ['ct-main-styles'],
218
+
'enabled' => class_exists('WeDevs_Dokan')
219
+
],
220
+
221
+
'ct-page-scroll-to-id-styles' => [
222
+
'url' => '/static/bundle/page-scroll-to-id.min.css',
223
+
'deps' => ['ct-main-styles'],
224
+
'enabled' => class_exists('malihuPageScroll2id')
225
+
],
226
+
227
+
'ct-eventkoi-styles' => [
228
+
'url' => '/static/bundle/eventkoi.min.css',
229
+
'deps' => ['ct-main-styles'],
230
+
'enabled' => (
231
+
class_exists('\EventKoi\Init')
232
+
&&
233
+
(
234
+
is_singular('event')
235
+
||
236
+
is_tax('event_cal')
237
+
)
238
+
)
239
+
],
240
+
];
241
+
242
+
$static_files = array_merge(
243
+
$static_files,
244
+
$this->dynamic_static_files()
245
+
);
246
+
247
+
return apply_filters(
248
+
'blocksy:static-files:all',
249
+
$static_files
250
+
);
251
+
}
252
+
253
+
public function dynamic_static_files($args = []) {
254
+
$args = wp_parse_args($args, [
255
+
'is_rendering_content' => is_singular()
256
+
]);
257
+
258
+
global $post;
259
+
260
+
$prefix = blocksy_manager()->screen->get_prefix();
261
+
262
+
$woo_extra_settings = get_option('blocksy_ext_woocommerce_extra_settings', [
263
+
'features' => []
264
+
]);
265
+
266
+
$render = new \Blocksy_Header_Builder_Render();
267
+
268
+
$is_elementor_preview = false;
269
+
270
+
if (
271
+
class_exists('Elementor\Plugin')
272
+
&&
273
+
(
274
+
\Elementor\Plugin::$instance->preview->is_preview_mode()
275
+
||
276
+
\Elementor\Plugin::$instance->editor->is_edit_mode()
277
+
)
278
+
) {
279
+
$is_elementor_preview = true;
280
+
}
281
+
282
+
$should_load_share_box = (
283
+
is_singular()
284
+
&&
285
+
(
286
+
blocksy_has_share_box()
287
+
||
288
+
is_customize_preview()
289
+
||
290
+
is_page(
291
+
blocksy_get_theme_mod('woocommerce_wish_list_page', '__EMPTY__')
292
+
)
293
+
||
294
+
(
295
+
function_exists('blocksy_has_product_specific_layer')
296
+
&&
297
+
blocksy_has_product_specific_layer('product_sharebox')
298
+
)
299
+
||
300
+
(
301
+
function_exists('is_account_page')
302
+
&&
303
+
is_account_page()
304
+
)
305
+
||
306
+
(
307
+
$post
308
+
&&
309
+
has_shortcode($post->post_content, 'product_page')
310
+
)
311
+
)
312
+
);
313
+
314
+
$should_load_flexy_styles = (
315
+
is_singular('blc-product-review')
316
+
||
317
+
(
318
+
is_singular()
319
+
&&
320
+
(
321
+
blocksy_get_theme_mod($prefix . '_related_posts_slideshow') === 'slider'
322
+
||
323
+
is_customize_preview()
324
+
)
325
+
)
326
+
);
327
+
328
+
if (
329
+
$post
330
+
&&
331
+
$args['is_rendering_content']
332
+
&&
333
+
! $should_load_flexy_styles
334
+
) {
335
+
$should_load_flexy_styles = (
336
+
$should_load_flexy_styles
337
+
||
338
+
(
339
+
has_shortcode(
340
+
$post->post_content,
341
+
'blocksy_posts'
342
+
)
343
+
&&
344
+
strpos(
345
+
$post->post_content,
346
+
'view="slider"'
347
+
) !== false
348
+
)
349
+
);
350
+
351
+
$should_load_flexy_styles = (
352
+
$should_load_flexy_styles
353
+
||
354
+
has_shortcode($post->post_content, 'product_page')
355
+
);
356
+
357
+
$should_load_flexy_styles = (
358
+
$should_load_flexy_styles
359
+
||
360
+
(
361
+
(
362
+
has_block('blocksy/query', $post->post_content)
363
+
||
364
+
has_block('blocksy/tax-query', $post->post_content)
365
+
)
366
+
&&
367
+
strpos(
368
+
$post->post_content,
369
+
'"has_slideshow":"yes"'
370
+
) !== false
371
+
)
372
+
);
373
+
}
374
+
375
+
if (function_exists('is_woocommerce') && ! $should_load_flexy_styles) {
376
+
$should_load_flexy_styles = (
377
+
$should_load_flexy_styles
378
+
||
379
+
blocksy_manager()->screen->is_product()
380
+
);
381
+
382
+
$should_load_flexy_styles = (
383
+
$should_load_flexy_styles
384
+
||
385
+
(
386
+
is_woocommerce()
387
+
&&
388
+
isset($woo_extra_settings['features']['added-to-cart-popup'])
389
+
&&
390
+
$woo_extra_settings['features']['added-to-cart-popup']
391
+
&&
392
+
blocksy_get_theme_mod('cart_popup_suggested_products', 'yes') === 'yes'
393
+
)
394
+
);
395
+
396
+
$should_load_flexy_styles = (
397
+
$should_load_flexy_styles
398
+
||
399
+
(
400
+
is_checkout()
401
+
&&
402
+
blocksy_get_theme_mod('checkout_suggested_products', 'yes') === 'yes'
403
+
)
404
+
);
405
+
406
+
$should_load_flexy_styles = (
407
+
$should_load_flexy_styles
408
+
||
409
+
(
410
+
is_cart()
411
+
&&
412
+
blocksy_get_theme_mod('cart_suggested_products', 'yes') === 'yes'
413
+
)
414
+
);
415
+
416
+
$should_load_flexy_styles = (
417
+
$should_load_flexy_styles
418
+
||
419
+
(
420
+
$render->contains_item('cart')
421
+
&&
422
+
blocksy_get_theme_mod('mini_cart_suggested_products', 'yes') === 'yes'
423
+
)
424
+
);
425
+
426
+
if (
427
+
$post
428
+
&&
429
+
! $should_load_flexy_styles
430
+
) {
431
+
$should_load_flexy_styles = (
432
+
$should_load_flexy_styles
433
+
||
434
+
(
435
+
(
436
+
has_shortcode($post->post_content, 'products')
437
+
||
438
+
has_shortcode($post->post_content, 'top_rated_products')
439
+
||
440
+
has_shortcode($post->post_content, 'featured_products')
441
+
||
442
+
has_shortcode($post->post_content, 'sale_products')
443
+
||
444
+
has_shortcode($post->post_content, 'best_selling_products')
445
+
||
446
+
has_shortcode($post->post_content, 'recent_products')
447
+
||
448
+
has_shortcode($post->post_content, 'product_category')
449
+
)
450
+
&&
451
+
isset($woo_extra_settings['features']['added-to-cart-popup'])
452
+
&&
453
+
$woo_extra_settings['features']['added-to-cart-popup']
454
+
&&
455
+
blocksy_get_theme_mod('cart_popup_suggested_products', 'yes') === 'yes'
456
+
)
457
+
);
458
+
}
459
+
}
460
+
461
+
if ($is_elementor_preview) {
462
+
$should_load_flexy_styles = true;
463
+
}
464
+
465
+
return [
466
+
'ct-woocommerce-cart-checkout-blocks' => [
467
+
'url' => '/static/bundle/woocommerce-cart-checkout-blocks.min.css',
468
+
'enabled' => (
469
+
has_block('woocommerce/cart')
470
+
||
471
+
has_block('woocommerce/checkout')
472
+
)
473
+
],
474
+
475
+
'ct-share-box-styles' => [
476
+
'url' => '/static/bundle/share-box.min.css',
477
+
'deps' => ['ct-main-styles'],
478
+
'enabled' => $should_load_share_box
479
+
],
480
+
481
+
'ct-flexy-styles' => [
482
+
'url' => '/static/bundle/flexy.min.css',
483
+
'deps' => ['ct-main-styles'],
484
+
'enabled' => $should_load_flexy_styles
485
+
],
486
+
];
487
+
}
488
+
489
+
public function enqueue_static_files($theme) {
490
+
foreach ($this->all_static_files() as $id => $internal_file) {
491
+
$file = wp_parse_args($internal_file, [
492
+
'enabled' => true,
493
+
'deps' => [],
494
+
'url' => ''
495
+
]);
496
+
497
+
$file['url'] = get_template_directory_uri() . $file['url'];
498
+
499
+
if (! $file['enabled']) {
500
+
wp_register_style(
501
+
$id,
502
+
$file['url'],
503
+
$file['deps'],
504
+
$theme->get('Version')
505
+
);
506
+
507
+
continue;
508
+
}
509
+
510
+
wp_enqueue_style(
511
+
$id,
512
+
$file['url'],
513
+
$file['deps'],
514
+
$theme->get('Version')
515
+
);
516
+
}
517
+
518
+
$this->check_for_patterns();
519
+
}
520
+
521
+
public function recheck_dynamic_styles($args = []) {
522
+
foreach ($this->dynamic_static_files($args) as $id => $file) {
523
+
$file = wp_parse_args($file, [
524
+
'enabled' => true
525
+
]);
526
+
527
+
if ($file['enabled']) {
528
+
wp_enqueue_style($id);
529
+
}
530
+
}
531
+
}
532
+
533
+
public function check_for_patterns() {
534
+
add_filter('pre_render_block', function ($block_content, $block) {
535
+
if ($block['blockName'] === 'core/block') {
536
+
537
+
if (
538
+
isset($block['attrs']['ref'])
539
+
&&
540
+
get_post($block['attrs']['ref'])
541
+
) {
542
+
543
+
global $post;
544
+
$original_post = $post;
545
+
546
+
$post = get_post($block['attrs']['ref']);
547
+
setup_postdata($post);
548
+
549
+
$this->recheck_dynamic_styles([
550
+
'is_rendering_content' => true
551
+
]);
552
+
553
+
$post = $original_post;
554
+
setup_postdata($post);
555
+
}
556
+
}
557
+
558
+
return $block_content;
559
+
}, 10, 2);
560
+
}
561
+
}
562
+