| @@ -8,15 +8,19 @@ | ||
| 8 | 8 | |
| 9 | 9 | use BitCode\BitForm\Admin\Admin_Bar; |
| 10 | 10 | use BitCode\BitForm\API\Route\Routes; |
| 11 | 11 | use BitCode\BitForm\Core\Ajax\AjaxService; |
| 12 | +use BitCode\BitForm\Core\Api\BitFormPublicApi; | |
| 12 | 13 | use BitCode\BitForm\Core\Capability\Request; |
| 13 | 14 | use BitCode\BitForm\Core\Database\FormModel; |
| 14 | 15 | use BitCode\BitForm\Core\Fallback\FormFallback; |
| 15 | 16 | use BitCode\BitForm\Core\Form\FormHandler; |
| 16 | 17 | use BitCode\BitForm\Core\Integration\Integrations; |
| 18 | +use BitCode\BitForm\Core\Util\CacheCompat; | |
| 17 | 19 | use BitCode\BitForm\Core\Util\FileDownloadProvider; |
| 20 | +use BitCode\BitForm\Core\Util\Translation\TranslationManager; | |
| 18 | 21 | use BitCode\BitForm\Core\Util\Utilities; |
| 22 | +use BitCode\BitForm\Core\WorkFlow\WorkflowExecutor; | |
| 19 | 23 | use BitCode\BitForm\Frontend\ConversationalFormView; |
| 20 | 24 | use BitCode\BitForm\Frontend\StandaloneFormView; |
| 21 | 25 | use BitCode\BitForm\Widgets\RegisterBitformBricksWidget; |
| 22 | 26 | use BitCode\BitForm\Widgets\RegisterGutenBlock; |
| @@ -27,9 +31,14 @@ | ||
| 27 | 31 | { |
| 28 | 32 | add_action('init', [PostType::class, 'registerBitformsPostType']); |
| 29 | 33 | add_action('init', [PostType::class, 'registerCustomPostType']); |
| 30 | 34 | add_action('update_option_bitform_custom_post_types', [PostType::class, 'scheduleRewriteFlush']); |
| 35 | + add_filter('wp_robots', [PostType::class, 'noindexBitformsPages']); | |
| 31 | 36 | add_action('bitforms_exec_integrations', [Integrations::class, 'integrationExecutionHelper'], 1, 5); |
| 37 | + // Reclaim safety net for queued workflows whose browser-fired trigger was lost | |
| 38 | + add_action('bitforms_reclaim_workflow', [WorkflowExecutor::class, 'reclaim'], 10, 4); | |
| 39 | + add_action('bitforms_reclaim_sweep', [WorkflowExecutor::class, 'sweep']); | |
| 40 | + add_filter('bitform_default_submit_confirmation_excluded_action_ids', ['BitCode\BitForm\Core\WorkFlow\Helper', 'workflowReferencedActionIds'], 10, 3); | |
| 32 | 41 | add_action('init', [Hooks::class, 'init_classes']); |
| 33 | 42 | add_action('init', [Hooks::class, 'versionUpdateRunFallbacks']); |
| 34 | 43 | add_action('rest_api_init', [Hooks::class, 'registerRoutes']); |
| 35 | 44 | add_filter('plugin_action_links_' . plugin_basename(BITFORMS_PLUGIN_MAIN_FILE), [Hooks::class, 'plugin_action_links']); |
| @@ -37,8 +46,9 @@ | ||
| 37 | 46 | add_action('bitform_dequeue_styles', [Hooks::class, 'dequeueStyles'], 1000, 100); |
| 38 | 47 | add_action('init', [ConversationalFormView::class, 'conversationalFormView']); |
| 39 | 48 | add_action('init', [StandaloneFormView::class, 'standaloneFormView']); |
| 40 | 49 | add_action('bitform_admin_form_changed', [Hooks::class, 'invalidateCustomUrlCache']); |
| 50 | + \BitCode\BitForm\Core\Util\CacheCompat::registerPurgeHooks(); | |
| 41 | 51 | add_action('wp_footer', [Hooks::class, 'updateBitFormVersion'], 9999, 0); |
| 42 | 52 | |
| 43 | 53 | // Register the BitForm widget for Gutenberg, and Bricks Builder |
| 44 | 54 | add_action('init', [new RegisterGutenBlock(), 'register']); |
| @@ -44,8 +54,13 @@ | ||
| 44 | 54 | add_action('init', [new RegisterGutenBlock(), 'register']); |
| 45 | 55 | add_action('init', [RegisterBitformBricksWidget::class, 'register_widgets'], 11); |
| 46 | 56 | // Add Bit Form menu to admin bar by "manage_bitform" capability |
| 47 | 57 | add_filter('bitforms_form_access_capability', [Hooks::class, 'bitformMenuAccessCapability']); |
| 58 | + | |
| 59 | + // Public API bridge for sibling Bit Apps plugins (Bit CRM). Consumers call | |
| 60 | + add_filter('bitform/api/crm_integrated_forms', fn ($default = null) => BitFormPublicApi::getCrmIntegratedForms(), 10, 1); | |
| 61 | + add_filter('bitform/api/toggle_form_status', fn ($default = null, $formId = 0, $status = 0) => BitFormPublicApi::toggleFormStatus($formId, $status), 10, 3); | |
| 62 | + add_filter('bitform/api/create_form_url', fn ($default = null, $args = []) => BitFormPublicApi::getCreateFormUrl($args), 10, 2); | |
| 48 | 63 | } |
| 49 | 64 | |
| 50 | 65 | public static function updateBitFormVersion() |
| 51 | 66 | { |
| @@ -52,8 +67,12 @@ | ||
| 52 | 67 | $currentBitFormVersion = BITFORMS_VERSION; |
| 53 | 68 | $installedBitFormVersion = get_option('bitforms_version'); |
| 54 | 69 | if ($currentBitFormVersion !== $installedBitFormVersion) { |
| 55 | 70 | (new FormFallback())->resetJsGeneratedPageIds(); |
| 71 | + // Without this the regenerated bundle keeps its ?bfv= URL and browsers | |
| 72 | + // and CDNs keep serving the stale file. | |
| 73 | + $formUpdateVersion = (int) get_option('bitform_form_update_version'); | |
| 74 | + update_option('bitform_form_update_version', $formUpdateVersion ? $formUpdateVersion + 1 : 1); | |
| 56 | 75 | update_option('bitforms_version', $currentBitFormVersion); |
| 57 | 76 | } |
| 58 | 77 | } |
| 59 | 78 | |
| @@ -83,10 +102,10 @@ | ||
| 83 | 102 | 'generated_script_page_ids' => ['operator' => 'LIKE', 'value' => $value], |
| 84 | 103 | ]; |
| 85 | 104 | $forms = $formModel->get('generated_script_page_ids,id', $condtions); |
| 86 | 105 | foreach ($forms as $form) { |
| 87 | - $pageIds = json_decode($form->generated_script_page_ids); | |
| 88 | - if (property_exists($pageIds, $postId)) { | |
| 106 | + $pageIds = Utilities::jsonObj($form->generated_script_page_ids ?? ''); | |
| 107 | + if ($pageIds && property_exists($pageIds, $postId)) { | |
| 89 | 108 | unset($pageIds->{$postId}); |
| 90 | 109 | $formModel->update(['generated_script_page_ids' => \wp_json_encode($pageIds)], ['id' => $form->id]); |
| 91 | 110 | } |
| 92 | 111 | } |
| @@ -97,15 +116,19 @@ | ||
| 97 | 116 | public static function init_classes() |
| 98 | 117 | { |
| 99 | 118 | if (Request::Check('admin')) { |
| 100 | 119 | (new Admin_Bar())->register(); |
| 120 | + TranslationManager::boot('admin'); | |
| 101 | 121 | } |
| 102 | 122 | if (Request::Check('ajax')) { |
| 103 | 123 | new AjaxService(); |
| 124 | + TranslationManager::boot('ajax'); | |
| 104 | 125 | } |
| 105 | 126 | if (Request::Check('frontend')) { |
| 106 | 127 | $formHandler = new FormHandler(); |
| 107 | 128 | $formHandler->frontend; |
| 129 | + TranslationManager::boot('frontend'); | |
| 130 | + CacheCompat::register(); | |
| 108 | 131 | } |
| 109 | 132 | if (Request::isPluginPage()) { |
| 110 | 133 | (new FileDownloadProvider())->register(); |
| 111 | 134 | } |