| @@ -29,38 +29,11 @@ | ||
| 29 | 29 | * @since 0.0.1 |
| 30 | 30 | */ |
| 31 | 31 | public function __construct() { |
| 32 | 32 | add_action( 'wp_enqueue_scripts', [ $this, 'register_frontend_assets' ] ); |
| 33 | - // Progressive-enhancement gate: mark that JS is available before the body | |
| 34 | - // paints, so enhanced fields (e.g. the dropdown) can hide their native | |
| 35 | - // control and show a matching placeholder without a flash. The native | |
| 36 | - // control stays visible when this class is absent (JS disabled/failed). | |
| 37 | - add_action( 'wp_head', [ $this, 'print_js_gate' ], 1 ); | |
| 38 | 33 | } |
| 39 | 34 | |
| 40 | 35 | /** |
| 41 | - * Print the progressive-enhancement gate inline in the head. | |
| 42 | - * | |
| 43 | - * A one-liner that adds the `suredonation-js` class to <html> synchronously, | |
| 44 | - * before the body renders. The class only has a visual effect where a | |
| 45 | - * SureDonation field stylesheet is loaded, so printing it on every front-end | |
| 46 | - * page is harmless and keeps the fix independent of where forms are embedded. | |
| 47 | - * | |
| 48 | - * @return void | |
| 49 | - * @since 1.1.1 | |
| 50 | - */ | |
| 51 | - public function print_js_gate() { | |
| 52 | - if ( is_admin() ) { | |
| 53 | - return; | |
| 54 | - } | |
| 55 | - | |
| 56 | - wp_print_inline_script_tag( | |
| 57 | - "document.documentElement.classList.add('suredonation-js');", | |
| 58 | - [ 'id' => 'suredonation-js-gate' ] | |
| 59 | - ); | |
| 60 | - } | |
| 61 | - | |
| 62 | - /** | |
| 63 | 36 | * Register frontend assets. |
| 64 | 37 | * |
| 65 | 38 | * @return void |
| 66 | 39 | * @since 0.0.1 |
| @@ -117,78 +90,8 @@ | ||
| 117 | 90 | 'suredonation-inputmask', |
| 118 | 91 | SUREDONATION_URL . 'assets/js/vendor/inputmask.min.js', |
| 119 | 92 | [], |
| 120 | 93 | SUREDONATION_VER, |
| 121 | - true | |
| 122 | - ); | |
| 123 | - | |
| 124 | - // Register the tom-select library (vendored) + its styles. | |
| 125 | - // Enqueued conditionally by the dropdown block render only when present. | |
| 126 | - wp_register_style( | |
| 127 | - 'suredonation-tom-select', | |
| 128 | - SUREDONATION_URL . 'assets/css/vendor/tom-select.css', | |
| 129 | - [], | |
| 130 | - SUREDONATION_VER | |
| 131 | - ); | |
| 132 | - | |
| 133 | - wp_register_script( | |
| 134 | - 'suredonation-tom-select', | |
| 135 | - SUREDONATION_URL . 'assets/js/vendor/tom-select.min.js', | |
| 136 | - [], | |
| 137 | - SUREDONATION_VER, | |
| 138 | - true | |
| 139 | - ); | |
| 140 | - | |
| 141 | - // Register the dropdown initializer. Depends on tom-select so enqueuing | |
| 142 | - // the dropdown handle pulls the library in, in the right order. | |
| 143 | - $dropdown_asset_file = SUREDONATION_DIR . 'assets/build/blocks/dropdown/frontend.asset.php'; | |
| 144 | - $dropdown_asset = file_exists( $dropdown_asset_file ) | |
| 145 | - ? require $dropdown_asset_file | |
| 146 | - : [ | |
| 147 | - 'dependencies' => [], | |
| 148 | - 'version' => SUREDONATION_VER, | |
| 149 | - ]; | |
| 150 | - | |
| 151 | - wp_register_script( | |
| 152 | - 'suredonation-dropdown', | |
| 153 | - SUREDONATION_URL . 'assets/build/blocks/dropdown/frontend.js', | |
| 154 | - array_merge( $dropdown_asset['dependencies'], [ 'suredonation-tom-select', 'wp-a11y' ] ), | |
| 155 | - $dropdown_asset['version'], | |
| 156 | - true | |
| 157 | - ); | |
| 158 | - | |
| 159 | - // Register the intl-tel-input library (vendored) + its styles. | |
| 160 | - // Enqueued conditionally by the phone block render only when present. | |
| 161 | - wp_register_style( | |
| 162 | - 'suredonation-intl-tel-input', | |
| 163 | - SUREDONATION_URL . 'assets/css/vendor/intl/intlTelInput.min.css', | |
| 164 | - [], | |
| 165 | - SUREDONATION_VER | |
| 166 | - ); | |
| 167 | - | |
| 168 | - wp_register_script( | |
| 169 | - 'suredonation-intl-tel-input', | |
| 170 | - SUREDONATION_URL . 'assets/js/vendor/intl/intTelInputWithUtils.min.js', | |
| 171 | - [], | |
| 172 | - SUREDONATION_VER, | |
| 173 | - true | |
| 174 | - ); | |
| 175 | - | |
| 176 | - // Register the phone initializer. Depends on intl-tel-input so enqueuing | |
| 177 | - // the phone handle pulls the library in, in the right order. | |
| 178 | - $phone_asset_file = SUREDONATION_DIR . 'assets/build/blocks/phone/frontend.asset.php'; | |
| 179 | - $phone_asset = file_exists( $phone_asset_file ) | |
| 180 | - ? require $phone_asset_file | |
| 181 | - : [ | |
| 182 | - 'dependencies' => [], | |
| 183 | - 'version' => SUREDONATION_VER, | |
| 184 | - ]; | |
| 185 | - | |
| 186 | - wp_register_script( | |
| 187 | - 'suredonation-phone', | |
| 188 | - SUREDONATION_URL . 'assets/build/blocks/phone/frontend.js', | |
| 189 | - array_merge( $phone_asset['dependencies'], [ 'suredonation-intl-tel-input' ] ), | |
| 190 | - $phone_asset['version'], | |
| 191 | 94 | true |
| 192 | 95 | ); |
| 193 | 96 | } |
| 194 | 97 | } |