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-shortcode.php +171 -434 1.5.62.0.2 View file →
@@ -1,434 +1,171 @@
1 -<?php
2 -
3 -class EasyOptInsShortcodes {
4 -
5 - var $settings;
6 - var $prerequisites = array();
7 - var $assets_enqueued = false;
8 -
9 - public function __construct( $settings = array() ) {
10 - global $pagenow, $typenow;
11 -
12 - $this->settings = $settings;
13 -
14 - // Add shortcode
15 - add_shortcode( $this->settings[ 'shortcode' ], array( $this, 'shortcode_content' ) );
16 -
17 - // Add shortcode aliases
18 - foreach ( $settings[ 'shortcode_aliases' ] as $shortcode) {
19 - add_shortcode( $shortcode, array( $this, 'shortcode_content' ) );
20 - }
21 -
22 - // Add shortcode generator button
23 - if ( FCA_EOI_EDITION != 'email_popup' && in_array( $pagenow, array( 'post.php', 'page.php', 'post-new.php', 'post-edit.php' ) ) && $typenow != 'download' ) {
24 - add_action( 'admin_head', array( $this, 'button_head' ) );
25 - add_action( 'media_buttons', array( $this, 'button' ), 1000 );
26 - add_action( 'admin_footer', array( $this, 'button_footer' ) );
27 - }
28 -
29 - if ( ! is_admin() ) {
30 - add_action( 'wp', array( $this, 'parse_shortcodes' ), 11 );
31 - }
32 - }
33 -
34 - public function wp_head() {
35 - foreach ( $this->prerequisites as $form_id => $head ) {
36 - echo $head;
37 - $this->prerequisites[ $form_id ] = '';
38 - }
39 - }
40 -
41 - public function parse_shortcodes() {
42 - global $post;
43 -
44 - if ( empty( $post ) ) {
45 - return;
46 - }
47 -
48 - if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $post->post_content, $matches )
49 - && array_key_exists( 2, $matches )
50 - && array_key_exists( 3, $matches )
51 - && in_array( $this->settings['shortcode'], $matches[2] )
52 - ) {
53 - foreach ( $matches[3] as $params ) {
54 - $params = shortcode_parse_atts( $params );
55 - if ( ! empty( $params['id'] ) ) {
56 - $this->add_prerequisites_for_form( (int) $params['id'] );
57 - }
58 - }
59 - }
60 -
61 - if ( ! empty( $this->prerequisites ) ) {
62 - $this->enqueue_assets();
63 - add_action( 'wp_head', array( $this, 'wp_head' ) );
64 - }
65 - }
66 -
67 - /**
68 - * @param int $form_id
69 - *
70 - * @return string
71 - */
72 - private function add_prerequisites_for_form( $form_id ) {
73 - $head = get_post_meta( $form_id, 'fca_eoi_head', true );
74 - if ( !empty ( $head ) ) {
75 - return $head;
76 - } else {
77 -
78 - if ( array_key_exists( $form_id, $this->prerequisites ) ) {
79 - return $this->prerequisites[ $form_id ];
80 - }
81 -
82 - $head = '';
83 -
84 - $fca_eoi_meta = get_post_meta( $form_id, 'fca_eoi', true );
85 - if ( ! $fca_eoi_meta ) {
86 - return $head;
87 - }
88 -
89 - $layout_id = $fca_eoi_meta['layout'];
90 -
91 - $layout = new EasyOptInsLayout( $layout_id );
92 - $scss_path = $layout->path_to_resource( 'layout', 'scss' );
93 -
94 - if ( file_exists( $scss_path ) ) {
95 - $css_path = str_replace ( '.scss' , '_min.css', $scss_path );
96 - $css = file_get_contents( $css_path );
97 - $head .= '<style>' .
98 - '.fca_eoi_form p { width: auto; }' .
99 - '#fca_eoi_form_' . $form_id . ' input{ max-width: 9999px; }' . $css . '}' .
100 - '</style>';
101 - }
102 -
103 -
104 - // Add per form CSS
105 - $head .= '<style>.fca_eoi_form{ margin: auto; }</style>';
106 -
107 - $css = '';
108 - if ( ! empty( $fca_eoi_meta[ $layout_id ] ) ) {
109 - $head .= "<style name='fca_eoi_form_style_$form_id'>";
110 -
111 - foreach ( $fca_eoi_meta[ $layout_id ] as $selector => $declarations ) {
112 - $css .= "#fca_eoi_form_$form_id $selector{";
113 - foreach ( $declarations as $property => $value ) {
114 - if ( strlen( $value ) ) {
115 - $css .= "$property:$value !important;";
116 - }
117 - }
118 - $css .= '}';
119 - }
120 -
121 - $head .= $css . '</style>';
122 - }
123 -
124 - if ( $layout->layout_type != 'lightbox' ) {
125 - $head .= '<script>' . EasyOptInsActivity::get_instance()->get_tracking_code( $form_id ) . '</script>';
126 - }
127 -
128 - $this->prerequisites[ $form_id ] = $head;
129 -
130 - delete_post_meta( $form_id, 'fca_eoi_head' );
131 - add_post_meta( $form_id, 'fca_eoi_head', $head );
132 -
133 -
134 - return $head;
135 -
136 - }
137 -
138 - }
139 -
140 - /**
141 - * @param int $form_id
142 - *
143 - * @return string
144 - */
145 - private function get_prerequisites_for_form( $form_id ) {
146 - $prerequisites = $this->add_prerequisites_for_form( $form_id );
147 -
148 - $this->prerequisites[ $form_id ] = '';
149 -
150 - if ( ! empty( $prerequisites ) ) {
151 - $this->enqueue_assets();
152 - return $prerequisites;
153 - }
154 -
155 - return '';
156 - }
157 -
158 - public function button_head() {
159 - ?>
160 -
161 - <style>
162 - #fca-eoi-media-button {
163 - background: url(<?php echo FCA_EOI_PLUGIN_URL . '/icon.png' ?>) 0 -1px no-repeat;
164 - background-size: 16px 16px;
165 - }
166 - </style>
167 -
168 - <?php
169 - }
170 -
171 - public function button() {
172 - if (current_user_can( 'delete_pages')){
173 -
174 - $button_title = __( 'Optin Cat' );
175 -
176 - if ( version_compare( $GLOBALS['wp_version'], '3.5', '<' ) ) {
177 - echo '<a href="#TB_inline?width=640&inlineId=fca-eoi-shortcode-thickbox" class="thickbox" title="' . $button_title . '">' . $button_title . '</a>';
178 - } else {
179 - $img = '<span class="wp-media-buttons-icon" id="fca-eoi-media-button"></span>';
180 - echo '<a href="#TB_inline?width=640&inlineId=fca-eoi-shortcode-thickbox" class="thickbox button" title="' . $button_title . '" style="padding-left: .4em;">' . $img . $button_title . '</a>';
181 - }
182 - }
183 - }
184 -
185 - public function button_footer() {
186 - $options = array();
187 -
188 - foreach ( get_posts( array( 'post_type' => 'easy-opt-ins', 'post_status' => 'publish', 'posts_per_page' => -1 ) ) as $post ) {
189 - $form_id = $post->ID;
190 - $layout = get_post_meta( $form_id, 'fca_eoi_layout', true );
191 -
192 - if ( ! empty( $layout ) && strpos( $layout, 'postbox_' ) === 0 ) {
193 - $options[ $form_id ] = empty( $post->post_title ) ? '(no title)' : $post->post_title;
194 - }
195 - }
196 -
197 - ?>
198 -
199 - <script type="text/javascript">
200 - jQuery( function( $ ) {
201 - $( '#fca-eoi-shortcode-insert' ).on( 'click', function() {
202 - var id = $( '#fca-eoi-shortcode' ).val();
203 -
204 - if ( '' === id ) {
205 - alert( <?php echo json_encode( __( 'You must choose a form' ) ) ?> );
206 - return;
207 - }
208 -
209 - window.send_to_editor( '[<?php echo $this->settings[ 'shortcode' ] ?> id="' + id + '"]' );
210 - } );
211 - } );
212 - </script>
213 - <div id="fca-eoi-shortcode-thickbox" style="display: none;">
214 - <div class="wrap" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;">
215 - <p><?php _e('Use the form below to insert an Optin Cat shortcode .' ) ?></p>
216 - <div>
217 - <select id="fca-eoi-shortcode">
218 - <option value=""><?php _e( 'Please select...' ) ?></option>
219 - <?php foreach ( $options as $form_id => $title ) { ?>
220 - <option value="<?php echo (int) $form_id ?>"><?php echo esc_html( $title ) ?></option>
221 - <?php } ?>
222 - </select>
223 - </div>
224 - <p class="submit">
225 - <input type="button" id="fca-eoi-shortcode-insert" class="button-primary" value="<?php _e( 'Insert' ) ?>">
226 - <a id="fca-eoi-shortcode-cancel" class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel' ) ?>"><?php _e( 'Cancel' ) ?></a>
227 - </p>
228 - </div>
229 - </div>
230 -
231 - <?php
232 - }
233 -
234 - public function enqueue_assets() {
235 -
236 - if ( $this->assets_enqueued ) {
237 - return;
238 - }
239 -
240 - $this->assets_enqueued = true;
241 -
242 - $protocol = is_ssl() ? 'https' : 'http';
243 -
244 - // Get lightboxes
245 - $lightboxes = get_posts( array(
246 - 'post_type' => 'easy-opt-ins',
247 - 'posts_per_page' => -1,
248 - 'orderby' => 'ID',
249 - 'meta_key' => 'fca_eoi_layout',
250 - 'meta_value' => 'lightbox_',
251 - 'meta_compare' => 'like',
252 - ) );
253 -
254 - // Get postboxes
255 - $postboxes = get_posts( array(
256 - 'post_type' => 'easy-opt-ins',
257 - 'posts_per_page' => -1,
258 - 'orderby' => 'ID',
259 - 'meta_key' => 'fca_eoi_layout',
260 - 'meta_value' => 'postbox_',
261 - 'meta_compare' => 'like',
262 - ) );
263 -
264 - // Get postboxes
265 - $widgets = get_posts( array(
266 - 'post_type' => 'easy-opt-ins',
267 - 'posts_per_page' => -1,
268 - 'orderby' => 'ID',
269 - 'meta_key' => 'fca_eoi_layout',
270 - 'meta_value' => 'layout_',
271 - 'meta_compare' => 'like',
272 - ) );
273 -
274 - // Exit function if not optin form exist
275 - if ( ! $lightboxes && ! $postboxes && ! $widgets ) {
276 - return;
277 - }
278 -
279 - wp_enqueue_script( 'jquery' );
280 -
281 - wp_enqueue_style( 'fca_eoi', FCA_EOI_PLUGIN_URL . '/assets/style-new.css' );
282 - wp_enqueue_script( 'fca_eoi_script_js', FCA_EOI_PLUGIN_URL . '/assets/script.js' );
283 -
284 - wp_enqueue_style( 'fontawesome', $protocol . '://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css' );
285 -
286 - wp_enqueue_script( 'tooltipster', FCA_EOI_PLUGIN_URL . '/assets/vendor/tooltipster/jquery.tooltipster.min.js' );
287 - wp_enqueue_style( 'tooltipster', FCA_EOI_PLUGIN_URL . '/assets/vendor/tooltipster/tooltipster.min.css' );
288 -
289 - wp_enqueue_script( 'featherlight', FCA_EOI_PLUGIN_URL . '/assets/vendor/featherlight/release/featherlight.min.js' );
290 - wp_enqueue_style( 'featherlight', FCA_EOI_PLUGIN_URL . '/assets/vendor/featherlight/release/featherlight.min.css' );
291 -
292 - //PASS VARIABLES TO JAVASCRIPT
293 - wp_localize_script( 'fca_eoi_script_js', 'fca_eoi', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
294 - }
295 -
296 - public function shortcode_content( $atts ) {
297 -
298 - $form_id = $atts['id'];
299 -
300 - /**
301 - * Check that we have a valid post ID
302 - */
303 - if( empty ( $form_id ) ) {
304 - return 'Missing form ID';
305 - }
306 - if( ! $post = get_post( $form_id ) ) {
307 - return 'Wrong form ID';
308 - }
309 -
310 - $fca_eoi_meta = get_post_meta( $form_id, 'fca_eoi', true );
311 - if( ! $fca_eoi_meta ) {
312 - return 'Form doesn\'t exist';
313 - }
314 -
315 - // Get template
316 - $layout_id = $fca_eoi_meta[ 'layout' ];
317 -
318 - $layout = new EasyOptInsLayout( $layout_id );
319 - $layout_type = $layout->layout_type;
320 - $html_path = $layout->path_to_resource( 'layout', 'html' );
321 - $html_wrap_path = $layout->path_to_html_wrapper();
322 -
323 - if ( ! file_exists( $html_path ) ) {
324 - return '';
325 - }
326 -
327 -
328 - $template = str_replace(
329 - '{{{layout}}}',
330 - file_get_contents( $html_path ),
331 - file_get_contents( $html_wrap_path )
332 - );
333 -
334 -
335 - $form_wrapper = '';
336 - $form_wrapper_end = '';
337 -
338 - if ( $layout->layout_type != 'lightbox' ) {
339 - $form_wrapper =
340 - '<div class="' .
341 - 'fca_eoi_form_wrapper ' .
342 - $layout->layout_class . '_wrapper ' .
343 - 'fca_eoi_layout_' . $layout->layout_number . '_wrapper' .
344 - '">';
345 - $form_wrapper_end = '</div>';
346 - }
347 -
348 - $errorTexts = fca_eoi_get_error_texts($form_id);
349 -
350 - //determine if ajax or thank you page redirect
351 - $thanks_mode = fca_eoi_get_thanks_mode($form_id);
352 - if ($thanks_mode == 'ajax') {
353 - $thanks_page = htmlentities ( K::get_var( 'thankyou_ajax', $fca_eoi_meta, '' ), ENT_COMPAT, "UTF-8");
354 - } else {
355 - $thanks_page = get_permalink( K::get_var( 'thank_you_page', $fca_eoi_meta ) );
356 - }
357 -
358 - if (empty ($thanks_page)) {
359 - $thanks_mode = 'redirect';
360 - $thanks_page = get_site_url();
361 - }
362 -
363 - // Fill template with our formatting stuff
364 - $template = str_replace(
365 - array(
366 - '<form>',
367 - '{{{description_copy}}}',
368 - '{{{headline_copy}}}',
369 - '{{{name_field}}}',
370 - '{{{email_field}}}',
371 - '{{{submit_button}}}',
372 - '{{{privacy_copy}}}',
373 - '{{{fatcatapps_link}}}',
374 - '</form>',
375 - ),
376 - array(
377 - sprintf(
378 - $form_wrapper .
379 - '<div id="fca_eoi_form_%s" class="fca_eoi_form_content">' .
380 - '<form method="post" action="#" class="fca_eoi_form %s %s" ' .
381 - 'data-fca_eoi_list_id="%s" data-fca_eoi_thank_you_page="%s" data-fca_eoi_thank_you_mode="%s" novalidate' .
382 - '>' .
383 - '<input type="hidden" id="fca_eoi_form_id" name="fca_eoi_form_id" value="%s" />',
384 - $form_id,
385 - 'fca_eoi_layout_' . $layout->layout_number,
386 - $layout->layout_class,
387 - K::get_var( 'list_id', $fca_eoi_meta ),
388 - $thanks_page,
389 - $thanks_mode,
390 - $post->ID
391 - ),
392 - '<div>{{{description_copy}}}</div>',
393 - '<div>{{{headline_copy}}}</div>',
394 - '<input class="fca_eoi_form_input_element" type="text" name="name" placeholder="{{{name_placeholder}}}">',
395 - '<input class="fca_eoi_form_input_element" type="email" name="email" placeholder="{{{email_placeholder}}}">',
396 - '<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}}}">',
397 - '<div>{{{privacy_copy}}}</div>',
398 - '{{#show_fatcatapps_link}}<div class="fca_eoi_layout_fatcatapps_link_wrapper fca_eoi_form_text_element"><a href="http://fatcatapps.com/eoi" target="_blank">Powered by Optin Cat</a></div>{{/show_fatcatapps_link}}',
399 - '<input type="hidden" name="id" value="' . $form_id . '"><input type="hidden" name="fca_eoi" value="1">
400 - <input type="hidden" name="fca_eoi_error_texts_email" class="fca_eoi_error_texts_email" value="' . htmlspecialchars ($errorTexts['invalid_email']) . '">
401 - <input type="hidden" name="fca_eoi_error_texts_required" class="fca_eoi_error_texts_required" value="' . htmlspecialchars ($errorTexts['field_required']) . '">' . wp_nonce_field( 'fca_eoi_submit_form', 'fca_eoi_nonce', TRUE, FALSE ) . '</form></div>' . $form_wrapper_end,
402 - ),
403 - $template
404 - );
405 -
406 - $mustache = new Mustache_Engine;
407 - $output = $mustache->render(
408 - $template,
409 - array(
410 - 'headline_copy' => $fca_eoi_meta[ 'headline_copy' ],
411 - 'description_copy' => $fca_eoi_meta[ 'description_copy' ],
412 - 'privacy_copy' => $fca_eoi_meta[ 'privacy_copy' ],
413 - 'name_placeholder' => $fca_eoi_meta[ 'name_placeholder' ],
414 - 'email_placeholder' => $fca_eoi_meta[ 'email_placeholder' ],
415 - 'button_copy' => $fca_eoi_meta[ 'button_copy' ],
416 - 'show_name_field' => K::get_var( 'show_name_field', $fca_eoi_meta ),
417 - 'show_fatcatapps_link' => K::get_var( 'show_fatcatapps_link', $fca_eoi_meta ),
418 - )
419 - );
420 -
421 - // add the fca_eoi_alter_form
422 - $output = apply_filters( 'fca_eoi_alter_form'
423 - , $output
424 - , $fca_eoi_meta
425 - );
426 -
427 -
428 - $prerequisites = $this->get_prerequisites_for_form( $form_id );
429 - $prerequisites = str_replace('<style', '<style scoped', $prerequisites);
430 -
431 - // Return form with debugging information if applicable
432 - return $prerequisites . $output . ( FCA_EOI_DEBUG ? @d( $fca_eoi_meta, $template ) : '' );
433 - }
434 -}
1 +<?php
2 +
3 +class EasyOptInsShortcodes {
4 +
5 + var $settings;
6 + var $prerequisites = array();
7 + var $assets_enqueued = false;
8 +
9 + public function __construct( $settings = array() ) {
10 + global $pagenow, $typenow;
11 +
12 + $this->settings = $settings;
13 +
14 + // Add shortcode
15 + add_shortcode( $this->settings[ 'shortcode' ], array( $this, 'shortcode_content' ) );
16 +
17 + // Add shortcode aliases
18 + foreach ( $settings[ 'shortcode_aliases' ] as $shortcode) {
19 + add_shortcode( $shortcode, array( $this, 'shortcode_content' ) );
20 + }
21 +
22 + // Add shortcode generator button
23 + if ( FCA_EOI_EDITION != 'email_popup' && in_array( $pagenow, array( 'post.php', 'page.php', 'post-new.php', 'post-edit.php' ) ) && $typenow != 'download' ) {
24 + add_action( 'admin_head', array( $this, 'button_head' ) );
25 + add_action( 'media_buttons', array( $this, 'button' ), 1000 );
26 + add_action( 'admin_footer', array( $this, 'button_footer' ) );
27 + }
28 +
29 + }
30 +
31 + public function button_head() {
32 + ?>
33 +
34 + <style>
35 + #fca-eoi-media-button {
36 + background: url(<?php echo FCA_EOI_PLUGIN_URL . '/icon.png' ?>) 0 -1px no-repeat;
37 + background-size: 16px 16px;
38 + }
39 + </style>
40 +
41 + <?php
42 + }
43 +
44 + public function button() {
45 + global $post;
46 + if (current_user_can( 'delete_pages' ) && $post->post_type != 'easy-opt-ins'){
47 +
48 + $button_title = __( 'Add Optin Form' );
49 +
50 + if ( version_compare( $GLOBALS['wp_version'], '3.5', '<' ) ) {
51 + echo '<a href="#TB_inline?width=640&inlineId=fca-eoi-shortcode-thickbox" class="thickbox" title="' . $button_title . '">' . $button_title . '</a>';
52 + } else {
53 + $img = '<span class="wp-media-buttons-icon" id="fca-eoi-media-button"></span>';
54 + echo '<a href="#TB_inline?width=640&inlineId=fca-eoi-shortcode-thickbox" class="thickbox button" title="' . $button_title . '" style="padding-left: .4em;">' . $img . $button_title . '</a>';
55 + }
56 + }
57 + }
58 +
59 + public function button_footer() {
60 + $options = array();
61 +
62 + foreach ( get_posts( array( 'post_type' => 'easy-opt-ins', 'post_status' => 'publish', 'posts_per_page' => -1 ) ) as $post ) {
63 + $form_id = $post->ID;
64 + $layout = get_post_meta( $form_id, 'fca_eoi_layout', true );
65 +
66 + if ( ! empty( $layout ) && strpos( $layout, 'postbox_' ) === 0 ) {
67 + $options[ $form_id ] = empty( $post->post_title ) ? '(no title)' : $post->post_title;
68 + }
69 + }
70 +
71 + ?>
72 +
73 + <script type="text/javascript">
74 + jQuery( function( $ ) {
75 + $( '#fca-eoi-shortcode-insert' ).on( 'click', function() {
76 + var id = $( '#fca-eoi-shortcode' ).val();
77 +
78 + if ( '' === id ) {
79 + alert( <?php echo json_encode( __( 'You must choose a form' ) ) ?> );
80 + return;
81 + }
82 +
83 + window.send_to_editor( '[<?php echo $this->settings[ 'shortcode' ] ?> id="' + id + '"]' );
84 + } );
85 + } );
86 + </script>
87 + <div id="fca-eoi-shortcode-thickbox" style="display: none;">
88 + <div class="wrap" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;">
89 + <p><?php _e('Use the form below to insert an Optin Cat shortcode .' ) ?></p>
90 + <div>
91 + <select id="fca-eoi-shortcode">
92 + <option value=""><?php _e( 'Please select...' ) ?></option>
93 + <?php foreach ( $options as $form_id => $title ) { ?>
94 + <option value="<?php echo (int) $form_id ?>"><?php echo esc_html( $title ) ?></option>
95 + <?php } ?>
96 + </select>
97 + </div>
98 + <p class="submit">
99 + <input type="button" id="fca-eoi-shortcode-insert" class="button-primary" value="<?php _e( 'Insert' ) ?>">
100 + <a id="fca-eoi-shortcode-cancel" class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel' ) ?>"><?php _e( 'Cancel' ) ?></a>
101 + </p>
102 + </div>
103 + </div>
104 +
105 + <?php
106 + }
107 +
108 + public function enqueue_assets() {
109 + $protocol = is_ssl() ? 'https' : 'http';
110 +
111 + wp_enqueue_script( 'jquery' );
112 + wp_enqueue_style( 'fontawesome', $protocol . '://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css', array(), FCA_EOI_VER );
113 +
114 + wp_enqueue_script( 'fca_eoi_tooltipster_js', FCA_EOI_PLUGIN_URL . '/assets/vendor/tooltipster/tooltipster.bundle.min.js', array(), FCA_EOI_VER, true );
115 + wp_enqueue_style( 'fca_eoi_tooltipster_css', FCA_EOI_PLUGIN_URL . '/assets/vendor/tooltipster/tooltipster.bundle.min.css', array(), FCA_EOI_VER );
116 + wp_enqueue_style( 'fca_eoi_tooltipster_theme_css', FCA_EOI_PLUGIN_URL . '/assets/vendor/tooltipster/tooltipster-borderless.min.css', array(), FCA_EOI_VER );
117 +
118 + wp_enqueue_script( 'fca_eoi_featherlight_js', FCA_EOI_PLUGIN_URL . '/assets/vendor/featherlight/release/featherlight.min.js', array(), FCA_EOI_VER, true );
119 + wp_enqueue_style( 'fca_eoi_featherlight_css', FCA_EOI_PLUGIN_URL . '/assets/vendor/featherlight/release/featherlight.min.css', array(), FCA_EOI_VER );
120 +
121 + wp_enqueue_script( 'fca_eoi_jstz', FCA_EOI_PLUGIN_URL . '/assets/vendor/jstz/jstz.min.js', array(), FCA_EOI_VER, true );
122 +
123 + wp_enqueue_style( 'fca_eoi', FCA_EOI_PLUGIN_URL . '/assets/style-new.min.css', array(), FCA_EOI_VER );
124 + wp_enqueue_script( 'fca_eoi_script_js', FCA_EOI_PLUGIN_URL . '/assets/script.min.js', array( 'fca_eoi_jstz', 'jquery', 'fca_eoi_tooltipster_js', 'fca_eoi_featherlight_js'), FCA_EOI_VER, true );
125 +
126 + //PASS VARIABLES TO JAVASCRIPT
127 + $data = array (
128 + 'ajax_url' => admin_url( 'admin-ajax.php' ),
129 + 'nonce' => wp_create_nonce( 'fca_eoi_submit_form' ),
130 + );
131 +
132 + wp_localize_script( 'fca_eoi_script_js', 'fcaEoiScriptData', $data );
133 + }
134 +
135 + public function shortcode_content( $atts ) {
136 + if ( empty ( $atts['id'] ) ) {
137 + return 'Optin Cat: Invalid Form ID';
138 + } else {
139 + $form_id = $atts['id'];
140 + $post = get_post( $form_id );
141 + }
142 +
143 + if( !is_object( $post ) OR $post->post_status == 'trash' ) {
144 + return 'Optin Cat: Missing Form Data. Is it in the trash?';
145 + }
146 +
147 + $animation = get_post_meta( $form_id, 'fca_eoi_animation', true);
148 + if (!empty( $animation ) ) {
149 + wp_enqueue_style( 'fca_eoi_powerups_animate', FCA_EOI_PLUGIN_URL . '/assets/vendor/animate/animate.min.css', array(), FCA_EOI_VER );
150 + }
151 +
152 + $this->enqueue_assets();
153 + $head = get_post_meta( $form_id, 'fca_eoi_head', true );
154 +
155 + $layout_id = get_post_meta ( $form_id, 'fca_eoi_layout', true );
156 + $layout = new EasyOptInsLayout( $layout_id );
157 +
158 + if ( $layout->layout_type !== 'lightbox' && $layout->layout_type !== 'banner' && $layout->layout_type !== 'overlay' ) {
159 +
160 + require_once FCA_EOI_PLUGIN_DIR . 'includes/classes/RobotDetector/RobotDetector.php';
161 + $robot_detector = new RobotDetector();
162 +
163 + if ( get_post( $form_id ) && !is_user_logged_in() && !$robot_detector->is_robot() ) {
164 + EasyOptInsActivity::get_instance()->add_impression( $form_id );
165 + }
166 +
167 + }
168 +
169 + return $head;
170 + }
171 +}