PluginProbe
Gutenify – Visual Site Builder Blocks & Starter Templates / 1.0.9
Gutenify – Visual Site Builder Blocks & Starter Templates v1.0.9
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 / inc / helpers.php

helpers.php in Gutenify – Visual Site Builder Blocks & Starter Templates 1.0.9, at inc/helpers.php

99 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Helpers file.
4 *
5 * @package Gutenify
6 */
7
8 /**
9 * Gutenify Settings.
10 *
11 * @return array
12 */
13 function gutenify_settings() {
14 $default_settings = array(
15 'active_post_types' => array( 'post', 'page' ),
16 'skip_gutenburg_post_type' => apply_filters( 'gutenify_skip_gutenburg_post_type', array() ),
17 );
18 $current_settings = get_option( 'gutenify_settings', array() );
19 $settings = wp_parse_args( $current_settings, $default_settings );
20 return $settings;
21 }
22
23 /**
24 * Update settings.
25 *
26 * @param array $new_settings New settings.
27 * @return array
28 */
29 function gutenify_update_settings( $new_settings ) {
30 $settings = gutenify_settings();
31 $settings = wp_parse_args( $new_settings, $settings );
32 update_option( 'gutenify_settings', $settings );
33 return $settings;
34 }
35
36 add_filter(
37 'block_editor_settings_all',
38 function( $args ) {
39 $args['__experimentalFeatures']['typography']['fontFamilies']['theme'][] = array(
40 'fontFamily' => '"Gilda Display", serif 1',
41 'name' => 'Gilda Display1',
42 'slug' => 'gilda-display1',
43 );
44 // error_log( print_r( $args['__experimentalFeatures']['typography']['fontFamilies']['theme'], true )) ;
45
46 return $args;
47 },
48 9
49 );
50
51 /**
52 * Minify Css.
53 * https://datayze.com/howto/minify-css-with-php
54 *
55 * @param string $css Css styles.
56 * @return String Minified css.
57 */
58 function gutenify_minimize_css_simple($input) {
59 if(trim($input) === "") return $input;
60 return preg_replace(
61 array(
62 // Remove comment(s)
63 '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
64 // Remove unused white-space(s)
65 '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
66 // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
67 '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
68 // Replace `:0 0 0 0` with `:0`
69 '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
70 // Replace `background-position:0` with `background-position:0 0`
71 '#(background-position):0(?=[;\}])#si',
72 // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space
73 '#(?<=[\s:,\-])0+\.(\d+)#s',
74 // Minify string value
75 '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si',
76 '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
77 // Minify HEX color code
78 '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
79 // Replace `(border|outline):none` with `(border|outline):0`
80 '#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
81 // Remove empty selector(s)
82 '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s'
83 ),
84 array(
85 '$1',
86 '$1$2$3$4$5$6$7',
87 '$1',
88 ':0',
89 '$1:0 0',
90 '.$1',
91 '$1$3',
92 '$1$2$4$5',
93 '$1$2$3',
94 '$1:0',
95 '$1$2'
96 ),
97 $input);
98 }
99