assets
1 week ago
BuilderPanel.php
1 week ago
Compiler.php
1 week ago
Engine.php
1 week ago
FrontendEnqueue.php
1 week ago
Migrator.php
1 week ago
Palettes.php
1 week ago
PreviewDraft.php
1 week ago
RestController.php
1 week ago
Sanitizer.php
1 week ago
Schema.php
1 week ago
Templates.php
1 week ago
Engine.php
92 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Style Customizer v2 — Engine gate. |
| 4 | * |
| 5 | * The single place that answers "is v2 active?" and "is this form a v2 form?". v2 is ON by |
| 6 | * default; {@see self::enabled()} only exposes an off-switch. |
| 7 | * |
| 8 | * @package EverestForms\Addons\StyleCustomizer\V2 |
| 9 | * @since x.x.x |
| 10 | */ |
| 11 | |
| 12 | namespace EverestForms\Addons\StyleCustomizer\V2; |
| 13 | |
| 14 | defined( 'ABSPATH' ) || exit; |
| 15 | |
| 16 | /** |
| 17 | * The v2 feature gate. |
| 18 | */ |
| 19 | final class Engine { |
| 20 | |
| 21 | /** |
| 22 | * Is the v2 engine enabled? ON by default; `EVF_STYLE_V2` and the `evf_style_v2_enabled` |
| 23 | * filter are the off-switch. |
| 24 | * |
| 25 | * @return bool |
| 26 | */ |
| 27 | public static function enabled() { |
| 28 | $enabled = defined( 'EVF_STYLE_V2' ) ? (bool) \EVF_STYLE_V2 : true; |
| 29 | |
| 30 | /** |
| 31 | * Filter whether the Style Customizer v2 engine is active. |
| 32 | * |
| 33 | * @param bool $enabled Whether v2 is active (default true). |
| 34 | */ |
| 35 | return (bool) apply_filters( 'evf_style_v2_enabled', $enabled ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Is a stored record a v2 record? Derived from the presence of `schema_version`. |
| 40 | * |
| 41 | * @param mixed $record Stored `everest_forms_styles[form_id]` record. |
| 42 | * @return bool |
| 43 | */ |
| 44 | public static function is_v2_record( $record ) { |
| 45 | return is_array( $record ) && isset( $record['schema_version'] ); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Is the Pro tier active? The single, server-side authoritative gate for every pro-tier |
| 50 | * feature; defaults to whether Everest Forms Pro is loaded, filterable to a licence check. |
| 51 | * |
| 52 | * @return bool |
| 53 | */ |
| 54 | public static function pro_active() { |
| 55 | /** |
| 56 | * Filter whether the Style Customizer v2 Pro tier is active. |
| 57 | * |
| 58 | * @param bool $active Default: the Everest Forms Pro plugin is loaded. |
| 59 | */ |
| 60 | return (bool) apply_filters( 'evf_style_v2_pro_active', defined( 'EFP_PLUGIN_FILE' ) ); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Boot the v2 engine. No-op unless enabled; safe to call more than once. |
| 65 | */ |
| 66 | public static function boot() { |
| 67 | if ( ! self::enabled() ) { |
| 68 | return; |
| 69 | } |
| 70 | |
| 71 | // Engine-aware frontend rendering (v2-compiled vs legacy per form). |
| 72 | FrontendEnqueue::register(); |
| 73 | |
| 74 | // Reusable custom colour palettes (registers the schema filter; must run before REST). |
| 75 | Palettes::register(); |
| 76 | |
| 77 | // REST read/save for the builder panel. |
| 78 | RestController::register(); |
| 79 | |
| 80 | // Live Fields → Style sync for the style-preview iframe. |
| 81 | PreviewDraft::register(); |
| 82 | |
| 83 | // Builder "Style" tab + React panel. |
| 84 | BuilderPanel::register(); |
| 85 | |
| 86 | /** |
| 87 | * Fires once the v2 engine boots. |
| 88 | */ |
| 89 | do_action( 'evf_style_v2_booted' ); |
| 90 | } |
| 91 | } |
| 92 |