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 +62 -332 1.3.82.0.2 View file →
@@ -19,141 +19,22 @@
19 19 add_shortcode( $shortcode, array( $this, 'shortcode_content' ) );
20 20 }
21 21
22 22 // Add shortcode generator button
23 - if ( in_array( $pagenow, array( 'post.php', 'page.php', 'post-new.php', 'post-edit.php' ) ) && $typenow != 'download' ) {
23 + if ( FCA_EOI_EDITION != 'email_popup' && in_array( $pagenow, array( 'post.php', 'page.php', 'post-new.php', 'post-edit.php' ) ) && $typenow != 'download' ) {
24 24 add_action( 'admin_head', array( $this, 'button_head' ) );
25 25 add_action( 'media_buttons', array( $this, 'button' ), 1000 );
26 26 add_action( 'admin_footer', array( $this, 'button_footer' ) );
27 27 }
28 28
29 - if ( ! is_admin() ) {
30 - add_action( 'wp', array( $this, 'parse_shortcodes' ), 11 );
31 - }
32 29 }
33 30
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 - if ( array_key_exists( $form_id, $this->prerequisites ) ) {
74 - return $this->prerequisites[ $form_id ];
75 - }
76 -
77 - $head = '';
78 -
79 - $fca_eoi_meta = get_post_meta( $form_id, 'fca_eoi', true );
80 - if ( ! $fca_eoi_meta ) {
81 - return $head;
82 - }
83 -
84 - $layout_id = $fca_eoi_meta['layout'];
85 - $layout = new EasyOptInsLayout( $layout_id );
86 - $scss_path = $layout->path_to_resource( 'layout', 'scss' );
87 -
88 - $scss = $layout->new_scss_compiler();
89 -
90 - if ( file_exists( $scss_path ) ) {
91 - $head .=
92 - '<style>' .
93 - '.fca_eoi_form p { width: auto; }' . $scss->compile(
94 - sprintf( '$ltr: %s;', is_rtl() ? 'false' : 'true' ) .
95 - '#fca_eoi_form_' . $form_id . '{' .
96 - 'input{ max-width: 9999px; }' .
97 - file_get_contents( $scss_path ) .
98 - '}'
99 - ) .
100 - '</style>';
101 - }
102 -
103 - // Add per form CSS
104 - if ( ! EasyOptInsLayout::uses_new_css() ) {
105 - $head .= '<style>.fca_eoi_form{ margin: auto; }</style>';
106 - }
107 -
108 - $css_for_scss = '';
109 - if ( ! empty( $fca_eoi_meta[ $layout_id ] ) ) {
110 - $head .= '<style>';
111 - $css_for_scss .= "#fca_eoi_form_$form_id {";
112 - foreach ( $fca_eoi_meta[ $layout_id ] as $selector => $declarations ) {
113 - $css_for_scss .= "$selector{";
114 - foreach ( $declarations as $property => $value ) {
115 - if ( strlen( $value ) ) {
116 - $css_for_scss .= "$property:$value !important;";
117 - }
118 - }
119 - $css_for_scss .= '}';
120 - }
121 - $css_for_scss .= '}';
122 - $head .= $scss->compile( $css_for_scss ) . '</style>';
123 - }
124 -
125 - if ( $layout->layout_type != 'lightbox' ) {
126 - $head .= '<script>' . EasyOptInsActivity::get_instance()->get_tracking_code( $form_id ) . '</script>';
127 - }
128 -
129 - $this->prerequisites[ $form_id ] = $head;
130 - return $head;
131 - }
132 -
133 - /**
134 - * @param int $form_id
135 - *
136 - * @return string
137 - */
138 - private function get_prerequisites_for_form( $form_id ) {
139 - $prerequisites = $this->add_prerequisites_for_form( $form_id );
140 - $this->prerequisites[ $form_id ] = '';
141 -
142 - if ( ! empty( $prerequisites ) ) {
143 - $this->enqueue_assets();
144 - return $prerequisites;
145 - }
146 -
147 - return '';
148 - }
149 -
150 31 public function button_head() {
151 32 ?>
152 33
153 34 <style>
154 35 #fca-eoi-media-button {
155 - background: url(<?php echo $this->settings['plugin_url'] . '/icon.png' ?>) 0 -1px no-repeat;
36 + background: url(<?php echo FCA_EOI_PLUGIN_URL . '/icon.png' ?>) 0 -1px no-repeat;
156 37 background-size: 16px 16px;
157 38 }
158 39 </style>
159 40
@@ -160,15 +41,19 @@
160 41 <?php
161 42 }
162 43
163 44 public function button() {
164 - $button_title = __( 'Optin Cat' );
165 -
166 - if ( version_compare( $GLOBALS['wp_version'], '3.5', '<' ) ) {
167 - echo '<a href="#TB_inline?width=640&inlineId=fca-eoi-shortcode-thickbox" class="thickbox" title="' . $button_title . '">' . $button_title . '</a>';
168 - } else {
169 - $img = '<span class="wp-media-buttons-icon" id="fca-eoi-media-button"></span>';
170 - 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>';
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 + }
171 56 }
172 57 }
173 58
174 59 public function button_footer() {
@@ -220,222 +105,67 @@
220 105 <?php
221 106 }
222 107
223 108 public function enqueue_assets() {
224 -
225 - if ( $this->assets_enqueued ) {
226 - return;
227 - }
228 -
229 - $this->assets_enqueued = true;
230 -
231 109 $protocol = is_ssl() ? 'https' : 'http';
232 -
233 - // Get lightboxes
234 - $lightboxes = get_posts( array(
235 - 'post_type' => 'easy-opt-ins',
236 - 'posts_per_page' => -1,
237 - 'orderby' => 'ID',
238 - 'meta_key' => 'fca_eoi_layout',
239 - 'meta_value' => 'lightbox_',
240 - 'meta_compare' => 'like',
241 - ) );
242 -
243 - // Get postboxes
244 - $postboxes = get_posts( array(
245 - 'post_type' => 'easy-opt-ins',
246 - 'posts_per_page' => -1,
247 - 'orderby' => 'ID',
248 - 'meta_key' => 'fca_eoi_layout',
249 - 'meta_value' => 'postbox_',
250 - 'meta_compare' => 'like',
251 - ) );
252 -
253 - // Get postboxes
254 - $widgets = get_posts( array(
255 - 'post_type' => 'easy-opt-ins',
256 - 'posts_per_page' => -1,
257 - 'orderby' => 'ID',
258 - 'meta_key' => 'fca_eoi_layout',
259 - 'meta_value' => 'layout_',
260 - 'meta_compare' => 'like',
261 - ) );
262 -
263 - // Exit function if not optin form exist
264 - if ( ! $lightboxes && ! $postboxes && ! $widgets ) {
265 - return;
266 - }
267 -
110 +
268 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 );
269 113
270 - wp_enqueue_style( 'fca_eoi', $this->settings[ 'plugin_url' ].'/assets/style' . ( EasyOptInsLayout::uses_new_css() ? '-new' : '' ) . '.css' );
271 - wp_enqueue_script( 'fca_eoi', $this->settings[ 'plugin_url' ].'/assets/script.js' );
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 );
272 125
273 - wp_enqueue_style( 'fontawesome', $protocol . '://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css' );
274 -
275 - wp_enqueue_script( 'tooltipster', $this->settings[ 'plugin_url' ] . '/assets/vendor/tooltipster/jquery.tooltipster.min.js' );
276 - wp_enqueue_style( 'tooltipster', $this->settings[ 'plugin_url' ] . '/assets/vendor/tooltipster/tooltipster.min.css' );
277 - wp_localize_script(
278 - 'fca_eoi'
279 - , 'fca_eoi'
280 - , array_merge( $this->settings['error_text'], array(
281 - 'ajax_url' => admin_url( 'admin-ajax.php' )
282 - ) )
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' ),
283 130 );
131 +
132 + wp_localize_script( 'fca_eoi_script_js', 'fcaEoiScriptData', $data );
284 133 }
285 134
286 135 public function shortcode_content( $atts ) {
287 -
288 - $form_id = $atts['id'];
289 -
290 - /**
291 - * Check that we have a valid post ID
292 - */
293 - if( empty ( $form_id ) ) {
294 - return 'Missing form ID';
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 );
295 141 }
296 - if( ! $post = get_post( $form_id ) ) {
297 - return 'Wrong form ID';
142 +
143 + if( !is_object( $post ) OR $post->post_status == 'trash' ) {
144 + return 'Optin Cat: Missing Form Data. Is it in the trash?';
298 145 }
299 -
300 - $fca_eoi_meta = get_post_meta( $form_id, 'fca_eoi', true );
301 - if( ! $fca_eoi_meta ) {
302 - return 'Form doesn\'t exist';
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 );
303 150 }
304 -
305 - // Get template
306 - $layout_id = $fca_eoi_meta[ 'layout' ];
307 -
308 - $layout = new EasyOptInsLayout( $layout_id );
309 - $layout_type = $layout->layout_type;
310 - $html_path = $layout->path_to_resource( 'layout', 'html' );
311 - $html_wrap_path = $layout->path_to_html_wrapper();
312 -
313 - if ( ! file_exists( $html_path ) ) {
314 - return '';
315 - }
316 -
317 - if ( EasyOptInsLayout::uses_new_css() ) {
318 - $template = str_replace(
319 - '{{{layout}}}',
320 - file_get_contents( $html_path ),
321 - file_get_contents( $html_wrap_path )
322 - );
323 - } else {
324 - $template = file_get_contents( $html_path );
325 - }
326 -
327 - $form_wrapper = '';
328 - $form_wrapper_end = '';
329 -
330 - if ( EasyOptInsLayout::uses_new_css() && $layout->layout_type != 'lightbox' ) {
331 - $form_wrapper =
332 - '<div class="' .
333 - 'fca_eoi_form_wrapper ' .
334 - $layout->layout_class . '_wrapper ' .
335 - 'fca_eoi_layout_' . $layout->layout_number . '_wrapper' .
336 - '">';
337 - $form_wrapper_end = '</div>';
338 - }
339 -
340 - // Fill template with our formatting stuff
341 - $template = str_replace(
342 - array(
343 - '<form>',
344 - '{{{description_copy}}}',
345 - '{{{headline_copy}}}',
346 - '{{{name_field}}}',
347 - '{{{email_field}}}',
348 - '{{{submit_button}}}',
349 - '{{{privacy_copy}}}',
350 - '{{{fatcatapps_link}}}',
351 - '</form>',
352 - ),
353 - array(
354 - sprintf(
355 - $form_wrapper .
356 - '<div id="fca_eoi_form_%s" class="fca_eoi_form_content">' .
357 - '<form method="post" action="" class="fca_eoi_form %s %s" ' .
358 - 'data-fca_eoi_list_id="%s" data-fca_eoi_thank_you_page="%s" novalidate' .
359 - '>' .
360 - '<input type="hidden" name="fca_eoi_form_id" value="%s" />'
361 - , $form_id
362 - , EasyOptInsLayout::uses_new_css()
363 - ? 'fca_eoi_layout_' . $layout->layout_number
364 - : 'fca_eoi_' . $layout_type
365 - , EasyOptInsLayout::uses_new_css()
366 - ? $layout->layout_class
367 - : 'fca_eoi_' . $layout_id
368 - , K::get_var( 'list_id', $fca_eoi_meta )
369 - , get_permalink( K::get_var( 'thank_you_page', $fca_eoi_meta ) )
370 - ? get_permalink( K::get_var( 'thank_you_page', $fca_eoi_meta ) )
371 - : ''
372 - , $post->ID
373 - ),
374 - '<div>{{{description_copy}}}</div>',
375 - EasyOptInsLayout::uses_new_css()
376 - ? '<div>{{{headline_copy}}}</div>'
377 - : '<span>{{{headline_copy}}}</span>',
378 - EasyOptInsLayout::uses_new_css()
379 - ? '<input class="fca_eoi_form_input_element" type="text" name="name" placeholder="{{{name_placeholder}}}">'
380 - : '<input type="text" name="name" placeholder="{{{name_placeholder}}}" />',
381 - EasyOptInsLayout::uses_new_css()
382 - ? '<input class="fca_eoi_form_input_element" type="email" name="email" placeholder="{{{email_placeholder}}}">'
383 - : '<input type="email" name="email" placeholder="{{{email_placeholder}}}" />',
384 - EasyOptInsLayout::uses_new_css()
385 - ? '<input class="fca_eoi_form_button_element" type="submit" value="{{{button_copy}}}">'
386 - : '<input type="submit" value="{{{button_copy}}}" />',
387 - EasyOptInsLayout::uses_new_css()
388 - ? '<div>{{{privacy_copy}}}</div>'
389 - : '<span >{{{privacy_copy}}}</span>',
390 - EasyOptInsLayout::uses_new_css()
391 - ? '{{#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}}'
392 - : '{{#show_fatcatapps_link}}<p class="fca_eoi_' . $layout_id . '_fatcatapps_link_wrapper"><a href="http://fatcatapps.com/eoi" target="_blank">Powered by Optin Cat</a></p>{{/show_fatcatapps_link}}',
393 - '<input type="hidden" name="id" value="' . $form_id . '"><input type="hidden" name="fca_eoi" value="1"></form></div>' . $form_wrapper_end,
394 - ),
395 - $template
396 - );
397 -
398 - $mustache = new Mustache_Engine;
399 - $output = $mustache->render(
400 - $template,
401 - array(
402 - 'headline_copy' => $fca_eoi_meta[ 'headline_copy' ],
403 - 'description_copy' => $fca_eoi_meta[ 'description_copy' ],
404 - 'privacy_copy' => $fca_eoi_meta[ 'privacy_copy' ],
405 - 'name_placeholder' => $fca_eoi_meta[ 'name_placeholder' ],
406 - 'email_placeholder' => $fca_eoi_meta[ 'email_placeholder' ],
407 - 'button_copy' => $fca_eoi_meta[ 'button_copy' ],
408 - 'show_name_field' => K::get_var( 'show_name_field', $fca_eoi_meta ),
409 - 'show_fatcatapps_link' => K::get_var( 'show_fatcatapps_link', $fca_eoi_meta ),
410 - )
411 - );
412 -
413 - // add the fca_eoi_alter_form
414 - $output = apply_filters( 'fca_eoi_alter_form'
415 - , $output
416 - , $fca_eoi_meta
417 - );
418 -
419 - $error_text = '';
420 -
421 - foreach ( $fca_eoi_meta as $key => $value ) {
422 - if ( strpos( $key, 'error_text_' ) === 0 ) {
423 - $text = substr( $key, 11 );
424 - $error_text .= 'fca_eoi[' . json_encode($text) . '] = ' . json_encode($value) . ';';
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 );
425 165 }
426 - }
427 -
428 - if ( ! empty( $error_text ) ) {
429 - $output .=
430 - '<script>' .
431 - 'if ( typeof fca_eoi === "undefined" ) {' .
432 - 'fca_eoi = {};' .
433 - '}' .
434 - $error_text .
435 - '</script>';
436 - }
437 -
438 - // Return form with debugging information if applicable
439 - return $this->get_prerequisites_for_form( $form_id ) . $output . ( FCA_EOI_DEBUG ? @d( $fca_eoi_meta, $template ) : '' );
166 +
167 + }
168 +
169 + return $head;
440 170 }
441 171 }