PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.8
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.8
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.8, at src/ai/consent/application/consent-handler.php

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