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