Popups by OptinMonster – Best WordPress Lead Generation Plugin - Version 1.4.2

Version Description

  • Fixed a bug that caused issues with PHP versions under 5.6.
Download this release

Release Info

Developer griffinjt
Plugin Icon 128x128 Popups by OptinMonster – Best WordPress Lead Generation Plugin
Version 1.4.2
Comparing to
See all releases

Code changes from version 1.3.4 to 1.4.2

Files changed (49) hide show
  1. OMAPI/Actions.php +4 -4
  2. OMAPI/Ajax.php +276 -276
  3. OMAPI/Api.php +12 -6
  4. OMAPI/Content.php +11 -11
  5. OMAPI/Menu.php +22 -22
  6. OMAPI/Output.php +6 -6
  7. OMAPI/Refresh.php +0 -0
  8. OMAPI/Review.php +9 -10
  9. OMAPI/Save.php +390 -347
  10. OMAPI/Shortcode.php +0 -0
  11. OMAPI/Type.php +0 -0
  12. OMAPI/Utils.php +25 -0
  13. OMAPI/Validate.php +4 -4
  14. OMAPI/Welcome.php +0 -0
  15. OMAPI/Widget.php +184 -184
  16. assets/css/images/dashboard-icon.png +0 -0
  17. assets/css/images/featured-logos.png +0 -0
  18. assets/css/images/features-ab-testing.png +0 -0
  19. assets/css/images/features-analytics.png +0 -0
  20. assets/css/images/features-builder.png +0 -0
  21. assets/css/images/features-exit-animated.gif +0 -0
  22. assets/css/images/logo-color-large.png +0 -0
  23. assets/css/images/logo-color-large@2x.png +0 -0
  24. assets/css/images/matthewwoodward.png +0 -0
  25. assets/css/images/menu-icon@2x.png +0 -0
  26. assets/css/images/michaelstelzner.png +0 -0
  27. assets/css/images/neilpatel.png +0 -0
  28. assets/css/images/omapi-graph.png +0 -0
  29. assets/css/images/title-icon@2x.png +0 -0
  30. assets/css/images/video-cta-button.png +0 -0
  31. assets/css/select2-spinner.gif +0 -0
  32. assets/css/select2.min.css +0 -0
  33. assets/css/select2.png +0 -0
  34. assets/css/select2x2.png +0 -0
  35. assets/css/settings.css +0 -0
  36. assets/fonts/FontAwesome.otf +0 -0
  37. assets/fonts/fontawesome-webfont.eot +0 -0
  38. assets/fonts/fontawesome-webfont.svg +0 -0
  39. assets/fonts/fontawesome-webfont.ttf +0 -0
  40. assets/fonts/fontawesome-webfont.woff +0 -0
  41. assets/js/clipboard.min.js +0 -0
  42. assets/js/helper.js +52 -12
  43. assets/js/jspdf.min.js +0 -0
  44. assets/js/select2.min.js +0 -0
  45. assets/js/settings.js +3 -3
  46. assets/js/tooltip.min.js +0 -0
  47. includes/class-am-notification.php +0 -0
  48. optin-monster-wp-api.php +28 -18
  49. readme.txt +16 -3
