PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.3.75
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.3.75
11.3.75 11.3.73 11.3.71 11.3.70 11.3.69 11.3.64 11.3.65 11.3.62 11.3.61 11.3.56 11.3.58 11.0.31 11.0.52 11.0.54 11.0.56 11.0.58 11.0.7 11.1.10 11.1.11 11.1.13 11.1.14 11.1.15 11.1.2 11.1.20 11.1.21 All 73 releases
leadin / public / admin / modules / api / class-user-meta-api-controller.php

class-user-meta-api-controller.php in HubSpot All-In-One Marketing – Forms, Popups, Live Chat 11.3.75, at public/admin/modules/api/class-user-meta-api-controller.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 namespace Leadin\admin\api;
4
5 use Leadin\api\Base_Api_Controller;
6 use Leadin\data\User_Metadata;
7
8 /**
9 * User meta review Api, used to set the user metadata.
10 */
11 class User_Meta_Api_Controller extends Base_Api_Controller {
12
13 /**
14 * Class constructor, register route.
15 */
16 public function __construct() {
17 self::register_leadin_route(
18 '/skip-review',
19 \WP_REST_Server::CREATABLE,
20 array( $this, 'skip_review' )
21 );
22 self::register_leadin_route(
23 '/track-consent',
24 \WP_REST_Server::CREATABLE,
25 array( $this, 'track_consent' )
26 );
27 }
28
29 /**
30 * Skip Review. Sets SKIP_REVIEW meta data for a user with current datetime.
31 */
32 public function skip_review() {
33 User_Metadata::set_skip_review( time() );
34 return new \WP_REST_Response( 'OK', 200 );
35 }
36
37 /**
38 * Used to set user consent on HubSpot anonymous tracking.
39 *
40 * @param array $request Request body.
41 */
42 public function track_consent( $request ) {
43 $data = json_decode( $request->get_body(), true );
44 if ( array_key_exists( 'canTrack', $data ) ) {
45 $consent = $data['canTrack'];
46 User_Metadata::set_track_consent( $consent ? 'true' : 'false' );
47 }
48 return new \WP_REST_Response(
49 wp_json_encode( User_Metadata::get_track_consent(), true ),
50 200
51 );
52 }
53
54 }
55