PluginProbe
GetResponse Forms by Optin Cat / 2.2.2
GetResponse Forms by Optin Cat v2.2.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-pointer.php

eoi-pointer.php in GetResponse Forms by Optin Cat 2.2.2, at includes/eoi-pointer.php

232 lines 8.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * To change this template, choose Tools | Templates
4 * and open the template in the editor.
5 */
6
7 /**
8 * Description of eoi-pointer
9 *
10 * @author thuantp
11 */
12 class EasyOptInsPointer {
13
14 private $settings;
15
16 public function __construct( $settings=null ) {
17
18 global $pagenow;
19
20 add_action('wp_ajax_tt_eoi_mailing_list', array($this, 'tt_eoi_mailing_list_pointer_ajax'));
21
22 // Show mailing list pointer popup once
23 $mailing_list = get_option('tt_eoi_mailing_list');
24 if ('easy-opt-ins' == $settings['post_type'] &&
25 (( isset($_REQUEST['action']) && 'edit' == $_REQUEST['action']) || 'post-new.php' == $pagenow) &&
26 !in_array($mailing_list, array('yes', 'no'))) {
27 add_action('admin_enqueue_scripts', array($this, 'enqueue_assets'));
28 }
29
30 $this->settings = $settings;
31 }
32
33 function enqueue_assets() {
34 wp_enqueue_style('wp-pointer');
35 wp_enqueue_script('wp-pointer');
36 add_action('admin_print_footer_scripts', array($this, 'tt_eoi_mailing_list_pointer'));
37 }
38
39 // Add mailing list subscription
40 function tt_eoi_mailing_list_pointer() {
41 global $current_user;
42
43 // Get current user info
44 get_currentuserinfo();
45
46 // Ajax request template
47 $ajax = '
48 jQuery.ajax({
49 type: "POST",
50 url: "' . admin_url('admin-ajax.php') . '",
51 data: {action: "tt_eoi_mailing_list", email: jQuery("#eoi_email").val(), nonce: "' . wp_create_nonce('tt_eoi_mailing_list') . '", subscribe: "%s" }
52 }).done(function( html ) {
53 eval( html );
54 });
55 ';
56
57 // Target
58 $id = '#wpadminbar';
59
60 // Buttons
61 $button_1_title = __('No, thanks');
62 $button_1_fn = sprintf($ajax, 'no');
63 $button_2_title = __("Let&#39;s do it!");
64 $button_2_fn = sprintf($ajax, 'yes');
65
66 // Content
67 $content = '<h3>' . __('Easily Grow Your List') . '</h3>';
68 $content .= '<p>' . __("Imagine you could get more email optins and make more money. Find out how in our totally free & ridicolously actionable 5-day course on \"How To Triple Your Email List\". No spam.") . '</p>';
69 $content .= '<p>' . '<input type="text" name="eoi_email" id="eoi_email" value="' . $current_user->user_email . '" style="width: 100%"/>' . '</p>';
70
71 // Options
72 $options = array(
73 'content' => $content,
74 'position' => array('edge' => 'top', 'align' => 'center')
75 );
76
77 $this->tt_eoi_print_script($id, $options, $button_1_title, $button_2_title, $button_1_fn, $button_2_fn);
78 }
79
80 function tt_eoi_mailing_list_pointer_ajax() {
81 global $current_user;
82
83 // Verify nonce
84 if (!wp_verify_nonce($_POST['nonce'], 'tt_eoi_mailing_list') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
85 die('No tricky business!');
86 }
87
88 // Check status
89 $result = ($_POST['subscribe'] == 'yes') ? 'yes' : 'no';
90 if ($result == 'no') {
91 update_option('tt_eoi_mailing_list', 'no');
92 exit();
93 }
94
95
96 // Get current user info
97 get_currentuserinfo();
98
99 $this->eoi_add_subscriber(
100 'https://www.getdrip.com/forms/6746603/submissions',
101
102 array( 'fields[name]' => $current_user->display_name,
103 'fields[email]' => $_POST['email'], //$current_user->user_email,,
104 'fields[url]' => get_bloginfo('url')
105 )
106 );
107
108 update_option('tt_eoi_mailing_list', $result);
109
110 // After custommers "sign up", display another pointer to ask them check the confirm email
111 $button_2_title = false;
112 $kind_of_email_link = '';
113 if ( strpos( $_POST['email'] , '@yahoo' ) !== false ) {
114 $button_2_title = 'Go to Yahoo! Mail';
115 $kind_of_email_link = 'https://mail.yahoo.com/';
116 } elseif ( strpos( $_POST['email'] , '@hotmail' ) !== false )
117 {
118 $button_2_title = 'Go to Hotmail';
119 $kind_of_email_link = 'https://www.hotmail.com/';
120 } elseif ( strpos( $_POST['email'] , '@gmail' ) !== false )
121 {
122 $button_2_title = 'Go to Gmail';
123 $kind_of_email_link = 'https://mail.google.com/';
124 } elseif ( strpos( $_POST['email'] , '@aol' ) !== false )
125 {
126 $button_2_title = 'Go to AOL Mail';
127 $kind_of_email_link = 'https://mail.aol.com/';
128 }
129
130 $button_2_func = "window.open('$kind_of_email_link', '_blank');";
131
132 // Target
133 $id = '#wpadminbar';
134
135 // Buttons
136 $button_1_title = __('Close', PTP_LOC);
137
138 // Content
139 $content = '<h3>' . __('Please confirm your email', PTP_LOC) . '</h3>';
140 $content .= '<p>' . __("Thanks! For privacy reasons you'll have to confirm your email. Please check your email inbox.", PTP_LOC) . '</p>';
141
142 // Options
143 $options = array(
144 'content' => $content,
145 'position' => array('edge' => 'top', 'align' => 'center')
146 );
147
148 $this->tt_eoi_print_script($id, $options, $button_1_title, $button_2_title , '' , $button_2_func , true);
149
150 exit();
151 }
152
153 function eoi_add_subscriber($url, $payload = array())
154 {
155 $data = http_build_query($payload);
156 $ch = curl_init();
157 curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC) ;
158 curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
159 curl_setopt($ch, CURLOPT_HEADER, false);
160 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
161 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
162 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
163 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
164 curl_setopt($ch, CURLOPT_POST, true);
165 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
166 curl_setopt($ch, CURLOPT_URL, $url);
167 $result = curl_exec($ch);
168 curl_close($ch);
169 return $result;
170 }
171
172 // Print JS Content
173 function tt_eoi_print_script($selector, $options, $button1, $button2 = false, $button1_fn = '', $button2_fn = '', $isCallBackFunc = false ) {
174
175 if( !$isCallBackFunc ) {
176 ?>
177 <script type="text/javascript">
178 //<![CDATA[
179 (function ($) {
180 <?php
181 }
182 ?>
183 var tt_eoi_pointer_options = <?php echo json_encode($options); ?>, setup;
184
185 tt_eoi_pointer_options = $.extend(tt_eoi_pointer_options, {
186 buttons:function (event, t) {
187 button = jQuery('<a id="pointer-close" style="margin-left:5px" class="button-secondary">' + '<?php echo $button1; ?>' + '</a>');
188 button.bind('click.pointer', function () {
189 t.element.pointer('close');
190 });
191 return button;
192 },
193 close:function () {
194 }
195 });
196
197 setup = function () {
198 $('<?php echo $selector; ?>').pointer(tt_eoi_pointer_options).pointer('open');
199 <?php if ($button2) : ?>
200 jQuery('#pointer-close').after('<a id="pointer-primary" class="button-primary">' + '<?php echo $button2; ?>' + '</a>');
201 jQuery('#pointer-primary').click(function () {
202 <?php echo $button2_fn; ?>
203 $('<?php echo $selector; ?>').pointer('close');
204 });
205
206 jQuery('#eoi_email').keypress(function ( event ) {
207 if ( event.which == 13 ) {
208 <?php echo $button2_fn; ?>
209 $('<?php echo $selector; ?>').pointer('close');
210 }
211
212 });
213 jQuery('#pointer-close').click(function () {
214 <?php echo $button1_fn; ?>
215 $('<?php echo $selector; ?>').pointer('close');
216 });
217 <?php endif; ?>
218 };
219
220 $(document).ready(setup);
221
222 <?php if( !$isCallBackFunc ) { ?>
223 })(jQuery);
224 //]]>
225 </script>
226 <?php
227 }
228 }
229
230 }
231 ?>
232