PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.4.0
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.4.0
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
← All changes | includes/Utils/Http.php +13 -6 3.0.53.4.0 View file →
@@ -39,10 +39,10 @@
39 39 * Determining the endpoint URL based on the mode.
40 40 *
41 41 * @return string
42 42 */
43 - public function url() {
44 - if ( $this->dev_mode ) {
43 + public function url($is_live_api = false) {
44 + if ( !$is_live_api && Helper::is_dev_api() ) {
45 45 $this->url = 'https://app.templately.dev/api/plugin';
46 46 }
47 47 return $this->url;
48 48 }
@@ -137,12 +137,14 @@
137 137 if ( empty( $query ) ) {
138 138 $query = $this->query;
139 139 }
140 140
141 + $is_live_api = null;
141 142 $headers = [
142 - 'Content-Type' => 'application/json',
143 - 'x-templately-ip' => Helper::get_ip(),
144 - 'x-templately-url' => home_url( '/' )
143 + 'Content-Type' => 'application/json',
144 + 'x-templately-ip' => Helper::get_ip(),
145 + 'x-templately-url' => home_url( '/' ),
146 + 'x-templately-version' => TEMPLATELY_VERSION,
145 147 ];
146 148
147 149 if ( ! empty( $args['headers'] ) ) {
148 150 $headers = wp_parse_args( $args['headers'], $headers );
@@ -148,8 +150,13 @@
148 150 $headers = wp_parse_args( $args['headers'], $headers );
149 151 unset( $args['headers'] );
150 152 }
151 153
154 + if ( ! empty( $args['is_live_api'] ) ) {
155 + $is_live_api = $args['is_live_api'];
156 + unset( $args['is_live_api'] );
157 + }
158 +
152 159 if ( defined( 'TEMPLATELY_DEBUG_LOG' ) && TEMPLATELY_DEBUG_LOG ) {
153 160 Helper::log( 'URL: ' . $this->url() );
154 161 Helper::log( 'QUERY: ' . $query );
155 162 }
@@ -165,9 +172,9 @@
165 172 $retryCount = 0;
166 173 $maxRetries = defined('TEMPLATELY_HTTP_RETRY') ? TEMPLATELY_HTTP_RETRY : 3;
167 174 $args = wp_parse_args( $args, $_default_args );
168 175 do {
169 - $response = wp_remote_post( $this->url(), $args );
176 + $response = wp_remote_post( $this->url($is_live_api), $args );
170 177 $retryCount++;
171 178 } while ( is_wp_error( $response ) && $retryCount < $maxRetries );
172 179
173 180 if ( defined( 'TEMPLATELY_DEBUG_LOG' ) && TEMPLATELY_DEBUG_LOG ) {