PluginProbe
Extendify / 0.9.3
Extendify v0.9.3
3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 0.7.0 All 126 releases
extendify / app / Library / Controllers / UserController.php

UserController.php in Extendify 0.9.3, at app/Library/Controllers/UserController.php

92 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Controls User info
4 */
5
6 namespace Extendify\Library\Controllers;
7
8 use Extendify\Http;
9 use Extendify\User;
10
11 if (!defined('ABSPATH')) {
12 die('No direct access.');
13 }
14
15 /**
16 * The controller for managing user data like API keys, etc
17 */
18 class UserController
19 {
20
21 /**
22 * Return the current user state
23 *
24 * @return array
25 */
26 public static function show()
27 {
28 return new \WP_REST_Response(User::state());
29 }
30
31 /**
32 * Return meta info about the current user
33 *
34 * @param \WP_REST_Request $request - The request.
35 * @return array
36 */
37 public static function meta($request)
38 {
39 $key = \sanitize_text_field(\wp_unslash($request->get_param('key')));
40 return new \WP_REST_Response(User::data($key));
41 }
42
43 /**
44 * Persist the data
45 *
46 * @param \WP_REST_Request $request - The request.
47 * @return array
48 */
49 public static function store($request)
50 {
51 $userData = json_decode($request->get_param('data'), true);
52 // Keep this key for historical reasons.
53 \update_user_meta(\get_current_user_id(), 'extendifysdk_user_data', $userData);
54
55 return new \WP_REST_Response(User::state());
56 }
57
58 /**
59 * Delete the data
60 *
61 * @return array
62 */
63 public static function delete()
64 {
65 \delete_user_meta(\get_current_user_id(), 'extendifysdk_user_data');
66 return new \WP_REST_Response(User::state());
67 }
68
69 /**
70 * Sign up the user to the mailing list.
71 *
72 * @param \WP_REST_Request $request - The request.
73 * @return WP_REST_Response|WP_Error
74 */
75 public static function mailingList($request)
76 {
77 $response = Http::post('/register-mailing-list', $request->get_params());
78 return new \WP_REST_Response($response);
79 }
80
81 /**
82 * Get the max imports
83 *
84 * @return WP_REST_Response|WP_Error
85 */
86 public static function maxImports()
87 {
88 $response = Http::get('/max-free-imports');
89 return new \WP_REST_Response($response);
90 }
91 }
92