@@ -12,170 +12,170 @@ |
||
12 | 12 | */ |
13 | 13 | abstract class WP_Async_Request { |
14 | 14 | |
15 | - /** |
|
16 | - * Prefix |
|
17 | - * |
|
18 | - * (default value: 'wp') |
|
19 | - * |
|
20 | - * @var string |
|
21 | - * @access protected |
|
22 | - */ |
|
23 | - protected $prefix = 'wp'; |
|
24 | - |
|
25 | - /** |
|
26 | - * Action |
|
27 | - * |
|
28 | - * (default value: 'async_request') |
|
29 | - * |
|
30 | - * @var string |
|
31 | - * @access protected |
|
32 | - */ |
|
33 | - protected $action = 'async_request'; |
|
34 | - |
|
35 | - /** |
|
36 | - * Identifier |
|
37 | - * |
|
38 | - * @var mixed |
|
39 | - * @access protected |
|
40 | - */ |
|
41 | - protected $identifier; |
|
42 | - |
|
43 | - /** |
|
44 | - * Data |
|
45 | - * |
|
46 | - * (default value: array()) |
|
47 | - * |
|
48 | - * @var array |
|
49 | - * @access protected |
|
50 | - */ |
|
51 | - protected $data = array(); |
|
52 | - |
|
53 | - /** |
|
54 | - * Initiate new async request |
|
55 | - */ |
|
56 | - public function __construct() { |
|
57 | - $this->identifier = $this->prefix . '_' . $this->action; |
|
58 | - |
|
59 | - add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
60 | - add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Set data used during the request |
|
65 | - * |
|
66 | - * @param array $data Data. |
|
67 | - * |
|
68 | - * @return $this |
|
69 | - */ |
|
70 | - public function data( $data ) { |
|
71 | - $this->data = $data; |
|
72 | - |
|
73 | - return $this; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Dispatch the async request |
|
78 | - * |
|
79 | - * @return array|WP_Error |
|
80 | - */ |
|
81 | - public function dispatch() { |
|
82 | - $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
83 | - $args = $this->get_post_args(); |
|
84 | - |
|
85 | - return wp_remote_post( esc_url_raw( $url ), $args ); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Get query args |
|
90 | - * |
|
91 | - * @return array |
|
92 | - */ |
|
93 | - protected function get_query_args() { |
|
94 | - if ( property_exists( $this, 'query_args' ) ) { |
|
95 | - return $this->query_args; |
|
96 | - } |
|
97 | - |
|
98 | - $args = array( |
|
99 | - 'action' => $this->identifier, |
|
100 | - 'nonce' => wp_create_nonce( $this->identifier ), |
|
101 | - ); |
|
102 | - |
|
103 | - /** |
|
104 | - * Filters the post arguments used during an async request. |
|
105 | - * |
|
106 | - * @param array $url |
|
107 | - */ |
|
108 | - return apply_filters( $this->identifier . '_query_args', $args ); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Get query URL |
|
113 | - * |
|
114 | - * @return string |
|
115 | - */ |
|
116 | - protected function get_query_url() { |
|
117 | - if ( property_exists( $this, 'query_url' ) ) { |
|
118 | - return $this->query_url; |
|
119 | - } |
|
120 | - |
|
121 | - $url = admin_url( 'admin-ajax.php' ); |
|
122 | - |
|
123 | - /** |
|
124 | - * Filters the post arguments used during an async request. |
|
125 | - * |
|
126 | - * @param string $url |
|
127 | - */ |
|
128 | - return apply_filters( $this->identifier . '_query_url', $url ); |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Get post args |
|
133 | - * |
|
134 | - * @return array |
|
135 | - */ |
|
136 | - protected function get_post_args() { |
|
137 | - if ( property_exists( $this, 'post_args' ) ) { |
|
138 | - return $this->post_args; |
|
139 | - } |
|
140 | - |
|
141 | - $args = array( |
|
142 | - 'timeout' => 0.01, |
|
143 | - 'blocking' => false, |
|
144 | - 'body' => $this->data, |
|
145 | - 'cookies' => $_COOKIE, |
|
146 | - 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
147 | - ); |
|
148 | - |
|
149 | - /** |
|
150 | - * Filters the post arguments used during an async request. |
|
151 | - * |
|
152 | - * @param array $args |
|
153 | - */ |
|
154 | - return apply_filters( $this->identifier . '_post_args', $args ); |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * Maybe handle |
|
159 | - * |
|
160 | - * Check for correct nonce and pass to handler. |
|
161 | - */ |
|
162 | - public function maybe_handle() { |
|
163 | - // Don't lock up other requests while processing |
|
164 | - session_write_close(); |
|
165 | - |
|
166 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
167 | - |
|
168 | - $this->handle(); |
|
169 | - |
|
170 | - wp_die(); |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * Handle |
|
175 | - * |
|
176 | - * Override this method to perform any actions required |
|
177 | - * during the async request. |
|
178 | - */ |
|
179 | - abstract protected function handle(); |
|
15 | + /** |
|
16 | + * Prefix |
|
17 | + * |
|
18 | + * (default value: 'wp') |
|
19 | + * |
|
20 | + * @var string |
|
21 | + * @access protected |
|
22 | + */ |
|
23 | + protected $prefix = 'wp'; |
|
24 | + |
|
25 | + /** |
|
26 | + * Action |
|
27 | + * |
|
28 | + * (default value: 'async_request') |
|
29 | + * |
|
30 | + * @var string |
|
31 | + * @access protected |
|
32 | + */ |
|
33 | + protected $action = 'async_request'; |
|
34 | + |
|
35 | + /** |
|
36 | + * Identifier |
|
37 | + * |
|
38 | + * @var mixed |
|
39 | + * @access protected |
|
40 | + */ |
|
41 | + protected $identifier; |
|
42 | + |
|
43 | + /** |
|
44 | + * Data |
|
45 | + * |
|
46 | + * (default value: array()) |
|
47 | + * |
|
48 | + * @var array |
|
49 | + * @access protected |
|
50 | + */ |
|
51 | + protected $data = array(); |
|
52 | + |
|
53 | + /** |
|
54 | + * Initiate new async request |
|
55 | + */ |
|
56 | + public function __construct() { |
|
57 | + $this->identifier = $this->prefix . '_' . $this->action; |
|
58 | + |
|
59 | + add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
60 | + add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Set data used during the request |
|
65 | + * |
|
66 | + * @param array $data Data. |
|
67 | + * |
|
68 | + * @return $this |
|
69 | + */ |
|
70 | + public function data( $data ) { |
|
71 | + $this->data = $data; |
|
72 | + |
|
73 | + return $this; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Dispatch the async request |
|
78 | + * |
|
79 | + * @return array|WP_Error |
|
80 | + */ |
|
81 | + public function dispatch() { |
|
82 | + $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
83 | + $args = $this->get_post_args(); |
|
84 | + |
|
85 | + return wp_remote_post( esc_url_raw( $url ), $args ); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Get query args |
|
90 | + * |
|
91 | + * @return array |
|
92 | + */ |
|
93 | + protected function get_query_args() { |
|
94 | + if ( property_exists( $this, 'query_args' ) ) { |
|
95 | + return $this->query_args; |
|
96 | + } |
|
97 | + |
|
98 | + $args = array( |
|
99 | + 'action' => $this->identifier, |
|
100 | + 'nonce' => wp_create_nonce( $this->identifier ), |
|
101 | + ); |
|
102 | + |
|
103 | + /** |
|
104 | + * Filters the post arguments used during an async request. |
|
105 | + * |
|
106 | + * @param array $url |
|
107 | + */ |
|
108 | + return apply_filters( $this->identifier . '_query_args', $args ); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Get query URL |
|
113 | + * |
|
114 | + * @return string |
|
115 | + */ |
|
116 | + protected function get_query_url() { |
|
117 | + if ( property_exists( $this, 'query_url' ) ) { |
|
118 | + return $this->query_url; |
|
119 | + } |
|
120 | + |
|
121 | + $url = admin_url( 'admin-ajax.php' ); |
|
122 | + |
|
123 | + /** |
|
124 | + * Filters the post arguments used during an async request. |
|
125 | + * |
|
126 | + * @param string $url |
|
127 | + */ |
|
128 | + return apply_filters( $this->identifier . '_query_url', $url ); |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Get post args |
|
133 | + * |
|
134 | + * @return array |
|
135 | + */ |
|
136 | + protected function get_post_args() { |
|
137 | + if ( property_exists( $this, 'post_args' ) ) { |
|
138 | + return $this->post_args; |
|
139 | + } |
|
140 | + |
|
141 | + $args = array( |
|
142 | + 'timeout' => 0.01, |
|
143 | + 'blocking' => false, |
|
144 | + 'body' => $this->data, |
|
145 | + 'cookies' => $_COOKIE, |
|
146 | + 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
147 | + ); |
|
148 | + |
|
149 | + /** |
|
150 | + * Filters the post arguments used during an async request. |
|
151 | + * |
|
152 | + * @param array $args |
|
153 | + */ |
|
154 | + return apply_filters( $this->identifier . '_post_args', $args ); |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * Maybe handle |
|
159 | + * |
|
160 | + * Check for correct nonce and pass to handler. |
|
161 | + */ |
|
162 | + public function maybe_handle() { |
|
163 | + // Don't lock up other requests while processing |
|
164 | + session_write_close(); |
|
165 | + |
|
166 | + check_ajax_referer( $this->identifier, 'nonce' ); |
|
167 | + |
|
168 | + $this->handle(); |
|
169 | + |
|
170 | + wp_die(); |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * Handle |
|
175 | + * |
|
176 | + * Override this method to perform any actions required |
|
177 | + * during the async request. |
|
178 | + */ |
|
179 | + abstract protected function handle(); |
|
180 | 180 | |
181 | 181 | } |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | * Initiate new async request |
55 | 55 | */ |
56 | 56 | public function __construct() { |
57 | - $this->identifier = $this->prefix . '_' . $this->action; |
|
57 | + $this->identifier = $this->prefix.'_'.$this->action; |
|
58 | 58 | |
59 | - add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
60 | - add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
59 | + add_action('wp_ajax_'.$this->identifier, array($this, 'maybe_handle')); |
|
60 | + add_action('wp_ajax_nopriv_'.$this->identifier, array($this, 'maybe_handle')); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return $this |
69 | 69 | */ |
70 | - public function data( $data ) { |
|
70 | + public function data($data) { |
|
71 | 71 | $this->data = $data; |
72 | 72 | |
73 | 73 | return $this; |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | * @return array|WP_Error |
80 | 80 | */ |
81 | 81 | public function dispatch() { |
82 | - $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
82 | + $url = add_query_arg($this->get_query_args(), $this->get_query_url()); |
|
83 | 83 | $args = $this->get_post_args(); |
84 | 84 | |
85 | - return wp_remote_post( esc_url_raw( $url ), $args ); |
|
85 | + return wp_remote_post(esc_url_raw($url), $args); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * @return array |
92 | 92 | */ |
93 | 93 | protected function get_query_args() { |
94 | - if ( property_exists( $this, 'query_args' ) ) { |
|
94 | + if (property_exists($this, 'query_args')) { |
|
95 | 95 | return $this->query_args; |
96 | 96 | } |
97 | 97 | |
98 | 98 | $args = array( |
99 | 99 | 'action' => $this->identifier, |
100 | - 'nonce' => wp_create_nonce( $this->identifier ), |
|
100 | + 'nonce' => wp_create_nonce($this->identifier), |
|
101 | 101 | ); |
102 | 102 | |
103 | 103 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @param array $url |
107 | 107 | */ |
108 | - return apply_filters( $this->identifier . '_query_args', $args ); |
|
108 | + return apply_filters($this->identifier.'_query_args', $args); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | * @return string |
115 | 115 | */ |
116 | 116 | protected function get_query_url() { |
117 | - if ( property_exists( $this, 'query_url' ) ) { |
|
117 | + if (property_exists($this, 'query_url')) { |
|
118 | 118 | return $this->query_url; |
119 | 119 | } |
120 | 120 | |
121 | - $url = admin_url( 'admin-ajax.php' ); |
|
121 | + $url = admin_url('admin-ajax.php'); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Filters the post arguments used during an async request. |
125 | 125 | * |
126 | 126 | * @param string $url |
127 | 127 | */ |
128 | - return apply_filters( $this->identifier . '_query_url', $url ); |
|
128 | + return apply_filters($this->identifier.'_query_url', $url); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @return array |
135 | 135 | */ |
136 | 136 | protected function get_post_args() { |
137 | - if ( property_exists( $this, 'post_args' ) ) { |
|
137 | + if (property_exists($this, 'post_args')) { |
|
138 | 138 | return $this->post_args; |
139 | 139 | } |
140 | 140 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | 'blocking' => false, |
144 | 144 | 'body' => $this->data, |
145 | 145 | 'cookies' => $_COOKIE, |
146 | - 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
146 | + 'sslverify' => apply_filters('https_local_ssl_verify', false), |
|
147 | 147 | ); |
148 | 148 | |
149 | 149 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @param array $args |
153 | 153 | */ |
154 | - return apply_filters( $this->identifier . '_post_args', $args ); |
|
154 | + return apply_filters($this->identifier.'_post_args', $args); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | // Don't lock up other requests while processing |
164 | 164 | session_write_close(); |
165 | 165 | |
166 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
166 | + check_ajax_referer($this->identifier, 'nonce'); |
|
167 | 167 | |
168 | 168 | $this->handle(); |
169 | 169 |
@@ -17,8 +17,8 @@ |
||
17 | 17 | */ |
18 | 18 | |
19 | 19 | if ( ! class_exists( 'WP_Async_Request' ) ) { |
20 | - require_once plugin_dir_path( __FILE__ ) . 'classes/wp-async-request.php'; |
|
20 | + require_once plugin_dir_path( __FILE__ ) . 'classes/wp-async-request.php'; |
|
21 | 21 | } |
22 | 22 | if ( ! class_exists( 'WP_Background_Process' ) ) { |
23 | - require_once plugin_dir_path( __FILE__ ) . 'classes/wp-background-process.php'; |
|
23 | + require_once plugin_dir_path( __FILE__ ) . 'classes/wp-background-process.php'; |
|
24 | 24 | } |
@@ -16,9 +16,9 @@ |
||
16 | 16 | GitHub Branch: master |
17 | 17 | */ |
18 | 18 | |
19 | -if ( ! class_exists( 'WP_Async_Request' ) ) { |
|
20 | - require_once plugin_dir_path( __FILE__ ) . 'classes/wp-async-request.php'; |
|
19 | +if ( ! class_exists('WP_Async_Request')) { |
|
20 | + require_once plugin_dir_path(__FILE__).'classes/wp-async-request.php'; |
|
21 | 21 | } |
22 | -if ( ! class_exists( 'WP_Background_Process' ) ) { |
|
23 | - require_once plugin_dir_path( __FILE__ ) . 'classes/wp-background-process.php'; |
|
22 | +if ( ! class_exists('WP_Background_Process')) { |
|
23 | + require_once plugin_dir_path(__FILE__).'classes/wp-background-process.php'; |
|
24 | 24 | } |
@@ -21,12 +21,12 @@ |
||
21 | 21 | */ |
22 | 22 | private $body; |
23 | 23 | |
24 | - public function __construct( $response ) { |
|
24 | + public function __construct($response) { |
|
25 | 25 | |
26 | 26 | $this->response = $response; |
27 | - $this->code = wp_remote_retrieve_response_code( $this->response ); |
|
28 | - $this->is_success = ! empty( $this->code ) && 2 === intval( $this->code / 100 ); |
|
29 | - $this->body = wp_remote_retrieve_body( $this->response ); |
|
27 | + $this->code = wp_remote_retrieve_response_code($this->response); |
|
28 | + $this->is_success = ! empty($this->code) && 2 === intval($this->code / 100); |
|
29 | + $this->body = wp_remote_retrieve_body($this->response); |
|
30 | 30 | |
31 | 31 | } |
32 | 32 |
@@ -4,46 +4,46 @@ |
||
4 | 4 | |
5 | 5 | class Response { |
6 | 6 | |
7 | - private $response; |
|
7 | + private $response; |
|
8 | 8 | |
9 | - /** |
|
10 | - * @var int|string |
|
11 | - */ |
|
12 | - private $code; |
|
9 | + /** |
|
10 | + * @var int|string |
|
11 | + */ |
|
12 | + private $code; |
|
13 | 13 | |
14 | - /** |
|
15 | - * @var bool |
|
16 | - */ |
|
17 | - private $is_success; |
|
14 | + /** |
|
15 | + * @var bool |
|
16 | + */ |
|
17 | + private $is_success; |
|
18 | 18 | |
19 | - /** |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - private $body; |
|
19 | + /** |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + private $body; |
|
23 | 23 | |
24 | - public function __construct( $response ) { |
|
24 | + public function __construct( $response ) { |
|
25 | 25 | |
26 | - $this->response = $response; |
|
27 | - $this->code = wp_remote_retrieve_response_code( $this->response ); |
|
28 | - $this->is_success = ! empty( $this->code ) && 2 === intval( $this->code / 100 ); |
|
29 | - $this->body = wp_remote_retrieve_body( $this->response ); |
|
26 | + $this->response = $response; |
|
27 | + $this->code = wp_remote_retrieve_response_code( $this->response ); |
|
28 | + $this->is_success = ! empty( $this->code ) && 2 === intval( $this->code / 100 ); |
|
29 | + $this->body = wp_remote_retrieve_body( $this->response ); |
|
30 | 30 | |
31 | - } |
|
31 | + } |
|
32 | 32 | |
33 | - public function is_success() { |
|
33 | + public function is_success() { |
|
34 | 34 | |
35 | - return $this->is_success; |
|
35 | + return $this->is_success; |
|
36 | 36 | |
37 | - } |
|
37 | + } |
|
38 | 38 | |
39 | - public function get_body() { |
|
39 | + public function get_body() { |
|
40 | 40 | |
41 | - return $this->body; |
|
42 | - } |
|
41 | + return $this->body; |
|
42 | + } |
|
43 | 43 | |
44 | - public function get_response() { |
|
44 | + public function get_response() { |
|
45 | 45 | |
46 | - return $this->response; |
|
47 | - } |
|
46 | + return $this->response; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | } |
@@ -2,6 +2,6 @@ |
||
2 | 2 | |
3 | 3 | // autoload.php @generated by Composer |
4 | 4 | |
5 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
5 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
6 | 6 | |
7 | 7 | return ComposerAutoloaderInit30c84c47a44576eaa4b38cc478d5e11b::getLoader(); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @return Response |
17 | 17 | */ |
18 | - public function request( $method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ); |
|
18 | + public function request($method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array()); |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @param $path |
@@ -27,6 +27,6 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return Response |
29 | 29 | */ |
30 | - public function get( $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ); |
|
30 | + public function get($path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array()); |
|
31 | 31 | |
32 | 32 | } |
@@ -4,29 +4,29 @@ |
||
4 | 4 | |
5 | 5 | interface Api_Service { |
6 | 6 | |
7 | - /** |
|
8 | - * @param $method |
|
9 | - * @param $path |
|
10 | - * @param array $headers |
|
11 | - * @param null $body |
|
12 | - * @param null $timeout |
|
13 | - * @param null $user_agent |
|
14 | - * @param array $args |
|
15 | - * |
|
16 | - * @return Response |
|
17 | - */ |
|
18 | - public function request( $method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ); |
|
7 | + /** |
|
8 | + * @param $method |
|
9 | + * @param $path |
|
10 | + * @param array $headers |
|
11 | + * @param null $body |
|
12 | + * @param null $timeout |
|
13 | + * @param null $user_agent |
|
14 | + * @param array $args |
|
15 | + * |
|
16 | + * @return Response |
|
17 | + */ |
|
18 | + public function request( $method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ); |
|
19 | 19 | |
20 | - /** |
|
21 | - * @param $path |
|
22 | - * @param array $headers |
|
23 | - * @param null $body |
|
24 | - * @param null $timeout |
|
25 | - * @param null $user_agent |
|
26 | - * @param array $args |
|
27 | - * |
|
28 | - * @return Response |
|
29 | - */ |
|
30 | - public function get( $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ); |
|
20 | + /** |
|
21 | + * @param $path |
|
22 | + * @param array $headers |
|
23 | + * @param null $body |
|
24 | + * @param null $timeout |
|
25 | + * @param null $user_agent |
|
26 | + * @param array $args |
|
27 | + * |
|
28 | + * @return Response |
|
29 | + */ |
|
30 | + public function get( $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ); |
|
31 | 31 | |
32 | 32 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | * @param $last_update |
20 | 20 | * @param $state |
21 | 21 | */ |
22 | - public function __construct( $state, $started = null, $index = null, $count = null, $last_update = null ) { |
|
22 | + public function __construct($state, $started = null, $index = null, $count = null, $last_update = null) { |
|
23 | 23 | $this->started = $started; |
24 | 24 | $this->index = $index; |
25 | 25 | $this->count = (int) $count; |
@@ -4,27 +4,27 @@ |
||
4 | 4 | |
5 | 5 | class Sync_Background_Process_Info { |
6 | 6 | |
7 | - public $started; |
|
8 | - public $index; |
|
9 | - public $count; |
|
10 | - public $last_update; |
|
11 | - public $state; |
|
7 | + public $started; |
|
8 | + public $index; |
|
9 | + public $count; |
|
10 | + public $last_update; |
|
11 | + public $state; |
|
12 | 12 | |
13 | - /** |
|
14 | - * Sync_Model constructor. |
|
15 | - * |
|
16 | - * @param $started |
|
17 | - * @param $index |
|
18 | - * @param $count |
|
19 | - * @param $last_update |
|
20 | - * @param $state |
|
21 | - */ |
|
22 | - public function __construct( $state, $started = null, $index = null, $count = null, $last_update = null ) { |
|
23 | - $this->started = $started; |
|
24 | - $this->index = $index; |
|
25 | - $this->count = (int) $count; |
|
26 | - $this->last_update = $last_update; |
|
27 | - $this->state = $state; |
|
28 | - } |
|
13 | + /** |
|
14 | + * Sync_Model constructor. |
|
15 | + * |
|
16 | + * @param $started |
|
17 | + * @param $index |
|
18 | + * @param $count |
|
19 | + * @param $last_update |
|
20 | + * @param $state |
|
21 | + */ |
|
22 | + public function __construct( $state, $started = null, $index = null, $count = null, $last_update = null ) { |
|
23 | + $this->started = $started; |
|
24 | + $this->index = $index; |
|
25 | + $this->count = (int) $count; |
|
26 | + $this->last_update = $last_update; |
|
27 | + $this->state = $state; |
|
28 | + } |
|
29 | 29 | |
30 | 30 | } |
@@ -21,9 +21,9 @@ |
||
21 | 21 | * |
22 | 22 | * @return bool |
23 | 23 | */ |
24 | - public static function is_local_entity_uri_exist( $entity_uri_service, $ids ) { |
|
25 | - foreach ( $ids as $id ) { |
|
26 | - if ( $entity_uri_service->is_internal( $id ) ) { |
|
24 | + public static function is_local_entity_uri_exist($entity_uri_service, $ids) { |
|
25 | + foreach ($ids as $id) { |
|
26 | + if ($entity_uri_service->is_internal($id)) { |
|
27 | 27 | return true; |
28 | 28 | } |
29 | 29 | } |
@@ -15,20 +15,20 @@ |
||
15 | 15 | |
16 | 16 | class Post_Entities_Validator { |
17 | 17 | |
18 | - /** |
|
19 | - * @param $entity_uri_service \Wordlift_Entity_Uri_Service |
|
20 | - * @param $ids array<string> An array of entity ids |
|
21 | - * |
|
22 | - * @return bool |
|
23 | - */ |
|
24 | - public static function is_local_entity_uri_exist( $entity_uri_service, $ids ) { |
|
25 | - foreach ( $ids as $id ) { |
|
26 | - if ( $entity_uri_service->is_internal( $id ) ) { |
|
27 | - return true; |
|
28 | - } |
|
29 | - } |
|
18 | + /** |
|
19 | + * @param $entity_uri_service \Wordlift_Entity_Uri_Service |
|
20 | + * @param $ids array<string> An array of entity ids |
|
21 | + * |
|
22 | + * @return bool |
|
23 | + */ |
|
24 | + public static function is_local_entity_uri_exist( $entity_uri_service, $ids ) { |
|
25 | + foreach ( $ids as $id ) { |
|
26 | + if ( $entity_uri_service->is_internal( $id ) ) { |
|
27 | + return true; |
|
28 | + } |
|
29 | + } |
|
30 | 30 | |
31 | - return false; |
|
32 | - } |
|
31 | + return false; |
|
32 | + } |
|
33 | 33 | |
34 | 34 | } |
@@ -21,16 +21,16 @@ |
||
21 | 21 | * |
22 | 22 | * @param $term_count Term_Count |
23 | 23 | */ |
24 | - public function __construct( $term_count ) { |
|
24 | + public function __construct($term_count) { |
|
25 | 25 | $this->term_count = $term_count; |
26 | 26 | } |
27 | 27 | |
28 | 28 | public function get_term_count() { |
29 | - $data = get_transient( self::TRANSIENT_KEY ); |
|
29 | + $data = get_transient(self::TRANSIENT_KEY); |
|
30 | 30 | |
31 | - if ( ! $data ) { |
|
31 | + if ( ! $data) { |
|
32 | 32 | $data = $this->term_count->get_term_count(); |
33 | - set_transient( self::TRANSIENT_KEY, $data, 8 * 60 * 60 ); |
|
33 | + set_transient(self::TRANSIENT_KEY, $data, 8 * 60 * 60); |
|
34 | 34 | |
35 | 35 | return $data; |
36 | 36 | } |
@@ -11,31 +11,31 @@ |
||
11 | 11 | */ |
12 | 12 | class Cached_Term_Count implements Term_Count { |
13 | 13 | |
14 | - const TRANSIENT_KEY = '_wl_vocabulary_term_count_transient'; |
|
15 | - /** |
|
16 | - * @var Term_Count |
|
17 | - */ |
|
18 | - private $term_count; |
|
19 | - |
|
20 | - /** |
|
21 | - * Cached_Term_Count constructor. |
|
22 | - * |
|
23 | - * @param $term_count Term_Count |
|
24 | - */ |
|
25 | - public function __construct( $term_count ) { |
|
26 | - $this->term_count = $term_count; |
|
27 | - } |
|
28 | - |
|
29 | - public function get_term_count() { |
|
30 | - $data = get_transient( self::TRANSIENT_KEY ); |
|
31 | - |
|
32 | - if ( ! $data ) { |
|
33 | - $data = $this->term_count->get_term_count(); |
|
34 | - set_transient( self::TRANSIENT_KEY, $data, 8 * 60 * 60 ); |
|
35 | - |
|
36 | - return $data; |
|
37 | - } |
|
38 | - |
|
39 | - return $data; |
|
40 | - } |
|
14 | + const TRANSIENT_KEY = '_wl_vocabulary_term_count_transient'; |
|
15 | + /** |
|
16 | + * @var Term_Count |
|
17 | + */ |
|
18 | + private $term_count; |
|
19 | + |
|
20 | + /** |
|
21 | + * Cached_Term_Count constructor. |
|
22 | + * |
|
23 | + * @param $term_count Term_Count |
|
24 | + */ |
|
25 | + public function __construct( $term_count ) { |
|
26 | + $this->term_count = $term_count; |
|
27 | + } |
|
28 | + |
|
29 | + public function get_term_count() { |
|
30 | + $data = get_transient( self::TRANSIENT_KEY ); |
|
31 | + |
|
32 | + if ( ! $data ) { |
|
33 | + $data = $this->term_count->get_term_count(); |
|
34 | + set_transient( self::TRANSIENT_KEY, $data, 8 * 60 * 60 ); |
|
35 | + |
|
36 | + return $data; |
|
37 | + } |
|
38 | + |
|
39 | + return $data; |
|
40 | + } |
|
41 | 41 | } |
@@ -4,9 +4,9 @@ |
||
4 | 4 | |
5 | 5 | interface Cache { |
6 | 6 | |
7 | - public function get( $cache_key ); |
|
7 | + public function get($cache_key); |
|
8 | 8 | |
9 | - public function put( $cache_key, $value ); |
|
9 | + public function put($cache_key, $value); |
|
10 | 10 | |
11 | 11 | public function flush_all(); |
12 | 12 |
@@ -4,10 +4,10 @@ |
||
4 | 4 | |
5 | 5 | interface Cache { |
6 | 6 | |
7 | - public function get( $cache_key ); |
|
7 | + public function get( $cache_key ); |
|
8 | 8 | |
9 | - public function put( $cache_key, $value ); |
|
9 | + public function put( $cache_key, $value ); |
|
10 | 10 | |
11 | - public function flush_all(); |
|
11 | + public function flush_all(); |
|
12 | 12 | |
13 | 13 | } |