# extendify/0.10.2/app/Onboarding/Controllers/WPController.php

Extendify, version 0.10.2. 65 lines.

- Page: https://pluginprobe.com/plugins/extendify/0.10.2/code/app/Onboarding/Controllers/WPController.php
- Raw: https://pluginprobe.com/plugins/extendify/0.10.2/raw/app/Onboarding/Controllers/WPController.php
- Modified: 2022-09-20T18:01:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/0.10.2/code/app/Onboarding/Controllers/WPController.php#L10-L20`.

```php
<?php
/**
 * WP Controller
 */

namespace Extendify\Onboarding\Controllers;

if (!defined('ABSPATH')) {
    die('No direct access.');
}

/**
 * The controller for interacting with WordPress.
 */
class WPController
{

    /**
     * Parse theme.json file.
     *
     * @param \WP_REST_Request $request - The request.
     * @return \WP_REST_Response
     */
    public static function parseThemeJson($request)
    {
        if (!$request->get_param('themeJson')) {
            return new \WP_Error('invalid_theme_json', __('Invalid Theme.json file', 'extendify'));
        }

        $themeJson = new \WP_Theme_JSON(json_decode($request->get_param('themeJson'), true), '');
        return new \WP_REST_Response([
            'success' => true,
            'styles' => $themeJson->get_stylesheet(),
        ]);
    }

    /**
     * Persist the data
     *
     * @param \WP_REST_Request $request - The request.
     * @return \WP_REST_Response
     */
    public static function updateOption($request)
    {
        $params = $request->get_json_params();
        \update_option($params['option'], $params['value']);
        return new \WP_REST_Response(['success' => true]);
    }

    /**
     * Get a setting from the options table
     *
     * @param \WP_REST_Request $request - The request.
     * @return \WP_REST_Response
     */
    public static function getOption($request)
    {
        $value = \get_option($request->get_param('option'), null);
        return new \WP_REST_Response([
            'success' => true,
            'data' => $value,
        ]);
    }
}

```
