resetJsGeneratedPageIds(); update_option('bitforms_version', $currentBitFormVersion); } } public static function registerRoutes() { $routes = new Routes(); $routes->register_routes(); } public static function isGeneratedScript($postId, $oldPost, $updatedPost) { $oldContent = $oldPost->post_content; $updatedContent = $updatedPost->post_content; $oldShortCodeMatch = \preg_match_all("/\[bitform\s+id\s*=\s*('|\")\s*(\d+)\s*('|\")\]/", $oldContent, $oldShortCodes); $updatedShortCodeMatch = \preg_match_all("/\[bitform\s+id\s*=\s*('|\")\s*(\d+)\s*('|\")\]/", $updatedContent, $updatedShortCodes); if ($oldShortCodeMatch && $updatedShortCodeMatch) { $oldShortCodes = $oldShortCodes[2]; $updatedShortCodes = $updatedShortCodes[2]; $checkEqualArray = array_diff($oldShortCodes, $updatedShortCodes); if (!empty($checkEqualArray)) { $formModel = new FormModel(); $value = "%$postId%"; $condtions = [ 'generated_script_page_ids' => ['operator' => 'LIKE', 'value' => $value], ]; $forms = $formModel->get('generated_script_page_ids,id', $condtions); foreach ($forms as $form) { $pageIds = json_decode($form->generated_script_page_ids); if (property_exists($pageIds, $postId)) { unset($pageIds->{$postId}); $formModel->update(['generated_script_page_ids' => \wp_json_encode($pageIds)], ['id' => $form->id]); } } } } } public static function localization_setup() { load_plugin_textdomain('bit-form', false, dirname(BITFORMS_PLUGIN_BASENAME) . '/languages'); } public static function init_classes() { if (Request::Check('admin')) { (new Admin_Bar())->register(); } if (Request::Check('ajax')) { new AjaxService(); } if (Request::Check('frontend')) { $formHandler = new FormHandler(); $formHandler->frontend; } if (Request::isPluginPage()) { (new FileDownloadProvider())->register(); } if (current_user_can('edit_posts')) { (new GutenBlockProvider())->register(); } include BITFORMS_PLUGIN_DIR_PATH . 'includes' . DIRECTORY_SEPARATOR . 'Frontend' . DIRECTORY_SEPARATOR . 'InitRoutes.php'; } public static function versionUpdateRunFallbacks() { $dir = BITFORMS_PLUGIN_DIR_PATH . 'includes' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'Fallback'; if (is_dir($dir) && is_file($dir . DIRECTORY_SEPARATOR . 'Init.php')) { include $dir . DIRECTORY_SEPARATOR . 'Init.php'; } } public static function plugin_action_links($links) { $links[] = '' . __('Docs') . ''; if (!Utilities::isPro()) { $links[] = '' . __('Upgrade to Pro') . ''; } return $links; } public static function dequeueScripts(...$formIds) { foreach ($formIds as $formId) { wp_deregister_script("bitform-script-{$formId}"); wp_dequeue_script("bitform-script-{$formId}"); } global $bitform_dequeued_scripts; if (!is_array($bitform_dequeued_scripts)) { $bitform_dequeued_scripts = []; } $bitform_dequeued_scripts = array_merge($bitform_dequeued_scripts, $formIds); } public static function dequeueStyles(...$formIds) { foreach ($formIds as $formId) { wp_deregister_style("bitform-style-{$formId}"); wp_dequeue_style("bitform-style-{$formId}"); wp_deregister_style("bitform-style-{$formId}-formid"); wp_dequeue_style("bitform-style-{$formId}-formid"); } global $bitform_dequeued_styles; if (!is_array($bitform_dequeued_styles)) { $bitform_dequeued_styles = []; } $bitform_dequeued_styles = array_merge($bitform_dequeued_styles, $formIds); } }