| @@ -8,14 +8,17 @@ | ||
| 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; |
| 19 | 22 | use BitCode\BitForm\Core\WorkFlow\WorkflowExecutor; |
| 20 | 23 | use BitCode\BitForm\Frontend\ConversationalFormView; |
| 21 | 24 | use BitCode\BitForm\Frontend\StandaloneFormView; |
| @@ -43,8 +46,9 @@ | ||
| 43 | 46 | add_action('bitform_dequeue_styles', [Hooks::class, 'dequeueStyles'], 1000, 100); |
| 44 | 47 | add_action('init', [ConversationalFormView::class, 'conversationalFormView']); |
| 45 | 48 | add_action('init', [StandaloneFormView::class, 'standaloneFormView']); |
| 46 | 49 | add_action('bitform_admin_form_changed', [Hooks::class, 'invalidateCustomUrlCache']); |
| 50 | + \BitCode\BitForm\Core\Util\CacheCompat::registerPurgeHooks(); | |
| 47 | 51 | add_action('wp_footer', [Hooks::class, 'updateBitFormVersion'], 9999, 0); |
| 48 | 52 | |
| 49 | 53 | // Register the BitForm widget for Gutenberg, and Bricks Builder |
| 50 | 54 | add_action('init', [new RegisterGutenBlock(), 'register']); |
| @@ -50,8 +54,13 @@ | ||
| 50 | 54 | add_action('init', [new RegisterGutenBlock(), 'register']); |
| 51 | 55 | add_action('init', [RegisterBitformBricksWidget::class, 'register_widgets'], 11); |
| 52 | 56 | // Add Bit Form menu to admin bar by "manage_bitform" capability |
| 53 | 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); | |
| 54 | 63 | } |
| 55 | 64 | |
| 56 | 65 | public static function updateBitFormVersion() |
| 57 | 66 | { |
| @@ -58,8 +67,12 @@ | ||
| 58 | 67 | $currentBitFormVersion = BITFORMS_VERSION; |
| 59 | 68 | $installedBitFormVersion = get_option('bitforms_version'); |
| 60 | 69 | if ($currentBitFormVersion !== $installedBitFormVersion) { |
| 61 | 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); | |
| 62 | 75 | update_option('bitforms_version', $currentBitFormVersion); |
| 63 | 76 | } |
| 64 | 77 | } |
| 65 | 78 | |
| @@ -103,15 +116,19 @@ | ||
| 103 | 116 | public static function init_classes() |
| 104 | 117 | { |
| 105 | 118 | if (Request::Check('admin')) { |
| 106 | 119 | (new Admin_Bar())->register(); |
| 120 | + TranslationManager::boot('admin'); | |
| 107 | 121 | } |
| 108 | 122 | if (Request::Check('ajax')) { |
| 109 | 123 | new AjaxService(); |
| 124 | + TranslationManager::boot('ajax'); | |
| 110 | 125 | } |
| 111 | 126 | if (Request::Check('frontend')) { |
| 112 | 127 | $formHandler = new FormHandler(); |
| 113 | 128 | $formHandler->frontend; |
| 129 | + TranslationManager::boot('frontend'); | |
| 130 | + CacheCompat::register(); | |
| 114 | 131 | } |
| 115 | 132 | if (Request::isPluginPage()) { |
| 116 | 133 | (new FileDownloadProvider())->register(); |
| 117 | 134 | } |