'), 56); if (current_user_can($capability)) { $submenu['bitform'][] = array(__('All Forms', 'bitform'), $capability, 'admin.php?page=bitform#/'); } } /** * Load the asset libraries * * @return void */ public function AdminAssets($current_screen) { if (!strpos($current_screen, 'bitform')) { return; } $parsed_url = parse_url(get_admin_url()); $site_url = $parsed_url['scheme'] . "://" . $parsed_url['host']; $site_url .= empty($parsed_url['port']) ? null : ':' . $parsed_url['port']; $base_path_admin = str_replace($site_url, null, get_admin_url()); wp_enqueue_script( 'bitforms-vendors', BITFORMS_ASSET_JS_URI . '/vendors-main.js', null, BITFORMS_VERSION, true ); wp_enqueue_script( 'bitforms-runtime', BITFORMS_ASSET_JS_URI . '/runtime.js', null, BITFORMS_VERSION, true ); wp_enqueue_script( 'bitforms-file', BITFORMS_ASSET_JS_URI . '/bitforms-file.js', array('bitforms-vendors', 'bitforms-runtime'), BITFORMS_VERSION, true ); if (wp_script_is('wp-i18n')) { $deps = array('bitforms-vendors', 'bitforms-runtime', 'bitforms-file', 'wp-i18n'); } else { $deps = array('bitforms-vendors', 'bitforms-runtime', 'bitforms-file'); } wp_enqueue_script( 'bitforms-admin-script', BITFORMS_ASSET_JS_URI . '/index.js', $deps, BITFORMS_VERSION, true ); wp_enqueue_script('tinymce_js', includes_url('js/tinymce/') . 'wp-tinymce.php', null, false, true); if (!wp_script_is('media-upload')) { wp_enqueue_media(); } $plugin_path = BITFORMS_ASSET_URI; echo " "; wp_enqueue_style( 'bitforms-styles', BITFORMS_ASSET_URI . '/css/bitforms.css', null, BITFORMS_VERSION, 'screen' ); wp_enqueue_style( 'bitforms-components-styles', BITFORMS_ASSET_URI . '/css/components.css', null, BITFORMS_VERSION, 'screen' ); $formHandler = FormHandler::getInstance(); $all_forms = $formHandler->admin->getAllForm(); $urlQuery = parse_url(FileDownloadProvider::getBaseDownloadURL(), PHP_URL_QUERY); $baseDLURL = FileDownloadProvider::getBaseDownloadURL(); $baseDLURL = empty($urlQuery) ? $baseDLURL . '?' : $baseDLURL . '&'; $ipTool = new IpTool(); $user_details = $ipTool->getUserDetail(); $integrationHandler = new IntegrationHandler(0, $user_details); $allFormIntegrations = $integrationHandler->getAllIntegration('app'); $allFormSettings = array(); if (!is_wp_error($allFormIntegrations)) { $integCount = []; foreach ($allFormIntegrations as $integration) { $type = $integration->integration_type; if (!is_null($type)) { if (!isset($integCount[$type])) { $integCount[$type] = 1; } else { $integCount[$type] += 1; } } } foreach ($allFormIntegrations as $integration) { $type = $integration->integration_type; if (!is_null($type)) { $integrationDetails = json_decode($integration->integration_details); $integrationDetails->id = $integration->id; if ($integCount[$type] > 1) { if (!isset($allFormSettings[$type])) { $allFormSettings[$type] = []; } array_push($allFormSettings[$type], $integrationDetails); } else { $allFormSettings[$type] = $integrationDetails; } } } } $users = get_users(['fields' => ['ID', 'user_nicename', 'user_email', 'display_name']]); $userMail = []; $userNames = []; foreach ($users as $key => $value) { $userMail[$key]['label'] = !empty($value->display_name) ? $value->display_name : ''; $userMail[$key]['value'] = !empty($value->user_email) ? $value->user_email : ''; $userMail[$key]['id'] = $value->ID; $userNames[$value->ID] = ['name' => $value->display_name, 'url' => get_edit_user_link($value->ID)]; } $bitforms = apply_filters( 'bitforms_localized_script', array( 'nonce' => wp_create_nonce('bitforms_save'), 'isPro' => false, 'assetsURL' => BITFORMS_ASSET_URI, 'baseURL' => $base_path_admin . 'admin.php?page=bitform#', 'baseDLURL' => $baseDLURL, 'styleURL' => BITFORMS_UPLOAD_BASE_URL . '/form-styles', 'ajaxURL' => admin_url('admin-ajax.php'), 'allForms' => is_wp_error($all_forms) ? null : $all_forms, 'allFormSettings' => $allFormSettings, 'userMail' => !empty($userMail) ? $userMail : [], 'user' => (object)$userNames, 'dateFormat' => get_option('date_format'), 'timeFormat' => get_option('time_format'), 'timeZone' => DateTimeHelper::wp_timezone_string(), 'googleRedirectURL' => get_rest_url() . 'bitform/v1/google', ) ); if (get_locale() !== 'en_US') { include_once BITFORMS_PLUGIN_DIR_PATH . '/languages/generatedString.php'; $bitforms['translations'] = $bitform_i18n_strings; } wp_localize_script('bitforms-admin-script', 'bits', $bitforms); // if (\function_exists('wp_set_script_translations')) // wp_set_script_translations('bitforms-admin-script', 'bitform', BITFORMS_PLUGIN_DIR_PATH . 'languages'); } /** * Bitforms apps-root id provider * @return void */ public function RootPage() { require_once BITFORMS_PLUGIN_DIR_PATH . '/views/view-root.php'; } public function AdminNotices() { global $plugin_page; if (strpos($plugin_page, 'bitform') === false) { return; } remove_all_actions('admin_notices'); remove_all_actions('all_admin_notices'); } }