PluginProbe
Meow Gallery / 4.2.0
Meow Gallery v4.2.0
5.5.5 5.5.4 5.5.3 5.5.2 5.5.1 5.5.0 5.4.9 5.4.8 5.4.7 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 All 157 releases
meow-gallery / common / classes / rest_license.php

rest_license.php in Meow Gallery 4.2.0, at common/classes/rest_license.php

43 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class MeowCommon_Classes_Rest_License
4 {
5 private $licenser = null;
6 private $namespace = null;
7
8 public function __construct( &$licenser ) {
9 $this->licenser = $licenser;
10 $this->namespace = "meow-licenser/{$licenser->prefix}/v1";
11 add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
12 }
13
14 function rest_api_init() {
15 register_rest_route( $this->namespace, '/get_license/', [
16 'methods' => 'POST',
17 'permission_callback' => function () {
18 return current_user_can( 'administrator' );
19 },
20 'callback' => [ $this, 'get_license' ]
21 ]);
22 register_rest_route( $this->namespace, '/set_license/', [
23 'methods' => 'POST',
24 'permission_callback' => function () {
25 return current_user_can( 'administrator' );
26 },
27 'callback' => [ $this, 'set_license' ]
28 ]);
29 }
30
31 function get_license() {
32 return new WP_REST_Response( [ 'success' => true, 'data' => $this->licenser->license ], 200 );
33 }
34
35 function set_license( $request ) {
36 $params = $request->get_json_params();
37 $serialKey = $params['serialKey'];
38 $this->licenser->validate_pro( $serialKey );
39 return new WP_REST_Response( [ 'success' => true, 'data' => $this->licenser->license ], 200 );
40 }
41 }
42
43 ?>