PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.9.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.9.1
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / includes / Core / Util / Utilities.php

Utilities.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.9.1, at includes/Core/Util/Utilities.php

82 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Core\Util;
4
5 use BitCode\BitForm\Admin\Form\Helpers;
6
7 final class Utilities
8 {
9 public static function isPro()
10 {
11 $integrateData = get_option('bitformpro_integrate_key_data');
12 $isProLicenseActivated = !empty($integrateData) && is_array($integrateData) && 'success' === $integrateData['status'];
13 return class_exists('BitCode\\BitFormPro\\Plugin') && $isProLicenseActivated;
14 }
15
16 public static function getRealPath($dir, $name)
17 {
18 if (!isset($dir)) {
19 return false;
20 }
21 $directories = array_diff(scandir($dir), ['..', '.']);
22 $name = strtolower($name);
23
24 foreach ($directories as $directory) {
25 $dirLower = strtolower($directory);
26 if ($dirLower === $name) {
27 return $directory;
28 }
29 }
30
31 return false;
32 }
33
34 public static function getFileNameExceptExtension($filename)
35 {
36 $path_parts = pathinfo($filename);
37 return $path_parts['filename'];
38 }
39
40 public static function styleGenerator($styleObj, $important = false)
41 {
42 if (is_array($styleObj)) {
43 $styleObj = json_decode(json_encode($styleObj));
44 }
45 $important = $important ? '!important' : '';
46 $classes = array_keys((array) $styleObj);
47 $css = '';
48 foreach ($classes as $class) {
49 $css .= $class;
50 $props = (array) $styleObj->{$class};
51 $propsKeys = array_keys($props);
52 $styleObject = '{';
53 foreach ($propsKeys as $property) {
54 $value = $props[$property];
55 if (empty($value)) {
56 continue;
57 }
58 if (is_object($value)) {
59 continue;
60 }
61 $styleObject .= "{$property}:{$value}{$important};";
62 }
63 $styleObject = rtrim($styleObject, ';');
64 $styleObject .= '}';
65 $css .= $styleObject;
66 }
67
68 return $css;
69 }
70
71 public static function appendCSS($formId, $css, $mode = 'a')
72 {
73 $fileName = '';
74 $path = '';
75 $path = 'form-styles';
76 $fileName = "bitform-{$formId}.css";
77 Helpers::saveFile($path, $fileName, $css, $mode);
78 $fileName = "bitform-{$formId}-formid.css";
79 Helpers::saveFile($path, $fileName, $css, $mode);
80 }
81 }
82