Version Description
- Fixed possible undefined errors for API credentials
Download this release
Release Info
Developer | channeleaton |
Plugin | Popups by OptinMonster – Best WordPress Lead Generation Plugin |
Version | 1.1.8 |
Comparing to | |
See all releases |
Code changes from version 1.1.7 to 1.1.8
- OMAPI/Api.php +169 -180
- optin-monster-wp-api.php +2 -2
- readme.txt +5 -2
OMAPI/Api.php
CHANGED
@@ -10,67 +10,67 @@
|
|
10 |
class OMAPI_Api {
|
11 |
|
12 |
/**
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
public $base = 'app.optinmonster.com/v1/';
|
20 |
|
21 |
/**
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
|
75 |
/**
|
76 |
* Additional data to add to request body
|
@@ -81,116 +81,109 @@ class OMAPI_Api {
|
|
81 |
*/
|
82 |
protected $additional_data = array();
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Processes the API request.
|
109 |
-
*
|
110 |
-
* @since 1.0.0
|
111 |
-
*
|
112 |
-
* @return mixed $value The response to the API call.
|
113 |
-
*/
|
114 |
-
public function request() {
|
115 |
-
|
116 |
-
// Build the body of the request.
|
117 |
-
$body = array(
|
118 |
-
'omapi-user' => $this->user,
|
119 |
-
'omapi-key' => $this->key
|
120 |
-
);
|
121 |
-
|
122 |
-
// If a plugin API request, add the data.
|
123 |
-
if ( 'info' == $this->route || 'update' == $this->route ) {
|
124 |
-
$body['omapi-plugin'] = $this->plugin;
|
125 |
-
}
|
126 |
-
|
127 |
-
// Add in additional data if needed.
|
128 |
-
if ( ! empty( $this->additional_data ) ) {
|
129 |
-
$body['omapi-data'] = maybe_serialize( $this->additional_data );
|
130 |
-
}
|
131 |
-
|
132 |
-
$string = http_build_query( $body, '', '&' );
|
133 |
-
|
134 |
-
// Build the headers of the request.
|
135 |
-
$headers = array(
|
136 |
-
'Content-Type' => 'application/x-www-form-urlencoded',
|
137 |
-
'Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0',
|
138 |
-
'Pragma' => 'no-cache',
|
139 |
-
'Expires' => 0,
|
140 |
-
'OMAPI-Referer' => site_url(),
|
141 |
-
'OMAPI-Sender' => 'WordPress',
|
142 |
-
);
|
143 |
-
|
144 |
-
|
145 |
-
if ( $this->apikey ) {
|
146 |
-
$headers['X-OptinMonster-ApiKey'] = $this->apikey;
|
147 |
-
}
|
148 |
-
|
149 |
-
// Setup data to be sent to the API.
|
150 |
-
$data = array(
|
151 |
-
'headers' => $headers,
|
152 |
-
'body' => $body,
|
153 |
-
'timeout' => 3000,
|
154 |
-
'sslverify' => false
|
155 |
-
);
|
156 |
-
|
157 |
-
// Perform the query and retrieve the response.
|
158 |
-
$response = 'GET' == $this->method ? wp_remote_get( esc_url_raw( $this->url ) . '?' . $string, $data ) : wp_remote_post( esc_url_raw( $this->url ), $data );
|
159 |
-
$response_code = wp_remote_retrieve_response_code( $response );
|
160 |
-
$response_body = json_decode( wp_remote_retrieve_body( $response ) );
|
161 |
-
//return new WP_Error( 'debug', '<pre>' . var_export( $response, true ) . '</pre>' );
|
162 |
-
|
163 |
-
// Bail out early if there are any errors.
|
164 |
-
if ( is_wp_error( $response_body ) ) {
|
165 |
-
return $response_body;
|
166 |
-
}
|
167 |
-
|
168 |
-
// If not a 200 status header, send back error.
|
169 |
-
if ( 200 != $response_code ) {
|
170 |
-
$type = ! empty( $response_body->type ) ? $response_body->type : 'api-error';
|
171 |
-
$error = ! empty( $response_body->error ) ? stripslashes( $response_body->error ) : '';
|
172 |
-
return new WP_Error( $type, sprintf( __( 'The API returned a <strong>%s</strong> response with this message: <strong>%s</strong>', 'optin-monster-api' ), $response_code, $error ) );
|
173 |
-
}
|
174 |
-
|
175 |
-
// Return the json decoded content.
|
176 |
-
return $response_body;
|
177 |
-
|
178 |
-
}
|
179 |
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
|
191 |
-
|
|
|
|
|
192 |
|
193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
|
195 |
/**
|
196 |
* Allow additional data to be passed in the request
|
@@ -201,9 +194,7 @@ class OMAPI_Api {
|
|
201 |
* return void
|
202 |
*/
|
203 |
public function set_additional_data( array $data ) {
|
204 |
-
|
205 |
$this->additional_data = array_merge( $this->additional_data, $data );
|
206 |
-
|
207 |
}
|
208 |
|
209 |
/**
|
@@ -214,20 +205,18 @@ class OMAPI_Api {
|
|
214 |
* return bool True if SSL is enabled, false otherwise.
|
215 |
*/
|
216 |
public function is_ssl() {
|
217 |
-
|
218 |
// Use the base is_ssl check first.
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
}
|
232 |
|
233 |
}
|
10 |
class OMAPI_Api {
|
11 |
|
12 |
/**
|
13 |
+
* Base API route.
|
14 |
+
*
|
15 |
+
* @since 1.0.0
|
16 |
+
*
|
17 |
+
* @var string
|
18 |
+
*/
|
19 |
public $base = 'app.optinmonster.com/v1/';
|
20 |
|
21 |
/**
|
22 |
+
* Current API route.
|
23 |
+
*
|
24 |
+
* @since 1.0.0
|
25 |
+
*
|
26 |
+
* @var bool|string
|
27 |
+
*/
|
28 |
+
public $route = false;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Full API URL endpoint.
|
32 |
+
*
|
33 |
+
* @since 1.0.0
|
34 |
+
*
|
35 |
+
* @var bool|string
|
36 |
+
*/
|
37 |
+
public $url = false;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Current API method.
|
41 |
+
*
|
42 |
+
* @since 1.0.0
|
43 |
+
*
|
44 |
+
* @var bool|string
|
45 |
+
*/
|
46 |
+
public $method = false;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* API Username.
|
50 |
+
*
|
51 |
+
* @since 1.0.0
|
52 |
+
*
|
53 |
+
* @var bool|string
|
54 |
+
*/
|
55 |
+
public $user = false;
|
56 |
+
|
57 |
+
/**
|
58 |
+
* API Key.
|
59 |
+
*
|
60 |
+
* @since 1.0.0
|
61 |
+
*
|
62 |
+
* @var bool|string
|
63 |
+
*/
|
64 |
+
public $key = false;
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Plugin slug.
|
68 |
+
*
|
69 |
+
* @since 1.0.0
|
70 |
+
*
|
71 |
+
* @var bool|string
|
72 |
+
*/
|
73 |
+
public $plugin = false;
|
74 |
|
75 |
/**
|
76 |
* Additional data to add to request body
|
81 |
*/
|
82 |
protected $additional_data = array();
|
83 |
|
84 |
+
/**
|
85 |
+
* Primary class constructor.
|
86 |
+
*
|
87 |
+
* @since 1.0.0
|
88 |
+
*
|
89 |
+
* @param string $route The API route to target.
|
90 |
+
* @param array $creds Array of API credentials.
|
91 |
+
* @param string $method The API method.
|
92 |
+
*/
|
93 |
+
public function __construct( $route, $creds, $method = 'POST' ) {
|
94 |
+
// Set class properties.
|
95 |
+
$this->route = $route;
|
96 |
+
$this->protocol = $this->is_ssl() ? 'https://' : 'http://';
|
97 |
+
$this->url = $this->protocol . $this->base . $this->route . '/';
|
98 |
+
$this->method = $method;
|
99 |
+
$this->user = ! empty( $creds['user'] ) ? $creds['user'] : '';
|
100 |
+
$this->key = ! empty( $creds['key'] ) ? $creds['key'] : '';
|
101 |
+
$this->apikey = ! empty( $creds['apikey'] ) ? $creds['apikey'] : '';
|
102 |
+
$this->plugin = OMAPI::get_instance()->plugin_slug;
|
103 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
+
/**
|
106 |
+
* Processes the API request.
|
107 |
+
*
|
108 |
+
* @since 1.0.0
|
109 |
+
*
|
110 |
+
* @return mixed $value The response to the API call.
|
111 |
+
*/
|
112 |
+
public function request() {
|
113 |
+
// Build the body of the request.
|
114 |
+
$body = array(
|
115 |
+
'omapi-user' => $this->user,
|
116 |
+
'omapi-key' => $this->key
|
117 |
+
);
|
118 |
+
|
119 |
+
// If a plugin API request, add the data.
|
120 |
+
if ( 'info' == $this->route || 'update' == $this->route ) {
|
121 |
+
$body['omapi-plugin'] = $this->plugin;
|
122 |
+
}
|
123 |
+
|
124 |
+
// Add in additional data if needed.
|
125 |
+
if ( ! empty( $this->additional_data ) ) {
|
126 |
+
$body['omapi-data'] = maybe_serialize( $this->additional_data );
|
127 |
+
}
|
128 |
+
|
129 |
+
$string = http_build_query( $body, '', '&' );
|
130 |
+
|
131 |
+
// Build the headers of the request.
|
132 |
+
$headers = array(
|
133 |
+
'Content-Type' => 'application/x-www-form-urlencoded',
|
134 |
+
'Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0',
|
135 |
+
'Pragma' => 'no-cache',
|
136 |
+
'Expires' => 0,
|
137 |
+
'OMAPI-Referer' => site_url(),
|
138 |
+
'OMAPI-Sender' => 'WordPress',
|
139 |
+
);
|
140 |
+
|
141 |
+
if ( $this->apikey ) {
|
142 |
+
$headers['X-OptinMonster-ApiKey'] = $this->apikey;
|
143 |
+
}
|
144 |
+
|
145 |
+
// Setup data to be sent to the API.
|
146 |
+
$data = array(
|
147 |
+
'headers' => $headers,
|
148 |
+
'body' => $body,
|
149 |
+
'timeout' => 3000,
|
150 |
+
'sslverify' => false
|
151 |
+
);
|
152 |
+
|
153 |
+
// Perform the query and retrieve the response.
|
154 |
+
$response = 'GET' == $this->method ? wp_remote_get( esc_url_raw( $this->url ) . '?' . $string, $data ) : wp_remote_post( esc_url_raw( $this->url ), $data );
|
155 |
+
$response_code = wp_remote_retrieve_response_code( $response );
|
156 |
+
$response_body = json_decode( wp_remote_retrieve_body( $response ) );
|
157 |
+
//return new WP_Error( 'debug', '<pre>' . var_export( $response, true ) . '</pre>' );
|
158 |
+
|
159 |
+
// Bail out early if there are any errors.
|
160 |
+
if ( is_wp_error( $response_body ) ) {
|
161 |
+
return $response_body;
|
162 |
+
}
|
163 |
+
|
164 |
+
// If not a 200 status header, send back error.
|
165 |
+
if ( 200 != $response_code ) {
|
166 |
+
$type = ! empty( $response_body->type ) ? $response_body->type : 'api-error';
|
167 |
+
$error = ! empty( $response_body->error ) ? stripslashes( $response_body->message ) : '';
|
168 |
+
return new WP_Error( $type, sprintf( __( 'The API returned a <strong>%s</strong> response with this message: <strong>%s</strong>', 'optin-monster-api' ), $response_code, $error ) );
|
169 |
+
}
|
170 |
|
171 |
+
// Return the json decoded content.
|
172 |
+
return $response_body;
|
173 |
+
}
|
174 |
|
175 |
+
/**
|
176 |
+
* Sets a class property.
|
177 |
+
*
|
178 |
+
* @since 1.0.0
|
179 |
+
*
|
180 |
+
* @param string $key The property to set.
|
181 |
+
* @param string $val The value to set for the property.
|
182 |
+
* @return mixed $value The response to the API call.
|
183 |
+
*/
|
184 |
+
public function set( $key, $val ) {
|
185 |
+
$this->{$key} = $val;
|
186 |
+
}
|
187 |
|
188 |
/**
|
189 |
* Allow additional data to be passed in the request
|
194 |
* return void
|
195 |
*/
|
196 |
public function set_additional_data( array $data ) {
|
|
|
197 |
$this->additional_data = array_merge( $this->additional_data, $data );
|
|
|
198 |
}
|
199 |
|
200 |
/**
|
205 |
* return bool True if SSL is enabled, false otherwise.
|
206 |
*/
|
207 |
public function is_ssl() {
|
|
|
208 |
// Use the base is_ssl check first.
|
209 |
+
if ( is_ssl() ) {
|
210 |
+
return true;
|
211 |
+
} else if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
|
212 |
+
// Also catch proxies and load balancers.
|
213 |
+
return true;
|
214 |
+
} else if ( defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ) {
|
215 |
+
return true;
|
216 |
+
}
|
217 |
+
|
218 |
+
// Otherwise, return false.
|
219 |
+
return false;
|
|
|
220 |
}
|
221 |
|
222 |
}
|
optin-monster-wp-api.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: OptinMonster API plugin to connect your WordPress site to your OptinMonster forms.
|
6 |
* Author: Thomas Griffin
|
7 |
* Author URI: https://thomasgriffin.io
|
8 |
-
* Version: 1.1.
|
9 |
* Text Domain: optin-monster-api
|
10 |
* Domain Path: languages
|
11 |
*
|
@@ -613,4 +613,4 @@ if ( ! function_exists( 'optin_monster_tag' ) ) {
|
|
613 |
return optin_monster( $id, 'slug', array(), $return );
|
614 |
|
615 |
}
|
616 |
-
}
|
5 |
* Description: OptinMonster API plugin to connect your WordPress site to your OptinMonster forms.
|
6 |
* Author: Thomas Griffin
|
7 |
* Author URI: https://thomasgriffin.io
|
8 |
+
* Version: 1.1.8
|
9 |
* Text Domain: optin-monster-api
|
10 |
* Domain Path: languages
|
11 |
*
|
613 |
return optin_monster( $id, 'slug', array(), $return );
|
614 |
|
615 |
}
|
616 |
+
}
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== OptinMonster - Best WordPress Popup and Lead Generation Plugin ===
|
2 |
-
Contributors: griffinjt, smub
|
3 |
Tags: wordpress popup, popup, lightbox popup, mailchimp, aweber, campaign monitor, constant contact, exit-intent, madmimi, infusionsoft, getresponse, hubspot, marketo, activecampaign, pardot, totalsend, emma, icontact, mailerlite, mailpoet, google analytics, pop over, optin forms, email list, subscribers, wordpress popup form, lightbox, wordpress popups, popups, lightbox popups, optin form, wordpress optin form, sidebar optin form, sidebar optin, sidebar form, wordpress overlay popup, wordpress popup plugin, popup plugin, wordpress lightbox optin, wordpress lightbox optin form, after post optin form, wordpress after post optin form, after post optin form plugin, lightbox popup plugin, wordpress popup solution, exit intent, exit-intent, optinmonster, optin monster, optin-monster, mobile popup, mobile popups, mobile optin forms, mobile optins, lightbox optins, wordpress mobile popup, wordpress mobile popups, wordpress mobile optin forms, wordpress lightbox optins, lead gen, lead generation, wordpress lead generation, lead generation wordpress, wordpress lead gen, fullscreen, welcome gate, interstitial
|
4 |
Requires at least: 3.5.1
|
5 |
Tested up to: 4.7.4
|
6 |
-
Stable tag: 1.1.
|
7 |
License: GNU General Public License v2.0 or later
|
8 |
|
9 |
OptinMonster helps you grow your email list by converting visitors into subscribers and customers. Get more email subscribers now!
|
@@ -160,6 +160,9 @@ OptinMonster is the <a href="http://optinmonster.com" rel="friend" title="OptinM
|
|
160 |
|
161 |
== Changelog ==
|
162 |
|
|
|
|
|
|
|
163 |
= 1.1.7 =
|
164 |
* Updated the API script domain for adblock.
|
165 |
* Added new authentication method for the new OptinMonster REST API.
|
1 |
=== OptinMonster - Best WordPress Popup and Lead Generation Plugin ===
|
2 |
+
Contributors: optinmonster, griffinjt, smub
|
3 |
Tags: wordpress popup, popup, lightbox popup, mailchimp, aweber, campaign monitor, constant contact, exit-intent, madmimi, infusionsoft, getresponse, hubspot, marketo, activecampaign, pardot, totalsend, emma, icontact, mailerlite, mailpoet, google analytics, pop over, optin forms, email list, subscribers, wordpress popup form, lightbox, wordpress popups, popups, lightbox popups, optin form, wordpress optin form, sidebar optin form, sidebar optin, sidebar form, wordpress overlay popup, wordpress popup plugin, popup plugin, wordpress lightbox optin, wordpress lightbox optin form, after post optin form, wordpress after post optin form, after post optin form plugin, lightbox popup plugin, wordpress popup solution, exit intent, exit-intent, optinmonster, optin monster, optin-monster, mobile popup, mobile popups, mobile optin forms, mobile optins, lightbox optins, wordpress mobile popup, wordpress mobile popups, wordpress mobile optin forms, wordpress lightbox optins, lead gen, lead generation, wordpress lead generation, lead generation wordpress, wordpress lead gen, fullscreen, welcome gate, interstitial
|
4 |
Requires at least: 3.5.1
|
5 |
Tested up to: 4.7.4
|
6 |
+
Stable tag: 1.1.8
|
7 |
License: GNU General Public License v2.0 or later
|
8 |
|
9 |
OptinMonster helps you grow your email list by converting visitors into subscribers and customers. Get more email subscribers now!
|
160 |
|
161 |
== Changelog ==
|
162 |
|
163 |
+
= 1.1.8 =
|
164 |
+
* Fixed possible undefined errors for API credentials
|
165 |
+
|
166 |
= 1.1.7 =
|
167 |
* Updated the API script domain for adblock.
|
168 |
* Added new authentication method for the new OptinMonster REST API.
|