PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.9
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.9
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / ai-consent / application / consent-handler.php

consent-handler.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.9, at src/ai-consent/application/consent-handler.php

53 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\AI_Consent\Application;
4
5 use Yoast\WP\SEO\Helpers\User_Helper;
6
7 /**
8 * Class Consent_Handler
9 * Handles the consent given or revoked by the user.
10 *
11 * @makePublic
12 */
13 class Consent_Handler implements Consent_Handler_Interface {
14
15 /**
16 * Holds the user helper instance.
17 *
18 * @var User_Helper
19 */
20 private $user_helper;
21
22 /**
23 * Class constructor.
24 *
25 * @param User_Helper $user_helper The user helper.
26 */
27 public function __construct( User_Helper $user_helper ) {
28 $this->user_helper = $user_helper;
29 }
30
31 /**
32 * Handles consent revoked by deleting the consent user metadata from the database.
33 *
34 * @param int $user_id The user ID.
35 *
36 * @return void
37 */
38 public function revoke_consent( int $user_id ) {
39 $this->user_helper->delete_meta( $user_id, '_yoast_wpseo_ai_consent' );
40 }
41
42 /**
43 * Handles consent granted by adding the consent user metadata to the database.
44 *
45 * @param int $user_id The user ID.
46 *
47 * @return void
48 */
49 public function grant_consent( int $user_id ) {
50 $this->user_helper->update_meta( $user_id, '_yoast_wpseo_ai_consent', true );
51 }
52 }
53