@@ -6,5 +6,5 @@ |
||
6 | 6 | $baseDir = dirname($vendorDir); |
7 | 7 | |
8 | 8 | return array( |
9 | - 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', |
|
9 | + 'Composer\\InstalledVersions' => $vendorDir.'/composer/InstalledVersions.php', |
|
10 | 10 | ); |
@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInit74415885e7c3fa89b174bf8bc3b1fc6d |
8 | 8 | { |
9 | - public static $prefixLengthsPsr4 = array ( |
|
9 | + public static $prefixLengthsPsr4 = array( |
|
10 | 10 | 'W' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'Wordlift\\Modules\\Redeem_Code\\' => 29, |
13 | 13 | ), |
14 | 14 | ); |
15 | 15 | |
16 | - public static $prefixDirsPsr4 = array ( |
|
16 | + public static $prefixDirsPsr4 = array( |
|
17 | 17 | 'Wordlift\\Modules\\Redeem_Code\\' => |
18 | - array ( |
|
19 | - 0 => __DIR__ . '/../..' . '/includes', |
|
18 | + array( |
|
19 | + 0 => __DIR__.'/../..'.'/includes', |
|
20 | 20 | ), |
21 | 21 | ); |
22 | 22 | |
23 | - public static $classMap = array ( |
|
24 | - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
|
23 | + public static $classMap = array( |
|
24 | + 'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php', |
|
25 | 25 | ); |
26 | 26 | |
27 | 27 | public static function getInitializer(ClassLoader $loader) |
28 | 28 | { |
29 | - return \Closure::bind(function () use ($loader) { |
|
29 | + return \Closure::bind(function() use ($loader) { |
|
30 | 30 | $loader->prefixLengthsPsr4 = ComposerStaticInit74415885e7c3fa89b174bf8bc3b1fc6d::$prefixLengthsPsr4; |
31 | 31 | $loader->prefixDirsPsr4 = ComposerStaticInit74415885e7c3fa89b174bf8bc3b1fc6d::$prefixDirsPsr4; |
32 | 32 | $loader->classMap = ComposerStaticInit74415885e7c3fa89b174bf8bc3b1fc6d::$classMap; |
@@ -6,5 +6,5 @@ |
||
6 | 6 | $baseDir = dirname($vendorDir); |
7 | 7 | |
8 | 8 | return array( |
9 | - 'Wordlift\\Modules\\Redeem_Code\\' => array($baseDir . '/includes'), |
|
9 | + 'Wordlift\\Modules\\Redeem_Code\\' => array($baseDir.'/includes'), |
|
10 | 10 | ); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | public static function loadClassLoader($class) |
10 | 10 | { |
11 | 11 | if ('Composer\Autoload\ClassLoader' === $class) { |
12 | - require __DIR__ . '/ClassLoader.php'; |
|
12 | + require __DIR__.'/ClassLoader.php'; |
|
13 | 13 | } |
14 | 14 | } |
15 | 15 | |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | return self::$loader; |
23 | 23 | } |
24 | 24 | |
25 | - require __DIR__ . '/platform_check.php'; |
|
25 | + require __DIR__.'/platform_check.php'; |
|
26 | 26 | |
27 | 27 | spl_autoload_register(array('ComposerAutoloaderInit74415885e7c3fa89b174bf8bc3b1fc6d', 'loadClassLoader'), true, true); |
28 | 28 | self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); |
29 | 29 | spl_autoload_unregister(array('ComposerAutoloaderInit74415885e7c3fa89b174bf8bc3b1fc6d', 'loadClassLoader')); |
30 | 30 | |
31 | - require __DIR__ . '/autoload_static.php'; |
|
31 | + require __DIR__.'/autoload_static.php'; |
|
32 | 32 | call_user_func(\Composer\Autoload\ComposerStaticInit74415885e7c3fa89b174bf8bc3b1fc6d::getInitializer($loader)); |
33 | 33 | |
34 | 34 | $loader->register(true); |
@@ -19,21 +19,21 @@ |
||
19 | 19 | * @return void |
20 | 20 | */ |
21 | 21 | function __wl_redeem_code() { |
22 | - // Autoloader for plugin itself. |
|
22 | + // Autoloader for plugin itself. |
|
23 | 23 | |
24 | - if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
|
25 | - require_once __DIR__ . '/vendor/autoload.php'; |
|
26 | - } |
|
24 | + if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
|
25 | + require_once __DIR__ . '/vendor/autoload.php'; |
|
26 | + } |
|
27 | 27 | |
28 | - $container_builder = new ContainerBuilder(); |
|
29 | - $loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
30 | - $loader->load( 'services.yml' ); |
|
31 | - $container_builder->compile(); |
|
28 | + $container_builder = new ContainerBuilder(); |
|
29 | + $loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
30 | + $loader->load( 'services.yml' ); |
|
31 | + $container_builder->compile(); |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var $rest_controller Rest_Controller |
|
35 | - */ |
|
36 | - $rest_controller = $container_builder->get( 'Wordlift\Modules\Redeem_Code\Rest_Controller' ); |
|
37 | - $rest_controller->register_hooks(); |
|
33 | + /** |
|
34 | + * @var $rest_controller Rest_Controller |
|
35 | + */ |
|
36 | + $rest_controller = $container_builder->get( 'Wordlift\Modules\Redeem_Code\Rest_Controller' ); |
|
37 | + $rest_controller->register_hooks(); |
|
38 | 38 | } |
39 | 39 | __wl_redeem_code(); |
@@ -21,19 +21,19 @@ |
||
21 | 21 | function __wl_redeem_code() { |
22 | 22 | // Autoloader for plugin itself. |
23 | 23 | |
24 | - if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
|
25 | - require_once __DIR__ . '/vendor/autoload.php'; |
|
24 | + if (file_exists(__DIR__.'/vendor/autoload.php')) { |
|
25 | + require_once __DIR__.'/vendor/autoload.php'; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | $container_builder = new ContainerBuilder(); |
29 | - $loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
30 | - $loader->load( 'services.yml' ); |
|
29 | + $loader = new YamlFileLoader($container_builder, new FileLocator(__DIR__)); |
|
30 | + $loader->load('services.yml'); |
|
31 | 31 | $container_builder->compile(); |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @var $rest_controller Rest_Controller |
35 | 35 | */ |
36 | - $rest_controller = $container_builder->get( 'Wordlift\Modules\Redeem_Code\Rest_Controller' ); |
|
36 | + $rest_controller = $container_builder->get('Wordlift\Modules\Redeem_Code\Rest_Controller'); |
|
37 | 37 | $rest_controller->register_hooks(); |
38 | 38 | } |
39 | 39 | __wl_redeem_code(); |
@@ -7,150 +7,150 @@ |
||
7 | 7 | |
8 | 8 | class Rest_Controller { |
9 | 9 | |
10 | - /** |
|
11 | - * @var Wordlift_Configuration_Service |
|
12 | - */ |
|
13 | - |
|
14 | - private $configuration_service; |
|
15 | - |
|
16 | - public function __construct() { |
|
17 | - $this->configuration_service = Wordlift_Configuration_Service::get_instance(); |
|
18 | - } |
|
19 | - |
|
20 | - public function register_hooks() { |
|
21 | - add_action( 'rest_api_init', array( $this, 'rest_api_init' ) ); |
|
22 | - } |
|
23 | - |
|
24 | - public function rest_api_init() { |
|
25 | - register_rest_route( |
|
26 | - WL_REST_ROUTE_DEFAULT_NAMESPACE, |
|
27 | - '/redeem-codes', |
|
28 | - array( |
|
29 | - 'methods' => 'POST', |
|
30 | - 'callback' => array( $this, 'create_sync' ), |
|
31 | - 'args' => array( |
|
32 | - 'redeem_code' => array( |
|
33 | - 'required' => true, |
|
34 | - 'validate_callback' => 'rest_validate_request_arg', |
|
35 | - ), |
|
36 | - 'enable_diagnostics' => array( |
|
37 | - 'required' => true, |
|
38 | - 'validate_callback' => 'rest_validate_request_arg', |
|
39 | - ), |
|
40 | - ), |
|
41 | - 'permission_callback' => function () { |
|
42 | - return current_user_can( 'manage_options' ); |
|
43 | - }, |
|
44 | - ) |
|
45 | - ); |
|
46 | - |
|
47 | - /** |
|
48 | - * POST /redeem-codes |
|
49 | - * Accept: application/json |
|
50 | - * Content-Type: application/json |
|
51 | - * |
|
52 | - * { "redeem_code": "a_redeem_code" } |
|
53 | - * |
|
54 | - * |
|
55 | - * Successful Response: |
|
56 | - * |
|
57 | - * Content-Type: application/json |
|
58 | - * |
|
59 | - * { "key": "a_key" } |
|
60 | - * |
|
61 | - * |
|
62 | - * Unsuccessful Response: |
|
63 | - * |
|
64 | - * Content-Type: application/json |
|
65 | - * |
|
66 | - * { |
|
67 | - * "title": "Invalid Redeem Code", |
|
68 | - * "status": 404, |
|
69 | - * "detail": "The redeem code is invalid, check for typos or try with another code." |
|
70 | - * } |
|
71 | - * |
|
72 | - * or |
|
73 | - * |
|
74 | - * { |
|
75 | - * "title": "Redeem Code already used", |
|
76 | - * "status": 409, |
|
77 | - * "detail": "The redeem code has been used already, try with another redeem code." |
|
78 | - * } |
|
79 | - */ |
|
80 | - } |
|
81 | - |
|
82 | - public function create_sync( $request ) { |
|
83 | - $redeem_code = $request->get_param( 'redeem_code' ); |
|
84 | - $enable_diagnostics = $request->get_param( 'enable_diagnostics' ); |
|
85 | - |
|
86 | - $url = trailingslashit( WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE ) . 'redeem-codes'; |
|
87 | - |
|
88 | - $body = wp_json_encode( |
|
89 | - array( |
|
90 | - 'redeem_code' => $redeem_code, |
|
91 | - ) |
|
92 | - ); |
|
93 | - |
|
94 | - $response = wp_remote_post( |
|
95 | - $url, |
|
96 | - array( |
|
97 | - 'timeout' => 60, |
|
98 | - 'user-agent' => User_Agent::get_user_agent(), |
|
99 | - 'headers' => array( |
|
100 | - 'Content-Type' => 'application/json', |
|
101 | - 'Expect' => '', |
|
102 | - ), |
|
103 | - 'body' => $body, |
|
104 | - ) |
|
105 | - ); |
|
106 | - |
|
107 | - $code = wp_remote_retrieve_response_code( $response ); |
|
108 | - $message = wp_remote_retrieve_response_message( $response ); |
|
109 | - |
|
110 | - if ( empty( $code ) || ! is_numeric( $code ) ) { |
|
111 | - wp_send_json_error( $message, $code ); |
|
112 | - } |
|
113 | - |
|
114 | - if ( 409 === $code ) { |
|
115 | - return new \WP_REST_Response( |
|
116 | - array( |
|
117 | - 'title' => 'Redeem Code already used', |
|
118 | - 'status' => $code, |
|
119 | - 'detail' => 'The redeem code has been used already, try with another redeem code.', |
|
120 | - ), |
|
121 | - $code |
|
122 | - ); |
|
123 | - } |
|
124 | - |
|
125 | - if ( 404 === $code ) { |
|
126 | - return new \WP_REST_Response( |
|
127 | - array( |
|
128 | - 'title' => 'Invalid Redeem Code', |
|
129 | - 'status' => $code, |
|
130 | - 'detail' => 'The redeem code is invalid, check for typos or try with another code.', |
|
131 | - ), |
|
132 | - $code |
|
133 | - ); |
|
134 | - } |
|
135 | - |
|
136 | - if ( 500 === $code ) { |
|
137 | - return new \WP_REST_Response( json_decode( $response['body'] ), $code ); |
|
138 | - } |
|
139 | - |
|
140 | - $key_array = json_decode( $response['body'] ); |
|
141 | - $key = $key_array->key; |
|
142 | - |
|
143 | - $this->configuration_service->set_key( $key ); |
|
144 | - $this->configuration_service->set_diagnostic_preferences( $enable_diagnostics ); |
|
145 | - |
|
146 | - return new \WP_REST_Response( |
|
147 | - array( |
|
148 | - 'key' => $key, |
|
149 | - 'status' => $this->configuration_service->get_dataset_uri(), |
|
150 | - 'language' => 'en', |
|
151 | - ), |
|
152 | - $code |
|
153 | - ); |
|
154 | - } |
|
10 | + /** |
|
11 | + * @var Wordlift_Configuration_Service |
|
12 | + */ |
|
13 | + |
|
14 | + private $configuration_service; |
|
15 | + |
|
16 | + public function __construct() { |
|
17 | + $this->configuration_service = Wordlift_Configuration_Service::get_instance(); |
|
18 | + } |
|
19 | + |
|
20 | + public function register_hooks() { |
|
21 | + add_action( 'rest_api_init', array( $this, 'rest_api_init' ) ); |
|
22 | + } |
|
23 | + |
|
24 | + public function rest_api_init() { |
|
25 | + register_rest_route( |
|
26 | + WL_REST_ROUTE_DEFAULT_NAMESPACE, |
|
27 | + '/redeem-codes', |
|
28 | + array( |
|
29 | + 'methods' => 'POST', |
|
30 | + 'callback' => array( $this, 'create_sync' ), |
|
31 | + 'args' => array( |
|
32 | + 'redeem_code' => array( |
|
33 | + 'required' => true, |
|
34 | + 'validate_callback' => 'rest_validate_request_arg', |
|
35 | + ), |
|
36 | + 'enable_diagnostics' => array( |
|
37 | + 'required' => true, |
|
38 | + 'validate_callback' => 'rest_validate_request_arg', |
|
39 | + ), |
|
40 | + ), |
|
41 | + 'permission_callback' => function () { |
|
42 | + return current_user_can( 'manage_options' ); |
|
43 | + }, |
|
44 | + ) |
|
45 | + ); |
|
46 | + |
|
47 | + /** |
|
48 | + * POST /redeem-codes |
|
49 | + * Accept: application/json |
|
50 | + * Content-Type: application/json |
|
51 | + * |
|
52 | + * { "redeem_code": "a_redeem_code" } |
|
53 | + * |
|
54 | + * |
|
55 | + * Successful Response: |
|
56 | + * |
|
57 | + * Content-Type: application/json |
|
58 | + * |
|
59 | + * { "key": "a_key" } |
|
60 | + * |
|
61 | + * |
|
62 | + * Unsuccessful Response: |
|
63 | + * |
|
64 | + * Content-Type: application/json |
|
65 | + * |
|
66 | + * { |
|
67 | + * "title": "Invalid Redeem Code", |
|
68 | + * "status": 404, |
|
69 | + * "detail": "The redeem code is invalid, check for typos or try with another code." |
|
70 | + * } |
|
71 | + * |
|
72 | + * or |
|
73 | + * |
|
74 | + * { |
|
75 | + * "title": "Redeem Code already used", |
|
76 | + * "status": 409, |
|
77 | + * "detail": "The redeem code has been used already, try with another redeem code." |
|
78 | + * } |
|
79 | + */ |
|
80 | + } |
|
81 | + |
|
82 | + public function create_sync( $request ) { |
|
83 | + $redeem_code = $request->get_param( 'redeem_code' ); |
|
84 | + $enable_diagnostics = $request->get_param( 'enable_diagnostics' ); |
|
85 | + |
|
86 | + $url = trailingslashit( WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE ) . 'redeem-codes'; |
|
87 | + |
|
88 | + $body = wp_json_encode( |
|
89 | + array( |
|
90 | + 'redeem_code' => $redeem_code, |
|
91 | + ) |
|
92 | + ); |
|
93 | + |
|
94 | + $response = wp_remote_post( |
|
95 | + $url, |
|
96 | + array( |
|
97 | + 'timeout' => 60, |
|
98 | + 'user-agent' => User_Agent::get_user_agent(), |
|
99 | + 'headers' => array( |
|
100 | + 'Content-Type' => 'application/json', |
|
101 | + 'Expect' => '', |
|
102 | + ), |
|
103 | + 'body' => $body, |
|
104 | + ) |
|
105 | + ); |
|
106 | + |
|
107 | + $code = wp_remote_retrieve_response_code( $response ); |
|
108 | + $message = wp_remote_retrieve_response_message( $response ); |
|
109 | + |
|
110 | + if ( empty( $code ) || ! is_numeric( $code ) ) { |
|
111 | + wp_send_json_error( $message, $code ); |
|
112 | + } |
|
113 | + |
|
114 | + if ( 409 === $code ) { |
|
115 | + return new \WP_REST_Response( |
|
116 | + array( |
|
117 | + 'title' => 'Redeem Code already used', |
|
118 | + 'status' => $code, |
|
119 | + 'detail' => 'The redeem code has been used already, try with another redeem code.', |
|
120 | + ), |
|
121 | + $code |
|
122 | + ); |
|
123 | + } |
|
124 | + |
|
125 | + if ( 404 === $code ) { |
|
126 | + return new \WP_REST_Response( |
|
127 | + array( |
|
128 | + 'title' => 'Invalid Redeem Code', |
|
129 | + 'status' => $code, |
|
130 | + 'detail' => 'The redeem code is invalid, check for typos or try with another code.', |
|
131 | + ), |
|
132 | + $code |
|
133 | + ); |
|
134 | + } |
|
135 | + |
|
136 | + if ( 500 === $code ) { |
|
137 | + return new \WP_REST_Response( json_decode( $response['body'] ), $code ); |
|
138 | + } |
|
139 | + |
|
140 | + $key_array = json_decode( $response['body'] ); |
|
141 | + $key = $key_array->key; |
|
142 | + |
|
143 | + $this->configuration_service->set_key( $key ); |
|
144 | + $this->configuration_service->set_diagnostic_preferences( $enable_diagnostics ); |
|
145 | + |
|
146 | + return new \WP_REST_Response( |
|
147 | + array( |
|
148 | + 'key' => $key, |
|
149 | + 'status' => $this->configuration_service->get_dataset_uri(), |
|
150 | + 'language' => 'en', |
|
151 | + ), |
|
152 | + $code |
|
153 | + ); |
|
154 | + } |
|
155 | 155 | |
156 | 156 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | } |
19 | 19 | |
20 | 20 | public function register_hooks() { |
21 | - add_action( 'rest_api_init', array( $this, 'rest_api_init' ) ); |
|
21 | + add_action('rest_api_init', array($this, 'rest_api_init')); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function rest_api_init() { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | '/redeem-codes', |
28 | 28 | array( |
29 | 29 | 'methods' => 'POST', |
30 | - 'callback' => array( $this, 'create_sync' ), |
|
30 | + 'callback' => array($this, 'create_sync'), |
|
31 | 31 | 'args' => array( |
32 | 32 | 'redeem_code' => array( |
33 | 33 | 'required' => true, |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | 'validate_callback' => 'rest_validate_request_arg', |
39 | 39 | ), |
40 | 40 | ), |
41 | - 'permission_callback' => function () { |
|
42 | - return current_user_can( 'manage_options' ); |
|
41 | + 'permission_callback' => function() { |
|
42 | + return current_user_can('manage_options'); |
|
43 | 43 | }, |
44 | 44 | ) |
45 | 45 | ); |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | */ |
80 | 80 | } |
81 | 81 | |
82 | - public function create_sync( $request ) { |
|
83 | - $redeem_code = $request->get_param( 'redeem_code' ); |
|
84 | - $enable_diagnostics = $request->get_param( 'enable_diagnostics' ); |
|
82 | + public function create_sync($request) { |
|
83 | + $redeem_code = $request->get_param('redeem_code'); |
|
84 | + $enable_diagnostics = $request->get_param('enable_diagnostics'); |
|
85 | 85 | |
86 | - $url = trailingslashit( WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE ) . 'redeem-codes'; |
|
86 | + $url = trailingslashit(WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE).'redeem-codes'; |
|
87 | 87 | |
88 | 88 | $body = wp_json_encode( |
89 | 89 | array( |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | ) |
105 | 105 | ); |
106 | 106 | |
107 | - $code = wp_remote_retrieve_response_code( $response ); |
|
108 | - $message = wp_remote_retrieve_response_message( $response ); |
|
107 | + $code = wp_remote_retrieve_response_code($response); |
|
108 | + $message = wp_remote_retrieve_response_message($response); |
|
109 | 109 | |
110 | - if ( empty( $code ) || ! is_numeric( $code ) ) { |
|
111 | - wp_send_json_error( $message, $code ); |
|
110 | + if (empty($code) || ! is_numeric($code)) { |
|
111 | + wp_send_json_error($message, $code); |
|
112 | 112 | } |
113 | 113 | |
114 | - if ( 409 === $code ) { |
|
114 | + if (409 === $code) { |
|
115 | 115 | return new \WP_REST_Response( |
116 | 116 | array( |
117 | 117 | 'title' => 'Redeem Code already used', |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | ); |
123 | 123 | } |
124 | 124 | |
125 | - if ( 404 === $code ) { |
|
125 | + if (404 === $code) { |
|
126 | 126 | return new \WP_REST_Response( |
127 | 127 | array( |
128 | 128 | 'title' => 'Invalid Redeem Code', |
@@ -133,15 +133,15 @@ discard block |
||
133 | 133 | ); |
134 | 134 | } |
135 | 135 | |
136 | - if ( 500 === $code ) { |
|
137 | - return new \WP_REST_Response( json_decode( $response['body'] ), $code ); |
|
136 | + if (500 === $code) { |
|
137 | + return new \WP_REST_Response(json_decode($response['body']), $code); |
|
138 | 138 | } |
139 | 139 | |
140 | - $key_array = json_decode( $response['body'] ); |
|
140 | + $key_array = json_decode($response['body']); |
|
141 | 141 | $key = $key_array->key; |
142 | 142 | |
143 | - $this->configuration_service->set_key( $key ); |
|
144 | - $this->configuration_service->set_diagnostic_preferences( $enable_diagnostics ); |
|
143 | + $this->configuration_service->set_key($key); |
|
144 | + $this->configuration_service->set_diagnostic_preferences($enable_diagnostics); |
|
145 | 145 | |
146 | 146 | return new \WP_REST_Response( |
147 | 147 | array( |