| @@ -1,12 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace BitCode\BitForm\Admin; |
| 4 | 4 | |
| 5 | -if (!defined('ABSPATH')) { | |
| 6 | - exit; | |
| 7 | -} | |
| 8 | - | |
| 9 | 5 | /** |
| 10 | 6 | * The admin menu and page handler class |
| 11 | 7 | */ |
| 12 | 8 | |
| @@ -11,20 +7,17 @@ | ||
| 11 | 7 | */ |
| 12 | 8 | |
| 13 | 9 | use BitCode\BitForm\Core\Form\FormHandler; |
| 14 | 10 | use BitCode\BitForm\Core\Integration\IntegrationHandler; |
| 15 | -use BitCode\BitForm\Core\Integration\Integrations; | |
| 16 | 11 | use BitCode\BitForm\Core\Util\DateTimeHelper; |
| 17 | 12 | use BitCode\BitForm\Core\Util\FileDownloadProvider; |
| 18 | 13 | use BitCode\BitForm\Core\Util\IpTool; |
| 19 | -use BitCode\BitForm\Core\Util\Utilities; | |
| 20 | 14 | use WP_Admin_Bar; |
| 21 | 15 | |
| 22 | 16 | class Admin_Bar |
| 23 | 17 | { |
| 24 | 18 | private static $fonts_url = [ |
| 25 | - // 'https://fonts.googleapis.com/css2?family=Outfit:wght@100;300;400;500;600;700&display=swap&family=Roboto:wght@300;400;500&display=swap', | |
| 26 | - 'https://fonts.googleapis.com/css2?family=DM+Sans:wght@100;200;300;400;500;600;700&display=swap', | |
| 19 | + 'https://fonts.googleapis.com/css2?family=Outfit:wght@100;300;400;500;600;700&display=swap&famildy=Roboto:wght@300;400;500&display=swap', | |
| 27 | 20 | 'https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap', |
| 28 | 21 | ]; |
| 29 | 22 | |
| 30 | 23 | public function register() |
| @@ -47,12 +40,12 @@ | ||
| 47 | 40 | { |
| 48 | 41 | global $submenu; |
| 49 | 42 | |
| 50 | 43 | $capability = apply_filters('bitforms_form_access_capability', 'manage_options'); |
| 51 | - $menuTitle = Utilities::isProLicensed() ? 'Bit Form Pro' : 'Bit Form'; | |
| 44 | + | |
| 52 | 45 | add_menu_page( |
| 53 | - __('Bit Form - Most advanced form builder and entries management plugin', 'bit-form'), | |
| 54 | - $menuTitle, | |
| 46 | + __('Bit Form - Most advanced form builder and database management system', 'bit-form'), | |
| 47 | + 'Bit Form', | |
| 55 | 48 | $capability, |
| 56 | 49 | 'bitform', |
| 57 | 50 | [$this, 'RootPage'], |
| 58 | 51 | '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>'), |
| @@ -59,16 +52,15 @@ | ||
| 59 | 52 | 56 |
| 60 | 53 | ); |
| 61 | 54 | if (current_user_can($capability)) { |
| 62 | 55 | $entriesCount = ''; |
| 63 | - // if (self::countUnreadEntries()) { | |
| 64 | - // $entriesCount = ' <span class="update-plugins">' . self::countUnreadEntries() . '</span>'; | |
| 65 | - // } | |
| 56 | + if (self::countUnreadEntries()) { | |
| 57 | + $entriesCount = ' <span class="update-plugins">' . self::countUnreadEntries() . '</span>'; | |
| 58 | + } | |
| 66 | 59 | |
| 67 | - $submenu['bitform'][] = [__('All Forms', 'bit-form') . $entriesCount, $capability, 'admin.php?page=bitform#/']; | |
| 68 | - $submenu['bitform'][] = [__('Form Templates', 'bit-form') . '<span class="bf-template-new-badge">New</span>', $capability, 'admin.php?page=bitform#/form-templates']; | |
| 69 | - $submenu['bitform'][] = [__('App Settings', 'bit-form'), $capability, 'admin.php?page=bitform#/app-settings/general']; | |
| 70 | - $submenu['bitform'][] = [__('Integrations', 'bit-form'), $capability, 'admin.php?page=bitform#/app-settings/integrations']; | |
| 60 | + $submenu['bitform'][] = [__('All Forms' . $entriesCount, 'bit-form'), $capability, 'admin.php?page=bitform#/']; | |
| 61 | + $submenu['bitform'][] = [__('Form Templates <span class="bf-template-new-badge">New</span>', 'bit-form'), $capability, 'admin.php?page=bitform#/form-templates']; | |
| 62 | + $submenu['bitform'][] = [__('App Settings', 'bit-form'), $capability, 'admin.php?page=bitform#/app-settings/recaptcha']; | |
| 71 | 63 | $submenu['bitform'][] = [__('SMTP', 'bit-form'), $capability, 'admin.php?page=bitform#/app-settings/smtp']; |
| 72 | 64 | $submenu['bitform'][] = [__('PDF Setting', 'bit-form'), $capability, 'admin.php?page=bitform#/app-settings/pdf']; |
| 73 | 65 | $submenu['bitform'][] = [__('CPT', 'bit-form'), $capability, 'admin.php?page=bitform#/app-settings/cpt']; |
| 74 | 66 | $submenu['bitform'][] = [__('Bit Form API', 'bit-form'), $capability, 'admin.php?page=bitform#/app-settings/api']; |
| @@ -73,23 +65,17 @@ | ||
| 73 | 65 | $submenu['bitform'][] = [__('CPT', 'bit-form'), $capability, 'admin.php?page=bitform#/app-settings/cpt']; |
| 74 | 66 | $submenu['bitform'][] = [__('Bit Form API', 'bit-form'), $capability, 'admin.php?page=bitform#/app-settings/api']; |
| 75 | 67 | $submenu['bitform'][] = [__('Payments', 'bit-form'), $capability, 'admin.php?page=bitform#/app-settings/payments']; |
| 76 | 68 | $submenu['bitform'][] = [__('Doc & Support', 'bit-form'), $capability, 'admin.php?page=bitform#/doc-support']; |
| 77 | - if (!Utilities::isPro()) { | |
| 78 | - $submenu['bitform'][] = ['<span class="bf-pro-btn">' . __('Get 74% OFF', 'bit-form') . '</span>', $capability, 'https://bit-form.com/#pricing', '_blank']; | |
| 79 | - } | |
| 80 | 69 | } |
| 81 | 70 | } |
| 82 | 71 | |
| 83 | 72 | public function AdminTopMenu(WP_Admin_Bar $wp_admin_bar) |
| 84 | 73 | { |
| 85 | - if (!(current_user_can('manage_options') || current_user_can('manage_bitform'))) { | |
| 86 | - return; | |
| 74 | + $indicator = ''; | |
| 75 | + if (self::countUnreadEntries()) { | |
| 76 | + $indicator = ' <div class="wp-core-ui wp-ui-notification bf-indicator-badge">' . self::countUnreadEntries() . '</div>'; | |
| 87 | 77 | } |
| 88 | - $indicator = ''; | |
| 89 | - // if (self::countUnreadEntries()) { | |
| 90 | - // $indicator = ' <div class="wp-core-ui wp-ui-notification bf-indicator-badge">' . self::countUnreadEntries() . '</div>'; | |
| 91 | - // } | |
| 92 | 78 | |
| 93 | 79 | $wp_admin_bar->add_node([ |
| 94 | 80 | 'id' => 'bitform', |
| 95 | 81 | 'title' => 'Bit Form' . $indicator, |
| @@ -100,51 +86,51 @@ | ||
| 100 | 86 | ]); |
| 101 | 87 | $wp_admin_bar->add_node([ |
| 102 | 88 | 'id' => 'bitform-all-forms', |
| 103 | 89 | 'parent' => 'bitform', |
| 104 | - 'title' => __('All Forms', 'bit-form') . $indicator, | |
| 90 | + 'title' => 'All Forms' . $indicator, | |
| 105 | 91 | 'href' => admin_url('admin.php?page=bitform#/'), |
| 106 | 92 | ]); |
| 107 | 93 | $wp_admin_bar->add_node([ |
| 108 | 94 | 'id' => 'bitform-form-templates', |
| 109 | 95 | 'parent' => 'bitform', |
| 110 | - 'title' => __('Form Templates', 'bit-form'), | |
| 96 | + 'title' => 'Form Templates', | |
| 111 | 97 | 'href' => admin_url('admin.php?page=bitform#/form-templates'), |
| 112 | 98 | ]); |
| 113 | 99 | $wp_admin_bar->add_node([ |
| 114 | 100 | 'id' => 'bitform-app-settings', |
| 115 | 101 | 'parent' => 'bitform', |
| 116 | - 'title' => __('App Settings', 'bit-form'), | |
| 117 | - 'href' => admin_url('admin.php?page=bitform#/app-settings/general'), | |
| 102 | + 'title' => 'App Settings', | |
| 103 | + 'href' => admin_url('admin.php?page=bitform#/app-settings/recaptcha'), | |
| 118 | 104 | ]); |
| 119 | 105 | $wp_admin_bar->add_node([ |
| 120 | 106 | 'id' => 'bitform-smtp', |
| 121 | 107 | 'parent' => 'bitform', |
| 122 | - 'title' => __('SMTP', 'bit-form'), | |
| 108 | + 'title' => 'SMTP', | |
| 123 | 109 | 'href' => admin_url('admin.php?page=bitform#/app-settings/smtp'), |
| 124 | 110 | ]); |
| 125 | 111 | $wp_admin_bar->add_node([ |
| 126 | 112 | 'id' => 'bitform-pdf-setting', |
| 127 | 113 | 'parent' => 'bitform', |
| 128 | - 'title' => __('PDF Setting', 'bit-form'), | |
| 114 | + 'title' => 'PDF Setting', | |
| 129 | 115 | 'href' => admin_url('admin.php?page=bitform#/app-settings/pdf'), |
| 130 | 116 | ]); |
| 131 | 117 | $wp_admin_bar->add_node([ |
| 132 | 118 | 'id' => 'bitform-cpt', |
| 133 | 119 | 'parent' => 'bitform', |
| 134 | - 'title' => __('CPT', 'bit-form'), | |
| 120 | + 'title' => 'CPT', | |
| 135 | 121 | 'href' => admin_url('admin.php?page=bitform#/app-settings/cpt'), |
| 136 | 122 | ]); |
| 137 | 123 | $wp_admin_bar->add_node([ |
| 138 | 124 | 'id' => 'bitform-api', |
| 139 | 125 | 'parent' => 'bitform', |
| 140 | - 'title' => __('Bit Form API', 'bit-form'), | |
| 126 | + 'title' => 'Bit Form API', | |
| 141 | 127 | 'href' => admin_url('admin.php?page=bitform#/app-settings/api'), |
| 142 | 128 | ]); |
| 143 | 129 | $wp_admin_bar->add_node([ |
| 144 | 130 | 'id' => 'bitform-payments', |
| 145 | 131 | 'parent' => 'bitform', |
| 146 | - 'title' => __('Payments', 'bit-form'), | |
| 132 | + 'title' => 'Payments', | |
| 147 | 133 | 'href' => admin_url('admin.php?page=bitform#/app-settings/payments'), |
| 148 | 134 | ]); |
| 149 | 135 | } |
| 150 | 136 | |
| @@ -165,9 +151,9 @@ | ||
| 165 | 151 | * @return void |
| 166 | 152 | */ |
| 167 | 153 | public function AdminAssets($current_screen) |
| 168 | 154 | { |
| 169 | - if (false === strpos($current_screen, 'bitform')) { | |
| 155 | + if (!strpos($current_screen, 'bitform')) { | |
| 170 | 156 | return; |
| 171 | 157 | } |
| 172 | 158 | $parsed_url = wp_parse_url(get_admin_url()); |
| 173 | 159 | $site_url = $parsed_url['scheme'] . '://' . $parsed_url['host']; |
| @@ -173,16 +159,15 @@ | ||
| 173 | 159 | $site_url = $parsed_url['scheme'] . '://' . $parsed_url['host']; |
| 174 | 160 | $site_url .= empty($parsed_url['port']) ? null : ':' . $parsed_url['port']; |
| 175 | 161 | $base_path_admin = str_replace($site_url, '', get_admin_url()); |
| 176 | 162 | // loading google fonts |
| 177 | - wp_enqueue_style('googleapis-BITFORM-PRECONNECT', 'https://fonts.googleapis.com', [], BITFORMS_VERSION, false); | |
| 178 | - wp_enqueue_style('gstatic-BITFORM-PRECONNECT-CROSSORIGIN', 'https://fonts.gstatic.com', [], BITFORMS_VERSION, false); | |
| 163 | + wp_enqueue_style('googleapis-BITFORM-PRECONNECT', 'https://fonts.googleapis.com'); | |
| 164 | + wp_enqueue_style('gstatic-BITFORM-PRECONNECT-CROSSORIGIN', 'https://fonts.gstatic.com'); | |
| 179 | 165 | foreach (self::$fonts_url as $i => $font_url) { |
| 180 | - wp_enqueue_style('bf-font-' . $i, $font_url, [], BITFORMS_VERSION); | |
| 166 | + wp_enqueue_style('bf-font-' . $i, $font_url); | |
| 181 | 167 | } |
| 182 | 168 | |
| 183 | 169 | if (defined('BITAPPS_DEV') && BITAPPS_DEV) { |
| 184 | - // Vite dev server scripts; null version intentional (dev mode, no cache busting needed). | |
| 185 | 170 | wp_enqueue_script('vite-client-helper-BITFORM-MODULE', BIT_DEV_URL . '/config/devHotModule.js', [], null); |
| 186 | 171 | wp_enqueue_script('vite-client-BITFORM-MODULE', BIT_DEV_URL . '/@vite/client', [], null); |
| 187 | 172 | wp_enqueue_script('index-BITFORM-MODULE', BIT_DEV_URL . '/main.jsx', [], null); |
| 188 | 173 | } |
| @@ -189,9 +174,9 @@ | ||
| 189 | 174 | |
| 190 | 175 | if (!defined('BITAPPS_DEV') || (defined('BITAPPS_DEV') && !BITAPPS_DEV)) { |
| 191 | 176 | $build_hash = file_get_contents(BITFORMS_PLUGIN_DIR_PATH . '/build-hash.txt'); |
| 192 | 177 | wp_enqueue_script('index-BITFORM-MODULE', BITFORMS_ASSET_URI . "/main-{$build_hash}.js", [], null); |
| 193 | - wp_enqueue_style('bf-css', BITFORMS_ASSET_URI . "/main-{$build_hash}.css", [], $build_hash); | |
| 178 | + wp_enqueue_style('bf-css', BITFORMS_ASSET_URI . "/main-{$build_hash}.css"); | |
| 194 | 179 | } |
| 195 | 180 | |
| 196 | 181 | // if (defined('BITAPPS_DEV') && BITAPPS_DEV) { |
| 197 | 182 | // wp_enqueue_script( |
| @@ -216,52 +201,49 @@ | ||
| 216 | 201 | // true |
| 217 | 202 | // ); |
| 218 | 203 | // } |
| 219 | 204 | |
| 220 | - // if (wp_script_is('wp-i18n')) { | |
| 221 | - // error_log('wp_script' . wp_script_is('wp-i18n')); | |
| 222 | - // $deps = ['bitforms-vendors', 'bitforms-runtime', 'bitforms-file', 'wp-i18n']; | |
| 223 | - // } else { | |
| 224 | - // $deps = ['bitforms-vendors', 'bitforms-runtime', 'bitforms-file']; | |
| 225 | - // } | |
| 226 | - // if (!defined('BITAPPS_DEV')) { | |
| 227 | - // wp_enqueue_script( | |
| 228 | - // 'bitforms-admin-script', | |
| 229 | - // BITFORMS_ASSET_JS_URI . '/index.js', | |
| 230 | - // $deps, | |
| 231 | - // BITFORMS_VERSION, | |
| 232 | - // true | |
| 233 | - // ); | |
| 234 | - // } | |
| 205 | + if (wp_script_is('wp-i18n')) { | |
| 206 | + $deps = ['bitforms-vendors', 'bitforms-runtime', 'bitforms-file', 'wp-i18n']; | |
| 207 | + } else { | |
| 208 | + $deps = ['bitforms-vendors', 'bitforms-runtime', 'bitforms-file']; | |
| 209 | + } | |
| 210 | + if (!defined('BITAPPS_DEV')) { | |
| 211 | + wp_enqueue_script( | |
| 212 | + 'bitforms-admin-script', | |
| 213 | + BITFORMS_ASSET_JS_URI . '/index.js', | |
| 214 | + $deps, | |
| 215 | + BITFORMS_VERSION, | |
| 216 | + true | |
| 217 | + ); | |
| 218 | + } | |
| 219 | + wp_enqueue_script('tinymce_js', includes_url('js/tinymce/') . 'wp-tinymce.php', null, false, true); | |
| 235 | 220 | |
| 236 | - wp_enqueue_script('tinymce_js', includes_url('js/tinymce/') . 'wp-tinymce.php', [], get_bloginfo('version'), true); | |
| 237 | - | |
| 238 | 221 | if (!wp_script_is('media-upload')) { |
| 239 | 222 | wp_enqueue_media(); |
| 240 | 223 | } |
| 241 | 224 | |
| 242 | - // $plugin_path = BITFORMS_ASSET_URI; | |
| 225 | + $plugin_path = BITFORMS_ASSET_URI; | |
| 243 | 226 | |
| 244 | 227 | echo "<meta name='theme-color' content='#13233c' />"; |
| 245 | 228 | |
| 246 | - // if (defined('BITAPPS_DEV') && !BITAPPS_DEV) { | |
| 247 | - // wp_enqueue_style( | |
| 248 | - // 'bitforms-styles', | |
| 249 | - // BITFORMS_ASSET_URI . '/css/bitforms.css', | |
| 250 | - // null, | |
| 251 | - // BITFORMS_VERSION, | |
| 252 | - // 'screen' | |
| 253 | - // ); | |
| 229 | + if (defined('BITAPPS_DEV') && !BITAPPS_DEV) { | |
| 230 | + wp_enqueue_style( | |
| 231 | + 'bitforms-styles', | |
| 232 | + BITFORMS_ASSET_URI . '/css/bitforms.css', | |
| 233 | + null, | |
| 234 | + BITFORMS_VERSION, | |
| 235 | + 'screen' | |
| 236 | + ); | |
| 254 | 237 | |
| 255 | - // wp_enqueue_style( | |
| 256 | - // 'bitforms-components-styles', | |
| 257 | - // BITFORMS_ASSET_URI . '/css/components.css', | |
| 258 | - // null, | |
| 259 | - // BITFORMS_VERSION, | |
| 260 | - // 'screen' | |
| 261 | - // ); | |
| 262 | - // } | |
| 263 | - | |
| 238 | + wp_enqueue_style( | |
| 239 | + 'bitforms-components-styles', | |
| 240 | + BITFORMS_ASSET_URI . '/css/components.css', | |
| 241 | + null, | |
| 242 | + BITFORMS_VERSION, | |
| 243 | + 'screen' | |
| 244 | + ); | |
| 245 | + } | |
| 264 | 246 | $formHandler = FormHandler::getInstance(); |
| 265 | 247 | $all_forms = $formHandler->admin->getAllForm(); |
| 266 | 248 | $urlQuery = wp_parse_url(FileDownloadProvider::getBaseDownloadURL(), PHP_URL_QUERY); |
| 267 | 249 | $baseDLURL = FileDownloadProvider::getBaseDownloadURL(); |
| @@ -269,12 +251,8 @@ | ||
| 269 | 251 | $ipTool = new IpTool(); |
| 270 | 252 | $user_details = $ipTool->getUserDetail(); |
| 271 | 253 | $integrationHandler = new IntegrationHandler(0, $user_details); |
| 272 | 254 | $allFormIntegrations = $integrationHandler->getAllIntegration('app'); |
| 273 | - | |
| 274 | - $integraions = Integrations::getInstance(); | |
| 275 | - $connectedIntegrationApps = $integraions->getConnectedIntegrationApp(); | |
| 276 | - | |
| 277 | 255 | $allFormSettings = []; |
| 278 | 256 | if (!is_wp_error($allFormIntegrations)) { |
| 279 | 257 | $integCount = []; |
| 280 | 258 | foreach ($allFormIntegrations as $integration) { |
| @@ -290,12 +268,8 @@ | ||
| 290 | 268 | foreach ($allFormIntegrations as $integration) { |
| 291 | 269 | $type = $integration->integration_type; |
| 292 | 270 | if (!is_null($type)) { |
| 293 | 271 | $integrationDetails = json_decode($integration->integration_details); |
| 294 | - | |
| 295 | - if (!is_object($integrationDetails) || is_null($integrationDetails)) { | |
| 296 | - $integrationDetails = new \stdClass(); | |
| 297 | - } | |
| 298 | 272 | $integrationDetails->id = $integration->id; |
| 299 | 273 | if ($integCount[$type] > 1) { |
| 300 | 274 | if (!isset($allFormSettings[$type])) { |
| 301 | 275 | $allFormSettings[$type] = []; |
| @@ -307,19 +281,22 @@ | ||
| 307 | 281 | } |
| 308 | 282 | } |
| 309 | 283 | } |
| 310 | 284 | |
| 311 | - if (!is_wp_error($connectedIntegrationApps)) { | |
| 312 | - $allFormSettings['connectedIntegrationApps'] = $connectedIntegrationApps; | |
| 285 | + $users = get_users(['fields' => ['ID', 'user_nicename', 'user_email', 'display_name']]); | |
| 286 | + $userMail = []; | |
| 287 | + $userNames = []; | |
| 288 | + foreach ($users as $key => $value) { | |
| 289 | + $userMail[$key]['label'] = !empty($value->display_name) ? $value->display_name : ''; | |
| 290 | + $userMail[$key]['value'] = !empty($value->user_email) ? $value->user_email : ''; | |
| 291 | + $userMail[$key]['id'] = $value->ID; | |
| 292 | + $userNames[$value->ID] = ['name' => $value->display_name, 'url' => get_edit_user_link($value->ID)]; | |
| 313 | 293 | } |
| 314 | - | |
| 315 | - $appSettings = get_option('bitform_app_settings', (object)[]); | |
| 316 | 294 | $bits = [ |
| 317 | 295 | 'configs' => ['bf_separator' => BITFORMS_BF_SEPARATOR], |
| 318 | 296 | 'nonce' => wp_create_nonce('bitforms_save'), |
| 319 | 297 | 'isPro' => false, |
| 320 | 298 | 'siteURL' => site_url(), |
| 321 | - 'rootURL' => BITFORMS_ROOT_URI, | |
| 322 | 299 | 'assetsURL' => BITFORMS_ASSET_URI, |
| 323 | 300 | 'baseURL' => $base_path_admin . 'admin.php?page=bitform#', |
| 324 | 301 | 'baseDLURL' => $baseDLURL, |
| 325 | 302 | 'styleURL' => BITFORMS_UPLOAD_BASE_URL . '/form-styles', |
| @@ -327,9 +304,10 @@ | ||
| 327 | 304 | 'ajaxURL' => admin_url('admin-ajax.php'), |
| 328 | 305 | 'allForms' => is_wp_error($all_forms) ? null : $all_forms, |
| 329 | 306 | 'allPages' => is_wp_error($this->getAllPages()) ? [] : $this->getAllPages(), |
| 330 | 307 | 'allFormSettings' => count($allFormSettings) > 0 ? $allFormSettings : (object)[], |
| 331 | - 'appSettings' => $appSettings, | |
| 308 | + 'userMail' => !empty($userMail) ? $userMail : [], | |
| 309 | + 'user' => (object) $userNames, | |
| 332 | 310 | 'dateFormat' => get_option('date_format'), |
| 333 | 311 | 'timeFormat' => get_option('time_format'), |
| 334 | 312 | 'timeZone' => DateTimeHelper::wp_timezone_string(), |
| 335 | 313 | 'googleRedirectURL' => get_rest_url() . 'bitform/v1/google', |
| @@ -334,13 +312,12 @@ | ||
| 334 | 312 | 'timeZone' => DateTimeHelper::wp_timezone_string(), |
| 335 | 313 | 'googleRedirectURL' => get_rest_url() . 'bitform/v1/google', |
| 336 | 314 | 'oneDriveRedirectURL' => get_rest_url() . 'bitform/v1/oneDrive', |
| 337 | 315 | 'zohoRedirectURL' => get_rest_url() . 'bitform/v1/zoho', |
| 338 | - 'oAuthRedirectURL' => get_rest_url() . 'bitform/v1/oauth-redirect', | |
| 316 | + 'userRoles' => get_editable_roles(), | |
| 339 | 317 | 'downloadedPdfFonts' => is_array(get_option('bitforms_pdf_fonts')) ? get_option('bitforms_pdf_fonts') : [], |
| 340 | 318 | 'permission' => empty(get_option('bitforms_allow_tracking')) ? false : true, |
| 341 | 319 | 'templatePath' => BITFORMS_ROOT_URI . '/static/templates', |
| 342 | - 'serverInfo' => ['php_version' => phpversion(), 'engine' => isset($_SERVER['SERVER_SOFTWARE']) ? sanitize_text_field(wp_unslash($_SERVER['SERVER_SOFTWARE'])) : '', 'wp_version' => get_bloginfo('version'), 'loaded_extensions' => get_loaded_extensions()], | |
| 343 | 320 | ]; |
| 344 | 321 | |
| 345 | 322 | $isMigratingToV2 = get_option('bitforms_migrating_to_v2', false); |
| 346 | 323 | if ($isMigratingToV2) { |
| @@ -353,16 +330,9 @@ | ||
| 353 | 330 | |
| 354 | 331 | $changelogVersion = get_option('bitforms_changelog_version', '0.0.0'); |
| 355 | 332 | $bits['changelogVersion'] = $changelogVersion; |
| 356 | 333 | |
| 357 | - $hideAnnouncementModal = (bool) get_option('bitforms_hide_announcement', false); | |
| 358 | - $bits['hideAnnouncementModal'] = $hideAnnouncementModal; | |
| 359 | - | |
| 360 | - $hideCashbackModal = (bool) get_option('bitforms_hide_cashback', false); | |
| 361 | - $bits['hideCashbackModal'] = $hideCashbackModal; | |
| 362 | - | |
| 363 | 334 | global $wpdb; |
| 364 | - // Direct query: table name interpolation only (no user input). $wpdb->prepare() cannot parameterize schema-check queries. | |
| 365 | 335 | $hasV1FormTable = $wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}bitforms_form_v1'"); |
| 366 | 336 | if ($hasV1FormTable) { |
| 367 | 337 | $bits['canRollbackToV1'] = true; |
| 368 | 338 | } |
| @@ -370,16 +340,11 @@ | ||
| 370 | 340 | $bitforms = apply_filters( |
| 371 | 341 | 'bitforms_localized_script', |
| 372 | 342 | $bits |
| 373 | 343 | ); |
| 374 | - | |
| 375 | - $allowBitFormTranslation = apply_filters('bitform_filter_allow_translation', true); | |
| 376 | - if ($allowBitFormTranslation && 'en_US' !== get_user_locale() && file_exists(BITFORMS_PLUGIN_DIR_PATH . '/languages/generatedString.php')) { | |
| 344 | + if ('en_US' !== get_locale() && file_exists(BITFORMS_PLUGIN_DIR_PATH . '/languages/generatedString.php')) { | |
| 377 | 345 | include_once BITFORMS_PLUGIN_DIR_PATH . '/languages/generatedString.php'; |
| 378 | - $bitforms['translations'] = $bitforms_i18n_strings; | |
| 379 | - | |
| 380 | - // Apply a filter to allow user/custom translations to modify the $bitforms translations | |
| 381 | - $bitforms['translations'] = apply_filters('bitform_filter_translations', $bitforms['translations']); | |
| 346 | + $bitforms['translations'] = $i18n_strings; | |
| 382 | 347 | } |
| 383 | 348 | wp_localize_script('index-BITFORM-MODULE', 'bits', $bitforms); |
| 384 | 349 | // !BIT_DEV && wp_localize_script('bitforms-admin-script', 'bits', $bitforms); |
| 385 | 350 | // echo !BIT_DEV ? '' : "<script>console.log(window.bits=JSON.parse('" . str_replace("'", '', wp_json_encode($bitforms)) . "'))</script>"; |
| @@ -461,9 +426,8 @@ | ||
| 461 | 426 | |
| 462 | 427 | private static function countUnreadEntries() |
| 463 | 428 | { |
| 464 | 429 | global $wpdb; |
| 465 | - // Direct query: table name interpolation only (no user input). status = 1 is a hardcoded literal. | |
| 466 | 430 | $unreadEntries = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}bitforms_form_entries WHERE status = 1"); |
| 467 | 431 | return $unreadEntries; |
| 468 | 432 | } |
| 469 | 433 | } |