PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.0
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.0
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 / FrontendHelpers.php

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

102 lines 3.5 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 final class FrontendHelpers {
6 public static $pageBuilderList = [
7 'action' => 'elementor', // elementor
8 'vcv-action' => 'frontend', // visual composer
9 'fl_builder' => '', // beaver builder
10 'action' => 'in-front-editor', // brizy
11 'ct_builder' => 'true', // oxygen
12 'breakdance' => 'builder', // breakdance
13 'lc_action_launch_editing' => '1', // live canvas
14 'vc_action' => 'vc_inline', // wp bakery
15 'et_fb' => '1', // divi
16 'et_pb_preview' => 'true', // divi
17 'bricks' => 'run', // bricks
18 'action' => 'architect', // thrive architect
19 'page' => 'livecomposer_editor', // live composer
20 ];
21
22 public static function getFormIdsFromPost() {
23 global $post;
24 global $wpdb;
25 global $bfUniqFormIds;
26
27 if (empty($post)) {
28 $bfUniqFormIds = [];
29 return;
30 };
31 $postId = $post->ID;
32 $formsIds = [];
33 // $bfMetaValues = $wpdb->get_results("SELECT pmt1.meta_value FROM wp_postmeta pmt1 LEFT OUTER JOIN wp_postmeta pmt2 ON (pmt1.meta_id < pmt2.meta_id AND pmt1.meta_key = pmt2.meta_key) WHERE pmt2.meta_id IS NULL AND pmt1.post_id = {$postId} AND pmt1.meta_value LIKE '%[bitform%' ORDER BY pmt1.meta_id DESC");
34 $bfMetaValues = $wpdb->get_results('SELECT meta_value FROM `' . $wpdb->postmeta . "` WHERE `post_id`={$post->ID} AND meta_value LIKE '%[bitform id=%'");
35 $postContent = $post->post_content;
36 $bfMetaValues[] = (object) ['meta_value' => $postContent];
37 foreach ($bfMetaValues as $bfShortcut) {
38 $meta_value = $bfShortcut->meta_value;
39 $meta_value = str_replace('\\', '', $meta_value);
40 \preg_match_all("/\[bitform\s+id\s*=\s*('|\")\s*(\d+)\s*('|\")\]/", $meta_value, $shortCode);
41 $shortCodes = $shortCode[2];
42 if (!empty($shortCodes)) {
43 $formsIds = array_merge($formsIds, $shortCodes);
44 }
45 }
46
47 $bfUniqFormIds = array_unique($formsIds);
48
49 return $bfUniqFormIds;
50 }
51
52 public static function isPageBuilder() {
53 global $bfMultipleFormsExists;
54 global $isPageBuilder;
55
56 $current_url = $_SERVER['REQUEST_URI'];
57 $isAdminSide = false !== strpos($current_url, '/wp-admin/');
58
59 $isPageBuilder = get_transient('is_page_builder');
60 $isPageBuilderSessionExists = false !== $isPageBuilder;
61 if ($isAdminSide) {
62 $isPageBuilder = true;
63 }
64
65 if ($isPageBuilder) {
66 $bfMultipleFormsExists = true;
67 return true;
68 }
69
70 if ($isPageBuilderSessionExists) {
71 set_transient('is_page_builder', $isPageBuilder);
72 }
73
74 self::getFormIdsFromPost();
75 global $bfUniqFormIds;
76 $bfMultipleFormsExists = $isPageBuilder ? true : count($bfUniqFormIds) > 1;
77 return $isPageBuilder;
78 }
79
80 public static function parseQueryParams($url) {
81 $url_components = parse_url($url);
82 if (isset($url_components['query'])) {
83 parse_str($url_components['query'], $queryParams);
84 return $queryParams;
85 }
86 return [];
87 }
88
89 public static function handleBfFormIdsSession($formId = null) {
90 global $bfFrontendFormIds;
91 $bfFrontendFormIds = get_transient('bf_frontend_form_ids');
92 if (empty($bfFrontendFormIds)) {
93 $bfFrontendFormIds = [];
94 }
95 if (is_null($formId)) {
96 return $bfFrontendFormIds;
97 }
98 $bfFrontendFormIds[] = $formId;
99 set_transient('bf_frontend_form_ids', $bfFrontendFormIds);
100 }
101 }
102