|
20 | 20 | use EightshiftForms\CustomPostType\Forms; |
21 | 21 | use EightshiftForms\Enqueue\SharedEnqueue; |
22 | 22 | use EightshiftForms\Enqueue\Captcha\EnqueueCaptcha; |
| 23 | +use EightshiftForms\Geolocation\GeolocationInterface; |
23 | 24 | use EightshiftForms\Geolocation\SettingsGeolocation; |
24 | 25 | use EightshiftForms\Hooks\FiltersOutputMock; |
25 | 26 | use EightshiftForms\Validation\ValidationPatterns; |
@@ -47,14 +48,23 @@ class EnqueueBlocks extends AbstractEnqueueBlocks |
47 | 48 | */ |
48 | 49 | protected EnrichmentInterface $enrichment; |
49 | 50 |
|
| 51 | + /** |
| 52 | + * Instance variable of geolocation data. |
| 53 | + * |
| 54 | + * @var GeolocationInterface |
| 55 | + */ |
| 56 | + protected GeolocationInterface $geolocation; |
| 57 | + |
50 | 58 | /** |
51 | 59 | * Create a new admin instance. |
52 | 60 | * |
53 | 61 | * @param EnrichmentInterface $enrichment Inject enrichment which holds data about for storing to enrichment. |
| 62 | + * @param GeolocationInterface $geolocation Inject geolocation which holds data about for storing to geolocation. |
54 | 63 | */ |
55 | | - public function __construct(EnrichmentInterface $enrichment) |
| 64 | + public function __construct(EnrichmentInterface $enrichment, GeolocationInterface $geolocation) |
56 | 65 | { |
57 | 66 | $this->enrichment = $enrichment; |
| 67 | + $this->geolocation = $geolocation; |
58 | 68 | } |
59 | 69 |
|
60 | 70 | /** |
@@ -316,6 +326,7 @@ public function enqueueBlockFrontendScript(): void |
316 | 326 | // Geolocation config. |
317 | 327 | $output['geolocation'] = [ |
318 | 328 | 'isUsed' => \apply_filters(SettingsGeolocation::FILTER_SETTINGS_GLOBAL_IS_VALID_NAME, false), |
| 329 | + 'location' => $this->geolocation->getUsersGeolocation(), |
319 | 330 | ]; |
320 | 331 |
|
321 | 332 | // Check if Captcha data is set and valid. |
|
0 commit comments