PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.2.89
WindPress – Tailwind CSS integration for WordPress v3.2.89
3.2.89 3.2.88 3.2.87 3.2.86 3.2.85 3.2.84 3.2.83 3.2.82 3.2.81 trunk 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 All 143 releases
windpress / src / Core / Scanner / BuildState.php

BuildState.php in WindPress – Tailwind CSS integration for WordPress 3.2.89, at src/Core/Scanner/BuildState.php

47 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace WindPress\WindPress\Core\Scanner;
5
6 use RuntimeException;
7 class BuildState
8 {
9 private const OPTION = 'windpress_scan_build_state';
10 public static function get(): array
11 {
12 $state = get_option(self::OPTION, \false);
13 if (!is_array($state) || empty($state['generation'])) {
14 $initial = ['generation' => wp_generate_uuid4(), 'last_full_build' => null];
15 if ($state === \false) {
16 add_option(self::OPTION, $initial, '', \false);
17 } else {
18 update_option(self::OPTION, $initial, \false);
19 }
20 $state = get_option(self::OPTION, \false);
21 if (!is_array($state) || empty($state['generation'])) {
22 throw new RuntimeException(__('Unable to initialize the scan generation.', 'windpress'));
23 }
24 }
25 return $state;
26 }
27 public static function matches(string $generation): bool
28 {
29 return hash_equals(self::get()['generation'], $generation);
30 }
31 public static function complete_full_build(): void
32 {
33 $state = ['generation' => wp_generate_uuid4(), 'last_full_build' => (int) round(microtime(\true) * 1000)];
34 if (!update_option(self::OPTION, $state, \false)) {
35 throw new RuntimeException(__('Unable to save the scan generation.', 'windpress'));
36 }
37 }
38 public static function acquire(): ?string
39 {
40 return \WindPress\WindPress\Core\Scanner\ScanLock::acquire('cache-publication');
41 }
42 public static function release(string $token): void
43 {
44 \WindPress\WindPress\Core\Scanner\ScanLock::release('cache-publication', $token);
45 }
46 }
47