PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.2.7
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.2.7
2.7.7 2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 All 28 releases
← All changes | admin/includes/class.request.php +14 -21 2.4.102.2.7 View file →
@@ -10,19 +10,14 @@
10 10 * @version 1.0
11 11 */
12 12
13 13 // Exit if accessed directly
14 -use WpOrg\Requests\Requests;
15 -
16 14 if ( ! defined( 'ABSPATH' ) ) {
17 15 exit;
18 16 }
19 17
20 18 class WINP_Request {
21 - //В новых версиях Вуди начиная с 2.2.10 будет обращаться к новой версии API библиотеки сниппетов
22 - // это делается для обратной совместимости, чтобы старые версии продолжили работать со старым API
23 - //const WINP_REQUEST_URL = 'http://185.75.88.217/v2/woody/'; //тестовая после переноса на другой сервер
24 - const WINP_REQUEST_URL = 'https://api.woodysnippet.com/v2/woody/';
19 + const WINP_REQUEST_URL = 'http://142.93.91.206/v1/woody/';
25 20
26 21 /**
27 22 * WINP_REQUEST constructor.
28 23 */
@@ -28,14 +23,8 @@
28 23 */
29 24 public function __construct() {
30 25 require_once WINP_PLUGIN_DIR . '/includes/jsonmapper/class-json-mapper.php';
31 26 require_once WINP_PLUGIN_DIR . '/includes/jsonmapper/exceptions/class-exception.php';
32 -
33 - /*add_filter( 'http_request_args', function ( $parsed_args, $url ) {
34 - $parsed_args['sslverify'] = false;
35 -
36 - return $parsed_args;
37 - }, 10, 2 );*/
38 27 }
39 28
40 29 /**
41 30 * Get license key
@@ -69,12 +58,12 @@
69 58 *
70 59 * @return array
71 60 */
72 61 private function get_headers() {
73 - return [
62 + return array(
74 63 'Authorization' => 'Bearer ' . $this->get_token(),
75 64 'PluginId' => $this->get_plugin_id(),
76 - ];
65 + );
77 66 }
78 67
79 68 /**
80 69 * Check is key data available
@@ -92,9 +81,9 @@
92 81 * @param array $args
93 82 *
94 83 * @return array|bool|WP_Error
95 84 */
96 - public function post( $point, $args = [] ) {
85 + public function post( $point, $args = array() ) {
97 86 if ( ! $this->is_key() ) {
98 87 return false;
99 88 }
100 89
@@ -110,9 +99,9 @@
110 99 * @param array $args
111 100 *
112 101 * @return array|bool|WP_Error
113 102 */
114 - public function get( $point, $args = [] ) {
103 + public function get( $point, $args = array() ) {
115 104 if ( ! $this->is_key() ) {
116 105 return false;
117 106 }
118 107
@@ -128,9 +117,9 @@
128 117 * @param array $args
129 118 *
130 119 * @return array|bool|WP_Error
131 120 */
132 - public function put( $point, $args = [] ) {
121 + public function put( $point, $args = array() ) {
133 122 if ( ! $this->is_key() ) {
134 123 return false;
135 124 }
136 125
@@ -242,9 +231,8 @@
242 231 try {
243 232 return $mapper->map( $body, new $object_name() );
244 233 } catch ( WINP\JsonMapper\Exception $exception ) {
245 234 error_log( 'Snippet api [map_object]: ' . $exception->getMessage() );
246 -
247 235 return false;
248 236 }
249 237 }
250 238
@@ -257,9 +245,11 @@
257 245 * @return bool|mixed
258 246 */
259 247 public function map_objects( $json, $object_name ) {
260 248 if ( ! $this->check_response( $json ) ) {
261 - error_log( 'Snippet api [map_objects]: ' . $this->get_response_error( $json ) );
249 + error_log(
250 + 'Snippet api [map_objects]: ' . $this->get_response_error( $json )
251 + );
262 252
263 253 return false;
264 254 }
265 255
@@ -276,12 +266,15 @@
276 266 $mapper->bExceptionOnUndefinedProperty = true;
277 267 $mapper->bExceptionOnMissingData = true;
278 268
279 269 try {
280 - return $mapper->mapArray( $body, [], $object_name );
270 + return $mapper->mapArray(
271 + $body,
272 + array(),
273 + $object_name
274 + );
281 275 } catch ( WINP\JsonMapper\Exception $exception ) {
282 276 error_log( 'Snippet api [map_objects]: ' . $exception->getMessage() );
283 -
284 277 return false;
285 278 }
286 279 }
287 280