PluginProbe
Extendify / 0.10.1
Extendify v0.10.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.10.1, at app/Onboarding/Controllers/DataController.php

107 lines 2.4 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($response);
28 }
29
30 /**
31 * Get styles with code template.
32 *
33 * @param \WP_REST_Request $request - The request.
34 * @return \WP_REST_Response
35 */
36 public static function getStyles($request)
37 {
38 $siteType = $request->get_param('siteType');
39 $styles = $request->get_param('styles');
40 $response = Http::get('/styles', [
41 'siteType' => $siteType,
42 'styles' => $styles,
43 ]);
44 return new \WP_REST_Response($response);
45 }
46 /**
47 * Get styles with code template.
48 *
49 * @param \WP_REST_Request $request - The request.
50 * @return \WP_REST_Response
51 */
52 public static function getTemplate($request)
53 {
54 $response = Http::get('/templates', $request->get_params());
55 if (\is_wp_error($response)) {
56 // TODO: Maybe handle errors better here, or higher up in the Http class.
57 wp_send_json_error(['message' => $response->get_error_message()], 400);
58 }
59
60 return new \WP_REST_Response($response);
61 }
62
63 /**
64 * Get Site type information.
65 *
66 * @return \WP_REST_Response
67 */
68 public static function getLayoutTypes()
69 {
70 $response = Http::get('/layout-types');
71 return new \WP_REST_Response($response);
72 }
73
74 /**
75 * Get Goals information.
76 *
77 * @return \WP_REST_Response
78 */
79 public static function getGoals()
80 {
81 $response = Http::get('/goals');
82 return new \WP_REST_Response($response);
83 }
84
85 /**
86 * Get Goals information.
87 *
88 * @return \WP_REST_Response
89 */
90 public static function getSuggestedPlugins()
91 {
92 $response = Http::get('/suggested-plugins');
93 return new \WP_REST_Response($response);
94 }
95
96 /**
97 * Create an order.
98 *
99 * @return \WP_REST_Response
100 */
101 public static function createOrder()
102 {
103 $response = Http::post('/create-order');
104 return new \WP_REST_Response($response);
105 }
106 }
107