You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: use SPARXSTAR_GLUON_COOKIE_TOKEN constant and integrate WP Consent API
- gluonRegisterCookies(): use self::SPARXSTAR_GLUON_COOKIE_TOKEN instead
of hardcoded '__Host-SparxstarGluon-TOKEN' to avoid registration/removal
drift when the scaffold is renamed.
- Add gluonSetTokenCookie(): consent-gated cookie writer; returns false and
writes nothing if the user has not granted functional consent or if
headers are already sent.
- Add gluonDeleteTokenCookie(): expires the cookie immediately and removes
it from $_COOKIE so callers see the change in the same request.
- Add gluonHandleConsentChange(): hooked on wp_set_consent; deletes the
token cookie the moment functional consent is withdrawn.
- Register wp_set_consent hook in gluonRegisterHooks().
Co-authored-by: MaximillianGroup <34328348+MaximillianGroup@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Starisian-Technologies/sparxstar-gluon/sessions/7b663b48-d6c7-4749-89fb-35939ca1fd1a
if ( ! $this->gluonIsConsentCategory( 'functional' ) ) {
191
+
returnfalse;
192
+
}
193
+
if ( headers_sent() ) {
194
+
returnfalse;
195
+
}
196
+
returnsetcookie(
197
+
self::SPARXSTAR_GLUON_COOKIE_TOKEN,
198
+
$token_value,
199
+
array(
200
+
'expires' => $expires,
201
+
'path' => '/',
202
+
'domain' => '',
203
+
'secure' => true,
204
+
'httponly' => true,
205
+
'samesite' => 'Strict',
206
+
)
207
+
);
208
+
}
209
+
210
+
/**
211
+
* Delete the plugin token cookie.
212
+
*
213
+
* Expires the cookie immediately and removes it from the current request's
214
+
* $_COOKIE superglobal so callers see the change without a page reload.
215
+
* Safe to call even when the cookie is not present.
216
+
*
217
+
* @since 1.0.0
218
+
* @return void
219
+
*/
220
+
publicfunctiongluonDeleteTokenCookie(): void {
221
+
if ( ! isset( $_COOKIE[ self::SPARXSTAR_GLUON_COOKIE_TOKEN ] ) ) {
222
+
return;
223
+
}
224
+
if ( ! headers_sent() ) {
225
+
setcookie(
226
+
self::SPARXSTAR_GLUON_COOKIE_TOKEN,
227
+
'',
228
+
array(
229
+
'expires' => time() - HOUR_IN_SECONDS,
230
+
'path' => '/',
231
+
'domain' => '',
232
+
'secure' => true,
233
+
'httponly' => true,
234
+
'samesite' => 'Strict',
235
+
)
236
+
);
237
+
}
238
+
unset( $_COOKIE[ self::SPARXSTAR_GLUON_COOKIE_TOKEN ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- key lookup only, no value used
239
+
}
240
+
241
+
/**
242
+
* React to WordPress Consent API consent changes.
243
+
*
244
+
* Fires on the `wp_set_consent` action. When functional consent is denied or
245
+
* withdrawn the token cookie is immediately deleted so no functional cookie
246
+
* persists without the user's agreement.
247
+
*
248
+
* @since 1.0.0
249
+
* @param string $category The consent category that changed (e.g. 'functional').
250
+
* @param string $value The new consent value ('allow' | 'deny').
0 commit comments