PluginProbe
Extendify / 0.11.1
Extendify v0.11.1
3.2.1 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 All 127 releases
extendify / app / Onboarding / Controllers / DataController.php

DataController.php in Extendify 0.11.1, at app/Onboarding/Controllers/DataController.php

142 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Data Controller
4 */
5
6 namespace Extendify\Onboarding\Controllers;
7
8 use Extendify\Http;
9
10 if (!defined('ABSPATH')) {
11 die('No direct access.');
12 }
13
14 /**
15 * The controller for handling general data
16 */
17 class DataController
18 {
19 /**
20 * Get Site type information.
21 *
22 * @return \WP_REST_Response
23 */
24 public static function getSiteTypes()
25 {
26 $response = Http::get('/site-types');
27 return new \WP_REST_Response(
28 $response,
29 wp_remote_retrieve_response_code($response)
30 );
31 }
32
33 /**
34 * Get styles with code template.
35 *
36 * @param \WP_REST_Request $request - The request.
37 * @return \WP_REST_Response
38 */
39 public static function getStyles($request)
40 {
41 $siteType = $request->get_param('siteType');
42 $styles = $request->get_param('styles');
43 $response = Http::get('/styles', [
44 'siteType' => $siteType,
45 'styles' => $styles,
46 ]);
47 return new \WP_REST_Response(
48 $response,
49 wp_remote_retrieve_response_code($response)
50 );
51 }
52 /**
53 * Get styles with code template.
54 *
55 * @param \WP_REST_Request $request - The request.
56 * @return \WP_REST_Response
57 */
58 public static function getTemplate($request)
59 {
60 $response = Http::get('/templates', $request->get_params());
61 if (\is_wp_error($response)) {
62 // TODO: Maybe handle errors better here, or higher up in the Http class.
63 wp_send_json_error(['message' => $response->get_error_message()], 400);
64 }
65
66 return new \WP_REST_Response(
67 $response,
68 wp_remote_retrieve_response_code($response)
69 );
70 }
71
72 /**
73 * Get Site type information.
74 *
75 * @return \WP_REST_Response
76 */
77 public static function getLayoutTypes()
78 {
79 $response = Http::get('/layout-types');
80 return new \WP_REST_Response(
81 $response,
82 wp_remote_retrieve_response_code($response)
83 );
84 }
85
86 /**
87 * Get Goals information.
88 *
89 * @return \WP_REST_Response
90 */
91 public static function getGoals()
92 {
93 $response = Http::get('/goals');
94 return new \WP_REST_Response(
95 $response,
96 wp_remote_retrieve_response_code($response)
97 );
98 }
99
100 /**
101 * Get Goals information.
102 *
103 * @return \WP_REST_Response
104 */
105 public static function getSuggestedPlugins()
106 {
107 $response = Http::get('/suggested-plugins');
108 return new \WP_REST_Response(
109 $response,
110 wp_remote_retrieve_response_code($response)
111 );
112 }
113
114 /**
115 * Create an order.
116 *
117 * @return \WP_REST_Response
118 */
119 public static function createOrder()
120 {
121 $response = Http::post('/create-order');
122 return new \WP_REST_Response(
123 $response,
124 wp_remote_retrieve_response_code($response)
125 );
126 }
127
128 /**
129 * Fetch exit questions
130 *
131 * @return \WP_REST_Response
132 */
133 public static function exitQuestions()
134 {
135 $response = Http::get('/exit-questions');
136 return new \WP_REST_Response(
137 $response,
138 wp_remote_retrieve_response_code($response)
139 );
140 }
141 }
142