PluginProbe
Extendify / 0.10.2
Extendify v0.10.2
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 / WPController.php

WPController.php in Extendify 0.10.2, at app/Onboarding/Controllers/WPController.php

65 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WP Controller
4 */
5
6 namespace Extendify\Onboarding\Controllers;
7
8 if (!defined('ABSPATH')) {
9 die('No direct access.');
10 }
11
12 /**
13 * The controller for interacting with WordPress.
14 */
15 class WPController
16 {
17
18 /**
19 * Parse theme.json file.
20 *
21 * @param \WP_REST_Request $request - The request.
22 * @return \WP_REST_Response
23 */
24 public static function parseThemeJson($request)
25 {
26 if (!$request->get_param('themeJson')) {
27 return new \WP_Error('invalid_theme_json', __('Invalid Theme.json file', 'extendify'));
28 }
29
30 $themeJson = new \WP_Theme_JSON(json_decode($request->get_param('themeJson'), true), '');
31 return new \WP_REST_Response([
32 'success' => true,
33 'styles' => $themeJson->get_stylesheet(),
34 ]);
35 }
36
37 /**
38 * Persist the data
39 *
40 * @param \WP_REST_Request $request - The request.
41 * @return \WP_REST_Response
42 */
43 public static function updateOption($request)
44 {
45 $params = $request->get_json_params();
46 \update_option($params['option'], $params['value']);
47 return new \WP_REST_Response(['success' => true]);
48 }
49
50 /**
51 * Get a setting from the options table
52 *
53 * @param \WP_REST_Request $request - The request.
54 * @return \WP_REST_Response
55 */
56 public static function getOption($request)
57 {
58 $value = \get_option($request->get_param('option'), null);
59 return new \WP_REST_Response([
60 'success' => true,
61 'data' => $value,
62 ]);
63 }
64 }
65