| | |
| | | |
| | | use JVBase\managers\Cache; |
| | | use JVBase\meta\Form; |
| | | use JVBase\utility\Features; |
| | | use JVBase\base\Site; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; // Exit if accessed directly |
| | |
| | | public function __construct() |
| | | { |
| | | $this->cache = Cache::for('forms', WEEK_IN_SECONDS); |
| | | |
| | | if (JVB_TESTING) { |
| | | $this->cache->flush(); |
| | | } |
| | | // Initialize forms from filter |
| | | $this->forms = $this->registerForms(); |
| | | $this->form_contact = apply_filters('jvb_form_contact', ''); |
| | | |
| | | |
| | | // Hook into the CustomBlocks render system |
| | | add_filter('jvb_render_block_jvb_forms', [$this, 'render'], 10, 2); |
| | | |
| | |
| | | } |
| | | |
| | | // Enqueue Turnstile if needed |
| | | if (Features::forSite()->hasIntegration('cloudflare')) { |
| | | if (Site::hasIntegration('cloudflare')) { |
| | | $cloudflare = JVB()->connect('cloudflare'); |
| | | if ($cloudflare->isSetUp()) { |
| | | $cloudflare->enqueueTurnstileScripts(); |
| | |
| | | } |
| | | } |
| | | |
| | | echo '<form id="' . esc_attr($form_id) . '" data-form-id="'.esc_attr($type).'" data-save="form">'; |
| | | echo '<form id="' . esc_attr($form_id) . '" data-form-id="'.esc_attr($type).'" data-save="form" data-handled data-step>'; |
| | | // wp_nonce_field('jvb_form_' . $type); |
| | | } |
| | | |
| | |
| | | echo '<div class="container">'; |
| | | if ($total > 1) { |
| | | echo '<div class="form-progress">'; |
| | | jvbRenderProgressBar('<span class="step-text">Step <span class="current">1</span> of ' . $total . '</span>'); |
| | | jvbRenderProgressBar('<span class="step-text">Step <span class="current">1</span> of ' . $total . '</span>', false, false); |
| | | echo '</div>'; |
| | | } |
| | | |
| | | // Render navigation if multiple sections |
| | | if (count($sections) > 1) { |
| | | echo '<nav class="tabs row start" role="tablist">'; |
| | | echo '<nav class="tabs row left" role="tablist">'; |
| | | $i = 1; |
| | | foreach ($sections as $slug => $section) { |
| | | $active_class = $i === 1 ? ' active' : ''; |
| | |
| | | |
| | | echo '<button type="button" class="tab' . $active_class . '" data-tab="' . esc_attr($slug) . '" data-step="'.$i.'" role="tab" aria-selected="' . $aria_selected . '">'; |
| | | echo '<span class="step-number">' . $i . '</span>'; |
| | | echo '<h2>' . esc_html($section['label'] ?? $section) . '</h2>'; |
| | | echo '<span>' . esc_html($section['label'] ?? $section) . '</span>'; |
| | | echo '</button>'; |
| | | $i++; |
| | | } |
| | |
| | | } |
| | | |
| | | // Add step navigation buttons |
| | | echo '<div class="step-navigation row btw">'; |
| | | echo '<div class="step-navigation row x-btw">'; |
| | | |
| | | if ($i > 0) { |
| | | echo '<button type="button" class="button secondary prev-step" data-action="prev-step">'; |
| | |
| | | */ |
| | | protected function renderTurnstile(): void |
| | | { |
| | | if (!Features::hasIntegration('cloudflare')) { |
| | | if (!Site::hasIntegration('cloudflare')) { |
| | | return; |
| | | } |
| | | |