PluginProbe
GetResponse Forms by Optin Cat / 2.0.2
GetResponse Forms by Optin Cat v2.0.2
1.3.4 1.3.5 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 2.0.0 All 36 releases
← All changes | includes/eoi-functions.php +110 -49 1.6.32.0.2 View file →
@@ -1,6 +1,14 @@
1 1 <?php
2 2
3 +require_once FCA_EOI_PLUGIN_DIR . 'includes/classes/k/k.php';
4 +
5 +
6 +function fca_eoi_tooltip ( $text = 'Tooltip', $icon = 'dashicons dashicons-editor-help' ) {
7 + return "<span class='$icon fca_eoi_tooltip' title='" . htmlentities( $text ) . "'></span>";
8 +}
9 +
10 +
3 11 /* REMOVE LINKS FOR USERS WITH FEWER PERMISSIONS THAN EDITOR */
4 12
5 13 function fca_eoi_remove_admin_bar_link() {
6 14 if (!current_user_can( 'delete_others_pages' ) && function_exists( 'remove_meta_box' )){
@@ -10,10 +18,10 @@
10 18 add_action( 'wp_dashboard_setup', 'fca_eoi_remove_admin_bar_link', 50 );
11 19
12 20 function fca_eoi_get_error_texts($post_meta) {
13 21
14 - $name_error = empty ( $post_meta[ 'error_text_field_required' ] ) ? "Error: Please enter a valid email address. For example \"max@domain.com\"." : $post_meta[ 'error_text_field_required' ];
15 - $email_error = empty ( $post_meta[ 'error_text_invalid_email' ] ) ? 'Error: This field is required.' : $post_meta[ 'error_text_invalid_email' ];
22 + $name_error = empty ( $post_meta[ 'error_text_field_required' ] ) ? "Please enter a valid email address. For example \"example@example.com\"." : $post_meta[ 'error_text_field_required' ];
23 + $email_error = empty ( $post_meta[ 'error_text_invalid_email' ] ) ? 'Please fill out this field to continue.' : $post_meta[ 'error_text_invalid_email' ];
16 24
17 25 $errorTexts = array(
18 26 'field_required' => $name_error,
19 27 'invalid_email' => $email_error,
@@ -23,9 +31,9 @@
23 31 }
24 32
25 33 function fca_eoi_get_thanks_mode($post_meta) {
26 34
27 - $mode = empty ( $post_meta[ 'thankyou_page_mode' ] ) ? 'not set' : $post_meta[ 'thankyou_page_mode' ];
35 + $mode = empty ( $post_meta[ 'thankyou_page_mode' ] ) ? 'ajax' : $post_meta[ 'thankyou_page_mode' ];
28 36 return $mode;
29 37 }
30 38
31 39
@@ -35,10 +43,10 @@
35 43 $optins_using_customform = get_posts( array(
36 44 'post_type' => 'easy-opt-ins',
37 45 'posts_per_page' => -1,
38 46 'post_status' => 'any',
39 - 'meta_key' => 'fca_eoi_provider',
40 - 'meta_value' => 'customform',
47 + 'meta_key' => 'fca_eoi_provider',
48 + 'meta_value' => 'customform',
41 49
42 50 ));
43 51
44 52 $forms_in_trash = get_posts( array(
@@ -44,10 +52,10 @@
44 52 $forms_in_trash = get_posts( array(
45 53 'post_type' => 'easy-opt-ins',
46 54 'posts_per_page' => -1,
47 55 'post_status' => 'trash',
48 - 'meta_key' => 'fca_eoi_provider',
49 - 'meta_value' => 'customform',
56 + 'meta_key' => 'fca_eoi_provider',
57 + 'meta_value' => 'customform',
50 58
51 59 ));
52 60
53 61 if ( count ( $optins_using_customform ) > 0 OR count ( $forms_in_trash ) > 0) {
@@ -79,15 +87,25 @@
79 87 $errorTexts = fca_eoi_get_error_texts($fca_eoi_meta);
80 88
81 89 //determine if ajax or thank you page redirect
82 90 $thanks_mode = fca_eoi_get_thanks_mode($fca_eoi_meta);
83 - if ($thanks_mode == 'ajax') {
84 - $thanks_page = htmlentities ( K::get_var( 'thankyou_ajax', $fca_eoi_meta ), ENT_QUOTES, "UTF-8");
91 + if ( $thanks_mode === 'redirect' ) {
92 + $mode = empty ( $fca_eoi_meta[ 'redirect_page_mode' ] ) ? 'page' : $fca_eoi_meta[ 'redirect_page_mode' ];
93 + $home_url = get_site_url();
94 + if ( $mode === 'page' ) {
95 + $thanks_page = get_permalink( K::get_var( 'thank_you_page', $fca_eoi_meta, $home_url ) );
96 + } else {
97 + $thanks_page = empty ( $fca_eoi_meta[ 'thank_you_url' ] ) ? $home_url : $fca_eoi_meta[ 'thank_you_url' ];
98 + }
99 +
85 100 } else {
86 - $thanks_mode = 'redirect';
87 - $thanks_page = get_permalink( K::get_var( 'thank_you_page', $fca_eoi_meta, get_site_url() ) );
101 + $thanks_page = htmlentities ( K::get_var( 'thankyou_ajax', $fca_eoi_meta, 'Thank you! Please check your inbox for your confirmation email.' ), ENT_QUOTES, "UTF-8");
88 102 }
89 -
103 +
104 + $sub_msg = htmlentities ( K::get_var( 'subscribing_message', $fca_eoi_meta, 'Subscribing...' ), ENT_QUOTES, "UTF-8");
105 +
106 + $cookie_dur = K::get_var( 'success_duration', $fca_eoi_meta['publish_lightbox'], 0 );
107 +
90 108 $layout_helper = new EasyOptInsLayout( $selected_layout );
91 109 $php_path = $layout_helper->path_to_resource( 'layout', 'php' );
92 110 $html_path = $layout_helper->path_to_resource( 'layout', 'html' );
93 111 $html_wrap_path = $layout_helper->path_to_html_wrapper();
@@ -107,18 +125,42 @@
107 125 }
108 126
109 127 //SET UP TEMPLATE
110 128
111 - $layout_html = str_replace('{{{layout}}}',file_get_contents( $html_path ),file_get_contents( $html_wrap_path ));
129 + $layout_html = str_replace('{{{layout}}}', file_get_contents( $html_path ), file_get_contents( $html_wrap_path ));
112 130
113 - $banding = K::get_var( 'show_fatcatapps_link', $fca_eoi_meta, false );
114 - $banding = $banding ? "<div class='fca_eoi_layout_fatcatapps_link_wrapper fca_eoi_form_text_element'><a href='https://fatcatapps.com/optincat/' target='_blank'>Powered by Optin Cat</a></div>" : '';
131 + global $dh_easy_opt_ins_plugin;
115 132
133 + if ( $dh_easy_opt_ins_plugin->post_type_obj->settings[ 'distribution' ] === 'free' ) {
134 + $banding = K::get_var( 'show_fatcatapps_link', $fca_eoi_meta, false );
135 + $banding = $banding ? "<div class='fca_eoi_layout_fatcatapps_link_wrapper fca_eoi_form_text_element'><a href='https://fatcatapps.com/optincat/' target='_blank'>Powered by Optin Cat</a></div>" : '';
136 + } else {
137 + $banding = '';
138 + }
139 +
140 + $animation = get_post_meta( $form_id, 'fca_eoi_animation', true );
141 + $animation_class = ( empty ( $animation ) || $animation == 'None' ) ? '' : "animated $animation";
142 +
143 +
144 + if ( $layout_helper->layout_type === 'banner' ) {
145 + $push_page = K::get_var( 'push_page', $fca_eoi_meta, 'on' );
146 + $toggle_position = K::get_var( 'toggle_overlay_position', $fca_eoi_meta, 'off' );
116 147
148 + if ( $push_page === 'on' && $toggle_position === 'off' ) {
149 + $push_page = 'down';
150 + }
151 +
152 + if ( $push_page === 'on' && $toggle_position === 'on' ) {
153 + $push_page = 'up';
154 + }
155 + } else {
156 + $push_page = '';
157 + }
158 +
117 159 $form_head = $form_wrapper;
118 160 $form_head .= "<div id='fca_eoi_form_$form_id' class='fca_eoi_form_content'>";
119 - $form_head .= "<form method='post' action='#' class='fca_eoi_form fca_eoi_layout_$layout_helper->layout_number $layout_helper->layout_class'";
120 - $form_head .= "data-fca_eoi_list_id='$list_id' data-fca_eoi_thank_you_page='$thanks_page' data-fca_eoi_thank_you_mode='$thanks_mode' novalidate>";
161 + $form_head .= "<form method='post' action='#' class='fca_eoi_form fca_eoi_layout_$layout_helper->layout_number $layout_helper->layout_class $animation_class' ";
162 + $form_head .= "data-fca_eoi_list_id='$list_id' data-fca_eoi_push_page='$push_page' data-fca_eoi_success_cookie_duration='$cookie_dur' data-fca_eoi_thank_you_page='$thanks_page' data-fca_eoi_thank_you_mode='$thanks_mode' data-fca_eoi_sub_msg='$sub_msg' novalidate>";
121 163 $form_head .= "<input type='hidden' id='fca_eoi_form_id' name='fca_eoi_form_id' value='$form_id'>";
122 164
123 165 //FILL TEMPLATE
124 166 $layout_html = str_replace(
@@ -138,9 +180,9 @@
138 180 '<div>{{{description_copy}}}</div>',
139 181 '<div>{{{headline_copy}}}</div>',
140 182 "<input class='fca_eoi_form_input_element' type='text' name='name' placeholder='{{{name_placeholder}}}'>",
141 183 '<input class="fca_eoi_form_input_element" type="email" name="email" placeholder="{{{email_placeholder}}}">',
142 - '<div class="fca_eoi_spiner_div"><span class="fca_eoi_loading_spinner"></span></div><input class="fca_eoi_form_button_element" type="submit" value="{{{button_copy}}}">',
184 + '<input class="fca_eoi_form_button_element" type="submit" value="{{{button_copy}}}">',
143 185 '<div>{{{privacy_copy}}}</div>',
144 186 $banding,
145 187 '<input type="hidden" name="fca_eoi" value="1">
146 188 <input type="hidden" name="fca_eoi_error_texts_email" class="fca_eoi_error_texts_email" value="' . htmlspecialchars ($errorTexts['invalid_email']) . '">
@@ -149,15 +191,20 @@
149 191 $layout_html
150 192 );
151 193
152 194 //ADD TEXTS
153 - $headline_copy = $fca_eoi_meta[ 'headline_copy' ];
154 - $description_copy = $fca_eoi_meta[ 'description_copy' ];
195 + $show_headline = K::get_var( 'show_headline_field', $fca_eoi_meta, 'on' );
196 + $show_description = K::get_var( 'show_description_field', $fca_eoi_meta, 'on' );
197 + $show_privacy = K::get_var( 'show_privacy_field', $fca_eoi_meta, 'on' );
198 +
199 + $headline_copy = $show_headline == 'off' ? '' : $fca_eoi_meta[ 'headline_copy' ];
200 + $description_copy = $show_description == 'off' ? '' : $fca_eoi_meta[ 'description_copy' ];
201 +
155 202 $name_placeholder = $fca_eoi_meta[ 'name_placeholder' ];
156 203 $email_placeholder = $fca_eoi_meta[ 'email_placeholder' ];
157 204
158 205 $button_copy = $fca_eoi_meta[ 'button_copy' ];
159 - $privacy_copy = $fca_eoi_meta[ 'privacy_copy' ];
206 + $privacy_copy = $show_privacy == 'off' ? '' : $fca_eoi_meta[ 'privacy_copy' ];
160 207
161 208 $output = str_replace(
162 209 array(
163 210 '{{{headline_copy}}}',
@@ -185,14 +232,14 @@
185 232
186 233 //ADD KEYUP ACTION TO TINY MCE VISUAL EDITOR
187 234 function fca_eoi_tiny_mce_before_init( $initArray ) {
188 235 global $post;
189 - if ( $post->post_type == 'easy-opt-ins' ) {
236 + if ( is_object ( $post ) && $post->post_type == 'easy-opt-ins' ) {
190 237 $initArray['setup'] = <<<JS
191 238 [function(ed) {
192 - ed.on('keyup', function(ed, e) {
239 + ed.on('keyup', function(ed, e) {
193 240 jQuery('[name="fca_eoi[description_copy]"]').html(tinymce.activeEditor.getContent()).trigger('keyup')
194 - });
241 + });
195 242
196 243 }][0]
197 244 JS;
198 245 return $initArray;
@@ -201,24 +248,8 @@
201 248 }
202 249 }
203 250 add_filter( 'tiny_mce_before_init', 'fca_eoi_tiny_mce_before_init' );
204 251
205 -function fca_eoi_migrate_css() {
206 -
207 - require_once FCA_EOI_PLUGIN_DIR . 'powerups/4_new_css/powerup.php';
208 -
209 - //CHECK CURRENT SETTING
210 - $isActive = powerup_new_css_is_active();
211 -
212 - if ( !$isActive ) {
213 - $new_css_obj = new EoiNewCssMigration();
214 - $new_css_obj->migrate( 'old', 'new' );
215 - powerup_new_css_set_active( TRUE );
216 - }
217 -
218 -}
219 -
220 -
221 252 //CONVERTS OLD EDITOR SAVE FORMAT TO NEW FORMAT
222 253 function fca_eoi_convert_post_meta() {
223 254 require_once FCA_EOI_PLUGIN_DIR . 'includes/eoi-layout.php';
224 255
@@ -286,9 +317,9 @@
286 317 } else if ( strpos($selector, 'email') !== false ) {
287 318 $type = 'email';
288 319 } else if ( strpos($selector, 'submit_button_wrapper input:hover') !== false ) {
289 320 $type = 'hover';
290 - } else if ( strpos($selector, 'submit_button_wrapper input') !== false && strpos($selector, 'hover') === false ) {
321 + } else if ( strpos($selector, 'submit_button_wrapper input') !== false && strpos($selector, 'hover') === false ) {
291 322 $type = 'button';
292 323 } else if ( strpos($selector, 'privacy') !== false ) {
293 324 $type = 'privacy';
294 325 } else if ( strpos($selector, 'fatcatapps') !== false ) {
@@ -306,9 +337,9 @@
306 337 } else {
307 338
308 339 $new_key = $type . '_' . str_replace ('-', '_', $css_property) . '_selector';
309 340 if ( strpos( $new_key, 'color' ) !== false && strpos( $new_key, 'border' ) === false && strpos( $new_key, 'background' ) === false ) {
310 - $new_key = str_replace ('_color', '_font_color', $new_key);
341 + $new_key = str_replace ('_color', '_font_color', $new_key);
311 342 }
312 343 $new_meta[trim($new_key)] = $selector;
313 344
314 345 $new_value_key = $type . '_' . str_replace ('-', '_', $css_property);
@@ -353,9 +384,10 @@
353 384 $css_path = str_replace ( '.scss' , '_min.css', $scss_path );
354 385 $css_file = file_get_contents( $css_path );
355 386 }
356 387
357 - $show_name = K::get_var( 'show_name_field', $new_meta, false );
388 + $show_name = !empty( $new_meta['show_name_field'] ) ? $new_meta['show_name_field'] : false;
389 +
358 390 if ( !$show_name ) {
359 391 $css .= "#fca_eoi_form_$form_id .fca_eoi_layout_email_field_wrapper {width: 100% !important;}";
360 392 $css .= "#fca_eoi_form_$form_id .fca_eoi_layout_name_field_wrapper {display: none !important;}";
361 393 }
@@ -363,9 +395,8 @@
363 395 //ADD CSS FROM FILE
364 396 $css .= $css_file;
365 397
366 398 //ADD CUSTOM CSS FROM SAVE
367 - $added_inherent_css_rule = false;
368 399 $added_widget_3_css_rule = false;
369 400
370 401 foreach ( $settings as $key => $property ) {
371 402 $input = str_replace ( '_selector', '', $key);
@@ -372,13 +403,10 @@
372 403
373 404 $selector = empty ( $new_meta[$key] ) ? '' : $new_meta[$key];
374 405
375 406 if ( !empty ( $selector ) ) {
376 - //BUTTON HOVER HACK
377 - if ( strpos ( $selector, '.fca_eoi_layout_submit_button_wrapper input' ) !== false && !$added_inherent_css_rule ) {
378 - $css .= "#fca_eoi_form_$form_id $selector:hover { background-color: inherit !important; }";
379 - $added_inherent_css_rule = true;
380 - }
407 +
408 +
381 409 //SPECIAL CASE FOR WIDGET 3
382 410 if ( $selector == '.fca_eoi_layout_3.fca_eoi_layout_widget div.fca_eoi_layout_headline_copy_wrapper div' && !$added_widget_3_css_rule && $input == 'headline_background_color' ) {
383 411 $css .= "#fca_eoi_form_$form_id form.fca_eoi_layout_3.fca_eoi_layout_widget svg.fca_eoi_layout_headline_copy_triangle { fill: $new_meta[$input] !important; }";
384 412 $added_widget_3_css_rule = true;
@@ -399,5 +427,38 @@
399 427 update_post_meta( $post->ID, 'fca_eoi_head', $head );
400 428
401 429 }
402 430 }
431 +}
432 +
433 +function fca_eoi_convert_option_save() {
434 +
435 + $old_options = get_option('paf');
436 + $license = get_option('fca_eoi_license_key');
437 +
438 + $new_options = array(
439 + 'license_key' => $license,
440 + );
441 +
442 + $options = array (
443 +
444 + 'eoi_powerup_custom_css' => 'custom_css',
445 + 'eoi_powerup_optin_bait' => 'optin_bait',
446 + 'eoi_powerup_animation' => 'animation',
447 + 'eoi_powerup_mp_groups' => 'mailchimp_groups',
448 +
449 + );
450 +
451 + if ( !empty( $old_options ) ) {
452 + forEach ( $options as $key => $value ) {
453 + if ( !empty ( $old_options[$key] ) && $old_options[$key][0] == 'on' ) {
454 + $new_options[$value] = 1;
455 + }
456 + }
457 +
458 + update_option( 'fca_eoi_settings', $new_options );
459 + delete_option ( 'paf' );
460 + delete_option ( 'fca_eoi_license_key' );
461 +
462 + }
463 +
403 464 }