OMAPI/Actions.php CHANGED
@@ -69,7 +69,7 @@ class OMAPI_Actions {
69
  public function set() {
70
 
71
  self::$instance = $this;
72
- $this->base = OMAPI::get_instance();
73
  $this->view = isset( $_GET['optin_monster_api_view'] ) ? stripslashes( $_GET['optin_monster_api_view'] ) : $this->base->get_view();
74
  $this->optin_id = isset( $_GET['optin_monster_api_id'] ) ? absint( $_GET['optin_monster_api_id'] ) : false;
75
 
@@ -132,10 +132,10 @@ class OMAPI_Actions {
132
 
133
  // Prepare variables.
134
  $status = (bool) get_post_meta( $this->optin_id, '_omapi_enabled', true );
135
- $new = $status ? false : true;
136
  $field = 'global';
137
  $type = get_post_meta( $this->optin_id, '_omapi_type', true );
138
- if ( 'post' == $type ) {
139
  $field = 'automatic';
140
  } else if ( 'sidebar' == $type ) {
141
  $field = false;
@@ -159,7 +159,7 @@ class OMAPI_Actions {
159
  public function test() {
160
 
161
  $status = (bool) get_post_meta( $this->optin_id, '_omapi_test', true );
162
- $new = $status ? false : true;
163
  return update_post_meta( $this->optin_id, '_omapi_test', $new );
164
 
165
  }
69
  public function set() {
70
 
71
  self::$instance = $this;
72
+ $this->base = OMAPI::get_instance();
73
  $this->view = isset( $_GET['optin_monster_api_view'] ) ? stripslashes( $_GET['optin_monster_api_view'] ) : $this->base->get_view();
74
  $this->optin_id = isset( $_GET['optin_monster_api_id'] ) ? absint( $_GET['optin_monster_api_id'] ) : false;
75
 
132
 
133
  // Prepare variables.
134
  $status = (bool) get_post_meta( $this->optin_id, '_omapi_enabled', true );
135
+ $new = $status ? false : true;
136
  $field = 'global';
137
  $type = get_post_meta( $this->optin_id, '_omapi_type', true );
138
+ if ( OMAPI_Utils::is_inline_type( $type ) ) {
139
  $field = 'automatic';
140
  } else if ( 'sidebar' == $type ) {
141
  $field = false;
159
  public function test() {
160
 
161
  $status = (bool) get_post_meta( $this->optin_id, '_omapi_test', true );
162
+ $new = $status ? false : true;
163
  return update_post_meta( $this->optin_id, '_omapi_test', $new );
164
 
165
  }
OMAPI/Ajax.php CHANGED
@@ -10,286 +10,286 @@
10
  class OMAPI_Ajax {
11
 
12
  /**
13
- * Holds the class object.
14
- *
15
- * @since 1.0.0
16
- *
17
- * @var object
18
- */
19
- public static $instance;
20
 
21
  /**
22
- * Path to the file.
23
- *
24
- * @since 1.0.0
25
- *
26
- * @var string
27
- */
28
- public $file = __FILE__;
29
-
30
- /**
31
- * Holds the base class object.
32
- *
33
- * @since 1.0.0
34
- *
35
- * @var object
36
- */
37
- public $base;
38
-
39
- /**
40
- * Primary class constructor.
41
- *
42
- * @since 1.0.0
43
- */
44
- public function __construct() {
45
-
46
- // Set our object.
47
- $this->set();
48
-
49
- // Load non-WordPress style ajax requests.
50
- if ( isset( $_REQUEST['optin-monster-ajax-route'] ) && $_REQUEST['optin-monster-ajax-route'] ) {
51
- if ( isset( $_REQUEST['action'] ) ) {
52
- add_action( 'init', array( $this, 'ajax' ), 999 );
53
- }
54
- }
55
 
56
  // Load actions and filters.
57
- add_action( 'wp_ajax_omapi_query_posts', array( $this, 'query_posts' ) );
58
- add_action( 'wp_ajax_omapi_query_taxonomies', array( $this, 'query_taxonomies' ) );
59
- add_action( 'wp_ajax_omapi_query_selected_posts', array( $this, 'query_selected_posts' ) );
60
- add_action( 'wp_ajax_omapi_query_selected_taxonomies', array( $this, 'query_selected_taxonomies' ) );
61
-
62
- }
63
-
64
- /**
65
- * Sets our object instance and base class instance.
66
- *
67
- * @since 1.0.0
68
- */
69
- public function set() {
70
-
71
- self::$instance = $this;
72
- $this->base = OMAPI::get_instance();
73
- $this->view = 'ajax';
74
-
75
- }
76
-
77
- /**
78
- * Callback to process external ajax requests.
79
- *
80
- * @since 1.0.0
81
- */
82
- public function ajax() {
83
-
84
- switch ( $_REQUEST['action'] ) {
85
- case 'mailpoet' :
86
- $this->mailpoet();
87
- break;
88
- }
89
-
90
- }
91
-
92
- /**
93
- * Queries the posts based on search parameters.
94
- *
95
- * @since 1.0.0
96
- */
97
- public function query_posts() {
98
-
99
- // Run a security check first.
100
- check_ajax_referer( 'omapi-query-nonce', 'nonce' );
101
-
102
- // Prepare variables.
103
- $search = stripslashes( $_POST['q'] );
104
- $post_types = get_post_types( array( 'public' => true ) );
105
- $ret = array();
106
- $args = array(
107
- 'post_type' => $post_types,
108
- 's' => $search,
109
- 'posts_per_page' => -1,
110
- 'post_status' => array( 'publish', 'future' ),
111
- );
112
-
113
- // Make the query.
114
- $posts = get_posts( $args );
115
- if ( empty( $posts ) ) {
116
- // Maybe they entered a post ID to search. Let's try that.
117
- $search = (int) $search;
118
- if ( $search ) {
119
- $id_args = array(
120
- 'post_type' => $post_types,
121
- 'post__in' => (array) $search,
122
- 'posts_per_page' => -1
123
- );
124
- $id_posts = get_posts( $id_args );
125
-
126
- if ( empty( $id_posts ) ) {
127
- $ret['items'] = array();
128
- } else {
129
- foreach ( $id_posts as $post ) {
130
- $ret['items'][] = array(
131
- 'id' => $post->ID,
132
- 'title' => $post->post_title
133
- );
134
- }
135
- }
136
- } else {
137
- $ret['items'] = array();
138
- }
139
- } else {
140
- foreach ( $posts as $post ) {
141
- $ret['items'][] = array(
142
- 'id' => $post->ID,
143
- 'title' => $post->post_title
144
- );
145
- }
146
- }
147
-
148
- // Send back the response.
149
- die( json_encode( $ret ) );
150
-
151
- }
152
-
153
- /**
154
- * Queries the taxonomies based on search parameters.
155
- *
156
- * @since 1.0.0
157
- */
158
- public function query_taxonomies() {
159
-
160
- // Run a security check first.
161
- check_ajax_referer( 'omapi-query-nonce', 'nonce' );
162
-
163
- // Prepare variables.
164
- $search = stripslashes( $_POST['q'] );
165
- $terms = get_tags( array( 'name__like' => $search ) );
166
- $ret = array();
167
-
168
- // Make the query.
169
- if ( empty( $terms ) ) {
170
- $ret['items'] = array();
171
- } else {
172
- foreach ( $terms as $term ) {
173
- $ret['items'][] = array(
174
- 'id' => $term->term_id,
175
- 'title' => $term->name
176
- );
177
- }
178
- }
179
-
180
- // Send back the response.
181
- die( json_encode( $ret ) );
182
-
183
- }
184
-
185
- /**
186
- * Queries the selected items for "never" and "only" output settings
187
- * to show pre-selected values by the user.
188
- *
189
- * @since 1.0.0
190
- */
191
- public function query_selected_posts() {
192
-
193
- // Run a security check first.
194
- check_ajax_referer( 'omapi-query-nonce', 'nonce' );
195
-
196
- // Prepare variables.
197
- $ids = explode( ',', stripslashes( $_POST['ids'] ) );
198
- $ret = array();
199
- $args = array(
200
- 'post__in' => $ids,
201
- 'posts_per_page' => -1,
202
- 'post_type' => get_post_types( array( 'public' => true ) ),
203
- 'post_status' => array( 'publish', 'future' ),
204
- );
205
-
206
- // Make the query.
207
- $posts = get_posts( $args );
208
- if ( empty( $posts ) ) {
209
- $ret['items'] = array();
210
- } else {
211
- foreach ( $posts as $post ) {
212
- $ret['items'][] = array(
213
- 'id' => $post->ID,
214
- 'title' => $post->post_title
215
- );
216
- }
217
- }
218
-
219
- // Send back the response.
220
- die( json_encode( $ret ) );
221
-
222
- }
223
-
224
- /**
225
- * Queries the selected tags to show pre-selected values by the user.
226
- *
227
- * @since 1.0.0
228
- */
229
- public function query_selected_taxonomies() {
230
-
231
- // Run a security check first.
232
- check_ajax_referer( 'omapi-query-nonce', 'nonce' );
233
-
234
- // Prepare variables.
235
- $ids = explode( ',', stripslashes( $_POST['ids'] ) );
236
- $ret = array();
237
- $ret['items'] = array();
238
-
239
- // Make the query.
240
- foreach ( $ids as $id ) {
241
- $tag = get_tag( absint( $id ) );
242
- if ( $tag ) {
243
- $ret['items'][] = array(
244
- 'id' => $tag->term_id,
245
- 'title' => $tag->name
246
- );
247
- }
248
- }
249
-
250
- // Send back the response.
251
- die( json_encode( $ret ) );
252
-
253
- }
254
-
255
- /**
256
- * Opts the user into MailPoet.
257
- *
258
- * @since 1.0.0
259
- */
260
- public function mailpoet() {
261
 
262
  // Run a security check first.
263
- check_ajax_referer( 'omapi', 'nonce' );
264
-
265
- // Prepare variables.
266
- $optin = $this->base->get_optin_by_slug( stripslashes( $_REQUEST['optin'] ) );
267
- $list = get_post_meta( $optin->ID, '_omapi_mailpoet_list', true );
268
- $email = stripslashes( $_REQUEST['email'] );
269
- $name = isset( $_REQUEST['name'] ) ? stripslashes( $_REQUEST['name'] ) : false;
270
- $user = array();
271
-
272
- // Possibly split name into first and last.
273
- if ( $name ) {
274
- $names = explode( ' ', $name );
275
- if ( isset( $names[0] ) ) {
276
- $user['firstname'] = $names[0];
277
- }
278
-
279
- if ( isset( $names[1] ) ) {
280
- $user['lastname'] = $names[1];
281
- }
282
- }
283
-
284
- // Save the email address.
285
- $user['email'] = $email;
286
-
287
- // Store the data.
288
- $data = array(
289
- 'user' => $user,
290
- 'user_list' => array( 'list_ids' => array( $list ) ),
291
- );
292
- $data = apply_filters( 'optin_monster_pre_optin_mailpoet', $data, $_REQUEST, $list, null );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
 
294
  // Save the subscriber. Check for MailPoet 3 first. Default to legacy.
295
  if ( class_exists( '\\MailPoet\\Config\\Initializer' ) ) {
@@ -318,8 +318,8 @@ class OMAPI_Ajax {
318
  $userHelper->addSubscriber( $data );
319
  }
320
 
321
- // Send back a response.
322
- die( json_encode( true ) );
323
 
324
  }
325
 
10
  class OMAPI_Ajax {
11
 
12
  /**
13
+ * Holds the class object.
14
+ *
15
+ * @since 1.0.0
16
+ *
17
+ * @var object
18
+ */
19
+ public static $instance;
20
 
21
  /**
22
+ * Path to the file.
23
+ *
24
+ * @since 1.0.0
25
+ *
26
+ * @var string
27
+ */
28
+ public $file = __FILE__;
29
+
30
+ /**
31
+ * Holds the base class object.
32
+ *
33
+ * @since 1.0.0
34
+ *
35
+ * @var object
36
+ */
37
+ public $base;
38
+
39
+ /**
40
+ * Primary class constructor.
41
+ *
42
+ * @since 1.0.0
43
+ */
44
+ public function __construct() {
45
+
46
+ // Set our object.
47
+ $this->set();
48
+
49
+ // Load non-WordPress style ajax requests.
50
+ if ( isset( $_REQUEST['optin-monster-ajax-route'] ) && $_REQUEST['optin-monster-ajax-route'] ) {
51
+ if ( isset( $_REQUEST['action'] ) ) {
52
+ add_action( 'init', array( $this, 'ajax' ), 999 );
53
+ }
54
+ }
55
 
56
  // Load actions and filters.
57
+ add_action( 'wp_ajax_omapi_query_posts', array( $this, 'query_posts' ) );
58
+ add_action( 'wp_ajax_omapi_query_taxonomies', array( $this, 'query_taxonomies' ) );
59
+ add_action( 'wp_ajax_omapi_query_selected_posts', array( $this, 'query_selected_posts' ) );
60
+ add_action( 'wp_ajax_omapi_query_selected_taxonomies', array( $this, 'query_selected_taxonomies' ) );
61
+
62
+ }
63
+
64
+ /**
65
+ * Sets our object instance and base class instance.
66
+ *
67
+ * @since 1.0.0
68
+ */
69
+ public function set() {
70
+
71
+ self::$instance = $this;
72
+ $this->base = OMAPI::get_instance();
73
+ $this->view = 'ajax';
74
+
75
+ }
76
+
77
+ /**
78
+ * Callback to process external ajax requests.
79
+ *
80
+ * @since 1.0.0
81
+ */
82
+ public function ajax() {
83
+
84
+ switch ( $_REQUEST['action'] ) {
85
+ case 'mailpoet' :
86
+ $this->mailpoet();
87
+ break;
88
+ }
89
+
90
+ }
91
+
92
+ /**
93
+ * Queries the posts based on search parameters.
94
+ *
95
+ * @since 1.0.0
96
+ */
97
+ public function query_posts() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
  // Run a security check first.
100
+ check_ajax_referer( 'omapi-query-nonce', 'nonce' );
101
+
102
+ // Prepare variables.
103
+ $search = stripslashes( $_POST['q'] );
104
+ $post_types = get_post_types( array( 'public' => true ) );
105
+ $ret = array();
106
+ $args = array(
107
+ 'post_type' => $post_types,
108
+ 's' => $search,
109
+ 'posts_per_page' => -1,
110
+ 'post_status' => array( 'publish', 'future' ),
111
+ );
112
+
113
+ // Make the query.
114
+ $posts = get_posts( $args );
115
+ if ( empty( $posts ) ) {
116
+ // Maybe they entered a post ID to search. Let's try that.
117
+ $search = (int) $search;
118
+ if ( $search ) {
119
+ $id_args = array(
120
+ 'post_type' => $post_types,
121
+ 'post__in' => (array) $search,
122
+ 'posts_per_page' => -1
123
+ );
124
+ $id_posts = get_posts( $id_args );
125
+
126
+ if ( empty( $id_posts ) ) {
127
+ $ret['items'] = array();
128
+ } else {
129
+ foreach ( $id_posts as $post ) {
130
+ $ret['items'][] = array(
131
+ 'id' => $post->ID,
132
+ 'title' => $post->post_title
133
+ );
134
+ }
135
+ }
136
+ } else {
137
+ $ret['items'] = array();
138
+ }
139
+ } else {
140
+ foreach ( $posts as $post ) {
141
+ $ret['items'][] = array(
142
+ 'id' => $post->ID,
143
+ 'title' => $post->post_title
144
+ );
145
+ }
146
+ }
147
+
148
+ // Send back the response.
149
+ die( json_encode( $ret ) );
150
+
151
+ }
152
+
153
+ /**
154
+ * Queries the taxonomies based on search parameters.
155
+ *
156
+ * @since 1.0.0
157
+ */
158
+ public function query_taxonomies() {
159
+
160
+ // Run a security check first.
161
+ check_ajax_referer( 'omapi-query-nonce', 'nonce' );
162
+
163
+ // Prepare variables.
164
+ $search = stripslashes( $_POST['q'] );
165
+ $terms = get_tags( array( 'name__like' => $search ) );
166
+ $ret = array();
167
+
168
+ // Make the query.
169
+ if ( empty( $terms ) ) {
170
+ $ret['items'] = array();
171
+ } else {
172
+ foreach ( $terms as $term ) {
173
+ $ret['items'][] = array(
174
+ 'id' => $term->term_id,
175
+ 'title' => $term->name
176
+ );
177
+ }
178
+ }
179
+
180
+ // Send back the response.
181
+ die( json_encode( $ret ) );
182
+
183
+ }
184
+
185
+ /**
186
+ * Queries the selected items for "never" and "only" output settings
187
+ * to show pre-selected values by the user.
188
+ *
189
+ * @since 1.0.0
190
+ */
191
+ public function query_selected_posts() {
192
+
193
+ // Run a security check first.
194
+ check_ajax_referer( 'omapi-query-nonce', 'nonce' );
195
+
196
+ // Prepare variables.
197
+ $ids = explode( ',', stripslashes( $_POST['ids'] ) );
198
+ $ret = array();
199
+ $args = array(
200
+ 'post__in' => $ids,
201
+ 'posts_per_page' => -1,
202
+ 'post_type' => get_post_types( array( 'public' => true ) ),
203
+ 'post_status' => array( 'publish', 'future' ),
204
+ );
205
+
206
+ // Make the query.
207
+ $posts = get_posts( $args );
208
+ if ( empty( $posts ) ) {
209
+ $ret['items'] = array();
210
+ } else {
211
+ foreach ( $posts as $post ) {
212
+ $ret['items'][] = array(
213
+ 'id' => $post->ID,
214
+ 'title' => $post->post_title
215
+ );
216
+ }
217
+ }
218
+
219
+ // Send back the response.
220
+ die( json_encode( $ret ) );
221
+
222
+ }
223
+
224
+ /**
225
+ * Queries the selected tags to show pre-selected values by the user.
226
+ *
227
+ * @since 1.0.0
228
+ */
229
+ public function query_selected_taxonomies() {
230
+
231
+ // Run a security check first.
232
+ check_ajax_referer( 'omapi-query-nonce', 'nonce' );
233
+
234
+ // Prepare variables.
235
+ $ids = explode( ',', stripslashes( $_POST['ids'] ) );
236
+ $ret = array();
237
+ $ret['items'] = array();
238
+
239
+ // Make the query.
240
+ foreach ( $ids as $id ) {
241
+ $tag = get_tag( absint( $id ) );
242
+ if ( $tag ) {
243
+ $ret['items'][] = array(
244
+ 'id' => $tag->term_id,
245
+ 'title' => $tag->name
246
+ );
247
+ }
248
+ }
249
+
250
+ // Send back the response.
251
+ die( json_encode( $ret ) );
252
+
253
+ }
254
+
255
+ /**
256
+ * Opts the user into MailPoet.
257
+ *
258
+ * @since 1.0.0
259
+ */
260
+ public function mailpoet() {
261
+
262
+ // Run a security check first.
263
+ check_ajax_referer( 'omapi', 'nonce' );
264
+
265
+ // Prepare variables.
266
+ $optin = $this->base->get_optin_by_slug( stripslashes( $_REQUEST['optin'] ) );
267
+ $list = get_post_meta( $optin->ID, '_omapi_mailpoet_list', true );
268
+ $email = ! empty( $_REQUEST['email'] ) ? stripslashes( $_REQUEST['email'] ) : false;
269
+ $name = ! empty( $_REQUEST['name'] ) ? stripslashes( $_REQUEST['name'] ) : false;
270
+ $user = array();
271
+
272
+ // Possibly split name into first and last.
273
+ if ( $name ) {
274
+ $names = explode( ' ', $name );
275
+ if ( isset( $names[0] ) ) {
276
+ $user['firstname'] = $names[0];
277
+ }
278
+
279
+ if ( isset( $names[1] ) ) {
280
+ $user['lastname'] = $names[1];
281
+ }
282
+ }
283
+
284
+ // Save the email address.
285
+ $user['email'] = $email;
286
+
287
+ // Store the data.
288
+ $data = array(
289
+ 'user' => $user,
290
+ 'user_list' => array( 'list_ids' => array( $list ) ),
291
+ );
292
+ $data = apply_filters( 'optin_monster_pre_optin_mailpoet', $data, $_REQUEST, $list, null );
293
 
294
  // Save the subscriber. Check for MailPoet 3 first. Default to legacy.
295
  if ( class_exists( '\\MailPoet\\Config\\Initializer' ) ) {
318
  $userHelper->addSubscriber( $data );
319
  }
320
 
321
+ // Send back a response.
322
+ die( json_encode( true ) );
323
 
324
  }
325
 
OMAPI/Api.php CHANGED
@@ -16,7 +16,7 @@ class OMAPI_Api {
16
  *
17
  * @var string
18
  */
19
- public $base = 'app.optinmonster.com/v1/';
20
 
21
  /**
22
  * Current API route.
@@ -93,8 +93,7 @@ class OMAPI_Api {
93
  public function __construct( $route, $creds, $method = 'POST' ) {
94
  // Set class properties.
95
  $this->route = $route;
96
- $this->protocol = 'https://';
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'] : '';
@@ -132,8 +131,8 @@ class OMAPI_Api {
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
  );
@@ -164,7 +163,14 @@ class OMAPI_Api {
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 ) && ! empty( $response_body->message ) ? stripslashes( $response_body->message ) : stripslashes( $response_body->error );
 
 
 
 
 
 
 
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
 
16
  *
17
  * @var string
18
  */
19
+ public $base = OPTINMONSTER_APP_API_URL;
20
 
21
  /**
22
  * Current API route.
93
  public function __construct( $route, $creds, $method = 'POST' ) {
94
  // Set class properties.
95
  $this->route = $route;
96
+ $this->url = $this->base . $this->route . '/';
 
97
  $this->method = $method;
98
  $this->user = ! empty( $creds['user'] ) ? $creds['user'] : '';
99
  $this->key = ! empty( $creds['key'] ) ? $creds['key'] : '';
131
  $headers = array(
132
  'Content-Type' => 'application/x-www-form-urlencoded',
133
  'Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0',
134
+ 'Pragma' => 'no-cache',
135
+ 'Expires' => 0,
136
  'OMAPI-Referer' => site_url(),
137
  'OMAPI-Sender' => 'WordPress',
138
  );
163
  // If not a 200 status header, send back error.
164
  if ( 200 != $response_code ) {
165
  $type = ! empty( $response_body->type ) ? $response_body->type : 'api-error';
166
+ $error = ! empty( $response_body->message ) ? stripslashes( $response_body->message ) : '';
167
+ if ( empty( $error ) ) {
168
+ $error = ! empty( $response_body->status_message ) ? stripslashes( $response_body->status_message ) : '';
169
+ }
170
+ if ( empty( $error ) ) {
171
+ $error = ! empty( $response_body->error ) ? stripslashes( $response_body->error ) : 'unknown';
172
+ }
173
+
174
  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 ) );
175
  }
176
 
OMAPI/Content.php CHANGED
@@ -74,7 +74,7 @@ class OMAPI_Content {
74
  public function set() {
75
 
76
  self::$instance = $this;
77
- $this->base = OMAPI::get_instance();
78
  $this->view = isset( $_GET['optin_monster_api_view'] ) ? stripslashes( $_GET['optin_monster_api_view'] ) : $this->base->get_view();
79
  $this->optin = isset( $_GET['optin_monster_api_id'] ) ? $this->base->get_optin( absint( $_GET['optin_monster_api_id'] ) ) : false;
80
 
@@ -195,7 +195,7 @@ class OMAPI_Content {
195
  <?php // If we have credentials only show the old stuff if it is saved ?>
196
  <?php if ( $credentials ) : ?>
197
  <?php if ( isset( $credentials['api'] ) && '' != $credentials['api'] || isset( $credentials['key'] ) && '' != $credentials['key'] ) : ?>
198
- <p>The Legacy API Username and Key below will be deprecated soon. Please <a href="https://app.optinmonster.com/account/api/" target="_blank">generate a new API key</a> and paste it above to authenticate using our new and improved REST API.</p>
199
  <?php echo $object->get_setting_ui( 'api', 'user' ); ?>
200
  <?php echo $object->get_setting_ui( 'api', 'key' ); ?>
201
  <?php endif; ?>
@@ -234,7 +234,7 @@ class OMAPI_Content {
234
  public function optin_overview( $object ) {
235
 
236
  $optins = $this->base->get_optins();
237
- $i = 0;
238
  if ( $optins ) :
239
  ?>
240
  <?php foreach ( $optins as $optin ) : $class = 0 == $i ? ' omapi-optin-first' : '';
@@ -297,7 +297,7 @@ class OMAPI_Content {
297
  echo $object->get_setting_ui( 'optins', 'enabled' );
298
 
299
  if ( 'sidebar' !== $type ) {
300
- if ( 'post' == $type ) {
301
  echo $object->get_setting_ui( 'optins', 'automatic' );
302
  echo $object->get_setting_ui( 'optins', 'automatic_shortcode');
303
  } else {
@@ -322,7 +322,7 @@ class OMAPI_Content {
322
 
323
  echo $object->get_setting_ui( 'optins', 'show_on_woocommerce');
324
  // Don't show if output can't use the_content filter
325
- if ( 'post' !== $type ) {
326
  echo $object->get_setting_ui( 'optins', 'is_wc_shop' );
327
  }
328
  echo $object->get_setting_ui( 'optins', 'is_wc_product');
@@ -354,7 +354,7 @@ class OMAPI_Content {
354
  echo $object->get_setting_ui( 'toggle', 'advanced-end' );
355
  }
356
 
357
- if ('sidebar' == $type ) {
358
  echo $object->get_setting_ui('note', 'sidebar_widget_notice');
359
  }
360
 
@@ -376,13 +376,13 @@ class OMAPI_Content {
376
  */
377
  public function get_optin_links( $optin_id ) {
378
 
379
- $optin = get_post( $optin_id );
380
- $slug = $optin->post_name;
381
- $status = (bool) get_post_meta( $optin_id, '_omapi_enabled', true );
382
  $status_link = $status ? __( 'Disable', 'optin-monster-api' ) : __( 'Go Live', 'optin-monster-api' );
383
  $status_desc = $status ? esc_attr__( 'Disable this campaign', 'optin-monster-api' ) : esc_attr__( 'Go live with this campaign', 'optin-monster-api' );
384
- $links = array();
385
- $links['editd'] = '<a href="' . esc_url_raw( 'https://app.optinmonster.com/campaigns/' . $slug . '/edit/' ) . '" title="' . esc_attr__( 'Edit this campaign on the OptinMonster App', 'optin-monster-api' ) . '" target="_blank">Edit Design</a>';
386
  $links['edito'] = '<a href="' . esc_url_raw( add_query_arg( array( 'optin_monster_api_view' => $this->view, 'optin_monster_api_action' => 'edit', 'optin_monster_api_id' => $optin_id ), admin_url( 'admin.php?page=optin-monster-api-settings' ) ) ) . '" title="' . esc_attr__( 'Edit the output settings for this campaign', 'optin-monster-api' ) . '">Edit Output Settings</a>';
387
  $links['status'] = '<a href="' . wp_nonce_url( esc_url_raw( add_query_arg( array( 'optin_monster_api_view' => $this->view, 'optin_monster_api_action' => 'status', 'optin_monster_api_id' => $optin_id ), admin_url( 'admin.php?page=optin-monster-api-settings' ) ) ), 'omapi-action' ) . '" title="' . $status_desc . '">' . $status_link . '</a>';
388
 
74
  public function set() {
75
 
76
  self::$instance = $this;
77
+ $this->base = OMAPI::get_instance();
78
  $this->view = isset( $_GET['optin_monster_api_view'] ) ? stripslashes( $_GET['optin_monster_api_view'] ) : $this->base->get_view();
79
  $this->optin = isset( $_GET['optin_monster_api_id'] ) ? $this->base->get_optin( absint( $_GET['optin_monster_api_id'] ) ) : false;
80
 
195
  <?php // If we have credentials only show the old stuff if it is saved ?>
196
  <?php if ( $credentials ) : ?>
197
  <?php if ( isset( $credentials['api'] ) && '' != $credentials['api'] || isset( $credentials['key'] ) && '' != $credentials['key'] ) : ?>
198
+ <p>The Legacy API Username and Key below will be deprecated soon. Please <a href="<?php echo OPTINMONSTER_APP_URL; ?>/account/api/" target="_blank">generate a new API key</a> and paste it above to authenticate using our new and improved REST API.</p>
199
  <?php echo $object->get_setting_ui( 'api', 'user' ); ?>
200
  <?php echo $object->get_setting_ui( 'api', 'key' ); ?>
201
  <?php endif; ?>
234
  public function optin_overview( $object ) {
235
 
236
  $optins = $this->base->get_optins();
237
+ $i = 0;
238
  if ( $optins ) :
239
  ?>
240
  <?php foreach ( $optins as $optin ) : $class = 0 == $i ? ' omapi-optin-first' : '';
297
  echo $object->get_setting_ui( 'optins', 'enabled' );
298
 
299
  if ( 'sidebar' !== $type ) {
300
+ if ( OMAPI_Utils::is_inline_type( $type ) ) {
301
  echo $object->get_setting_ui( 'optins', 'automatic' );
302
  echo $object->get_setting_ui( 'optins', 'automatic_shortcode');
303
  } else {
322
 
323
  echo $object->get_setting_ui( 'optins', 'show_on_woocommerce');
324
  // Don't show if output can't use the_content filter
325
+ if ( ! OMAPI_Utils::is_inline_type( $type ) ) {
326
  echo $object->get_setting_ui( 'optins', 'is_wc_shop' );
327
  }
328
  echo $object->get_setting_ui( 'optins', 'is_wc_product');
354
  echo $object->get_setting_ui( 'toggle', 'advanced-end' );
355
  }
356
 
357
+ if ( 'sidebar' == $type || 'inline' == $type ) {
358
  echo $object->get_setting_ui('note', 'sidebar_widget_notice');
359
  }
360
 
376
  */
377
  public function get_optin_links( $optin_id ) {
378
 
379
+ $optin = get_post( $optin_id );
380
+ $slug = $optin->post_name;
381
+ $status = (bool) get_post_meta( $optin_id, '_omapi_enabled', true );
382
  $status_link = $status ? __( 'Disable', 'optin-monster-api' ) : __( 'Go Live', 'optin-monster-api' );
383
  $status_desc = $status ? esc_attr__( 'Disable this campaign', 'optin-monster-api' ) : esc_attr__( 'Go live with this campaign', 'optin-monster-api' );
384
+ $links = array();
385
+ $links['editd'] = '<a href="' . esc_url_raw( OPTINMONSTER_APP_URL . '/campaigns/' . $slug . '/edit/' ) . '" title="' . esc_attr__( 'Edit this campaign on the OptinMonster App', 'optin-monster-api' ) . '" target="_blank">Edit Design</a>';
386
  $links['edito'] = '<a href="' . esc_url_raw( add_query_arg( array( 'optin_monster_api_view' => $this->view, 'optin_monster_api_action' => 'edit', 'optin_monster_api_id' => $optin_id ), admin_url( 'admin.php?page=optin-monster-api-settings' ) ) ) . '" title="' . esc_attr__( 'Edit the output settings for this campaign', 'optin-monster-api' ) . '">Edit Output Settings</a>';
387
  $links['status'] = '<a href="' . wp_nonce_url( esc_url_raw( add_query_arg( array( 'optin_monster_api_view' => $this->view, 'optin_monster_api_action' => 'status', 'optin_monster_api_id' => $optin_id ), admin_url( 'admin.php?page=optin-monster-api-settings' ) ) ), 'omapi-action' ) . '" title="' . $status_desc . '">' . $status_link . '</a>';
388
 
OMAPI/Menu.php CHANGED
@@ -84,7 +84,7 @@ class OMAPI_Menu {
84
  public function set() {
85
 
86
  self::$instance = $this;
87
- $this->base = OMAPI::get_instance();
88
  $this->view = isset( $_GET['optin_monster_api_view'] ) ? stripslashes( $_GET['optin_monster_api_view'] ) : $this->base->get_view();
89
 
90
  }
@@ -194,8 +194,8 @@ class OMAPI_Menu {
194
  $this->base->plugin_slug . '-settings',
195
  'omapi',
196
  array(
197
- 'ajax' => admin_url( 'admin-ajax.php' ),
198
- 'nonce' => wp_create_nonce( 'omapi-query-nonce' ),
199
  'confirm' => __( 'Are you sure you want to reset these settings?', 'optin-monster-api' ),
200
  'date_format' => 'F j, Y',
201
  'supportData' => $this->get_support_data(),
@@ -279,7 +279,7 @@ class OMAPI_Menu {
279
  'Template types to Show on' => get_post_meta( $optin->ID, '_omapi_show', true ),
280
  'Shortcodes Synced and Recognized' => get_post_meta( $optin->ID, '_omapi_shortcode', true ) ? htmlspecialchars_decode( get_post_meta( $optin->ID, '_omapi_shortcode_output', true ) ) : 'None recognized',
281
  );
282
- if ( 'post' == $design_type ) {
283
  $optin_data[$slug]['Automatic Output Status'] = get_post_meta( $optin->ID, '_omapi_automatic', true ) ? 'Enabled' : 'Disabled';
284
  }
285
 
@@ -303,7 +303,7 @@ class OMAPI_Menu {
303
  $plugins = get_plugins();
304
  $active_plugins = get_option( 'active_plugins', array() );
305
  $used_plugins = "\n";
306
- $api_ping = wp_remote_request( 'https://api.optinmonster.com/v1/ping' );
307
  foreach ( $plugins as $plugin_path => $plugin ) {
308
  if ( ! in_array( $plugin_path, $active_plugins ) ) {
309
  continue;
@@ -399,8 +399,8 @@ class OMAPI_Menu {
399
  public function get_panels() {
400
 
401
  // Only load the API panel if no API credentials have been set.
402
- $panels = array();
403
- $creds = $this->base->get_api_credentials();
404
  $can_migrate = $this->base->can_migrate();
405
  $is_legacy_active = $this->base->is_legacy_active();
406
 
@@ -410,7 +410,7 @@ class OMAPI_Menu {
410
  }
411
 
412
  // Set default panels.
413
- $panels['api'] = __( 'API Credentials', 'optin-monster-api' );
414
 
415
  // Set the settings panel.
416
  //$panels['settings'] = __( 'Settings', 'optin-monster-api' );
@@ -432,16 +432,16 @@ class OMAPI_Menu {
432
  *
433
  * @since 1.0.0
434
  *
435
- * @param string $id The optin ID to target.
436
  * @param string $setting The possible subkey setting for the option.
437
- * @return string HTML setting string.
438
  */
439
  public function get_setting_ui( $id, $setting = '' ) {
440
 
441
  // Prepare variables.
442
  $ret = '';
443
  $optin_id = isset( $_GET['optin_monster_api_id'] ) ? absint( $_GET['optin_monster_api_id'] ) : 0;
444
- $value = 'optins' == $id ? get_post_meta( $optin_id, '_omapi_' . $setting, true ) : $this->base->get_option( $id, $setting );
445
  $optin = get_post( $optin_id);
446
 
447
  // Load the type of setting UI based on the option.
@@ -506,7 +506,7 @@ class OMAPI_Menu {
506
  case 'optins' :
507
  switch ( $setting ) {
508
  case 'enabled' :
509
- $ret = $this->get_checkbox_field( $setting, $value, $id, __( 'Enable campaign on site?', 'optin-monster-api' ), __( 'The campaign will not be displayed on this site unless this setting is checked.', 'optin-monster-api' ) );
510
  break 2;
511
 
512
  case 'automatic' :
@@ -792,7 +792,7 @@ class OMAPI_Menu {
792
  }
793
 
794
  // Add default option.
795
- $ret[] = array(
796
  'name' => __( 'Select your MailPoet list...', 'optin-monster-api' ),
797
  'value' => 'none'
798
  );
@@ -854,7 +854,7 @@ class OMAPI_Menu {
854
  *
855
  * @param string $setting The name of the setting to be saved to the DB.
856
  * @param mixed $value The value of the setting.
857
- * @param string $id The setting ID to target for name field.
858
  * @param string $label The label of the input field.
859
  * @param string $desc The description for the input field.
860
  * @param string $place Placeholder text for the field.
@@ -896,7 +896,7 @@ class OMAPI_Menu {
896
  *
897
  * @param string $setting The name of the setting to be saved to the DB.
898
  * @param mixed $value The value of the setting.
899
- * @param string $id The setting ID to target for name field.
900
  * @param string $label The label of the input field.
901
  * @param string $desc The description for the input field.
902
  * @param string $place Placeholder text for the field.
@@ -930,7 +930,7 @@ class OMAPI_Menu {
930
  *
931
  * @param string $setting The name of the setting to be saved to the DB.
932
  * @param mixed $value The value of the setting.
933
- * @param string $id The setting ID to target for name field.
934
  * @param array $classes Array of classes to add to the field.
935
  * @return string $html HTML representation of the data.
936
  */
@@ -955,7 +955,7 @@ class OMAPI_Menu {
955
  *
956
  * @param string $setting The name of the setting to be saved to the DB.
957
  * @param mixed $value The value of the setting.
958
- * @param string $id The setting ID to target for name field.
959
  * @param string $label The label of the input field.
960
  * @param string $desc The description for the input field.
961
  * @param string $place Placeholder text for the field.
@@ -989,7 +989,7 @@ class OMAPI_Menu {
989
  *
990
  * @param string $setting The name of the setting to be saved to the DB.
991
  * @param mixed $value The value of the setting.
992
- * @param string $id The setting ID to target for name field.
993
  * @param string $label The label of the input field.
994
  * @param string $desc The description for the input field.
995
  * @param array $classes Array of classes to add to the field.
@@ -1022,7 +1022,7 @@ class OMAPI_Menu {
1022
  *
1023
  * @param string $setting The name of the setting to be saved to the DB.
1024
  * @param mixed $value The value of the setting.
1025
- * @param string $id The setting ID to target for name field.
1026
  * @param array $data The data to be used for option fields.
1027
  * @param string $label The label of the input field.
1028
  * @param string $desc The description for the input field.
@@ -1161,7 +1161,7 @@ class OMAPI_Menu {
1161
  $field .= '<div class="omapi-support-links ' . $setting . '"><h3>' . $title . '</h3><ul>';
1162
  $field .= '<li><a target="_blank" href="' . esc_url( 'https://optinmonster.com/docs/' ) . '">'. __('Documentation','optin-monster-api') . '</a></li>';
1163
  $field .= '<li><a target="_blank" href="' . esc_url( 'https://wordpress.org/plugins/optinmonster/changelog/' ) . '">'. __('Changelog','optin-monster-api') . '</a></li>';
1164
- $field .= '<li><a target="_blank" href="' . esc_url( 'https://app.optinmonster.com/account/support/' ) . '">'. __('Create a Support Ticket','optin-monster-api') . '</a></li>';
1165
  $field .= '</ul></div>';
1166
 
1167
  return apply_filters( 'optin_monster_api_support_links', $field, $setting);
@@ -1172,7 +1172,7 @@ class OMAPI_Menu {
1172
  $field ='';
1173
 
1174
  $field .= '<div class="omapi-support-data ' . $setting . '"><h3>' . $title . '</h3>';
1175
- $link = 'https://app.optinmonster.com/account/support/';
1176
  $field .= '<p>' . sprintf( wp_kses( __( 'Download the report and attach to your <a href="%s">support ticket</a> to help speed up the process.', 'optin-monster-api' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( $link ) ) . '</p>';
1177
  $field .= '<a href="' . esc_url_raw( '#' ) . '" id="js--omapi-support-pdf" class="button button-primary button-large omapi-support-data-button" title="Download a PDF Report for Support" target="_blank">Download PDF Report</a>';
1178
  $field .= '</div>';
@@ -1378,7 +1378,7 @@ class OMAPI_Menu {
1378
  $html .= '<li><a target="_blank" href="' . esc_url_raw( 'https://optinmonster.com/docs/' ) . '">' . __('Need Help?', 'optin-monster-api') . '</a></li>';
1379
  $html .= '<li><a href="' . esc_url_raw( 'https://optinmonster.com/contact-us/' ) . '" target="_blank">' . __('Send Us Feedback', 'optin-monster-api') . '</a></li>';
1380
  if( $screen->id === 'toplevel_page_optin-monster-api-settings' ) {
1381
- $html .= '<li class="omapi-menu-button"><a id="omapi-create-new-optin-button" href="https://app.optinmonster.com/campaigns/new/" class="button button-secondary omapi-new-optin" title="' . __( 'Create New Campaign', 'optin-monster-api' ) . '" target="_blank">' . __( 'Create New Campaign', 'optin-monster-api' ) . '</a></li>';
1382
  }
1383
  $html .= '</ul></div>';
1384
  $html .= '</div>';
84
  public function set() {
85
 
86
  self::$instance = $this;
87
+ $this->base = OMAPI::get_instance();
88
  $this->view = isset( $_GET['optin_monster_api_view'] ) ? stripslashes( $_GET['optin_monster_api_view'] ) : $this->base->get_view();
89
 
90
  }
194
  $this->base->plugin_slug . '-settings',
195
  'omapi',
196
  array(
197
+ 'ajax' => admin_url( 'admin-ajax.php' ),
198
+ 'nonce' => wp_create_nonce( 'omapi-query-nonce' ),
199
  'confirm' => __( 'Are you sure you want to reset these settings?', 'optin-monster-api' ),
200
  'date_format' => 'F j, Y',
201
  'supportData' => $this->get_support_data(),
279
  'Template types to Show on' => get_post_meta( $optin->ID, '_omapi_show', true ),
280
  'Shortcodes Synced and Recognized' => get_post_meta( $optin->ID, '_omapi_shortcode', true ) ? htmlspecialchars_decode( get_post_meta( $optin->ID, '_omapi_shortcode_output', true ) ) : 'None recognized',
281
  );
282
+ if ( OMAPI_Utils::is_inline_type( $design_type ) ) {
283
  $optin_data[$slug]['Automatic Output Status'] = get_post_meta( $optin->ID, '_omapi_automatic', true ) ? 'Enabled' : 'Disabled';
284
  }
285
 
303
  $plugins = get_plugins();
304
  $active_plugins = get_option( 'active_plugins', array() );
305
  $used_plugins = "\n";
306
+ $api_ping = wp_remote_request( OPTINMONSTER_APP_URL . '/v1/ping' );
307
  foreach ( $plugins as $plugin_path => $plugin ) {
308
  if ( ! in_array( $plugin_path, $active_plugins ) ) {
309
  continue;
399
  public function get_panels() {
400
 
401
  // Only load the API panel if no API credentials have been set.
402
+ $panels = array();
403
+ $creds = $this->base->get_api_credentials();
404
  $can_migrate = $this->base->can_migrate();
405
  $is_legacy_active = $this->base->is_legacy_active();
406
 
410
  }
411
 
412
  // Set default panels.
413
+ $panels['api'] = __( 'API Credentials', 'optin-monster-api' );
414
 
415
  // Set the settings panel.
416
  //$panels['settings'] = __( 'Settings', 'optin-monster-api' );
432
  *
433
  * @since 1.0.0
434
  *
435
+ * @param string $id The optin ID to target.
436
  * @param string $setting The possible subkey setting for the option.
437
+ * @return string HTML setting string.
438
  */
439
  public function get_setting_ui( $id, $setting = '' ) {
440
 
441
  // Prepare variables.
442
  $ret = '';
443
  $optin_id = isset( $_GET['optin_monster_api_id'] ) ? absint( $_GET['optin_monster_api_id'] ) : 0;
444
+ $value = 'optins' == $id ? get_post_meta( $optin_id, '_omapi_' . $setting, true ) : $this->base->get_option( $id, $setting );
445
  $optin = get_post( $optin_id);
446
 
447
  // Load the type of setting UI based on the option.
506
  case 'optins' :
507
  switch ( $setting ) {
508
  case 'enabled' :
509
+ $ret = $this->get_checkbox_field( $setting, $value, $id, __( 'Enable campaign on site?', 'optin-monster-api' ), __( 'The campaign will not be displayed on this site unless this setting is checked.', 'optin-monster-api' ) );
510
  break 2;
511
 
512
  case 'automatic' :
792
  }
793
 
794
  // Add default option.
795
+ $ret[] = array(
796
  'name' => __( 'Select your MailPoet list...', 'optin-monster-api' ),
797
  'value' => 'none'
798
  );
854
  *
855
  * @param string $setting The name of the setting to be saved to the DB.
856
  * @param mixed $value The value of the setting.
857
+ * @param string $id The setting ID to target for name field.
858
  * @param string $label The label of the input field.
859
  * @param string $desc The description for the input field.
860
  * @param string $place Placeholder text for the field.
896
  *
897
  * @param string $setting The name of the setting to be saved to the DB.
898
  * @param mixed $value The value of the setting.
899
+ * @param string $id The setting ID to target for name field.
900
  * @param string $label The label of the input field.
901
  * @param string $desc The description for the input field.
902
  * @param string $place Placeholder text for the field.
930
  *
931
  * @param string $setting The name of the setting to be saved to the DB.
932
  * @param mixed $value The value of the setting.
933
+ * @param string $id The setting ID to target for name field.
934
  * @param array $classes Array of classes to add to the field.
935
  * @return string $html HTML representation of the data.
936
  */
955
  *
956
  * @param string $setting The name of the setting to be saved to the DB.
957
  * @param mixed $value The value of the setting.
958
+ * @param string $id The setting ID to target for name field.
959
  * @param string $label The label of the input field.
960
  * @param string $desc The description for the input field.
961
  * @param string $place Placeholder text for the field.
989
  *
990
  * @param string $setting The name of the setting to be saved to the DB.
991
  * @param mixed $value The value of the setting.
992
+ * @param string $id The setting ID to target for name field.
993
  * @param string $label The label of the input field.
994
  * @param string $desc The description for the input field.
995
  * @param array $classes Array of classes to add to the field.
1022
  *
1023
  * @param string $setting The name of the setting to be saved to the DB.
1024
  * @param mixed $value The value of the setting.
1025
+ * @param string $id The setting ID to target for name field.
1026
  * @param array $data The data to be used for option fields.
1027
  * @param string $label The label of the input field.
1028
  * @param string $desc The description for the input field.
1161
  $field .= '<div class="omapi-support-links ' . $setting . '"><h3>' . $title . '</h3><ul>';
1162
  $field .= '<li><a target="_blank" href="' . esc_url( 'https://optinmonster.com/docs/' ) . '">'. __('Documentation','optin-monster-api') . '</a></li>';
1163
  $field .= '<li><a target="_blank" href="' . esc_url( 'https://wordpress.org/plugins/optinmonster/changelog/' ) . '">'. __('Changelog','optin-monster-api') . '</a></li>';
1164
+ $field .= '<li><a target="_blank" href="' . esc_url( OPTINMONSTER_APP_URL . '/account/support/' ) . '">'. __('Create a Support Ticket','optin-monster-api') . '</a></li>';
1165
  $field .= '</ul></div>';
1166
 
1167
  return apply_filters( 'optin_monster_api_support_links', $field, $setting);
1172
  $field ='';
1173
 
1174
  $field .= '<div class="omapi-support-data ' . $setting . '"><h3>' . $title . '</h3>';
1175
+ $link = OPTINMONSTER_APP_URL . '/account/support/';
1176
  $field .= '<p>' . sprintf( wp_kses( __( 'Download the report and attach to your <a href="%s">support ticket</a> to help speed up the process.', 'optin-monster-api' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( $link ) ) . '</p>';
1177
  $field .= '<a href="' . esc_url_raw( '#' ) . '" id="js--omapi-support-pdf" class="button button-primary button-large omapi-support-data-button" title="Download a PDF Report for Support" target="_blank">Download PDF Report</a>';
1178
  $field .= '</div>';
1378
  $html .= '<li><a target="_blank" href="' . esc_url_raw( 'https://optinmonster.com/docs/' ) . '">' . __('Need Help?', 'optin-monster-api') . '</a></li>';
1379
  $html .= '<li><a href="' . esc_url_raw( 'https://optinmonster.com/contact-us/' ) . '" target="_blank">' . __('Send Us Feedback', 'optin-monster-api') . '</a></li>';
1380
  if( $screen->id === 'toplevel_page_optin-monster-api-settings' ) {
1381
+ $html .= '<li class="omapi-menu-button"><a id="omapi-create-new-optin-button" href="' . OPTINMONSTER_APP_URL . '/campaigns/new/" class="button button-secondary omapi-new-optin" title="' . __( 'Create New Campaign', 'optin-monster-api' ) . '" target="_blank">' . __( 'Create New Campaign', 'optin-monster-api' ) . '</a></li>';
1382
  }
1383
  $html .= '</ul></div>';
1384
  $html .= '</div>';
OMAPI/Output.php CHANGED
@@ -148,7 +148,7 @@ class OMAPI_Output {
148
  */
149
  public function api_script() {
150
 
151
- wp_enqueue_script( $this->base->plugin_slug . '-api-script', OPTINMONSTER_API, array( 'jquery' ), $this->base->version );
152
 
153
  if ( version_compare( get_bloginfo( 'version' ), '4.1.0', '>=' ) ) {
154
  add_filter( 'script_loader_tag', array( $this, 'filter_api_script' ), 10, 2 );
@@ -190,7 +190,7 @@ class OMAPI_Output {
190
  public function filter_api_url( $url ) {
191
 
192
  // If the handle is not ours, do nothing.
193
- if ( false === strpos( $url, 'a.optmstr.com/app/js/api.min.js' ) ) {
194
  return $url;
195
  }
196
 
@@ -329,7 +329,7 @@ class OMAPI_Output {
329
  }
330
 
331
  // If the type is a sidebar or after post optin, pass over it.
332
- if ( isset( $fields['type'] ) && 'post' !== $fields['type'] ) {
333
  continue;
334
  }
335
 
@@ -653,7 +653,7 @@ class OMAPI_Output {
653
  }
654
 
655
  // If the type is a sidebar or after post optin, pass over it.
656
- if ( isset( $fields['type'] ) && ( 'post' == $fields['type'] || 'sidebar' == $fields['type'] ) ) {
657
  continue;
658
  }
659
 
@@ -1128,10 +1128,10 @@ class OMAPI_Output {
1128
  $this->base->plugin_slug . '-wp-helper',
1129
  plugins_url( 'assets/js/helper.js', OMAPI_FILE ),
1130
  array( 'jquery'),
1131
- $this->base->version,
1132
  true
1133
  );
1134
  }
1135
  }
1136
 
1137
- }
148
  */
149
  public function api_script() {
150
 
151
+ wp_enqueue_script( $this->base->plugin_slug . '-api-script', OPTINMONSTER_APIJS_URL, array( 'jquery' ), $this->base->version );
152
 
153
  if ( version_compare( get_bloginfo( 'version' ), '4.1.0', '>=' ) ) {
154
  add_filter( 'script_loader_tag', array( $this, 'filter_api_script' ), 10, 2 );
190
  public function filter_api_url( $url ) {
191
 
192
  // If the handle is not ours, do nothing.
193
+ if ( false === strpos( $url, str_replace( 'https://', '', OPTINMONSTER_APIJS_URL ) ) ) {
194
  return $url;
195
  }
196
 
329
  }
330
 
331
  // If the type is a sidebar or after post optin, pass over it.
332
+ if ( isset( $fields['type'] ) && ! OMAPI_Utils::is_inline_type( $fields['type'] ) ) {
333
  continue;
334
  }
335
 
653
  }
654
 
655
  // If the type is a sidebar or after post optin, pass over it.
656
+ if ( isset( $fields['type'] ) && ( 'sidebar' == $fields['type'] || OMAPI_Utils::is_inline_type( $fields['type'] ) ) ) {
657
  continue;
658
  }
659
 
1128
  $this->base->plugin_slug . '-wp-helper',
1129
  plugins_url( 'assets/js/helper.js', OMAPI_FILE ),
1130
  array( 'jquery'),
1131
+ $this->base->version . ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? time() : '' ),
1132
  true
1133
  );
1134
  }
1135
  }
1136
 
1137
+ }
OMAPI/Refresh.php CHANGED
File without changes
OMAPI/Review.php CHANGED
@@ -80,8 +80,7 @@ class OMAPI_Review {
80
  public function __construct() {
81
 
82
  // Set default class properties
83
- $this->protocol = 'https://';
84
- $this->url = $this->protocol . $this->route;
85
 
86
  // Set our object.
87
  $this->set();
@@ -109,7 +108,7 @@ class OMAPI_Review {
109
  public function set() {
110
 
111
  self::$instance = $this;
112
- $this->base = OMAPI::get_instance();
113
 
114
  }
115
 
@@ -336,8 +335,8 @@ class OMAPI_Review {
336
  $headers = array(
337
  'Content-Type' => 'application/x-www-form-urlencoded',
338
  'Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0',
339
- 'Pragma' => 'no-cache',
340
- 'Expires' => 0,
341
  'OMAPI-Referer' => site_url(),
342
  'OMAPI-Sender' => 'WordPress'
343
  );
@@ -384,12 +383,12 @@ class OMAPI_Review {
384
 
385
  // Verify that we can do a check for reviews.
386
  $review = get_option( 'omapi_review' );
387
- $time = time();
388
- $load = false;
389
 
390
  if ( ! $review ) {
391
  $review = array(
392
- 'time' => $time,
393
  'dismissed' => false
394
  );
395
  $load = true;
@@ -409,7 +408,7 @@ class OMAPI_Review {
409
  update_option( 'omapi_review', $review );
410
 
411
  // Run through optins on the site to see if any have been loaded for more than a week.
412
- $valid = false;
413
  $optins = $this->base->get_optins();
414
  if ( ! $optins ) {
415
  return;
@@ -479,7 +478,7 @@ class OMAPI_Review {
479
  $review = array();
480
  }
481
 
482
- $review['time'] = time();
483
  $review['dismissed'] = true;
484
 
485
  update_option( 'omapi_review', $review );
80
  public function __construct() {
81
 
82
  // Set default class properties
83
+ $this->url = 'https://' . $this->route;
 
84
 
85
  // Set our object.
86
  $this->set();
108
  public function set() {
109
 
110
  self::$instance = $this;
111
+ $this->base = OMAPI::get_instance();
112
 
113
  }
114
 
335
  $headers = array(
336
  'Content-Type' => 'application/x-www-form-urlencoded',
337
  'Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0',
338
+ 'Pragma' => 'no-cache',
339
+ 'Expires' => 0,
340
  'OMAPI-Referer' => site_url(),
341
  'OMAPI-Sender' => 'WordPress'
342
  );
383
 
384
  // Verify that we can do a check for reviews.
385
  $review = get_option( 'omapi_review' );
386
+ $time = time();
387
+ $load = false;
388
 
389
  if ( ! $review ) {
390
  $review = array(
391
+ 'time' => $time,
392
  'dismissed' => false
393
  );
394
  $load = true;
408
  update_option( 'omapi_review', $review );
409
 
410
  // Run through optins on the site to see if any have been loaded for more than a week.
411
+ $valid = false;
412
  $optins = $this->base->get_optins();
413
  if ( ! $optins ) {
414
  return;
478
  $review = array();
479
  }
480
 
481
+ $review['time'] = time();
482
  $review['dismissed'] = true;
483
 
484
  update_option( 'omapi_review', $review );
OMAPI/Save.php CHANGED
@@ -10,173 +10,173 @@
10
  class OMAPI_Save {
11
 
12
  /**
13
- * Holds the class object.
14
- *
15
- * @since 1.0.0
16
- *
17
- * @var object
18
- */
19
- public static $instance;
20
 
21
  /**
22
- * Path to the file.
23
- *
24
- * @since 1.0.0
25
- *
26
- * @var string
27
- */
28
- public $file = __FILE__;
29
-
30
- /**
31
- * Holds any save errors.
32
- *
33
- * @since 1.0.0
34
- *
35
- * @var array
36
- */
37
- public $errors = array();
38
-
39
- /**
40
- * Holds the base class object.
41
- *
42
- * @since 1.0.0
43
- *
44
- * @var object
45
- */
46
- public $base;
47
-
48
- /**
49
- * Primary class constructor.
50
- *
51
- * @since 1.0.0
52
- */
53
- public function __construct() {
54
-
55
- // Set our object.
56
- $this->set();
57
 
58
  // Possibly save settings.
59
  $this->maybe_save();
60
 
61
- }
62
 
63
- /**
64
- * Sets our object instance and base class instance.
65
- *
66
- * @since 1.0.0
67
- */
68
- public function set() {
69
 
70
- self::$instance = $this;
71
- $this->base = OMAPI::get_instance();
72
- $this->view = isset( $_GET['optin_monster_api_view'] ) ? stripslashes( $_GET['optin_monster_api_view'] ) : $this->base->get_view();
73
 
74
- }
75
 
76
- /**
77
- * Maybe save options if the action has been requested.
78
- *
79
- * @since 1.0.0
80
- */
81
- public function maybe_save() {
82
 
83
- // If we are missing our save action, return early.
84
- if ( empty( $_POST['omapi_save'] ) ) {
85
- return;
86
- }
87
 
88
- // If the subkey is empty, return early.
89
- if ( empty( $_POST['omapi'][ $this->view ] ) ) {
90
- return;
91
- }
92
 
93
- // Run a current user check on saving.
94
- if ( ! current_user_can( apply_filters( 'optin_monster_api_save_cap', 'manage_options' ) ) ) {
95
- return;
96
- }
97
 
98
- // Verify the nonce field.
99
- check_admin_referer( 'omapi_nonce_' . $this->view, 'omapi_nonce_' . $this->view );
100
 
101
- // Save the settings.
102
- $this->save();
103
 
104
- // Provide action to save settings.
105
- do_action( 'optin_monster_api_save_settings', $this->view );
106
 
107
- }
108
 
109
- /**
110
- * Save the plugin options.
111
- *
112
- * @since 1.0.0
113
- */
114
- public function save() {
115
 
116
- // Prepare variables.
117
- $data = stripslashes_deep( $_POST['omapi'][ $this->view ] );
118
 
119
  // Save the data.
120
- switch ( $this->view ) {
121
- case 'api' :
122
  // Create a new API instance to verify API credentials.
123
- $option = $this->base->get_option();
124
- $apikey = isset( $data['apikey'] ) ? $data['apikey'] : false;
125
- $user = isset( $data['user'] ) ? $data['user'] : false;
126
- $key = isset( $data['key'] ) ? $data['key'] : false;
127
- $old_user = isset( $option['api']['user'] ) ? $option['api']['user'] : false;
128
- $old_key = isset( $option['api']['key'] ) ? $option['api']['key'] : false;
129
- $old_apikey = isset( $option['api']['apikey'] ) ? $option['api']['apikey'] : false;
130
 
131
 
132
  // Check for new single apikey and break early with only that data check
133
- if ( $apikey ) {
134
- // Verify this new API Key works but posting to the Legacy route
135
- $api = new OMAPI_Api( 'verify', array( 'apikey' => $apikey ) );
136
- $ret = $api->request();
137
 
138
- if ( is_wp_error( $ret ) ) {
139
- $this->errors['error'] = $ret->get_error_message();
140
- } else {
141
- $option['api']['apikey'] = $apikey;
142
 
143
- // Go ahead and remove the old user and key so we get the 'new' user stuff
144
- $option['api']['user'] = '';
145
- $option['api']['key'] = '';
146
 
147
- // Remove any error messages.
148
- $option['is_invalid'] = false;
149
- $option['is_expired'] = false;
150
- $option['is_disabled'] = false;
151
 
152
- // Store the optin data.
153
- $this->store_optins( $ret );
154
 
155
- // Allow option to be filtered before saving.
156
- $option = apply_filters( 'optin_monster_api_save', $option, $data, $this->view );
157
 
158
- // Save the option.
159
- update_option( 'optin_monster_api', $option );
160
 
161
- }
162
- // End since we are working with the new apikey
163
- break;
164
- }
165
 
166
- // Catch apikey not set errors
167
- if ( ! $apikey ) {
168
 
169
- // Did we used to have one and user is trying to remove it?
170
- if ( $old_apikey ) {
171
- $option['api']['apikey'] = '';
172
 
173
- // Save the option.
174
- update_option( 'optin_monster_api', $option );
175
 
176
- // Explicitly end here so we don't accidentally try grabbing the next round of checks on $user and $key
177
- break;
178
- }
179
- }
180
 
181
  // If one or both items are missing, fail.
182
  if ( ! $user || ! $key ) {
@@ -220,241 +220,284 @@ class OMAPI_Save {
220
  update_option( 'optin_monster_api', $option );
221
  }
222
  }
223
- break;
224
-
225
- case 'optins' :
226
- // Prepare variables.
227
- $data['categories'] = isset( $_POST['post_category'] ) ? stripslashes_deep( $_POST['post_category'] ) : array();
228
- $data['taxonomies'] = isset( $_POST['tax_input'] ) ? stripslashes_deep( $_POST['tax_input'] ) : array();
229
- $optin_id = absint( $_GET['optin_monster_api_id'] );
230
- $fields = array();
231
- $fields['enabled'] = isset( $data['enabled'] ) ? 1 : 0;
232
-
233
- $fields['automatic'] = isset( $data['automatic'] ) ? 1 : 0;
234
- $fields['users'] = isset( $data['users'] ) ? esc_attr( $data['users'] ) : 'all';
235
- $fields['never'] = isset( $data['never'] ) ? explode( ',', $data['never'] ) : array();
236
- $fields['only'] = isset( $data['only'] ) ? explode( ',', $data['only'] ) : array();
237
- $fields['categories'] = isset( $data['categories'] ) ? $data['categories'] : array();
238
- $fields['taxonomies'] = isset( $data['taxonomies'] ) ? $data['taxonomies'] : array();
239
- $fields['show'] = isset( $data['show'] ) ? $data['show'] : array();
240
-
241
- // WooCommerce Fields.
242
- $fields['show_on_woocommerce'] = isset( $data['show_on_woocommerce'] ) ? 1 : 0;
243
- $fields['is_wc_shop'] = isset( $data['is_wc_shop'] ) ? 1 : 0;
244
- $fields['is_wc_product'] = isset( $data['is_wc_product'] ) ? 1 : 0;
245
- $fields['is_wc_cart'] = isset( $data['is_wc_cart'] ) ? 1 : 0;
246
- $fields['is_wc_checkout'] = isset( $data['is_wc_checkout'] ) ? 1 : 0;
247
- $fields['is_wc_account'] = isset( $data['is_wc_account'] ) ? 1 : 0;
248
- $fields['is_wc_endpoint'] = isset( $data['is_wc_endpoint'] ) ? 1 : 0;
249
- $fields['is_wc_endpoint_order_pay'] = isset( $data['is_wc_endpoint_order_pay'] ) ? 1 : 0;
250
- $fields['is_wc_endpoint_order_received'] = isset( $data['is_wc_endpoint_order_received'] ) ? 1 : 0;
251
- $fields['is_wc_endpoint_view_order'] = isset( $data['is_wc_endpoint_view_order'] ) ? 1 : 0;
252
- $fields['is_wc_endpoint_edit_account'] = isset( $data['is_wc_endpoint_edit_account'] ) ? 1 : 0;
253
- $fields['is_wc_endpoint_edit_address'] = isset( $data['is_wc_endpoint_edit_address'] ) ? 1 : 0;
254
- $fields['is_wc_endpoint_lost_password'] = isset( $data['is_wc_endpoint_lost_password'] ) ? 1 : 0;
255
- $fields['is_wc_endpoint_customer_logout'] = isset( $data['is_wc_endpoint_customer_logout'] ) ? 1 : 0;
256
- $fields['is_wc_endpoint_add_payment_method'] = isset( $data['is_wc_endpoint_add_payment_method'] ) ? 1 : 0;
257
-
258
- // Save the data from the regular taxonomies fields into the WC specific tax field.
259
- $fields['is_wc_product_category'] = isset( $data['taxonomies']['product_cat'] ) ? $data['taxonomies']['product_cat'] : array();
260
- $fields['is_wc_product_tag'] = isset( $data['taxonomies']['product_tag'] ) ? $data['taxonomies']['product_tag'] : array();
261
 
262
 
263
  // Convert old test mode data and remove.
264
- $test_mode = get_post_meta( $optin_id, '_omapi_test', true );
265
- if ( isset( $test_mode ) && $test_mode ) {
266
- $fields['users'] = 'in';
267
- delete_post_meta( $optin_id, '_omapi_test' );
268
- }
269
-
270
- if ( $this->base->is_mailpoet_active() ) {
271
- $fields['mailpoet'] = isset( $data['mailpoet'] ) ? 1 : 0;
272
- $fields['mailpoet_list'] = isset( $data['mailpoet_list'] ) ? esc_attr( $data['mailpoet_list'] ) : 'none';
273
- }
274
-
275
- // Allow fields to be filtered.
276
- $fields = apply_filters( 'optin_monster_save_fields', $fields, $optin_id );
277
-
278
- // Loop through each field and save the data.
279
- foreach ( $fields as $key => $val ) {
280
- update_post_meta( $optin_id, '_omapi_' . $key, $val );
281
- }
282
- break;
283
-
284
- case 'settings' :
285
- $option = $this->base->get_option();
286
- $option['settings']['cookies'] = isset( $data['cookies'] ) ? 1 : 0;
287
-
288
- // Allow option to be filtered before saving.
289
  $option = apply_filters( 'optin_monster_api_save', $option, $data, $this->view );
290
 
291
  // Save the option.
292
  update_option( 'optin_monster_api', $option );
293
- break;
294
- }
295
  // If selected, clear out all local cookies.
296
- if ( $this->base->get_option( 'settings', 'cookies' ) ) {
297
- $this->base->actions->cookies();
298
- }
299
-
300
- // Add message to show error or success messages.
301
- if ( ! empty( $this->errors ) ) {
302
- add_action( 'optin_monster_api_messages_' . $this->view, array( $this, 'errors' ) );
303
- } else {
304
  // Add a success message.
305
  add_action( 'optin_monster_api_messages_' . $this->view, array( $this, 'message' ) );
306
- }
307
-
308
- }
309
-
310
- /**
311
- * Store the optin data locally on the site.
312
- *
313
- * @since 1.0.0
314
- *
315
- * @param array $optins Array of optin objects to store.
316
- */
317
- public function store_optins( $optins ) {
318
-
319
- // Do nothing if this is just a success message.
320
- if ( isset( $optins->success ) ) {
321
- return;
322
- }
323
-
324
- // Loop through all of the local optins so we can try to match and update.
325
- $local_optins = $this->base->get_optins();
326
- if ( $local_optins ) {
327
- $data = array();
328
- foreach ( $local_optins as $optin ) {
329
- if ( isset( $optins->{$optin->post_name} ) ) {
330
- $data['ID'] = $optin->ID;
331
- $data['post_title'] = $optins->{$optin->post_name}->title;
332
- $data['post_content'] = $optins->{$optin->post_name}->output;
333
- $data['post_status'] = 'publish';
334
- wp_update_post( $data );
335
- update_post_meta( $optin->ID, '_omapi_type', $optins->{$optin->post_name}->type );
336
- update_post_meta( $optin->ID, '_omapi_ids', $optins->{$optin->post_name}->ids );
337
- if ( ! empty( $optins->{$optin->post_name}->shortcodes ) ) {
338
- $raw_shortcodes = $optins->{$optin->post_name}->shortcodes;
339
- $shortcode_array = is_array( $optins->{$optin->post_name}->shortcodes ) ? implode( '|||', array_map( 'htmlentities', $raw_shortcodes ) ) : (array) htmlentities( $raw_shortcodes );
340
- update_post_meta( $optin->ID, '_omapi_shortcode_output', $shortcode_array );
341
- update_post_meta( $optin->ID, '_omapi_shortcode', true );
342
- } else {
343
- delete_post_meta( $optin->ID, '_omapi_shortcode_output' );
344
- delete_post_meta( $optin->ID, '_omapi_shortcode' );
345
- }
346
- unset( $optins->{$optin->post_name} );
347
- } else {
348
- // Delete the local optin. It does not exist remotely.
349
- wp_delete_post( $optin->ID, true );
350
- unset( $optins->{$optin->post_name} );
351
- }
352
- unset( $data );
353
- }
354
-
355
- // If we still have optins, they are new and we need to add them.
356
- if ( ! empty( $optins ) ) {
357
- foreach ( (array) $optins as $slug => $optin ) {
358
- $data = array();
359
- $data['post_name'] = $slug;
360
- $data['post_title'] = $optin->title;
361
- $data['post_excerpt'] = $optin->id;
362
- $data['post_content'] = $optin->output;
363
- $data['post_status'] = 'publish';
364
- $data['post_type'] = 'omapi';
365
- $post_id = wp_insert_post( $data );
366
- if ( 'post' == $optin->type ) {
367
- update_post_meta( $post_id, '_omapi_automatic', 1 );
368
- }
369
- update_post_meta( $post_id, '_omapi_type', $optin->type );
370
- update_post_meta( $post_id, '_omapi_ids', $optin->ids );
371
- if ( ! empty( $optin->shortcodes ) ) {
372
- $raw_shortcodes = $optin->shortcodes;
373
- $shortcode_array = is_array( $optin->shortcodes ) ? implode( '|||', array_map( 'htmlentities', $raw_shortcodes ) ) : (array) htmlentities( $raw_shortcodes );
374
- update_post_meta( $post_id, '_omapi_shortcode_output', $shortcode_array );
375
- update_post_meta( $post_id, '_omapi_shortcode', true );
376
- } else {
377
- delete_post_meta( $post_id, '_omapi_shortcode_output' );
378
- delete_post_meta( $post_id, '_omapi_shortcode' );
379
- }
380
- }
381
- }
382
- } else {
383
- foreach ( (array) $optins as $slug => $optin ) {
384
- // Maybe update an optin rather than add a new one.
385
- $local = $this->base->get_optin_by_slug( $slug );
386
- $data = array();
387
- if ( $local ) {
388
- $data['ID'] = $local->ID;
389
- $data['post_title'] = $optin->title;
390
- $data['post_content'] = $optin->output;
391
- $data['post_status'] = 'publish';
392
- wp_update_post( $data );
393
- update_post_meta( $local->ID, '_omapi_type', $optin->type );
394
- update_post_meta( $local->ID, '_omapi_ids', $optin->ids );
395
- if ( ! empty( $optin->shortcodes ) ) {
396
- $raw_shortcodes = $optin->shortcodes;
397
- $shortcode_array = is_array( $optin->shortcodes ) ? implode( '|||', array_map( 'htmlentities', $raw_shortcodes ) ) : (array) htmlentities( $raw_shortcodes );
398
- update_post_meta( $local->ID, '_omapi_shortcode_output', $shortcode_array );
399
- update_post_meta( $local->ID, '_omapi_shortcode', true );
400
- } else {
401
- delete_post_meta( $local->ID, '_omapi_shortcode_output' );
402
- delete_post_meta( $local->ID, '_omapi_shortcode' );
403
- }
404
- } else {
405
- $data['post_name'] = $slug;
406
- $data['post_title'] = $optin->title;
407
- $data['post_excerpt'] = $optin->id;
408
- $data['post_content'] = $optin->output;
409
- $data['post_status'] = 'publish';
410
- $data['post_type'] = 'omapi';
411
- $post_id = wp_insert_post( $data );
412
- if ( 'post' == $optin->type ) {
413
- update_post_meta( $post_id, '_omapi_automatic', 1 );
414
- }
415
- update_post_meta( $post_id, '_omapi_type', $optin->type );
416
- update_post_meta( $post_id, '_omapi_ids', $optin->ids );
417
- if ( ! empty( $optin->shortcodes ) ) {
418
- $raw_shortcodes = $optin->shortcodes;
419
- $shortcode_array = is_array( $optin->shortcodes ) ? implode( '|||', array_map( 'htmlentities', $raw_shortcodes ) ) : (array) htmlentities( $raw_shortcodes );
420
- delete_post_meta( $post_id, '_omapi_shortcode_output', $shortcode_array );
421
- delete_post_meta( $post_id, '_omapi_shortcode', true );
422
- } else {
423
- delete_post_meta( $post_id, '_omapi_shortcode_output' );
424
- delete_post_meta( $post_id, '_omapi_shortcode' );
425
- }
426
- }
427
  }
428
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
429
 
430
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
431
 
432
- /**
433
- * Output any error messages.
434
- *
435
- * @since 1.0.0
436
- */
437
- public function errors() {
438
 
439
  foreach ( $this->errors as $id => $message ) :
440
- ?>
441
- <div class="<?php echo sanitize_html_class( $id, 'error' ); ?>"><p><?php echo $message; ?></p></div>
442
- <?php
443
  endforeach;
444
 
445
- }
446
 
447
- /**
448
- * Output a save message.
449
- *
450
- * @since 1.0.0
451
- */
452
- public function message() {
453
 
454
- ?>
455
- <div class="updated"><p><?php _e( 'Your settings have been saved successfully.', 'optin-monster-api' ); ?></p></div>
456
- <?php
457
 
458
- }
459
 
460
  }
10
  class OMAPI_Save {
11
 
12
  /**
13
+ * Holds the class object.
14
+ *
15
+ * @since 1.0.0
16
+ *
17
+ * @var object
18
+ */
19
+ public static $instance;
20
 
21
  /**
22
+ * Path to the file.
23
+ *
24
+ * @since 1.0.0
25
+ *
26
+ * @var string
27
+ */
28
+ public $file = __FILE__;
29
+
30
+ /**
31
+ * Holds any save errors.
32
+ *
33
+ * @since 1.0.0
34
+ *
35
+ * @var array
36
+ */
37
+ public $errors = array();
38
+
39
+ /**
40
+ * Holds the base class object.
41
+ *
42
+ * @since 1.0.0
43
+ *
44
+ * @var object
45
+ */
46
+ public $base;
47
+
48
+ /**
49
+ * Primary class constructor.
50
+ *
51
+ * @since 1.0.0
52
+ */
53
+ public function __construct() {
54
+
55
+ // Set our object.
56
+ $this->set();
57
 
58
  // Possibly save settings.
59
  $this->maybe_save();
60
 
61
+ }
62
 
63
+ /**
64
+ * Sets our object instance and base class instance.
65
+ *
66
+ * @since 1.0.0
67
+ */
68
+ public function set() {
69
 
70
+ self::$instance = $this;
71
+ $this->base = OMAPI::get_instance();
72
+ $this->view = isset( $_GET['optin_monster_api_view'] ) ? stripslashes( $_GET['optin_monster_api_view'] ) : $this->base->get_view();
73
 
74
+ }
75
 
76
+ /**
77
+ * Maybe save options if the action has been requested.
78
+ *
79
+ * @since 1.0.0
80
+ */
81
+ public function maybe_save() {
82
 
83
+ // If we are missing our save action, return early.
84
+ if ( empty( $_POST['omapi_save'] ) ) {
85
+ return;
86
+ }
87
 
88
+ // If the subkey is empty, return early.
89
+ if ( empty( $_POST['omapi'][ $this->view ] ) ) {
90
+ return;
91
+ }
92
 
93
+ // Run a current user check on saving.
94
+ if ( ! current_user_can( apply_filters( 'optin_monster_api_save_cap', 'manage_options' ) ) ) {
95
+ return;
96
+ }
97
 
98
+ // Verify the nonce field.
99
+ check_admin_referer( 'omapi_nonce_' . $this->view, 'omapi_nonce_' . $this->view );
100
 
101
+ // Save the settings.
102
+ $this->save();
103
 
104
+ // Provide action to save settings.
105
+ do_action( 'optin_monster_api_save_settings', $this->view );
106
 
107
+ }
108
 
109
+ /**
110
+ * Save the plugin options.
111
+ *
112
+ * @since 1.0.0
113
+ */
114
+ public function save() {
115
 
116
+ // Prepare variables.
117
+ $data = stripslashes_deep( $_POST['omapi'][ $this->view ] );
118
 
119
  // Save the data.
120
+ switch ( $this->view ) {
121
+ case 'api' :
122
  // Create a new API instance to verify API credentials.
123
+ $option = $this->base->get_option();
124
+ $apikey = isset( $data['apikey'] ) ? $data['apikey'] : false;
125
+ $user = isset( $data['user'] ) ? $data['user'] : false;
126
+ $key = isset( $data['key'] ) ? $data['key'] : false;
127
+ $old_user = isset( $option['api']['user'] ) ? $option['api']['user'] : false;
128
+ $old_key = isset( $option['api']['key'] ) ? $option['api']['key'] : false;
129
+ $old_apikey = isset( $option['api']['apikey'] ) ? $option['api']['apikey'] : false;
130
 
131
 
132
  // Check for new single apikey and break early with only that data check
133
+ if ( $apikey ) {
134
+ // Verify this new API Key works but posting to the Legacy route
135
+ $api = new OMAPI_Api( 'verify', array( 'apikey' => $apikey ) );
136
+ $ret = $api->request();
137
 
138
+ if ( is_wp_error( $ret ) ) {
139
+ $this->errors['error'] = $ret->get_error_message();
140
+ } else {
141
+ $option['api']['apikey'] = $apikey;
142
 
143
+ // Go ahead and remove the old user and key so we get the 'new' user stuff
144
+ $option['api']['user'] = '';
145
+ $option['api']['key'] = '';
146
 
147
+ // Remove any error messages.
148
+ $option['is_invalid'] = false;
149
+ $option['is_expired'] = false;
150
+ $option['is_disabled'] = false;
151
 
152
+ // Store the optin data.
153
+ $this->store_optins( $ret );
154
 
155
+ // Allow option to be filtered before saving.
156
+ $option = apply_filters( 'optin_monster_api_save', $option, $data, $this->view );
157
 
158
+ // Save the option.
159
+ update_option( 'optin_monster_api', $option );
160
 
161
+ }
162
+ // End since we are working with the new apikey
163
+ break;
164
+ }
165
 
166
+ // Catch apikey not set errors
167
+ if ( ! $apikey ) {
168
 
169
+ // Did we used to have one and user is trying to remove it?
170
+ if ( $old_apikey ) {
171
+ $option['api']['apikey'] = '';
172
 
173
+ // Save the option.
174
+ update_option( 'optin_monster_api', $option );
175
 
176
+ // Explicitly end here so we don't accidentally try grabbing the next round of checks on $user and $key
177
+ break;
178
+ }
179
+ }
180
 
181
  // If one or both items are missing, fail.
182
  if ( ! $user || ! $key ) {
220
  update_option( 'optin_monster_api', $option );
221
  }
222
  }
223
+ break;
224
+
225
+ case 'optins' :
226
+ // Prepare variables.
227
+ $data['categories'] = isset( $_POST['post_category'] ) ? stripslashes_deep( $_POST['post_category'] ) : array();
228
+ $data['taxonomies'] = isset( $_POST['tax_input'] ) ? stripslashes_deep( $_POST['tax_input'] ) : array();
229
+ $optin_id = absint( $_GET['optin_monster_api_id'] );
230
+ $fields = array();
231
+ $fields['enabled'] = isset( $data['enabled'] ) ? 1 : 0;
232
+
233
+ $fields['automatic'] = isset( $data['automatic'] ) ? 1 : 0;
234
+ $fields['users'] = isset( $data['users'] ) ? esc_attr( $data['users'] ) : 'all';
235
+ $fields['never'] = isset( $data['never'] ) ? explode( ',', $data['never'] ) : array();
236
+ $fields['only'] = isset( $data['only'] ) ? explode( ',', $data['only'] ) : array();
237
+ $fields['categories'] = isset( $data['categories'] ) ? $data['categories'] : array();
238
+ $fields['taxonomies'] = isset( $data['taxonomies'] ) ? $data['taxonomies'] : array();
239
+ $fields['show'] = isset( $data['show'] ) ? $data['show'] : array();
240
+
241
+ // WooCommerce Fields.
242
+ $fields['show_on_woocommerce'] = isset( $data['show_on_woocommerce'] ) ? 1 : 0;
243
+ $fields['is_wc_shop'] = isset( $data['is_wc_shop'] ) ? 1 : 0;
244
+ $fields['is_wc_product'] = isset( $data['is_wc_product'] ) ? 1 : 0;
245
+ $fields['is_wc_cart'] = isset( $data['is_wc_cart'] ) ? 1 : 0;
246
+ $fields['is_wc_checkout'] = isset( $data['is_wc_checkout'] ) ? 1 : 0;
247
+ $fields['is_wc_account'] = isset( $data['is_wc_account'] ) ? 1 : 0;
248
+ $fields['is_wc_endpoint'] = isset( $data['is_wc_endpoint'] ) ? 1 : 0;
249
+ $fields['is_wc_endpoint_order_pay'] = isset( $data['is_wc_endpoint_order_pay'] ) ? 1 : 0;
250
+ $fields['is_wc_endpoint_order_received'] = isset( $data['is_wc_endpoint_order_received'] ) ? 1 : 0;
251
+ $fields['is_wc_endpoint_view_order'] = isset( $data['is_wc_endpoint_view_order'] ) ? 1 : 0;
252
+ $fields['is_wc_endpoint_edit_account'] = isset( $data['is_wc_endpoint_edit_account'] ) ? 1 : 0;
253
+ $fields['is_wc_endpoint_edit_address'] = isset( $data['is_wc_endpoint_edit_address'] ) ? 1 : 0;
254
+ $fields['is_wc_endpoint_lost_password'] = isset( $data['is_wc_endpoint_lost_password'] ) ? 1 : 0;
255
+ $fields['is_wc_endpoint_customer_logout'] = isset( $data['is_wc_endpoint_customer_logout'] ) ? 1 : 0;
256
+ $fields['is_wc_endpoint_add_payment_method'] = isset( $data['is_wc_endpoint_add_payment_method'] ) ? 1 : 0;
257
+
258
+ // Save the data from the regular taxonomies fields into the WC specific tax field.
259
+ $fields['is_wc_product_category'] = isset( $data['taxonomies']['product_cat'] ) ? $data['taxonomies']['product_cat'] : array();
260
+ $fields['is_wc_product_tag'] = isset( $data['taxonomies']['product_tag'] ) ? $data['taxonomies']['product_tag'] : array();
261
 
262
 
263
  // Convert old test mode data and remove.
264
+ $test_mode = get_post_meta( $optin_id, '_omapi_test', true );
265
+ if ( isset( $test_mode ) && $test_mode ) {
266
+ $fields['users'] = 'in';
267
+ delete_post_meta( $optin_id, '_omapi_test' );
268
+ }
269
+
270
+ if ( $this->base->is_mailpoet_active() ) {
271
+ $fields['mailpoet'] = isset( $data['mailpoet'] ) ? 1 : 0;
272
+ $fields['mailpoet_list'] = isset( $data['mailpoet_list'] ) ? esc_attr( $data['mailpoet_list'] ) : 'none';
273
+ }
274
+
275
+ // Allow fields to be filtered.
276
+ $fields = apply_filters( 'optin_monster_save_fields', $fields, $optin_id );
277
+
278
+ // Loop through each field and save the data.
279
+ foreach ( $fields as $key => $val ) {
280
+ update_post_meta( $optin_id, '_omapi_' . $key, $val );
281
+ }
282
+ break;
283
+
284
+ case 'settings' :
285
+ $option = $this->base->get_option();
286
+ $option['settings']['cookies'] = isset( $data['cookies'] ) ? 1 : 0;
287
+
288
+ // Allow option to be filtered before saving.
289
  $option = apply_filters( 'optin_monster_api_save', $option, $data, $this->view );
290
 
291
  // Save the option.
292
  update_option( 'optin_monster_api', $option );
293
+ break;
294
+ }
295
  // If selected, clear out all local cookies.
296
+ if ( $this->base->get_option( 'settings', 'cookies' ) ) {
297
+ $this->base->actions->cookies();
298
+ }
299
+
300
+ // Add message to show error or success messages.
301
+ if ( ! empty( $this->errors ) ) {
302
+ add_action( 'optin_monster_api_messages_' . $this->view, array( $this, 'errors' ) );
303
+ } else {
304
  // Add a success message.
305
  add_action( 'optin_monster_api_messages_' . $this->view, array( $this, 'message' ) );
306
+ }
307
+
308
+ }
309
+
310
+ /**
311
+ * Store the optin data locally on the site.
312
+ *
313
+ * @since 1.0.0
314
+ *
315
+ * @param array $optins Array of optin objects to store.
316
+ */
317
+ public function store_optins( $optins ) {
318
+
319
+ // Do nothing if this is just a success message.
320
+ if ( isset( $optins->success ) ) {
321
+ return;
322
+ }
323
+
324
+ // Loop through all of the local optins so we can try to match and update.
325
+ $local_optins = $this->base->get_optins();
326
+ if ( $local_optins ) {
327
+ $this->sync_optins( $local_optins, $optins );
328
+ } else {
329
+ $this->add_optins( $optins );
330
+ }
331
+
332
+ }
333
+
334
+ /**
335
+ * Add the retrieved optins as new optin post objects in the DB.
336
+ *
337
+ * @since 1.3.5
338
+ *
339
+ * @param array $optins Array of optin objects to store.
340
+ */
341
+ public function add_optins( $optins ) {
342
+ foreach ( (array) $optins as $slug => $optin ) {
343
+ // Maybe update an optin rather than add a new one.
344
+ $local = $this->base->get_optin_by_slug( $slug );
345
+ if ( $local ) {
346
+ $this->update_optin( $local, $optin );
347
+ } else {
348
+ $this->new_optin( $slug, $optin );
349
+ }
350
+ }
351
+ }
352
+
353
+ /**
354
+ * Sync the retrieved optins with our stored optins.
355
+ *
356
+ * @since 1.3.5
357
+ *
358
+ * @param array $local_optins Array of local optin objects to sync.
359
+ * @param array $optins Array of optin objects to store.
360
+ */
361
+ public function sync_optins( $local_optins, $remote_optins ) {
362
+ foreach ( $local_optins as $local ) {
363
+ if ( isset( $remote_optins->{$local->post_name} ) ) {
364
+
365
+ $this->update_optin( $local, $remote_optins->{$local->post_name} );
366
+
367
+ unset( $remote_optins->{$local->post_name} );
368
+ } else {
369
+ // Delete the local optin. It does not exist remotely.
370
+ wp_delete_post( $local->ID, true );
371
+ unset( $remote_optins->{$local->post_name} );
372
+ }
373
+ }
374
+
375
+ // If we still have optins, they are new and we need to add them.
376
+ if ( ! empty( $remote_optins ) ) {
377
+ foreach ( (array) $remote_optins as $slug => $optin ) {
378
+ $this->new_optin( $slug, $optin );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
379
  }
380
+ }
381
+ }
382
+
383
+ /**
384
+ * Update an existing optin post object in the DB with the one fetched from the API.
385
+ *
386
+ * @since 1.3.5
387
+ *
388
+ * @param object $local The local optin post object.
389
+ * @param object $optin The optin object.
390
+ *
391
+ * @return void
392
+ */
393
+ public function update_optin( $local, $optin ) {
394
+ wp_update_post( array(
395
+ 'ID' => $local->ID, // Existing ID
396
+ 'post_title' => $optin->title,
397
+ 'post_content' => $optin->output,
398
+ 'post_status' => 'publish',
399
+ ) );
400
+
401
+ $this->update_optin_meta( $local->ID, $optin );
402
+ }
403
+
404
+ /**
405
+ * Generate a new optin post object in the DB.
406
+ *
407
+ * @since 1.3.5
408
+ *
409
+ * @param string $slug The campaign slug.
410
+ * @param object $optin The optin object.
411
+ *
412
+ * @return void
413
+ */
414
+ public function new_optin( $slug, $optin ) {
415
+ $post_id = wp_insert_post( array(
416
+ 'post_name' => $slug,
417
+ 'post_title' => $optin->title,
418
+ 'post_excerpt' => $optin->id,
419
+ 'post_content' => $optin->output,
420
+ 'post_status' => 'publish',
421
+ 'post_type' => 'omapi',
422
+ ) );
423
+
424
+ if ( OMAPI_Utils::is_inline_type( $optin->type ) ) {
425
+ update_post_meta( $post_id, '_omapi_automatic', 1 );
426
+ }
427
+
428
+ $this->update_optin_meta( $post_id, $optin );
429
+ }
430
+
431
+ /**
432
+ * Update the optin post object's post-meta with an API object's values.
433
+ *
434
+ * @since 1.3.5
435
+ *
436
+ * @param int $post_id The post (optin) ID.
437
+ * @param object $optin The optin object.
438
+ *
439
+ * @return void
440
+ */
441
+ public function update_optin_meta( $post_id, $optin ) {
442
+ update_post_meta( $post_id, '_omapi_type', $optin->type );
443
+ update_post_meta( $post_id, '_omapi_ids', $optin->ids );
444
+
445
+ $shortcodes = ! empty( $optin->shortcodes ) ? $optin->shortcodes : null;
446
+
447
+ $this->update_shortcodes_meta( $post_id, $shortcodes );
448
+ }
449
 
450
+ /**
451
+ * Store the raw shortcodes to the optin's meta for later retrieval/parsing.
452
+ *
453
+ * @since 1.3.5
454
+ *
455
+ * @param int $post_id The post (optin) ID.
456
+ * @param string|array|null The shortcodes to store to meta, or delete from meta if null.
457
+ *
458
+ * @return void
459
+ */
460
+ protected function update_shortcodes_meta( $post_id, $shortcodes = null ) {
461
+ if ( ! empty( $shortcodes ) ) {
462
+
463
+ $shortcodes = is_array( $shortcodes )
464
+ ? implode( '|||', array_map( 'htmlentities', $shortcodes ) )
465
+ : (array) htmlentities( $shortcodes );
466
+
467
+ update_post_meta( $post_id, '_omapi_shortcode_output', $shortcodes );
468
+ update_post_meta( $post_id, '_omapi_shortcode', true );
469
+ } else {
470
+ delete_post_meta( $post_id, '_omapi_shortcode_output' );
471
+ delete_post_meta( $post_id, '_omapi_shortcode' );
472
+ }
473
+ }
474
 
475
+ /**
476
+ * Output any error messages.
477
+ *
478
+ * @since 1.0.0
479
+ */
480
+ public function errors() {
481
 
482
  foreach ( $this->errors as $id => $message ) :
483
+ ?>
484
+ <div class="<?php echo sanitize_html_class( $id, 'error' ); ?>"><p><?php echo $message; ?></p></div>
485
+ <?php
486
  endforeach;
487
 
488
+ }
489
 
490
+ /**
491
+ * Output a save message.
492
+ *
493
+ * @since 1.0.0
494
+ */
495
+ public function message() {
496
 
497
+ ?>
498
+ <div class="updated"><p><?php _e( 'Your settings have been saved successfully.', 'optin-monster-api' ); ?></p></div>
499
+ <?php
500
 
501
+ }
502
 
503
  }
OMAPI/Shortcode.php CHANGED
File without changes
OMAPI/Type.php CHANGED
File without changes
OMAPI/Utils.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Utils class.
4
+ *
5
+ * @since 1.3.6
6
+ *
7
+ * @package OMAPI
8
+ * @author Justin Sternberg
9
+ */
10
+ class OMAPI_Utils {
11
+
12
+ /**
13
+ * Determines if given type is an inline type.
14
+ *
15
+ * @since 1.3.6
16
+ *
17
+ * @param string $type Type to check
18
+ *
19
+ * @return boolean
20
+ */
21
+ public static function is_inline_type( $type ) {
22
+ return 'post' === $type || 'inline' === $type;
23
+ }
24
+
25
+ }
OMAPI/Validate.php CHANGED
@@ -62,7 +62,7 @@ class OMAPI_Validate {
62
  public function set() {
63
 
64
  self::$instance = $this;
65
- $this->base = OMAPI::get_instance();
66
  $this->view = isset( $_GET['optin_monster_api_view'] ) ? stripslashes( $_GET['optin_monster_api_view'] ) : $this->base->get_view();
67
 
68
  }
@@ -114,7 +114,7 @@ class OMAPI_Validate {
114
  $ret = $api->request();
115
  if ( is_wp_error( $ret ) ) {
116
  $option = $this->base->get_option();
117
- $type = $ret->get_error_code();
118
  switch ( $type ) {
119
  case 'missing' :
120
  case 'auth' :
@@ -168,10 +168,10 @@ class OMAPI_Validate {
168
  }
169
  } elseif ( isset( $option['is_disabled'] ) && $option['is_disabled'] ) {
170
  echo '<div class="error"><p>' . __( 'The subscription to this OptinMonster account has been disabled, likely due to a refund or other administrator action. Please contact OptinMonster support to resolve this issue.', 'optin-monster-api' ) . '</p>';
171
- echo '<p><a href="https://app.optinmonster.com/account/support/?utm_source=orgplugin&utm_medium=link&utm_campaign=wpdashboard" class="button button-primary button-large omapi-new-optin" title="Contact OptinMonster Support" target="_blank">Contact Support</a></p></div>';
172
  } elseif ( isset( $option['is_expired'] ) && $option['is_expired'] ) {
173
  echo '<div class="error"><p>' . __( 'The subscription to this OptinMonster account has expired. Please renew your subscription to use the OptinMonster API.', 'optin-monster-api' ) . '</p>';
174
- echo '<p><a href="https://app.optinmonster.com/account/billing/?utm_source=orgplugin&utm_medium=link&utm_campaign=wpdashboard" class="button button-primary button-large omapi-new-optin" title="Renew Subscription" target="_blank">Renew Subscription</a></p></div>';
175
  } else {
176
  // If user has dismissed before no point going through page checks
177
  if ( $this->should_user_see_connect_nag() ) {
62
  public function set() {
63
 
64
  self::$instance = $this;
65
+ $this->base = OMAPI::get_instance();
66
  $this->view = isset( $_GET['optin_monster_api_view'] ) ? stripslashes( $_GET['optin_monster_api_view'] ) : $this->base->get_view();
67
 
68
  }
114
  $ret = $api->request();
115
  if ( is_wp_error( $ret ) ) {
116
  $option = $this->base->get_option();
117
+ $type = $ret->get_error_code();
118
  switch ( $type ) {
119
  case 'missing' :
120
  case 'auth' :
168
  }
169
  } elseif ( isset( $option['is_disabled'] ) && $option['is_disabled'] ) {
170
  echo '<div class="error"><p>' . __( 'The subscription to this OptinMonster account has been disabled, likely due to a refund or other administrator action. Please contact OptinMonster support to resolve this issue.', 'optin-monster-api' ) . '</p>';
171
+ echo '<p><a href="' . OPTINMONSTER_APP_URL . '/account/support/?utm_source=orgplugin&utm_medium=link&utm_campaign=wpdashboard" class="button button-primary button-large omapi-new-optin" title="Contact OptinMonster Support" target="_blank">Contact Support</a></p></div>';
172
  } elseif ( isset( $option['is_expired'] ) && $option['is_expired'] ) {
173
  echo '<div class="error"><p>' . __( 'The subscription to this OptinMonster account has expired. Please renew your subscription to use the OptinMonster API.', 'optin-monster-api' ) . '</p>';
174
+ echo '<p><a href="' . OPTINMONSTER_APP_URL . '/account/billing/?utm_source=orgplugin&utm_medium=link&utm_campaign=wpdashboard" class="button button-primary button-large omapi-new-optin" title="Renew Subscription" target="_blank">Renew Subscription</a></p></div>';
175
  } else {
176
  // If user has dismissed before no point going through page checks
177
  if ( $this->should_user_see_connect_nag() ) {
OMAPI/Welcome.php CHANGED
File without changes
OMAPI/Widget.php CHANGED
@@ -9,193 +9,193 @@
9
  */
10
  class OMAPI_Widget extends WP_Widget {
11
 
12
- /**
13
- * Holds the class object.
14
- *
15
- * @since 1.0.0
16
- *
17
- * @var object
18
- */
19
- public static $instance;
20
-
21
- /**
22
- * Path to the file.
23
- *
24
- * @since 1.0.0
25
- *
26
- * @var string
27
- */
28
- public $file = __FILE__;
29
-
30
- /**
31
- * Holds the base class object.
32
- *
33
- * @since 1.0.0
34
- *
35
- * @var object
36
- */
37
- public $base;
38
-
39
- /**
40
- * Constructor. Sets up and creates the widget with appropriate settings.
41
- *
42
- * @since 1.0.0
43
- */
44
- public function __construct() {
45
-
46
- // Load the base class object.
47
- $this->base = OMAPI::get_instance();
48
-
49
- $widget_ops = apply_filters( 'optin_monster_api_widget_ops',
50
- array(
51
- 'classname' => 'optin-monster-api',
52
- 'description' => __( 'Place an OptinMonster campaign into a widgetized area.', 'optin-monster-api' )
53
- )
54
- );
55
-
56
- $control_ops = apply_filters( 'optin_monster_api_widget_control_ops',
57
- array(
58
- 'id_base' => 'optin-monster-api',
59
- 'height' => 350,
60
- 'width' => 225
61
- )
62
- );
63
-
64
- parent::__construct(
65
- 'optin-monster-api',
66
- apply_filters( 'optin_monster_api_widget_name', __( 'OptinMonster', 'optin-monster-api' ) ),
67
- $widget_ops,
68
- $control_ops
69
- );
70
-
71
- }
72
-
73
- /**
74
- * Outputs the widget within the widgetized area.
75
- *
76
- * @since 1.0.0
77
- *
78
- * @param array $args The default widget arguments.
79
- * @param array $instance The input settings for the current widget instance.
80
- *
81
- * @return void
82
- */
83
- public function widget( $args, $instance ) {
84
-
85
- $title = apply_filters( 'widget_title', $instance['title'] );
86
- $optin_id = $instance['optin_monster_id'];
87
-
88
- do_action( 'optin_monster_api_widget_before_output', $args, $instance );
89
-
90
- echo $args['before_widget'];
91
-
92
- do_action( 'optin_monster_api_widget_before_title', $args, $instance );
93
-
94
- // If a title exists, output it.
95
- if ( $title ) {
96
- echo $args['before_title'] . $title . $args['after_title'];
97
- }
98
-
99
- do_action( 'optin_monster_api_widget_before_optin', $args, $instance );
100
-
101
- // If a optin has been selected, output it.
102
- if ( $optin_id ) {
103
- // Grab the optin object. If it does not exist, return early.
104
- $optin = absint( $optin_id ) ? $this->base->get_optin( $optin_id ) : $this->base->get_optin_by_slug( $optin_id );
105
- if ( ! $optin ) {
106
- return;
107
- }
108
-
109
- // If in test mode but not logged in, skip over the optin.
110
- $test = (bool) get_post_meta( $optin->ID, '_omapi_test', true );
111
- if ( $test && ! is_user_logged_in() ) {
112
- return;
113
- }
114
-
115
- // Load the optin.
116
- optin_monster( $optin->ID );
117
- }
118
-
119
- do_action( 'optin_monster_api_widget_after_optin', $args, $instance );
120
-
121
- echo $args['after_widget'];
122
-
123
- do_action( 'optin_monster_api_widget_after_output', $args, $instance );
124
-
125
- }
126
-
127
- /**
128
- * Sanitizes and updates the widget.
129
- *
130
- * @since 1.0.0
131
- *
132
- * @param array $new_instance The new input settings for the current widget instance.
133
- * @param array $old_instance The old input settings for the current widget instance.
134
- *
135
- * @return array
136
- */
137
- public function update( $new_instance, $old_instance ) {
138
-
139
- // Set $instance to the old instance in case no new settings have been updated for a particular field.
140
- $instance = $old_instance;
141
-
142
- // Sanitize user inputs.
143
- $instance['title'] = trim( $new_instance['title'] );
144
- $instance['optin_monster_id'] = absint( $new_instance['optin_monster_id'] );
145
-
146
- return apply_filters( 'optin_monster_api_widget_update_instance', $instance, $new_instance );
147
-
148
- }
149
-
150
- /**
151
- * Outputs the widget form where the user can specify settings.
152
- *
153
- * @since 1.0.0
154
- *
155
- * @param array $instance The input settings for the current widget instance.
156
- *
157
- * @return void
158
- */
159
- public function form( $instance ) {
160
-
161
- // Get all available optins and widget properties.
162
- $optins = $this->base->get_optins();
163
- $title = isset( $instance['title'] ) ? $instance['title'] : '';
164
- $optin_id = isset( $instance['optin_monster_id'] ) ? $instance['optin_monster_id'] : false;
165
-
166
- do_action( 'optin_monster_api_widget_before_form', $instance );
167
- ?>
168
- <p>
169
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'optin-monster-api' ); ?></label>
170
- <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" style="width: 100%;" />
171
- </p>
172
- <?php do_action( 'optin_monster_api_widget_middle_form', $instance ); ?>
173
- <p>
174
- <label for="<?php echo $this->get_field_id( 'optin_monster_id' ); ?>"><?php _e( 'Campaign', 'optin-monster-api' ); ?></label>
175
- <select id="<?php echo esc_attr( $this->get_field_id( 'optin_monster_id' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'optin_monster_id' ) ); ?>" style="width: 100%;">
176
- <?php
177
- foreach ( $optins as $optin ) {
178
- $type = get_post_meta( $optin->ID, '_omapi_type', true );
179
- $enabled = (bool) get_post_meta( $optin->ID, '_omapi_enabled', true );
180
-
181
- // Only allow sidebar types.
182
- if ( 'sidebar' !== $type ) {
183
- continue;
184
- }
185
 
186
  // Display disabled or enabled selection.
187
  if ( $enabled ) {
188
  echo '<option value="' . $optin->ID . '"' . selected( $optin->ID, $optin_id, false ) . '>' . $optin->post_title . '</option>';
189
- } else {
190
- echo '<option value="' . $optin->ID . '" disabled="disabled"' . selected( $optin->ID, $optin_id, false ) . '>' . $optin->post_title . ' (' . __( 'Not Enabled', 'optin-monster-api' ) . ')</option>';
191
- }
192
- }
193
- ?>
194
- </select>
195
- </p>
196
- <?php
197
- do_action( 'optin_monster_api_widget_after_form', $instance );
198
-
199
- }
200
 
201
  }
9
  */
10
  class OMAPI_Widget extends WP_Widget {
11
 
12
+ /**
13
+ * Holds the class object.
14
+ *
15
+ * @since 1.0.0
16
+ *
17
+ * @var object
18
+ */
19
+ public static $instance;
20
+
21
+ /**
22
+ * Path to the file.
23
+ *
24
+ * @since 1.0.0
25
+ *
26
+ * @var string
27
+ */
28
+ public $file = __FILE__;
29
+
30
+ /**
31
+ * Holds the base class object.
32
+ *
33
+ * @since 1.0.0
34
+ *
35
+ * @var object
36
+ */
37
+ public $base;
38
+
39
+ /**
40
+ * Constructor. Sets up and creates the widget with appropriate settings.
41
+ *
42
+ * @since 1.0.0
43
+ */
44
+ public function __construct() {
45
+
46
+ // Load the base class object.
47
+ $this->base = OMAPI::get_instance();
48
+
49
+ $widget_ops = apply_filters( 'optin_monster_api_widget_ops',
50
+ array(
51
+ 'classname' => 'optin-monster-api',
52
+ 'description' => __( 'Place an OptinMonster campaign into a widgetized area.', 'optin-monster-api' )
53
+ )
54
+ );
55
+
56
+ $control_ops = apply_filters( 'optin_monster_api_widget_control_ops',
57
+ array(
58
+ 'id_base' => 'optin-monster-api',
59
+ 'height' => 350,
60
+ 'width' => 225
61
+ )
62
+ );
63
+
64
+ parent::__construct(
65
+ 'optin-monster-api',
66
+ apply_filters( 'optin_monster_api_widget_name', __( 'OptinMonster', 'optin-monster-api' ) ),
67
+ $widget_ops,
68
+ $control_ops
69
+ );
70
+
71
+ }
72
+
73
+ /**
74
+ * Outputs the widget within the widgetized area.
75
+ *
76
+ * @since 1.0.0
77
+ *
78
+ * @param array $args The default widget arguments.
79
+ * @param array $instance The input settings for the current widget instance.
80
+ *
81
+ * @return void
82
+ */
83
+ public function widget( $args, $instance ) {
84
+
85
+ $title = apply_filters( 'widget_title', $instance['title'] );
86
+ $optin_id = $instance['optin_monster_id'];
87
+
88
+ do_action( 'optin_monster_api_widget_before_output', $args, $instance );
89
+
90
+ echo $args['before_widget'];
91
+
92
+ do_action( 'optin_monster_api_widget_before_title', $args, $instance );
93
+
94
+ // If a title exists, output it.
95
+ if ( $title ) {
96
+ echo $args['before_title'] . $title . $args['after_title'];
97
+ }
98
+
99
+ do_action( 'optin_monster_api_widget_before_optin', $args, $instance );
100
+
101
+ // If a optin has been selected, output it.
102
+ if ( $optin_id ) {
103
+ // Grab the optin object. If it does not exist, return early.
104
+ $optin = absint( $optin_id ) ? $this->base->get_optin( $optin_id ) : $this->base->get_optin_by_slug( $optin_id );
105
+ if ( ! $optin ) {
106
+ return;
107
+ }
108
+
109
+ // If in test mode but not logged in, skip over the optin.
110
+ $test = (bool) get_post_meta( $optin->ID, '_omapi_test', true );
111
+ if ( $test && ! is_user_logged_in() ) {
112
+ return;
113
+ }
114
+
115
+ // Load the optin.
116
+ optin_monster( $optin->ID );
117
+ }
118
+
119
+ do_action( 'optin_monster_api_widget_after_optin', $args, $instance );
120
+
121
+ echo $args['after_widget'];
122
+
123
+ do_action( 'optin_monster_api_widget_after_output', $args, $instance );
124
+
125
+ }
126
+
127
+ /**
128
+ * Sanitizes and updates the widget.
129
+ *
130
+ * @since 1.0.0
131
+ *
132
+ * @param array $new_instance The new input settings for the current widget instance.
133
+ * @param array $old_instance The old input settings for the current widget instance.
134
+ *
135
+ * @return array
136
+ */
137
+ public function update( $new_instance, $old_instance ) {
138
+
139
+ // Set $instance to the old instance in case no new settings have been updated for a particular field.
140
+ $instance = $old_instance;
141
+
142
+ // Sanitize user inputs.
143
+ $instance['title'] = trim( $new_instance['title'] );
144
+ $instance['optin_monster_id'] = absint( $new_instance['optin_monster_id'] );
145
+
146
+ return apply_filters( 'optin_monster_api_widget_update_instance', $instance, $new_instance );
147
+
148
+ }
149
+
150
+ /**
151
+ * Outputs the widget form where the user can specify settings.
152
+ *
153
+ * @since 1.0.0
154
+ *
155
+ * @param array $instance The input settings for the current widget instance.
156
+ *
157
+ * @return void
158
+ */
159
+ public function form( $instance ) {
160
+
161
+ // Get all available optins and widget properties.
162
+ $optins = $this->base->get_optins();
163
+ $title = isset( $instance['title'] ) ? $instance['title'] : '';
164
+ $optin_id = isset( $instance['optin_monster_id'] ) ? $instance['optin_monster_id'] : false;
165
+
166
+ do_action( 'optin_monster_api_widget_before_form', $instance );
167
+ ?>
168
+ <p>
169
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'optin-monster-api' ); ?></label>
170
+ <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" style="width: 100%;" />
171
+ </p>
172
+ <?php do_action( 'optin_monster_api_widget_middle_form', $instance ); ?>
173
+ <p>
174
+ <label for="<?php echo $this->get_field_id( 'optin_monster_id' ); ?>"><?php _e( 'Campaign', 'optin-monster-api' ); ?></label>
175
+ <select id="<?php echo esc_attr( $this->get_field_id( 'optin_monster_id' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'optin_monster_id' ) ); ?>" style="width: 100%;">
176
+ <?php
177
+ foreach ( $optins as $optin ) {
178
+ $type = get_post_meta( $optin->ID, '_omapi_type', true );
179
+ $enabled = (bool) get_post_meta( $optin->ID, '_omapi_enabled', true );
180
+
181
+ // Only allow sidebar types.
182
+ if ( 'sidebar' !== $type && 'inline' !== $type ) {
183
+ continue;
184
+ }
185
 
186
  // Display disabled or enabled selection.
187
  if ( $enabled ) {
188
  echo '<option value="' . $optin->ID . '"' . selected( $optin->ID, $optin_id, false ) . '>' . $optin->post_title . '</option>';
189
+ } else {
190
+ echo '<option value="' . $optin->ID . '" disabled="disabled"' . selected( $optin->ID, $optin_id, false ) . '>' . $optin->post_title . ' (' . __( 'Not Enabled', 'optin-monster-api' ) . ')</option>';
191
+ }
192
+ }
193
+ ?>
194
+ </select>
195
+ </p>
196
+ <?php
197
+ do_action( 'optin_monster_api_widget_after_form', $instance );
198
+
199
+ }
200
 
201
  }
assets/css/images/dashboard-icon.png CHANGED
File without changes
assets/css/images/featured-logos.png CHANGED
File without changes
assets/css/images/features-ab-testing.png CHANGED
File without changes
assets/css/images/features-analytics.png CHANGED
File without changes
assets/css/images/features-builder.png CHANGED
File without changes
assets/css/images/features-exit-animated.gif CHANGED
File without changes
assets/css/images/logo-color-large.png CHANGED
File without changes
assets/css/images/logo-color-large@2x.png CHANGED
File without changes
assets/css/images/matthewwoodward.png CHANGED
File without changes
assets/css/images/menu-icon@2x.png CHANGED
File without changes
assets/css/images/michaelstelzner.png CHANGED
File without changes
assets/css/images/neilpatel.png CHANGED
File without changes
assets/css/images/omapi-graph.png CHANGED
File without changes
assets/css/images/title-icon@2x.png CHANGED
File without changes
assets/css/images/video-cta-button.png CHANGED
File without changes
assets/css/select2-spinner.gif CHANGED
File without changes
assets/css/select2.min.css CHANGED
File without changes
assets/css/select2.png CHANGED
File without changes
assets/css/select2x2.png CHANGED
File without changes
assets/css/settings.css CHANGED
File without changes
assets/fonts/FontAwesome.otf CHANGED
File without changes
assets/fonts/fontawesome-webfont.eot CHANGED
File without changes
assets/fonts/fontawesome-webfont.svg CHANGED
File without changes
assets/fonts/fontawesome-webfont.ttf CHANGED
File without changes
assets/fonts/fontawesome-webfont.woff CHANGED
File without changes
assets/js/clipboard.min.js CHANGED
File without changes
assets/js/helper.js CHANGED
@@ -1,33 +1,73 @@
1
  /* ==========================================================
2
  * helper.js
3
  * ==========================================================
4
- * Copyright 2015 Thomas Griffin.
5
- * https://thomasgriffin.io
6
  * ========================================================== */
7
  jQuery(document).ready(function($){
 
 
8
  $(document).on('OptinMonsterPreOptin', function(event, optin, object){
 
9
  $.each(omapi_localized.slugs, function(i, v) {
10
 
11
- if ( i !== optin.optin.replace('-', '_') ) {
12
  return;
13
  }
14
 
15
- if ( ! v.mailpoet ) {
16
  return;
17
  }
18
 
19
  // Send a request to force optin to work even if no provider is set.
20
- var data = optin.optin_data;
21
- data.no_provider = true;
22
  object.setProp('optin_data', data);
23
 
24
- // Now make an ajax request to make the optin locally.
25
- data.action = 'mailpoet';
26
- data.nonce = omapi_localized.nonce;
27
- data.optin = optin.original_optin;
28
- $.post(omapi_localized.ajax, data, function(){}, 'json');
29
 
30
  return false;
31
  });
32
  });
33
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  /* ==========================================================
2
  * helper.js
3
  * ==========================================================
4
+ * Copyright 2018 Awesome Motive.
5
+ * https://awesomemotive.com
6
  * ========================================================== */
7
  jQuery(document).ready(function($){
8
+
9
+ // Legacy Campaigns
10
  $(document).on('OptinMonsterPreOptin', function(event, optin, object){
11
+ var slug = optin.optin.replace('-', '_');
12
  $.each(omapi_localized.slugs, function(i, v) {
13
 
14
+ if ( ! v.mailpoet ) {
15
  return;
16
  }
17
 
18
+ if ( i !== slug ) {
19
  return;
20
  }
21
 
22
  // Send a request to force optin to work even if no provider is set.
23
+ var data = optin.optin_data;
 
24
  object.setProp('optin_data', data);
25
 
26
+ data.optin = optin.original_optin;
27
+
28
+ // Post to MailPoet.
29
+ postToMailPoet(data);
 
30
 
31
  return false;
32
  });
33
  });
34
+
35
+ // Default Campaigns
36
+ document.addEventListener('om.Optin.init.submit', function(event){
37
+ var campaign = event.detail.Campaign;
38
+ var optin = event.detail.Optin;
39
+
40
+ $.each(omapi_localized.slugs, function(i, v) {
41
+
42
+ if ( ! v.mailpoet ) {
43
+ return;
44
+ }
45
+
46
+ if ( i !== campaign.id ) {
47
+ return;
48
+ }
49
+
50
+ // Send a request to force optin to work even if no provider is set.
51
+ var data = optin.data;
52
+ data.optin = campaign.id;
53
+
54
+ if ( data.fields ) {
55
+ $.extend( data, data.fields );
56
+ }
57
+
58
+ // Post to MailPoet.
59
+ postToMailPoet(data);
60
+
61
+ return false;
62
+ });
63
+ });
64
+
65
+ function postToMailPoet(data) {
66
+ // Now make an ajax request to make the optin locally.
67
+ data.action = 'mailpoet';
68
+ data.nonce = omapi_localized.nonce;
69
+ data.no_provider = true;
70
+
71
+ $.post(omapi_localized.ajax, data, function(){}, 'json');
72
+ }
73
+ });
assets/js/jspdf.min.js CHANGED
File without changes
assets/js/select2.min.js CHANGED
File without changes
assets/js/settings.js CHANGED
@@ -1,8 +1,8 @@
1
  /* ==========================================================
2
  * edit.js
3
  * ==========================================================
4
- * Copyright 2015 Thomas Griffin.
5
- * https://thomasgriffin.io
6
  * ========================================================== */
7
  jQuery(document).ready(function ($) {
8
 
@@ -303,4 +303,4 @@ jQuery(document).ready(function ($) {
303
 
304
 
305
 
306
- });
1
  /* ==========================================================
2
  * edit.js
3
  * ==========================================================
4
+ * Copyright 2018 Awesome Motive.
5
+ * https://awesomemotive.com
6
  * ========================================================== */
7
  jQuery(document).ready(function ($) {
8
 
303
 
304
 
305
 
306
+ });
assets/js/tooltip.min.js CHANGED
File without changes
includes/class-am-notification.php CHANGED
File without changes
optin-monster-wp-api.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: OptinMonster API plugin to connect your WordPress site to your OptinMonster account.
6
  * Author: OptinMonster Team
7
  * Author URI: https://optinmonster.com
8
- * Version: 1.3.4
9
  * Text Domain: optin-monster-api
10
  * Domain Path: languages
11
  *
@@ -40,7 +40,7 @@ define( 'OMAPI_FILE', __FILE__ );
40
  * @since 1.0.0
41
  *
42
  * @package OMAPI
43
- * @author Thomas Griffin
44
  */
45
  class OMAPI {
46
 
@@ -60,7 +60,7 @@ class OMAPI {
60
  *
61
  * @var string
62
  */
63
- public $version = '1.3.4';
64
 
65
  /**
66
  * The name of the plugin.
@@ -142,7 +142,17 @@ class OMAPI {
142
  public function init() {
143
 
144
  // Define necessary plugin constants.
145
- define( 'OPTINMONSTER_API', 'https://a.optmstr.com/app/js/api.min.js' );
 
 
 
 
 
 
 
 
 
 
146
 
147
  // Load our global option.
148
  $this->load_option();
@@ -184,8 +194,8 @@ class OMAPI {
184
 
185
  // Register global components.
186
  $this->ajax = new OMAPI_Ajax();
187
- $this->type = new OMAPI_Type();
188
- $this->output = new OMAPI_Output();
189
  $this->shortcode = new OMAPI_Shortcode();
190
 
191
  // Fire a hook to say that the global classes are loaded.
@@ -224,7 +234,7 @@ class OMAPI {
224
  *
225
  * @since 1.0.0
226
  *
227
- * @param int $id The optin ID used to retrieve a optin.
228
  * @return array|bool Array of optin data or false if none found.
229
  */
230
  public function get_optin( $id ) {
@@ -309,7 +319,7 @@ class OMAPI {
309
 
310
  // Prepare variables.
311
  $option = $this->get_option();
312
- $key = false;
313
  $user = false;
314
  $apikey = false;
315
 
@@ -462,8 +472,8 @@ class OMAPI {
462
  public static function default_options() {
463
 
464
  $options = array(
465
- 'api' => array(),
466
- 'optins' => array(),
467
  'is_expired' => false,
468
  'is_disabled' => false,
469
  'is_invalid' => false,
@@ -524,8 +534,8 @@ register_activation_hook( __FILE__, 'optin_monster_api_activation_hook' );
524
  *
525
  * @since 1.0.0
526
  *
527
- * @global int $wp_version The version of WordPress for this install.
528
- * @global object $wpdb The WordPress database object.
529
  * @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false otherwise.
530
  */
531
  function optin_monster_api_activation_hook( $network_wide ) {
@@ -599,10 +609,10 @@ if ( ! function_exists( 'optin_monster' ) ) {
599
  *
600
  * @since 1.0.0
601
  *
602
- * @param int $id The ID of the optin to load.
603
- * @param string $type The type of field to query.
604
- * @param array $args Associative array of args to be passed.
605
- * @param bool $return Flag to echo or return the optin HTML.
606
  */
607
  function optin_monster( $id, $type = 'id', $args = array(), $return = false ) {
608
 
@@ -634,8 +644,8 @@ if ( ! function_exists( 'optin_monster_tag' ) ) {
634
  *
635
  * @since 1.0.0
636
  *
637
- * @param int $string The post name of the optin to load.
638
- * @param bool $return Flag to echo or return the optin HTML.
639
  */
640
  function optin_monster_tag( $id, $return = false ) {
641
 
5
  * Description: OptinMonster API plugin to connect your WordPress site to your OptinMonster account.
6
  * Author: OptinMonster Team
7
  * Author URI: https://optinmonster.com
8
+ * Version: 1.4.2
9
  * Text Domain: optin-monster-api
10
  * Domain Path: languages
11
  *
40
  * @since 1.0.0
41
  *
42
  * @package OMAPI
43
+ * @author Thomas Griffin
44
  */
45
  class OMAPI {
46
 
60
  *
61
  * @var string
62
  */
63
+ public $version = '1.4.2';
64
 
65
  /**
66
  * The name of the plugin.
142
  public function init() {
143
 
144
  // Define necessary plugin constants.
145
+ if ( ! defined( 'OPTINMONSTER_APIJS_URL' ) ) {
146
+ define( 'OPTINMONSTER_APIJS_URL', 'https://a.optmstr.com/app/js/api.min.js' );
147
+ }
148
+
149
+ if ( ! defined( 'OPTINMONSTER_APP_URL' ) ) {
150
+ define( 'OPTINMONSTER_APP_URL', 'https://app.optinmonster.com' );
151
+ }
152
+
153
+ if ( ! defined( 'OPTINMONSTER_APP_API_URL' ) ) {
154
+ define( 'OPTINMONSTER_APP_API_URL', 'https://app.optinmonster.com/v1/' );
155
+ }
156
 
157
  // Load our global option.
158
  $this->load_option();
194
 
195
  // Register global components.
196
  $this->ajax = new OMAPI_Ajax();
197
+ $this->type = new OMAPI_Type();
198
+ $this->output = new OMAPI_Output();
199
  $this->shortcode = new OMAPI_Shortcode();
200
 
201
  // Fire a hook to say that the global classes are loaded.
234
  *
235
  * @since 1.0.0
236
  *
237
+ * @param int $id The optin ID used to retrieve a optin.
238
  * @return array|bool Array of optin data or false if none found.
239
  */
240
  public function get_optin( $id ) {
319
 
320
  // Prepare variables.
321
  $option = $this->get_option();
322
+ $key = false;
323
  $user = false;
324
  $apikey = false;
325
 
472
  public static function default_options() {
473
 
474
  $options = array(
475
+ 'api' => array(),
476
+ 'optins' => array(),
477
  'is_expired' => false,
478
  'is_disabled' => false,
479
  'is_invalid' => false,
534
  *
535
  * @since 1.0.0
536
  *
537
+ * @global int $wp_version The version of WordPress for this install.
538
+ * @global object $wpdb The WordPress database object.
539
  * @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false otherwise.
540
  */
541
  function optin_monster_api_activation_hook( $network_wide ) {
609
  *
610
  * @since 1.0.0
611
  *
612
+ * @param int $id The ID of the optin to load.
613
+ * @param string $type The type of field to query.
614
+ * @param array $args Associative array of args to be passed.
615
+ * @param bool $return Flag to echo or return the optin HTML.
616
  */
617
  function optin_monster( $id, $type = 'id', $args = array(), $return = false ) {
618
 
644
  *
645
  * @since 1.0.0
646
  *
647
+ * @param int $string The post name of the optin to load.
648
+ * @param bool $return Flag to echo or return the optin HTML.
649
  */
650
  function optin_monster_tag( $id, $return = false ) {
651
 
readme.txt CHANGED
@@ -2,9 +2,9 @@
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.9.2
6
- Requires PHP: 5.2.4
7
- Stable tag: 1.3.4
8
  License: GNU General Public License v2.0 or later
9
 
10
  OptinMonster helps you grow your email list by converting visitors into subscribers and customers. Get more email subscribers now!
@@ -160,6 +160,19 @@ OptinMonster is the <a href="https://optinmonster.com" rel="friend" title="Optin
160
 
161
  == Changelog ==
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  = 1.3.4 =
164
  * Updated the API url to reflect the new endpoint.
165
 
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.9.6
6
+ Requires PHP: 5.3
7
+ Stable tag: 1.4.2
8
  License: GNU General Public License v2.0 or later
9
 
10
  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.4.2 =
164
+ * Fixed a bug that caused issues with PHP versions under 5.6.
165
+
166
+ = 1.4.1 =
167
+ * Include a file that was missing in 1.4.0. Sorry!
168
+
169
+ = 1.4.0 =
170
+ * Updated to work with OptinMonster 5.0 campaigns.
171
+ * Fix PHP notices.
172
+
173
+ = 1.3.5 =
174
+ * Fix issue where shortcodes in campaigns would not be parsed until the campaigns were refreshed a second time.
175
+
176
  = 1.3.4 =
177
  * Updated the API url to reflect the new endpoint.
178