PluginProbe
Extendify / 3.1.5
Extendify v3.1.5
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 / Shared / Controllers / SiteProfileController.php

SiteProfileController.php in Extendify 3.1.5, at app/Shared/Controllers/SiteProfileController.php

46 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Controls Site Profile options
5 */
6
7 namespace Extendify\Shared\Controllers;
8
9 defined('ABSPATH') || die('No direct access.');
10
11 use Extendify\Shared\Services\Sanitizer;
12
13 /**
14 * The controller for persisting site data
15 */
16
17 class SiteProfileController
18 {
19 /**
20 * Persist single data
21 *
22 * @param \WP_REST_Request $request - The request.
23 * @return \WP_REST_Response
24 */
25 public static function store($request)
26 {
27 $value = $request->get_param('siteProfile');
28 // sanitize_text_field() on the raw JSON entity-encodes from the first "<"
29 // to the end, corrupting it. Decode first so we sanitize fields, not JSON.
30 $siteProfile = is_string($value) ? json_decode($value, true) : $value;
31 \update_option('extendify_site_profile', Sanitizer::sanitizeUnknown($siteProfile));
32 return new \WP_REST_Response($siteProfile);
33 }
34
35 /**
36 * Get option data by name.
37 *
38 * @return \WP_REST_Response
39 */
40 public static function get()
41 {
42 $siteProfile = \get_option('extendify_site_profile', []);
43 return new \WP_REST_Response($siteProfile);
44 }
45 }
46