PluginProbe
GetResponse Forms by Optin Cat / 1.7.2
GetResponse Forms by Optin Cat v1.7.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
getresponse / includes / eoi-shortcode.php

eoi-shortcode.php in GetResponse Forms by Optin Cat 1.7.2, at includes/eoi-shortcode.php

162 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 = __( 'Optin Cat' );
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', 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_style( 'fca_eoi', FCA_EOI_PLUGIN_URL . '/assets/style-new.css', array(), FCA_EOI_VER );
122 wp_enqueue_script( 'fca_eoi_script_js', FCA_EOI_PLUGIN_URL . '/assets/script.js', array(), FCA_EOI_VER, true );
123
124 //PASS VARIABLES TO JAVASCRIPT
125 $data = array (
126 'ajax_url' => admin_url( 'admin-ajax.php' ),
127 'nonce' => wp_create_nonce( 'fca_eoi_submit_form' ),
128 );
129
130 wp_localize_script( 'fca_eoi_script_js', 'fca_eoi', $data );
131 }
132
133 public function shortcode_content( $atts ) {
134 if ( empty ( $atts['id'] ) ) {
135 return 'Optin Cat: Invalid Form ID';
136 } else {
137 $form_id = $atts['id'];
138 $post = get_post( $form_id );
139 }
140
141 if( !is_object( $post ) OR $post->post_status == 'trash' ) {
142 return 'Optin Cat: Missing Form Data. Is it in the trash?';
143 }
144
145 $animation = get_post_meta( $form_id, 'fca_eoi_animation', true);
146 if (!empty ($animation) ) {
147 wp_enqueue_style( 'fca_eoi_powerups_animate', FCA_EOI_PLUGIN_URL . '/assets/vendor/animate/animate.css', array(), FCA_EOI_VER );
148 }
149 $this->enqueue_assets();
150 $head = get_post_meta( $form_id, 'fca_eoi_head', true );
151
152 $layout_id = get_post_meta ( $form_id, 'fca_eoi_layout', true );
153 $layout = new EasyOptInsLayout( $layout_id );
154
155 if ( $layout->layout_type != 'lightbox' ) {
156 $head .= '<script>' . EasyOptInsActivity::get_instance()->get_tracking_code( $form_id ) . '</script>';
157 }
158
159 return $head;
160 }
161 }
162