PluginProbe
ezCache / 1.2
ezCache v1.2
2.6.5 2.6.4 2.6.2 2.6.3 2.6.1 2.6.0 2.5.6 2.5.5 2.5.4 2.5.3 2.5.2 2.5.1 2.5 2.2.1 2.2.2 trunk 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.3 1.3.1 1.3.10 1.3.11 All 49 releases
ezcache / includes / Rest / LicenseController.php

LicenseController.php in ezCache 1.2, at includes/Rest/LicenseController.php

44 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Upress\EzCache\Rest;
3
4 use Upress\EzCache\LicenseApi;
5 use WP_REST_Request;
6
7 class LicenseController {
8 function show() {
9 $manager = new LicenseApi();
10 $key = $manager->get_masked_license_key();
11 $license_data = $manager->get_license_data( false );
12
13 return wp_send_json_success( array_merge( (array) $license_data, [ 'key' => $key ] ) );
14 }
15
16 /**
17 * @param WP_REST_Request $request
18 */
19 function update( $request ) {
20 $input = $request->get_json_params();
21 $key = isset( $input['licenseKey'] ) ? trim( strtoupper( $input['licenseKey'] ) ) : '';
22
23 $manager = new LicenseApi();
24 $license_data = $manager->update_license( $key );
25 if ( is_wp_error( $license_data ) ) {
26 return wp_send_json_error( $license_data );
27 }
28 $key = $manager->get_masked_license_key();
29
30 return wp_send_json_success( array_merge( (array) $license_data, [ 'key' => $key ] ) );
31 }
32
33 function destroy() {
34 $manager = new LicenseApi();
35 $response = $manager->clear_license();
36
37 if ( is_wp_error( $response ) ) {
38 return wp_send_json_error( $response );
39 }
40
41 return wp_send_json_success( $response );
42 }
43 }
44