PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 4.1.0
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v4.1.0
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
blockspare / inc / blockspare-functions.php

blockspare-functions.php in BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites 4.1.0, at inc/blockspare-functions.php

71 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!function_exists('blockspare_checkalignment')) {
3 function blockspare_checkalignment($alignment = '', $attributes = '')
4 {
5 $align_class = $alignment == '' ? 'center' : $alignment;
6 $align_class .= ' ' . blockspare_visibility_classes($attributes);
7 return trim($align_class);
8 }
9 }
10
11 function blockspare_visibility_classes($attributes)
12 {
13 $classes = [];
14
15 if (!empty($attributes['hideOnDesktop'])) {
16 $classes[] = 'blockspare-hide-frontend-desktop';
17 }
18 if (!empty($attributes['hideOnTablet'])) {
19 $classes[] = 'blockspare-hide-frontend-tablet';
20 }
21 if (!empty($attributes['hideOnMobile'])) {
22 $classes[] = 'blockspare-hide-frontend-mobile';
23 }
24
25 return implode(' ', $classes);
26 }
27
28 function blockspare_minify_css($css)
29 {
30
31 // Remove comments
32 $css = preg_replace('!/\*.*?\*/!s', '', $css);
33 // Remove whitespace
34 $css = preg_replace('/\s+/', ' ', $css);
35 // Remove space around symbols
36 $css = str_replace([' {', '{ '], '{', $css);
37 $css = str_replace([' }', '} '], '}', $css);
38 $css = str_replace([' ;', '; '], ';', $css);
39 $css = str_replace([' :', ': '], ':', $css);
40 $css = str_replace([' ,', ', '], ',', $css);
41 return trim($css);
42 }
43
44 function blockspare_visibility_css($attributes, $blockuniqueclass)
45 {
46 $css = '';
47
48 if (!empty($attributes['hideOnDesktop'])) {
49 $css .= '@media (min-width: 1025px) {';
50 $css .= '.' . $blockuniqueclass . '.blockspare-hide-frontend-desktop {';
51 $css .= 'display: none !important;';
52 $css .= '}}';
53 }
54
55 if (!empty($attributes['hideOnTablet'])) {
56 $css .= '@media (min-width: 768px) and (max-width: 1024px) {';
57 $css .= '.' . $blockuniqueclass . '.blockspare-hide-frontend-tablet {';
58 $css .= 'display: none !important;';
59 $css .= '}}';
60 }
61
62 if (!empty($attributes['hideOnMobile'])) {
63 $css .= '@media (max-width: 767px) {';
64 $css .= '.' . $blockuniqueclass . '.blockspare-hide-frontend-mobile {';
65 $css .= 'display: none !important;';
66 $css .= '}}';
67 }
68
69 return $css;
70 }
71