PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.20
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.20
1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 All 164 releases
← All changes | includes/Services/Settings/General_Section.php +37 -0 1.10.1 → 1.10.20 View file →
@@ -21,8 +21,17 @@
21 21 return 'general';
22 22 }
23 23
24 24 /**
25 + * Read by the Settings service on every request, so it rides in alloptions.
26 + *
27 + * @return bool
28 + */
29 + public function autoload(): bool {
30 + return true;
31 + }
32 +
33 + /**
25 34 * Section defaults.
26 35 */
27 36 public function defaults(): array {
28 37 return array(
@@ -42,8 +51,36 @@
42 51 'store_email' => '',
43 52 'policies_and_conditions' => '',
44 53 'store_tax_ids' => array(),
45 54 );
55 + }
56 +
57 + /**
58 + * The PERSISTED tracking consent, bypassing the read view.
59 + *
60 + * `read()` ends by applying `woocommerce_pos_general_settings`, so the
61 + * ordinary accessor lets any plugin filtering that hook manufacture a
62 + * consent the merchant never gave. Telemetry send-gates must ask the
63 + * database instead. Still runs `migrate()`, so a merchant whose choice
64 + * predates the move out of the legacy `tools` option is honoured rather
65 + * than silently switched off.
66 + *
67 + * Display and UI reads keep using the filtered accessor.
68 + *
69 + * Falls back to the section default rather than an empty string: the value
70 + * is mirrored to the POS client, whose schema expects one of the three
71 + * states, and `undecided` is the fail-closed one.
72 + *
73 + * @return string One of allowed|denied|undecided.
74 + */
75 + public function raw_tracking_consent(): string {
76 + $raw = $this->migrate( $this->read_raw() );
77 + $defaults = $this->defaults();
78 + $fallback = \is_string( $defaults['tracking_consent'] ?? null ) ? $defaults['tracking_consent'] : 'undecided';
79 +
80 + $consent = $raw['tracking_consent'] ?? $fallback;
81 +
82 + return \is_string( $consent ) ? $consent : $fallback;
46 83 }
47 84
48 85 /**
49 86 * Migrate tracking_consent from the legacy `tools` option if it was set