PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 1.4
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v1.4
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 / Admin / Admin_Bar.php

Admin_Bar.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 1.4, at includes/Admin/Admin_Bar.php

219 lines 9.0 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\Admin;
4
5 /**
6 * The admin menu and page handler class
7 */
8
9 use BitCode\BitForm\Core\Util\IpTool;
10 use BitCode\BitForm\Core\Form\FormHandler;
11 use BitCode\BitForm\Core\Util\DateTimeHelper;
12 use BitCode\BitForm\Core\Util\FileDownloadProvider;
13 use BitCode\BitForm\Core\Integration\IntegrationHandler;
14
15 class Admin_Bar
16 {
17 public function register()
18 {
19 add_action('in_admin_header', array($this, 'AdminNotices'));
20 add_action('admin_menu', array($this, 'AdminMenu'));
21 add_action('admin_enqueue_scripts', array($this, 'AdminAssets'));
22 }
23
24
25 /**
26 * Register the admin menu
27 *
28 * @return void
29 */
30 public function AdminMenu()
31 {
32 global $submenu;
33
34
35 $capability = apply_filters('bitforms_form_access_capability', 'manage_options');
36 add_menu_page(__('Bit Form - wordpress form builder and database management system', 'bitform'), 'Bit Form', $capability, 'bitform', array($this, 'RootPage'), 'data:image/svg+xml;base64,' . base64_encode('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 163 163"><path fill="#fff" d="M106 0H57A57 57 0 000 57v49a57 57 0 0057 57h49a57 57 0 0057-57V57a57 57 0 00-57-57zM51 60v3l-1 59v12c0 5-3 8-8 6-2-1-3-4-3-6v-21-55a29 29 0 011-4 5 5 0 015-4h33a4 4 0 004-2c2-3 8-2 10-1a9 9 0 015 9 9 9 0 01-7 8c-3 1-6 0-9-3a3 3 0 00-1-1H51zm73 74c-6 5-12 6-20 6H72a8 8 0 01-4-1 5 5 0 01-2-6 5 5 0 015-3h35c11-1 20-10 21-20 0-11-8-20-18-23a6 6 0 00-1 0H78h-1v14l1 2h18a4 4 0 003-1c4-4 8-3 11-1 4 2 5 7 3 12-2 4-9 6-13 2a6 6 0 00-5-1H71c-3 0-5-2-5-6V82c0-4 1-5 5-6h17a21 21 0 0021-24c-1-9-8-16-16-18a25 25 0 00-6 0H46c-4 0-7-3-7-6s3-5 7-5h42a33 33 0 0132 23c2 11 0 20-6 29l-1 2 5 2c11 4 17 12 19 23 3 12-2 24-13 32z"/></svg>'), 56);
37
38 if (current_user_can($capability)) {
39 $submenu['bitform'][] = array(__('All Forms', 'bitform'), $capability, 'admin.php?page=bitform#/');
40 }
41 }
42
43 /**
44 * Load the asset libraries
45 *
46 * @return void
47 */
48 public function AdminAssets($current_screen)
49 {
50 if (!strpos($current_screen, 'bitform')) {
51 return;
52 }
53 $parsed_url = parse_url(get_admin_url());
54 $site_url = $parsed_url['scheme'] . "://" . $parsed_url['host'];
55 $site_url .= empty($parsed_url['port']) ? null : ':' . $parsed_url['port'];
56 $base_path_admin = str_replace($site_url, null, get_admin_url());
57 wp_enqueue_script(
58 'bitforms-vendors',
59 BITFORMS_ASSET_JS_URI . '/vendors-main.js',
60 null,
61 BITFORMS_VERSION,
62 true
63 );
64 wp_enqueue_script(
65 'bitforms-runtime',
66 BITFORMS_ASSET_JS_URI . '/runtime.js',
67 null,
68 BITFORMS_VERSION,
69 true
70 );
71 wp_enqueue_script(
72 'bitforms-file',
73 BITFORMS_ASSET_JS_URI . '/bitforms-file.js',
74 array('bitforms-vendors', 'bitforms-runtime'),
75 BITFORMS_VERSION,
76 true
77 );
78
79 if (wp_script_is('wp-i18n')) {
80 $deps = array('bitforms-vendors', 'bitforms-runtime', 'bitforms-file', 'wp-i18n');
81 } else {
82 $deps = array('bitforms-vendors', 'bitforms-runtime', 'bitforms-file');
83 }
84 wp_enqueue_script(
85 'bitforms-admin-script',
86 BITFORMS_ASSET_JS_URI . '/index.js',
87 $deps,
88 BITFORMS_VERSION,
89 true
90 );
91 wp_enqueue_script('tinymce_js', includes_url('js/tinymce/') . 'wp-tinymce.php', null, false, true);
92
93 if (!wp_script_is('media-upload')) {
94 wp_enqueue_media();
95 }
96
97 $plugin_path = BITFORMS_ASSET_URI;
98
99
100 echo "<link rel='manifest' href='{$plugin_path}/js/manifest.json' />
101 <link rel='preconnect' href='https://fonts.gstatic.com'>
102 <link rel='stylesheet preload prefetch' type='text/css' crossorigin='anonymous' as='style' crossorigin='anonymous' href='https://fonts.googleapis.com/css2?family=Montserrat:wght@100;300;400;500;600;700;800&display=swap'>
103 <link href='https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap' rel='stylesheet'>
104 <meta name='theme-color' content='#13233c' />
105 <meta name='description' content='Bit Form | Fast Modern Form builder for Wordpress' />
106 <meta name='keywords' content='Fastest WP form, Bitform, Fast Modern Form builder for Wordpress'>";
107
108 wp_enqueue_style(
109 'bitforms-styles',
110 BITFORMS_ASSET_URI . '/css/bitforms.css',
111 null,
112 BITFORMS_VERSION,
113 'screen'
114 );
115
116 wp_enqueue_style(
117 'bitforms-components-styles',
118 BITFORMS_ASSET_URI . '/css/components.css',
119 null,
120 BITFORMS_VERSION,
121 'screen'
122 );
123 $formHandler = FormHandler::getInstance();
124 $all_forms = $formHandler->admin->getAllForm();
125 $urlQuery = parse_url(FileDownloadProvider::getBaseDownloadURL(), PHP_URL_QUERY);
126 $baseDLURL = FileDownloadProvider::getBaseDownloadURL();
127 $baseDLURL = empty($urlQuery) ? $baseDLURL . '?' : $baseDLURL . '&';
128 $ipTool = new IpTool();
129 $user_details = $ipTool->getUserDetail();
130 $integrationHandler = new IntegrationHandler(0, $user_details);
131 $allFormIntegrations = $integrationHandler->getAllIntegration('app');
132 $allFormSettings = array();
133 if (!is_wp_error($allFormIntegrations)) {
134 $integCount = [];
135 foreach ($allFormIntegrations as $integration) {
136 $type = $integration->integration_type;
137 if (!is_null($type)) {
138 if (!isset($integCount[$type])) {
139 $integCount[$type] = 1;
140 } else {
141 $integCount[$type] += 1;
142 }
143 }
144 }
145 foreach ($allFormIntegrations as $integration) {
146 $type = $integration->integration_type;
147 if (!is_null($type)) {
148 $integrationDetails = json_decode($integration->integration_details);
149 $integrationDetails->id = $integration->id;
150 if ($integCount[$type] > 1) {
151 if (!isset($allFormSettings[$type])) {
152 $allFormSettings[$type] = [];
153 }
154 array_push($allFormSettings[$type], $integrationDetails);
155 } else {
156 $allFormSettings[$type] = $integrationDetails;
157 }
158 }
159 }
160 }
161
162 $users = get_users(['fields' => ['ID', 'user_nicename', 'user_email', 'display_name']]);
163 $userMail = [];
164 $userNames = [];
165 foreach ($users as $key => $value) {
166 $userMail[$key]['label'] = !empty($value->display_name) ? $value->display_name : '';
167 $userMail[$key]['value'] = !empty($value->user_email) ? $value->user_email : '';
168 $userMail[$key]['id'] = $value->ID;
169 $userNames[$value->ID] = ['name' => $value->display_name, 'url' => get_edit_user_link($value->ID)];
170 }
171 $bitforms = apply_filters(
172 'bitforms_localized_script',
173 array(
174 'nonce' => wp_create_nonce('bitforms_save'),
175 'isPro' => false,
176 'assetsURL' => BITFORMS_ASSET_URI,
177 'baseURL' => $base_path_admin . 'admin.php?page=bitform#',
178 'baseDLURL' => $baseDLURL,
179 'styleURL' => BITFORMS_UPLOAD_BASE_URL . '/form-styles',
180 'ajaxURL' => admin_url('admin-ajax.php'),
181 'allForms' => is_wp_error($all_forms) ? null : $all_forms,
182 'allFormSettings' => $allFormSettings,
183 'userMail' => !empty($userMail) ? $userMail : [],
184 'user' => (object)$userNames,
185 'dateFormat' => get_option('date_format'),
186 'timeFormat' => get_option('time_format'),
187 'timeZone' => DateTimeHelper::wp_timezone_string(),
188 'googleRedirectURL' => get_rest_url() . 'bitform/v1/google',
189 )
190 );
191 if (get_locale() !== 'en_US') {
192 include_once BITFORMS_PLUGIN_DIR_PATH . '/languages/generatedString.php';
193 $bitforms['translations'] = $bitform_i18n_strings;
194 }
195 wp_localize_script('bitforms-admin-script', 'bits', $bitforms);
196 // if (\function_exists('wp_set_script_translations'))
197 // wp_set_script_translations('bitforms-admin-script', 'bitform', BITFORMS_PLUGIN_DIR_PATH . 'languages');
198 }
199
200 /**
201 * Bitforms apps-root id provider
202 * @return void
203 */
204 public function RootPage()
205 {
206 require_once BITFORMS_PLUGIN_DIR_PATH . '/views/view-root.php';
207 }
208
209 public function AdminNotices()
210 {
211 global $plugin_page;
212 if (strpos($plugin_page, 'bitform') === false) {
213 return;
214 }
215 remove_all_actions('admin_notices');
216 remove_all_actions('all_admin_notices');
217 }
218 }
219