WordPress Landing Pages - Version 1.5.1

Version Description

  • Misc bug fixes
Download this release

Release Info

Developer adbox
Plugin Icon 128x128 WordPress Landing Pages
Version 1.5.1
Comparing to
See all releases

Code changes from version 1.5.0 to 1.5.1

css/customizer-load.css CHANGED
@@ -34,7 +34,7 @@ margin-top: 0px !important;
34
  color:#000000 !important;
35
  }
36
  .live-preview-active {
37
- background: rgba(253, 253, 252, 1) ";
38
  border-radius: 0px;
39
  padding: 0px;
40
  outline: 2px dashed rgb(255, 0, 0);
34
  color:#000000 !important;
35
  }
36
  .live-preview-active {
37
+ background: rgba(253, 253, 252, 1);
38
  border-radius: 0px;
39
  padding: 0px;
40
  outline: 2px dashed rgb(255, 0, 0);
landing-pages.php CHANGED
@@ -3,14 +3,14 @@
3
  Plugin Name: Landing Pages
4
  Plugin URI: http://www.inboundnow.com/landing-pages/
5
  Description: The first true all-in-one Landing Page solution for WordPress, including ongoing conversion metrics, a/b split testing, unlimited design options and so much more!
6
- Version: 1.5.0
7
  Author: Inbound Now
8
  Author URI: http://www.inboundnow.com/
9
  Text Domain: landing-pages
10
  Domain Path: shared/languages/landing-pages/
11
  */
12
 
13
- define('LANDINGPAGES_CURRENT_VERSION', '1.5.0' );
14
  define('LANDINGPAGES_URLPATH', WP_PLUGIN_URL.'/'.plugin_basename( dirname(__FILE__) ).'/' );
15
  define('LANDINGPAGES_PATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/' );
16
  define('LANDINGPAGES_PLUGIN_SLUG', plugin_basename( dirname(__FILE__) ) );
@@ -26,60 +26,60 @@ define('INBOUNDNOW_LABEL', 'inboundnow-legacy' );
26
 
27
 
28
  if (is_admin())
29
- if(!isset($_SESSION)){@session_start();}
30
 
31
 
32
  /* load core files */
33
  switch (is_admin()) :
34
- case true :
35
- /* loads admin files */
36
- // include_once('modules/module.cron.php'); not ready yet
37
- include_once('modules/module.language-support.php');
38
- include_once('modules/module.javascript-admin.php');
39
- include_once('modules/module.activate.php');
40
- include_once('modules/module.global-settings.php');
41
- include_once('modules/module.clone.php');
42
- include_once('modules/module.extension-updater.php');
43
- include_once('modules/module.extension-licensing.php');
44
- include_once('modules/module.admin-menus.php');
45
- include_once('modules/module.welcome.php');
46
- include_once('modules/module.install.php');
47
- include_once('modules/module.alert.php');
48
- include_once('modules/module.metaboxes.php');
49
- include_once('modules/module.landing-page.php');
50
- include_once('modules/module.load-extensions.php');
51
- include_once('modules/module.post-type.php');
52
- include_once('modules/module.track.php');
53
- include_once('modules/module.ajax-setup.php');
54
- include_once('modules/module.utils.php');
55
- include_once('modules/module.sidebar.php');
56
- include_once('modules/module.widgets.php');
57
- include_once('modules/module.cookies.php');
58
- include_once('modules/module.ab-testing.php');
59
- include_once('modules/module.click-tracking.php');
60
- include_once('modules/module.templates.php');
61
- include_once('modules/module.store.php');
62
- include_once('modules/module.customizer.php');
63
-
64
-
65
- BREAK;
66
-
67
- case false :
68
- /* load front-end files */
69
- include_once('modules/module.javascript-frontend.php');
70
- include_once('modules/module.post-type.php');
71
- include_once('modules/module.track.php');
72
- include_once('modules/module.ajax-setup.php');
73
- include_once('modules/module.utils.php');
74
- include_once('modules/module.sidebar.php');
75
- include_once('modules/module.widgets.php');
76
- include_once('modules/module.cookies.php');
77
- include_once('modules/module.ab-testing.php');
78
- include_once('modules/module.click-tracking.php');
79
- include_once('modules/module.landing-page.php');
80
- include_once('modules/module.customizer.php');
81
-
82
- BREAK;
83
  endswitch;
84
 
85
  add_action( 'init', 'inbound_load_shared_lp_init' , 11 );
@@ -92,36 +92,45 @@ function inbound_load_shared_lp_init(){
92
  add_action( 'plugins_loaded', 'inbound_load_shared_landing_pages' , 11 );
93
  function inbound_load_shared_landing_pages(){
94
 
95
- /* Check if Shared Files Already Loaded */
96
- if (defined('INBOUDNOW_SHARED'))
97
- return;
98
-
99
- /* Define Shared Constant for Load Prevention*/
100
- define('INBOUDNOW_SHARED','loaded');
101
-
102
- /* Singleton Shared Class Loads */
103
- include_once('shared/inbound-shortcodes/inbound-shortcodes.php'); // Shared Shortcodes
104
- include_once('shared/classes/menu.class.php'); // Inbound Marketing Menu
105
- include_once('shared/classes/feedback.class.php'); // Inbound Feedback Form
106
- include_once('shared/classes/debug.class.php'); // Inbound Debug & Scripts Class
107
- include_once('shared/classes/compatibility.class.php'); // Inbound Compatibility Class
108
- include_once('shared/tracking/store.lead.php'); // Lead Storage from landing pages
109
- include_once('shared/classes/form.class.php'); // Mirrored forms
110
- include_once('shared/extend/inboundnow.extend.php');
111
- include_once('shared/extend/inboundnow.extension-licensing.php'); // Legacy - Inboundnow Package Licensing
112
- include_once('shared/extend/inboundnow.extension-updating.php'); // Legacy -Inboundnow Package Updating
113
- include_once('shared/extend/inboundnow.global-settings.php'); // Inboundnow Global Settings
114
- include_once('shared/assets/assets.loader.class.php'); // Load Shared CSS and JS Assets
115
- include_once('shared/functions/global.shared.functions.php'); // Global Shared Utility functions
116
- include_once('shared/functions/global.leads.cpt.php'); // Shared Lead functionality
117
- include_once('shared/metaboxes/template.metaboxes.php'); // Shared Shortcodes
118
 
119
  }
120
 
121
  /* lagacy - Conditional check LP active */
122
  function lp_check_active()
123
  {
124
- return 1;
125
  }
126
 
 
 
 
 
127
 
 
 
 
 
 
3
  Plugin Name: Landing Pages
4
  Plugin URI: http://www.inboundnow.com/landing-pages/
5
  Description: The first true all-in-one Landing Page solution for WordPress, including ongoing conversion metrics, a/b split testing, unlimited design options and so much more!
6
+ Version: 1.5.1
7
  Author: Inbound Now
8
  Author URI: http://www.inboundnow.com/
9
  Text Domain: landing-pages
10
  Domain Path: shared/languages/landing-pages/
11
  */
12
 
13
+ define('LANDINGPAGES_CURRENT_VERSION', '1.5.1' );
14
  define('LANDINGPAGES_URLPATH', WP_PLUGIN_URL.'/'.plugin_basename( dirname(__FILE__) ).'/' );
15
  define('LANDINGPAGES_PATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/' );
16
  define('LANDINGPAGES_PLUGIN_SLUG', plugin_basename( dirname(__FILE__) ) );
26
 
27
 
28
  if (is_admin())
29
+ if(!isset($_SESSION)){@session_start();}
30
 
31
 
32
  /* load core files */
33
  switch (is_admin()) :
34
+ case true :
35
+ /* loads admin files */
36
+ // include_once('modules/module.cron.php'); not ready yet
37
+ include_once('modules/module.language-support.php');
38
+ include_once('modules/module.javascript-admin.php');
39
+ include_once('modules/module.activate.php');
40
+ include_once('modules/module.global-settings.php');
41
+ include_once('modules/module.clone.php');
42
+ include_once('modules/module.extension-updater.php');
43
+ include_once('modules/module.extension-licensing.php');
44
+ include_once('modules/module.admin-menus.php');
45
+ include_once('modules/module.welcome.php');
46
+ include_once('modules/module.install.php');
47
+ include_once('modules/module.alert.php');
48
+ include_once('modules/module.metaboxes.php');
49
+ include_once('modules/module.landing-page.php');
50
+ include_once('modules/module.load-extensions.php');
51
+ include_once('modules/module.post-type.php');
52
+ include_once('modules/module.track.php');
53
+ include_once('modules/module.ajax-setup.php');
54
+ include_once('modules/module.utils.php');
55
+ include_once('modules/module.sidebar.php');
56
+ include_once('modules/module.widgets.php');
57
+ include_once('modules/module.cookies.php');
58
+ include_once('modules/module.ab-testing.php');
59
+ include_once('modules/module.click-tracking.php');
60
+ include_once('modules/module.templates.php');
61
+ include_once('modules/module.store.php');
62
+ include_once('modules/module.customizer.php');
63
+
64
+
65
+ BREAK;
66
+
67
+ case false :
68
+ /* load front-end files */
69
+ include_once('modules/module.javascript-frontend.php');
70
+ include_once('modules/module.post-type.php');
71
+ include_once('modules/module.track.php');
72
+ include_once('modules/module.ajax-setup.php');
73
+ include_once('modules/module.utils.php');
74
+ include_once('modules/module.sidebar.php');
75
+ include_once('modules/module.widgets.php');
76
+ include_once('modules/module.cookies.php');
77
+ include_once('modules/module.ab-testing.php');
78
+ include_once('modules/module.click-tracking.php');
79
+ include_once('modules/module.landing-page.php');
80
+ include_once('modules/module.customizer.php');
81
+
82
+ BREAK;
83
  endswitch;
84
 
85
  add_action( 'init', 'inbound_load_shared_lp_init' , 11 );
92
  add_action( 'plugins_loaded', 'inbound_load_shared_landing_pages' , 11 );
93
  function inbound_load_shared_landing_pages(){
94
 
95
+ /* Check if Shared Files Already Loaded */
96
+ if (defined('INBOUDNOW_SHARED'))
97
+ return;
98
+
99
+ /* Define Shared Constant for Load Prevention*/
100
+ define('INBOUDNOW_SHARED','loaded');
101
+
102
+ /* Singleton Shared Class Loads */
103
+ include_once('shared/inbound-shortcodes/inbound-shortcodes.php'); // Shared Shortcodes
104
+ include_once('shared/classes/menu.class.php'); // Inbound Marketing Menu
105
+ include_once('shared/classes/feedback.class.php'); // Inbound Feedback Form
106
+ include_once('shared/classes/debug.class.php'); // Inbound Debug & Scripts Class
107
+ include_once('shared/classes/compatibility.class.php'); // Inbound Compatibility Class
108
+ include_once('shared/tracking/store.lead.php'); // Lead Storage from landing pages
109
+ include_once('shared/classes/form.class.php'); // Mirrored forms
110
+ include_once('shared/extend/inboundnow.extend.php');
111
+ include_once('shared/extend/inboundnow.extension-licensing.php'); // Legacy - Inboundnow Package Licensing
112
+ include_once('shared/extend/inboundnow.extension-updating.php'); // Legacy -Inboundnow Package Updating
113
+ include_once('shared/extend/inboundnow.global-settings.php'); // Inboundnow Global Settings
114
+ include_once('shared/assets/assets.loader.class.php'); // Load Shared CSS and JS Assets
115
+ include_once('shared/functions/global.shared.functions.php'); // Global Shared Utility functions
116
+ include_once('shared/functions/global.leads.cpt.php'); // Shared Lead functionality
117
+ include_once('shared/metaboxes/template.metaboxes.php'); // Shared Shortcodes
118
 
119
  }
120
 
121
  /* lagacy - Conditional check LP active */
122
  function lp_check_active()
123
  {
124
+ return 1;
125
  }
126
 
127
+ /* Function to check This has been loaded for the tests */
128
+ function landingpages_is_active() {
129
+ return true;
130
+ }
131
 
132
+ /* Function to check plugin code is running in travis */
133
+ function inbound_travis_check() {
134
+ echo '*** Landing Pages Plugin is Running on Travis ***';
135
+ return true;
136
+ }
modules/module.ab-testing.php CHANGED
@@ -1,951 +1,955 @@
1
- <?php
2
-
3
- /* ADMIN ONLY AB TESTING FUNCTIONS */
4
- if (is_admin())
5
- {
6
- include_once(LANDINGPAGES_PATH.'modules/module.ab-testing.metaboxes.php');
7
-
8
- /**
9
- * [lp_ab_unset_variation description]
10
- * @param [type] $variations [description]
11
- * @param [type] $vid [description]
12
- * @return [type] [description]
13
- */
14
- function lp_ab_unset_variation($variations,$vid)
15
- {
16
- if(($key = array_search($vid, $variations)) !== false) {
17
- unset($variations[$key]);
18
- }
19
-
20
- return $variations;
21
- }
22
-
23
- /**
24
- * [lp_ab_get_lp_active_status returns if landing page is in rotation or not]
25
- * @param [OBJ] $post [description]
26
- * @param [INT] $vid [description]
27
- * @return [INT]
28
- */
29
- function lp_ab_get_lp_active_status($post,$vid=null)
30
- {
31
- if ($vid==0)
32
- {
33
- $variation_status = get_post_meta( $post->ID , 'lp_ab_variation_status' , true);
34
- }
35
- else
36
- {
37
- $variation_status = get_post_meta( $post->ID , 'lp_ab_variation_status-'.$vid , true);
38
- }
39
-
40
- if (!is_numeric($variation_status))
41
- {
42
- return 1;
43
- }
44
- else
45
- {
46
- return $variation_status;
47
- }
48
- }
49
-
50
-
51
- add_action('init','lp_ab_testing_admin_init');
52
- function lp_ab_testing_admin_init($hook)
53
- {
54
- if (!is_admin()||!isset($_GET['post']))
55
- return;
56
-
57
- $post = get_post($_GET['post']);
58
-
59
- if (isset($post)&&($post->post_type=='landing-page'&&(isset($_GET['action'])&&$_GET['action']=='edit')))
60
- {
61
-
62
- $current_variation_id = lp_ab_testing_get_current_variation_id();
63
- //echo $current_variation_id;
64
- $variations = get_post_meta($post->ID,'lp-ab-variations', true);
65
-
66
- //remove landing page's main save_post action
67
- if ($current_variation_id>0)
68
- {
69
- remove_action('save_post','lp_save_meta',10);
70
- }
71
-
72
- //check for delete command
73
- if (isset($_GET['ab-action'])&&$_GET['ab-action']=='delete-variation')
74
- {
75
- $array_variations = explode(',',$variations);
76
- $array_variations = lp_ab_unset_variation($array_variations,$_GET['lp-variation-id']);
77
-
78
- /* set next variation to be open */
79
- $current_variation_id = current($array_variations);
80
- $_SESSION['lp_ab_test_open_variation'] = $current_variation_id;
81
-
82
- $variations = implode(',' , $array_variations);
83
- update_post_meta($post->ID,'lp-ab-variations', $variations);
84
-
85
-
86
- if (isset($_GET['lp-variation-id']) && $_GET['lp-variation-id'] > 0 ) {
87
- $suffix = '-'.$_GET['lp-variation-id'];
88
- $len = strlen($suffix);
89
- } else {
90
- $suffix = '';
91
- $len = strlen($suffix);
92
- }
93
-
94
- //delete each meta value associated with variation
95
- global $wpdb;
96
- $data = array();
97
- $wpdb->query("
98
- SELECT `meta_key`, `meta_value`
99
- FROM $wpdb->postmeta
100
- WHERE `post_id` = ".$_GET['post']."
101
- ");
102
-
103
- foreach($wpdb->last_result as $k => $v){
104
- $data[$v->meta_key] = $v->meta_value;
105
- };
106
- //echo $len;exit;
107
- foreach ($data as $key=>$value)
108
- {
109
- if (substr($key,-$len)==$suffix)
110
- {
111
- delete_post_meta($_GET['post'], $key, $value);
112
- }
113
- }
114
-
115
- $_GET['lp-variation-id'] = $current_variation_id;
116
- }
117
-
118
- //check for pause command
119
- if (isset($_GET['ab-action'])&&$_GET['ab-action']=='pause-variation')
120
- {
121
- if ($_GET['lp-variation-id']==0)
122
- {
123
- update_post_meta( $post->ID , 'lp_ab_variation_status' , '0' );
124
- }
125
- else
126
- {
127
- update_post_meta( $post->ID , 'lp_ab_variation_status-'.$_GET['lp-variation-id'] , '0');
128
- }
129
- }
130
-
131
- //check for pause command
132
- if (isset($_GET['ab-action'])&&$_GET['ab-action']=='play-variation')
133
- {
134
- if ($_GET['lp-variation-id']==0)
135
- {
136
- update_post_meta( $post->ID , 'lp_ab_variation_status' , '1' );
137
- }
138
- else
139
- {
140
- update_post_meta( $post->ID , 'lp_ab_variation_status-'.$_GET['lp-variation-id'] , '1');
141
- }
142
- }
143
-
144
- //return;
145
-
146
- (isset($_GET['new-variation'])&&$_GET['new-variation']==1) ? $new_variation = 1 : $new_variation = 0;
147
-
148
- $content_area = lp_content_area($post,null,true);
149
-
150
- //prepare for new variation creation - use A as default content if not being cloned
151
- if (($new_variation==1&&!isset($_GET['clone']))||isset($_GET['clone'])&&$_GET['clone']==0)
152
- {
153
- $content_area = get_post_field('post_content', $_GET['post']);
154
- $content_area = wpautop($content_area);
155
- }
156
- else if ($new_variation==1&&isset($_GET['clone']))
157
- {
158
- $content_area = get_post_field('content-'.$_GET['clone'], $_GET['post']);
159
- $content_area = wpautop($content_area);
160
- }
161
-
162
- //if new variation and cloning then programatically prepare the next variation id
163
- if($new_variation==1&&isset($_GET['clone']))
164
- {
165
- $array_variations = explode(',',$variations);
166
- sort($array_variations,SORT_NUMERIC);
167
-
168
- $lid = end($array_variations);
169
- $current_variation_id = $lid+1;
170
-
171
- $_SESSION['lp_ab_test_open_variation'] = $current_variation_id;
172
- }
173
- //echo $current_variation_id;exit;
174
- //enqueue and localize scripts
175
- wp_enqueue_style('lp-ab-testing-admin-css', LANDINGPAGES_URLPATH . 'css/admin-ab-testing.css');
176
- wp_enqueue_script('lp-ab-testing-admin-js', LANDINGPAGES_URLPATH . 'js/admin/admin.post-edit-ab-testing.js', array( 'jquery' ));
177
- wp_localize_script( 'lp-ab-testing-admin-js', 'variation', array( 'pid' => $_GET['post'], 'vid' => $current_variation_id , 'new_variation' => $new_variation , 'variations'=> $variations , 'content_area' => $content_area ));
178
-
179
- }
180
-
181
- }
182
-
183
- /* force visual editor to open in text mode */
184
-
185
- function lp_ab_testing_force_default_editor() {
186
- //allowed: tinymce, html, test
187
- return 'html';
188
- }
189
-
190
- add_filter('lp_edit_main_headline','lp_ab_testing_admin_prepare_headline');
191
- function lp_ab_testing_admin_prepare_headline($main_headline)
192
- {
193
-
194
- $current_variation_id = lp_ab_testing_get_current_variation_id();
195
-
196
- if (isset($_REQUEST['post']))
197
- {
198
- $post_id = $_REQUEST['post'];
199
- }
200
- else if (isset($_REQUEST['lp_id']))
201
- {
202
- $post_id = $_REQUEST['lp_id'];
203
- }
204
-
205
- //return "hello";
206
-
207
- if ($current_variation_id>0&&!isset($_REQUEST['new-variation'])&&!isset($_REQUEST['clone']))
208
- {
209
- $main_headline = get_post_meta($post_id,'lp-main-headline-'.$current_variation_id, true);
210
- }
211
- else if (isset($_GET['clone'])&&$_GET['clone']>0)
212
- {
213
- $main_headline = get_post_meta($post_id,'lp-main-headline-'.$_GET['clone'], true);
214
- }
215
-
216
- if (!$main_headline&&isset($_REQUEST['post']))
217
- {
218
- get_post_meta($_REQUEST['post'],'lp-main-headline', true);
219
- }
220
-
221
- return $main_headline;
222
- }
223
-
224
- //disable this because it will populate all wp_editor isntances rather than targeted instances
225
- //add_filter('the_editor_content', 'lp_ab_testing_the_editor_content');
226
- function lp_ab_testing_the_editor_content($content)
227
- {
228
- $current_variation_id = lp_ab_testing_get_current_variation_id();
229
-
230
- if (isset($_REQUEST['post']))
231
- {
232
- $post_id = $_REQUEST['post'];
233
- }
234
- else if (isset($_REQUEST['lp_id']))
235
- {
236
- $post_id = $_REQUEST['lp_id'];
237
- }
238
-
239
- if ($current_variation_id>0&&!isset($_REQUEST['new-variation'])&&!isset($_REQUEST['clone']))
240
- {
241
- $content = get_post_field('content-'.$current_variation_id, $post_id);
242
- }
243
- else if (isset($_GET['clone']))
244
- {
245
- $content = get_post_meta($post_id,'lp-main-headline-'.$_GET['clone'], true);
246
- }
247
-
248
- return $content;
249
- }
250
-
251
-
252
- add_filter('lp_edit_variation_notes','lp_ab_testing_admin_prepare_notes');
253
- function lp_ab_testing_admin_prepare_notes($variation_notes)
254
- {
255
- $current_variation_id = lp_ab_testing_get_current_variation_id();
256
-
257
- if (isset($_REQUEST['post']))
258
- {
259
- $post_id = $_REQUEST['post'];
260
- }
261
- else if (isset($_REQUEST['lp_id']))
262
- {
263
- $post_id = $_REQUEST['lp_id'];
264
- }
265
-
266
- //return "hello";
267
-
268
- if ($current_variation_id>0&&!isset($_REQUEST['new-variation'])&&!isset($_REQUEST['clone']))
269
- {
270
- $variation_notes = get_post_meta($post_id,'lp-variation-notes-'.$current_variation_id, true);
271
- }
272
- else if (isset($_GET['clone'])&&$_GET['clone']>0)
273
- {
274
- $variation_notes = get_post_meta($post_id,'lp-variation-notes-'.$_GET['clone'], true);
275
- }
276
-
277
- if (!$variation_notes&&isset($_REQUEST['post']))
278
- {
279
- get_post_meta($_REQUEST['post'],'lp-variation-notes', true);
280
- }
281
-
282
- return $variation_notes;
283
- }
284
-
285
- add_filter('lp_selected_template_id','lp_ab_testing_prepare_id');//prepare name id for hidden selected template input
286
- add_filter('lp_display_headline_input_id','lp_ab_testing_prepare_id');//prepare id for main headline in template customizer mode
287
- add_filter('lp_display_notes_input_id','lp_ab_testing_prepare_id');//prepare id for main headline in template customizer mode
288
- function lp_ab_testing_prepare_id($id)
289
- {
290
- $current_variation_id = lp_ab_testing_get_current_variation_id();
291
-
292
- //check if variation clone is initiated
293
- if (isset($_GET['new_meta_key']))
294
- $current_variation_id = $_GET['new_meta_key'];
295
-
296
- if ($current_variation_id>0)
297
- {
298
- $id = $id.'-'.$current_variation_id;
299
- }
300
-
301
- return $id;
302
- }
303
-
304
- //prepare id for wp_editor in template customizer
305
- add_filter('lp_wp_editor_id','lp_ab_testing_prepare_wysiwyg_editor_id');
306
- function lp_ab_testing_prepare_wysiwyg_editor_id($id)
307
- {
308
- $current_variation_id = lp_ab_testing_get_current_variation_id();
309
- //echo $current_variation_id;exit;
310
- if ($current_variation_id>0)
311
- {
312
- switch ($id) {
313
- case "wp_content":
314
- $id = 'content-'.$current_variation_id;
315
- break;
316
- case "lp-conversion-area":
317
- $id = 'landing-page-myeditor-'.$current_variation_id;
318
- break;
319
- default:
320
- $id = $id.'-'.$current_variation_id;
321
- }
322
-
323
- }
324
-
325
- return $id;
326
- }
327
-
328
-
329
- add_filter('lp_show_metabox','lp_ab_testing_admin_prepare_meta_ids', 5, 2);
330
- function lp_ab_testing_admin_prepare_meta_ids($lp_custom_fields, $main_key)
331
- {
332
- if (isset($_REQUEST['new-variation'])&&!isset($_REQUEST['clone']))
333
- {
334
- return $lp_custom_fields;
335
- }
336
-
337
- $current_variation_id = lp_ab_testing_get_current_variation_id();
338
-
339
- if (isset($_GET['clone'])) {
340
- $current_variation_id = $_GET['clone'];
341
- }
342
-
343
- if ($current_variation_id>0)
344
- {
345
- $post_id = $_GET['post'];
346
- foreach ($lp_custom_fields as $key=>$field)
347
- {
348
- $default = get_post_meta($post_id, $field['id'], true);
349
-
350
- $id = $field['id'];
351
- $field['id'] = $id.'-'.$current_variation_id ;
352
-
353
- if ($default) {
354
- $field['default'] = $default;
355
- }
356
-
357
- $lp_custom_fields[$key] = $field;
358
- }
359
- return $lp_custom_fields;
360
- }
361
-
362
- //print_r($lp_custom_fields);exit;
363
- return $lp_custom_fields;
364
- }
365
-
366
- add_filter('lp_variation_selected_template','lp_ab_testing_lp_variation_selected_template', 10, 2);
367
- function lp_ab_testing_lp_variation_selected_template($selected_template, $post)
368
- {
369
- if (isset($_GET['new-variation']))
370
- return $selected_template;
371
-
372
- $current_variation_id = lp_ab_testing_get_current_variation_id();
373
-
374
- if ($current_variation_id>0)
375
- {
376
- $selected_template = get_post_meta( $post->ID , 'lp-selected-template-'.$current_variation_id , true);
377
- }
378
-
379
- //print_r($lp_custom_fields);exit;
380
- return $selected_template;
381
- }
382
-
383
- //add filter to modify thumbnail preview
384
- add_filter('lp_live_screenshot_url', 'lp_ab_testing_prepare_screenshot');
385
- function lp_ab_testing_prepare_screenshot($link)
386
- {
387
- $variation_id = lp_ab_testing_get_current_variation_id();
388
- $link = $link."?lp-variation-id=".$variation_id;
389
- return $link;
390
- }
391
-
392
-
393
-
394
- add_filter("post_type_link", "lp_ab_append_variation_id_to_adminbar_link", 10,2);
395
- function lp_ab_append_variation_id_to_adminbar_link($link, $post)
396
- {
397
- if( $post->post_type == 'landing-page' )
398
- {
399
- $current_variation_id = lp_ab_testing_get_current_variation_id();
400
-
401
- if ($current_variation_id>0)
402
- $link = $link."?lp-variation-id=".$current_variation_id;
403
- }
404
-
405
- return $link;
406
- }
407
-
408
- if(!defined('AUTOSAVE_INTERVAL')) {
409
- define('AUTOSAVE_INTERVAL', 86400);
410
- }
411
-
412
- add_filter('wp_insert_post_data','lp_ab_testing_wp_insert_post_data',10,2);
413
- function lp_ab_testing_wp_insert_post_data($data,$postarr)
414
- {
415
-
416
- //exit;
417
- //$variation_id = lp_ab_testing_get_current_variation_id();
418
- //echo $variation_id;exit;
419
- if (isset($postarr['lp-variation-id'])&&$postarr['lp-variation-id']>0)
420
- {
421
- $postarr = array();
422
- $data = array();
423
-
424
- remove_action('save_post','lp_save_meta',10);
425
- remove_action('save_post','lp_ab_testing_save_post',10);
426
-
427
- $postID = $_POST['post_ID'];
428
- if($parent_id = wp_is_post_revision($_POST['post_ID']))
429
- {
430
- $postID = $parent_id;
431
- }
432
-
433
- lp_ab_testing_save_post($postID);
434
-
435
- }
436
- else
437
- {
438
- //echo "here";exit;
439
- //$this_data = json_encode($data);
440
- //mail('hudson.atwell@gmail.com','test2',$this_data);
441
- }
442
-
443
- if (count($data)>1)
444
- return $data;
445
- }
446
-
447
- add_action('save_post','lp_ab_testing_save_post');
448
- function lp_ab_testing_save_post($postID)
449
- {
450
- global $post;
451
-
452
- $var_final = (isset($_POST['lp-variation-id'])) ? $_POST['lp-variation-id'] : '0';
453
- if ( isset($_POST['post_type']) && $_POST['post_type']=='landing-page')
454
- {
455
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ||$_POST['post_type']=='revision')
456
- {
457
- return;
458
- }
459
-
460
- if($parent_id = wp_is_post_revision($postID))
461
- {
462
- $postID = $parent_id;
463
- }
464
-
465
-
466
- $this_variation = $var_final;
467
- //echo $this_variation;
468
- //print_r($_POST);exit;
469
-
470
- //first add to varation list if not present.
471
- $variations = get_post_meta($postID,'lp-ab-variations', true);
472
- if ($variations)
473
- {
474
- $array_variations = explode(',',$variations);
475
- if (!in_array($this_variation,$array_variations))
476
- {
477
- $array_variations[] = $this_variation;
478
- }
479
- }
480
- else
481
- {
482
- if ($this_variation>0)
483
- {
484
- $array_variations[] = 0;
485
- $array_variations[] = $this_variation;
486
- }
487
- else
488
- {
489
- $array_variations[] = $this_variation;
490
- }
491
- }
492
-
493
- //print_r($array_variations);exit;
494
- //update_post_meta($postID,'lp-ab-variations', "");
495
- update_post_meta($postID,'lp-ab-variations', implode(',',$array_variations));
496
- //add_post_meta($postID, 'lp_ab_variation_status-'.$this_variation , 1);
497
-
498
- //echo $this_variation;exit;
499
- if ($this_variation==0)
500
- {
501
- return;
502
- }
503
- //echo $this_variation;exit;
504
- //print_r($_POST);
505
-
506
- //next alter all custom fields to store correct varation and create custom fields for special inputs
507
- $ignore_list = array('post_status','post_type','tax_input','post_author','user_ID','post_ID','catslist','post_title','samplepermalinknonce',
508
- 'autosavenonce','action','autosave','mm','jj','aa','hh','mn','ss','_wp_http_referer','lp-variation-id','_wpnonce','originalaction','original_post_status',
509
- 'referredby','_wp_original_http_referer','meta-box-order-nonce','closedpostboxesnonce','hidden_post_status','hidden_post_password','hidden_post_visibility','visibility',
510
- 'post_password','hidden_mm','cur_mm','hidden_jj','cur_jj','hidden_aa','cur_aa','hidden_hh','cur_hh','hidden_mn','cur_mn','original_publish','save','newlanding_page_category','newlanding_page_category_parent',
511
- '_ajax_nonce-add-landing_page_category','lp_lp_custom_fields_nonce','lp-selected-template','post_mime_type','ID','comment_status','ping_status');
512
-
513
- //$special_list = array('content','post-content');
514
- //print_r($_POST);exit;
515
- //echo $this_variation;exit;
516
- foreach ($_POST as $key=>$value)
517
- {
518
- //echo $key." : -{$this_variation} : $value<br>";
519
- if (!in_array($key,$ignore_list)&&!strstr($key,'nonce'))
520
- {
521
- if ($key=='post_content')
522
- $key = 'content';
523
-
524
- if (!strstr($key,"-{$this_variation}"))
525
- {
526
- $new_array[$key.'-'.$this_variation] = $value;
527
- }
528
- else
529
- {
530
- //echo $key." : -{$this_variation}<br>";
531
- $new_array[$key] = $value;
532
- }
533
- }
534
- //echo $key." : -{$this_variation} : $value<br>";
535
- }
536
-
537
- //print_r($new_array);exit;
538
-
539
- foreach($new_array as $key => $val)
540
- {
541
- $old = get_post_meta($postID, $key, true);
542
- $new = $val;
543
- //echo "$key : $old v. $new <br>";
544
- //if (isset($new) && $new != $old ) {
545
- update_post_meta($postID, $key, $new);
546
- //} elseif ('' == $new && $old) {
547
- //delete_post_meta($postID, $key, $old);
548
- //}
549
- }
550
-
551
- }
552
- }
553
-
554
- }
555
-
556
- /* PERFORM FRONT-END ONLY ACTIONS */
557
- else
558
- {
559
-
560
- //prepare customizer meta data for ab varations
561
- add_filter('lp_get_value','lp_ab_testing_prepare_variation_meta', 1 , 4);
562
- function lp_ab_testing_prepare_variation_meta($return, $post, $key, $id)
563
- {
564
- if (isset($_REQUEST['lp-variation-id'])||isset($_COOKIE['lp-variation-id']))
565
- {
566
- (isset($_REQUEST['lp-variation-id'])) ? $variation_id = $_REQUEST['lp-variation-id'] : $variation_id = $_COOKIE['lp-variation-id'];
567
- if ($variation_id>0)
568
- return get_post_meta($post->ID, $key.'-'.$id. '-' .$variation_id , true);
569
- else
570
- return $return;
571
- }
572
- else
573
- {
574
- return $return;
575
- }
576
- }
577
-
578
- //prepare customizer, admin, and preview links for variations
579
- add_filter('lp_customizer_customizer_link', 'lp_ab_append_variation_id_to_link');
580
- add_filter('lp_customizer_admin_bar_link', 'lp_ab_append_variation_id_to_link');
581
- add_filter('lp_customizer_preview_link','lp_ab_append_variation_id_to_link');
582
-
583
- function lp_ab_append_variation_id_to_link($link)
584
- {
585
-
586
- $current_variation_id = lp_ab_testing_get_current_variation_id();
587
-
588
- if ($current_variation_id>0)
589
- $link = $link."&lp-variation-id=".$current_variation_id;
590
-
591
- return $link;
592
- }
593
-
594
- }
595
-
596
- /*PERFORM ACTIONS REQUIRED ON BOTH FRONT AND BACKEND */
597
-
598
- add_filter('lp_content_area','lp_ab_testing_alter_content_area_admin', 10, 2);
599
- function lp_ab_testing_alter_content_area_admin($content)
600
- {
601
- global $post;
602
-
603
- $variation_id = lp_ab_testing_get_current_variation_id();
604
-
605
- if ($variation_id>0)
606
- {
607
- $content = get_post_meta($post->ID,'content-'.$variation_id, true);
608
- if ( !is_admin() )
609
- {
610
- $content = wpautop($content);
611
- $content = do_shortcode($content);
612
- }
613
- }
614
-
615
- return $content;
616
- }
617
-
618
- /* RETURN LETTER FROM ARRAY KEY */
619
- function lp_ab_key_to_letter($key) {
620
- $alphabet = array( 'A', 'B', 'C', 'D', 'E',
621
- 'F', 'G', 'H', 'I', 'J',
622
- 'K', 'L', 'M', 'N', 'O',
623
- 'P', 'Q', 'R', 'S', 'T',
624
- 'U', 'V', 'W', 'X', 'Y',
625
- 'Z'
626
- );
627
-
628
- if (isset($alphabet[$key])) {
629
- return $alphabet[$key];
630
- }
631
- }
632
-
633
- /* GET CURRENT VARIATION ID */
634
- function lp_ab_testing_get_current_variation_id()
635
- {
636
- if ( isset($_GET['ab-action']) &&is_admin())
637
- {
638
- return $_SESSION['lp_ab_test_open_variation'];
639
- }
640
-
641
- if (!isset($_SESSION['lp_ab_test_open_variation'])&&!isset($_REQUEST['lp-variation-id']))
642
- {
643
- $current_variation_id = 0;
644
- }
645
- //echo $_REQUEST['lp-variation-id'];
646
- if (isset($_REQUEST['lp-variation-id']))
647
- {
648
- $_SESSION['lp_ab_test_open_variation'] = $_REQUEST['lp-variation-id'];
649
- $current_variation_id = $_REQUEST['lp-variation-id'];
650
- //echo "setting session $current_variation_id";
651
- }
652
-
653
- if (isset($_GET['message'])&&$_GET['message']==1&&isset( $_SESSION['lp_ab_test_open_variation'] ))
654
- {
655
- $current_variation_id = $_SESSION['lp_ab_test_open_variation'];
656
-
657
- //echo "here:".$_SESSION['lp_ab_test_open_variation'];
658
- }
659
-
660
- if (isset($_GET['ab-action'])&&$_GET['ab-action']=='delete-variation')
661
- {
662
- $current_variation_id = 0;
663
- $_SESSION['lp_ab_test_open_variation'] = 0;
664
- }
665
-
666
- if (!isset($current_variation_id))
667
- $current_variation_id = 0 ;
668
-
669
- return $current_variation_id;
670
- }
671
-
672
- //ready conversion area for displaying ab variations
673
- add_filter('lp_conversion_area_pre_standardize','lp_ab_testing_prepare_conversion_area' , 10 , 2 );
674
- function lp_ab_testing_prepare_conversion_area($content,$post=null)
675
- {
676
- $current_variation_id = lp_ab_testing_get_current_variation_id();
677
-
678
- if (isset($post))
679
- {
680
- $post_id = $post->ID;
681
- }
682
- else if (isset($_REQUEST['post']))
683
- {
684
- $post_id = $_REQUEST['post'];
685
- }
686
- else if (isset($_REQUEST['lp_id']))
687
- {
688
- $post_id = $_REQUEST['lp_id'];
689
- }
690
-
691
-
692
- if ($current_variation_id>0)
693
- $content = get_post_meta($post_id,'landing-page-myeditor-'.$current_variation_id, true);
694
-
695
- return $content;
696
- }
697
-
698
- //ready conversion area for displaying ab variations
699
- add_filter('lp_conversion_area_position','lp_ab_testing_lp_conversion_area_position' , 10 , 2 );
700
- function lp_ab_testing_lp_conversion_area_position($position, $post = null, $key = 'default')
701
- {
702
-
703
- $current_variation_id = lp_ab_testing_get_current_variation_id();
704
-
705
- if (isset($post))
706
- {
707
- $post_id = $post->ID;
708
- }
709
- else if (isset($_REQUEST['post']))
710
- {
711
- $post_id = $_REQUEST['post'];
712
- }
713
- else if (isset($_REQUEST['lp_id']))
714
- {
715
- $post_id = $_REQUEST['lp_id'];
716
- }
717
-
718
- if ($current_variation_id>0)
719
- $position = get_post_meta($post->ID, "{$key}-conversion-area-placement-".$current_variation_id, true);
720
-
721
- return $position;
722
- }
723
-
724
-
725
- add_filter('lp_main_headline','lp_ab_testing_prepare_headline', 10, 2);
726
- function lp_ab_testing_prepare_headline($main_headline, $post = null)
727
- {
728
-
729
- $current_variation_id = lp_ab_testing_get_current_variation_id();
730
-
731
- if (isset($post))
732
- {
733
- $post_id = $post->ID;
734
- }
735
- else if (isset($_REQUEST['post']))
736
- {
737
- $post_id = $_REQUEST['post'];
738
- }
739
- else if (isset($_REQUEST['lp_id']))
740
- {
741
- $post_id = $_REQUEST['lp_id'];
742
- }
743
- else if (isset($_REQUEST['post_id']))
744
- {
745
- $post_id = $_REQUEST['post_id'];
746
- }
747
-
748
-
749
- if ($current_variation_id>0)
750
- $main_headline = get_post_meta($post_id,'lp-main-headline-'.$current_variation_id, true);
751
-
752
- if (!$main_headline)
753
- {
754
- get_post_meta($post_id,'lp-main-headline', true);
755
- }
756
-
757
-
758
- return $main_headline;
759
- }
760
-
761
- add_action('init','lp_ab_testing_add_rewrite_rules');
762
- function lp_ab_testing_add_rewrite_rules()
763
- {
764
- $this_path = LANDINGPAGES_PATH;
765
- $this_path = explode('wp-content',$this_path);
766
- $this_path = "wp-content".$this_path[1];
767
-
768
- $slug = get_option( 'lp-main-landing-page-permalink-prefix', 'go' );
769
- //echo $slug;exit;
770
- add_rewrite_rule("$slug/([^/]*)?", $this_path."modules/module.redirect-ab-testing.php?permalink_name=$1 ",'top');
771
- add_rewrite_rule("landing-page=([^/]*)?", $this_path.'modules/module.redirect-ab-testing.php?permalink_name=$1','top');
772
-
773
- add_filter('mod_rewrite_rules', 'lp_ab_testing_modify_rules', 1);
774
- function lp_ab_testing_modify_rules($rules)
775
- {
776
- if (!stristr($rules,'RewriteCond %{QUERY_STRING} !lp-variation-id'))
777
- {
778
- $rules_array = preg_split ('/$\R?^/m', $rules);
779
- if (count($rules_array)<3)
780
- {
781
- $rules_array = explode("\n", $rules);
782
- $rules_array = array_filter($rules_array);
783
- }
784
-
785
- //print_r($rules_array);exit;
786
-
787
- $this_path = LANDINGPAGES_PATH;
788
- $this_path = explode('wp-content',$this_path);
789
- $this_path = "wp-content".$this_path[1];
790
- $slug = get_option( 'lp-main-landing-page-permalink-prefix', 'go' );
791
-
792
- $i = 0;
793
- foreach ($rules_array as $key=>$val)
794
- {
795
-
796
- if (stristr($val,"RewriteRule ^{$slug}/([^/]*)? "))
797
- {
798
- $new_val = "RewriteCond %{QUERY_STRING} !lp-variation-id";
799
- $rules_array[$i] = $new_val;
800
- $i++;
801
- $rules_array[$i] = $val;
802
- $i++;
803
- }
804
- else
805
- {
806
- $rules_array[$i] = $val;
807
- $i++;
808
- }
809
- }
810
-
811
- $rules = implode("\r\n", $rules_array);
812
- }
813
-
814
- return $rules;
815
- }
816
-
817
- }
818
-
819
-
820
- add_filter('lp_selected_template','lp_ab_testing_get_selected_template');//get correct selected template for each variation
821
- function lp_ab_testing_get_selected_template($template)
822
- {
823
- global $post;
824
-
825
- $current_variation_id = lp_ab_testing_get_current_variation_id();
826
-
827
- if ($current_variation_id>0)
828
- {
829
- $new_template = get_post_meta($post->ID, 'lp-selected-template-'.$current_variation_id, true);
830
- if ($new_template)
831
- $template = $new_template;
832
- }
833
-
834
- return $template;
835
- }
836
-
837
- //prepare custom js and css for
838
- add_filter('lp_custom_js_name','lp_ab_testing_prepare_name');
839
- add_filter('lp_custom_css_name','lp_ab_testing_prepare_name');
840
- function lp_ab_testing_prepare_name($id)
841
- {
842
- $current_variation_id = lp_ab_testing_get_current_variation_id();
843
- //echo $current_variation_id;exit;
844
- if ($current_variation_id>0)
845
- {
846
- $id = $id.'-'.$current_variation_id;
847
- }
848
-
849
- return $id;
850
- }
851
-
852
- add_action('wp_ajax_lp_ab_testing_prepare_variation', 'lp_ab_testing_prepare_variation_callback');
853
- add_action('wp_ajax_nopriv_lp_ab_testing_prepare_variation', 'lp_ab_testing_prepare_variation_callback');
854
-
855
- function lp_ab_testing_prepare_variation_callback()
856
- {
857
- if (!lp_determine_spider())
858
- {
859
- //echo "hello";
860
- //PRINT trim($_POST['current_url']);
861
- $page_id = lp_url_to_postid( trim($_POST['current_url']) );
862
- //echo $page_id;
863
- $variations = get_post_meta($page_id,'lp-ab-variations', true);
864
- $marker = get_post_meta($page_id,'lp-ab-variations-marker', true);
865
- if (!is_numeric($marker))
866
- $marker = 0;
867
-
868
- //echo "marker$marker";
869
-
870
- if ($variations)
871
- {
872
- //echo $variations;
873
- $variations = explode(',',$variations);
874
- //print_r($variations);
875
-
876
- $variation_id = $variations[$marker];
877
-
878
- $marker++;
879
-
880
- if ($marker>=count($variations))
881
- {
882
- //echo "here";
883
- $marker = 0;
884
- }
885
-
886
- update_post_meta($page_id, 'lp-ab-variations-marker', $marker);
887
-
888
- echo $variation_id;
889
- die();
890
- }
891
-
892
- }
893
- }
894
-
895
-
896
- add_filter('the_content','lp_ab_testing_alter_content_area', 10, 2);
897
- add_filter('get_the_content','lp_ab_testing_alter_content_area', 10, 2);
898
- function lp_ab_testing_alter_content_area($content)
899
- {
900
- global $post;
901
-
902
- $variation_id = lp_ab_testing_get_current_variation_id();
903
-
904
- if ($variation_id>0)
905
- {
906
- $content = do_shortcode(get_post_meta($post->ID,'content-'.$variation_id, true));
907
- }
908
-
909
- return $content;
910
- }
911
-
912
- add_filter('wp_title','lp_ab_testing_alter_title_area', 9, 2);
913
- add_filter('the_title','lp_ab_testing_alter_title_area', 10, 2);
914
- add_filter('get_the_title','lp_ab_testing_alter_title_area', 10, 2);
915
- function lp_ab_testing_alter_title_area( $content , $id = null)
916
- {
917
- global $post;
918
-
919
- if (!isset($post))
920
- return $content;
921
-
922
- if ( ( $post->post_type!='landing-page'||is_admin()) || $id != $post->ID)
923
- return $content;
924
-
925
- return lp_main_headline($post, null, true);
926
- }
927
-
928
- add_action('lp_record_impression','lp_ab_testing_record_impression', 10, 2);
929
- function lp_ab_testing_record_impression($page_id, $variation_id=0)
930
- {
931
- $impressions = get_post_meta($page_id,'lp-ab-variation-impressions-'.$variation_id, true);
932
- if (!is_numeric($impressions))
933
- $impressions = 1;
934
- else
935
- $impressions++;
936
-
937
- update_post_meta($page_id,'lp-ab-variation-impressions-'.$variation_id, $impressions);
938
- }
939
-
940
-
941
- add_action('lp_launch_customizer_pre','lp_ab_testing_customizer_enqueue');
942
- function lp_ab_testing_customizer_enqueue($post)
943
- {
944
- //echo 1; exit;
945
- $permalink = get_permalink( $post->ID );
946
- $randomstring = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10);
947
-
948
- wp_enqueue_script( 'lp_ab_testing_customizer_js', LANDINGPAGES_URLPATH . 'js/customizer.ab-testing.js', array( 'jquery' ) );
949
- wp_localize_script( 'lp_ab_testing_customizer_js', 'ab_customizer', array( 'lp_id' => $post->ID ,'permalink' => $permalink , 'randomstring' => $randomstring));
950
- wp_enqueue_style('lp_ab_testing_customizer_css', LANDINGPAGES_URLPATH . 'css/customizer-ab-testing.css');
 
 
 
 
951
  }
1
+ <?php
2
+
3
+ /* ADMIN ONLY AB TESTING FUNCTIONS */
4
+ if (is_admin())
5
+ {
6
+ include_once(LANDINGPAGES_PATH.'modules/module.ab-testing.metaboxes.php');
7
+
8
+ /**
9
+ * [lp_ab_unset_variation description]
10
+ * @param [type] $variations [description]
11
+ * @param [type] $vid [description]
12
+ * @return [type] [description]
13
+ */
14
+ function lp_ab_unset_variation($variations,$vid)
15
+ {
16
+ if(($key = array_search($vid, $variations)) !== false) {
17
+ unset($variations[$key]);
18
+ }
19
+
20
+ return $variations;
21
+ }
22
+
23
+ /**
24
+ * [lp_ab_get_lp_active_status returns if landing page is in rotation or not]
25
+ * @param [OBJ] $post [description]
26
+ * @param [INT] $vid [description]
27
+ * @return [INT]
28
+ */
29
+ function lp_ab_get_lp_active_status($post,$vid=null)
30
+ {
31
+ if ($vid==0)
32
+ {
33
+ $variation_status = get_post_meta( $post->ID , 'lp_ab_variation_status' , true);
34
+ }
35
+ else
36
+ {
37
+ $variation_status = get_post_meta( $post->ID , 'lp_ab_variation_status-'.$vid , true);
38
+ }
39
+
40
+ if (!is_numeric($variation_status))
41
+ {
42
+ return 1;
43
+ }
44
+ else
45
+ {
46
+ return $variation_status;
47
+ }
48
+ }
49
+
50
+
51
+ add_action('init','lp_ab_testing_admin_init');
52
+ function lp_ab_testing_admin_init($hook)
53
+ {
54
+ if (!is_admin()||!isset($_GET['post']))
55
+ return;
56
+
57
+ $post = get_post($_GET['post']);
58
+
59
+ if (isset($post)&&($post->post_type=='landing-page'&&(isset($_GET['action'])&&$_GET['action']=='edit')))
60
+ {
61
+
62
+ $current_variation_id = lp_ab_testing_get_current_variation_id();
63
+ //echo $current_variation_id;
64
+ $variations = get_post_meta($post->ID,'lp-ab-variations', true);
65
+
66
+ //remove landing page's main save_post action
67
+ if ($current_variation_id>0)
68
+ {
69
+ remove_action('save_post','lp_save_meta',10);
70
+ }
71
+
72
+ //check for delete command
73
+ if (isset($_GET['ab-action'])&&$_GET['ab-action']=='delete-variation')
74
+ {
75
+ $array_variations = explode(',',$variations);
76
+ $array_variations = lp_ab_unset_variation($array_variations,$_GET['lp-variation-id']);
77
+
78
+ /* set next variation to be open */
79
+ $current_variation_id = current($array_variations);
80
+ $_SESSION['lp_ab_test_open_variation'] = $current_variation_id;
81
+
82
+ $variations = implode(',' , $array_variations);
83
+ update_post_meta($post->ID,'lp-ab-variations', $variations);
84
+
85
+
86
+ if (isset($_GET['lp-variation-id']) && $_GET['lp-variation-id'] > 0 ) {
87
+ $suffix = '-'.$_GET['lp-variation-id'];
88
+ $len = strlen($suffix);
89
+ } else {
90
+ $suffix = '';
91
+ $len = strlen($suffix);
92
+ }
93
+
94
+ //delete each meta value associated with variation
95
+ global $wpdb;
96
+ $data = array();
97
+ $wpdb->query("
98
+ SELECT `meta_key`, `meta_value`
99
+ FROM $wpdb->postmeta
100
+ WHERE `post_id` = ".$_GET['post']."
101
+ ");
102
+
103
+ foreach($wpdb->last_result as $k => $v){
104
+ $data[$v->meta_key] = $v->meta_value;
105
+ };
106
+ //echo $len;exit;
107
+ foreach ($data as $key=>$value)
108
+ {
109
+ if (substr($key,-$len)==$suffix)
110
+ {
111
+ delete_post_meta($_GET['post'], $key, $value);
112
+ }
113
+ }
114
+
115
+ $_GET['lp-variation-id'] = $current_variation_id;
116
+ }
117
+
118
+ //check for pause command
119
+ if (isset($_GET['ab-action'])&&$_GET['ab-action']=='pause-variation')
120
+ {
121
+ if ($_GET['lp-variation-id']==0)
122
+ {
123
+ update_post_meta( $post->ID , 'lp_ab_variation_status' , '0' );
124
+ }
125
+ else
126
+ {
127
+ update_post_meta( $post->ID , 'lp_ab_variation_status-'.$_GET['lp-variation-id'] , '0');
128
+ }
129
+ }
130
+
131
+ //check for pause command
132
+ if (isset($_GET['ab-action'])&&$_GET['ab-action']=='play-variation')
133
+ {
134
+ if ($_GET['lp-variation-id']==0)
135
+ {
136
+ update_post_meta( $post->ID , 'lp_ab_variation_status' , '1' );
137
+ }
138
+ else
139
+ {
140
+ update_post_meta( $post->ID , 'lp_ab_variation_status-'.$_GET['lp-variation-id'] , '1');
141
+ }
142
+ }
143
+
144
+ //return;
145
+
146
+ (isset($_GET['new-variation'])&&$_GET['new-variation']==1) ? $new_variation = 1 : $new_variation = 0;
147
+
148
+ $content_area = lp_content_area($post,null,true);
149
+
150
+ //prepare for new variation creation - use A as default content if not being cloned
151
+ if (($new_variation==1&&!isset($_GET['clone']))||isset($_GET['clone'])&&$_GET['clone']==0)
152
+ {
153
+ $content_area = get_post_field('post_content', $_GET['post']);
154
+ $content_area = wpautop($content_area);
155
+ }
156
+ else if ($new_variation==1&&isset($_GET['clone']))
157
+ {
158
+ $content_area = get_post_field('content-'.$_GET['clone'], $_GET['post']);
159
+ $content_area = wpautop($content_area);
160
+ }
161
+
162
+ //if new variation and cloning then programatically prepare the next variation id
163
+ if($new_variation==1&&isset($_GET['clone']))
164
+ {
165
+ $array_variations = explode(',',$variations);
166
+ sort($array_variations,SORT_NUMERIC);
167
+
168
+ $lid = end($array_variations);
169
+ $current_variation_id = $lid+1;
170
+
171
+ $_SESSION['lp_ab_test_open_variation'] = $current_variation_id;
172
+ }
173
+ //echo $current_variation_id;exit;
174
+ //enqueue and localize scripts
175
+ wp_enqueue_style('lp-ab-testing-admin-css', LANDINGPAGES_URLPATH . 'css/admin-ab-testing.css');
176
+ wp_enqueue_script('lp-ab-testing-admin-js', LANDINGPAGES_URLPATH . 'js/admin/admin.post-edit-ab-testing.js', array( 'jquery' ));
177
+ wp_localize_script( 'lp-ab-testing-admin-js', 'variation', array( 'pid' => $_GET['post'], 'vid' => $current_variation_id , 'new_variation' => $new_variation , 'variations'=> $variations , 'content_area' => $content_area ));
178
+
179
+ }
180
+
181
+ }
182
+
183
+ /* force visual editor to open in text mode */
184
+
185
+ function lp_ab_testing_force_default_editor() {
186
+ //allowed: tinymce, html, test
187
+ return 'html';
188
+ }
189
+
190
+ add_filter('lp_edit_main_headline','lp_ab_testing_admin_prepare_headline');
191
+ function lp_ab_testing_admin_prepare_headline($main_headline)
192
+ {
193
+
194
+ $current_variation_id = lp_ab_testing_get_current_variation_id();
195
+
196
+ if (isset($_REQUEST['post']))
197
+ {
198
+ $post_id = $_REQUEST['post'];
199
+ }
200
+ else if (isset($_REQUEST['lp_id']))
201
+ {
202
+ $post_id = $_REQUEST['lp_id'];
203
+ }
204
+
205
+ //return "hello";
206
+
207
+ if ($current_variation_id>0&&!isset($_REQUEST['new-variation'])&&!isset($_REQUEST['clone']))
208
+ {
209
+ $main_headline = get_post_meta($post_id,'lp-main-headline-'.$current_variation_id, true);
210
+ }
211
+ else if (isset($_GET['clone'])&&$_GET['clone']>0)
212
+ {
213
+ $main_headline = get_post_meta($post_id,'lp-main-headline-'.$_GET['clone'], true);
214
+ }
215
+
216
+ if (!$main_headline&&isset($_REQUEST['post']))
217
+ {
218
+ get_post_meta($_REQUEST['post'],'lp-main-headline', true);
219
+ }
220
+
221
+ return $main_headline;
222
+ }
223
+
224
+ //disable this because it will populate all wp_editor isntances rather than targeted instances
225
+ //add_filter('the_editor_content', 'lp_ab_testing_the_editor_content');
226
+ function lp_ab_testing_the_editor_content($content)
227
+ {
228
+ $current_variation_id = lp_ab_testing_get_current_variation_id();
229
+
230
+ if (isset($_REQUEST['post']))
231
+ {
232
+ $post_id = $_REQUEST['post'];
233
+ }
234
+ else if (isset($_REQUEST['lp_id']))
235
+ {
236
+ $post_id = $_REQUEST['lp_id'];
237
+ }
238
+
239
+ if ($current_variation_id>0&&!isset($_REQUEST['new-variation'])&&!isset($_REQUEST['clone']))
240
+ {
241
+ $content = get_post_field('content-'.$current_variation_id, $post_id);
242
+ }
243
+ else if (isset($_GET['clone']))
244
+ {
245
+ $content = get_post_meta($post_id,'lp-main-headline-'.$_GET['clone'], true);
246
+ }
247
+
248
+ return $content;
249
+ }
250
+
251
+
252
+ add_filter('lp_edit_variation_notes','lp_ab_testing_admin_prepare_notes');
253
+ function lp_ab_testing_admin_prepare_notes($variation_notes)
254
+ {
255
+ $current_variation_id = lp_ab_testing_get_current_variation_id();
256
+
257
+ if (isset($_REQUEST['post']))
258
+ {
259
+ $post_id = $_REQUEST['post'];
260
+ }
261
+ else if (isset($_REQUEST['lp_id']))
262
+ {
263
+ $post_id = $_REQUEST['lp_id'];
264
+ }
265
+
266
+ //return "hello";
267
+
268
+ if ($current_variation_id>0&&!isset($_REQUEST['new-variation'])&&!isset($_REQUEST['clone']))
269
+ {
270
+ $variation_notes = get_post_meta($post_id,'lp-variation-notes-'.$current_variation_id, true);
271
+ }
272
+ else if (isset($_GET['clone'])&&$_GET['clone']>0)
273
+ {
274
+ $variation_notes = get_post_meta($post_id,'lp-variation-notes-'.$_GET['clone'], true);
275
+ }
276
+
277
+ if (!$variation_notes&&isset($_REQUEST['post']))
278
+ {
279
+ get_post_meta($_REQUEST['post'],'lp-variation-notes', true);
280
+ }
281
+
282
+ return $variation_notes;
283
+ }
284
+
285
+ add_filter('lp_selected_template_id','lp_ab_testing_prepare_id');//prepare name id for hidden selected template input
286
+ add_filter('lp_display_headline_input_id','lp_ab_testing_prepare_id');//prepare id for main headline in template customizer mode
287
+ add_filter('lp_display_notes_input_id','lp_ab_testing_prepare_id');//prepare id for main headline in template customizer mode
288
+ function lp_ab_testing_prepare_id($id)
289
+ {
290
+ $current_variation_id = lp_ab_testing_get_current_variation_id();
291
+
292
+ //check if variation clone is initiated
293
+ if (isset($_GET['new_meta_key']))
294
+ $current_variation_id = $_GET['new_meta_key'];
295
+
296
+ if ($current_variation_id>0)
297
+ {
298
+ $id = $id.'-'.$current_variation_id;
299
+ }
300
+
301
+ return $id;
302
+ }
303
+
304
+ //prepare id for wp_editor in template customizer
305
+ add_filter('lp_wp_editor_id','lp_ab_testing_prepare_wysiwyg_editor_id');
306
+ function lp_ab_testing_prepare_wysiwyg_editor_id($id)
307
+ {
308
+ $current_variation_id = lp_ab_testing_get_current_variation_id();
309
+ //echo $current_variation_id;exit;
310
+ if ($current_variation_id>0)
311
+ {
312
+ switch ($id) {
313
+ case "wp_content":
314
+ $id = 'content-'.$current_variation_id;
315
+ break;
316
+ case "lp-conversion-area":
317
+ $id = 'landing-page-myeditor-'.$current_variation_id;
318
+ break;
319
+ default:
320
+ $id = $id.'-'.$current_variation_id;
321
+ }
322
+
323
+ }
324
+
325
+ return $id;
326
+ }
327
+
328
+
329
+ add_filter('lp_show_metabox','lp_ab_testing_admin_prepare_meta_ids', 5, 2);
330
+ function lp_ab_testing_admin_prepare_meta_ids($lp_custom_fields, $main_key)
331
+ {
332
+ if (isset($_REQUEST['new-variation'])&&!isset($_REQUEST['clone']))
333
+ {
334
+ return $lp_custom_fields;
335
+ }
336
+
337
+ $current_variation_id = lp_ab_testing_get_current_variation_id();
338
+
339
+ if (isset($_GET['clone'])) {
340
+ $current_variation_id = $_GET['clone'];
341
+ }
342
+
343
+ if ($current_variation_id>0)
344
+ {
345
+ $post_id = $_GET['post'];
346
+ foreach ($lp_custom_fields as $key=>$field)
347
+ {
348
+ $default = get_post_meta($post_id, $field['id'], true);
349
+
350
+ $id = $field['id'];
351
+ $field['id'] = $id.'-'.$current_variation_id ;
352
+
353
+ if ($default) {
354
+ $field['default'] = $default;
355
+ }
356
+
357
+ $lp_custom_fields[$key] = $field;
358
+ }
359
+ return $lp_custom_fields;
360
+ }
361
+
362
+ //print_r($lp_custom_fields);exit;
363
+ return $lp_custom_fields;
364
+ }
365
+
366
+ add_filter('lp_variation_selected_template','lp_ab_testing_lp_variation_selected_template', 10, 2);
367
+ function lp_ab_testing_lp_variation_selected_template($selected_template, $post)
368
+ {
369
+ if (isset($_GET['new-variation']))
370
+ return $selected_template;
371
+
372
+ $current_variation_id = lp_ab_testing_get_current_variation_id();
373
+
374
+ if ($current_variation_id>0)
375
+ {
376
+ $selected_template = get_post_meta( $post->ID , 'lp-selected-template-'.$current_variation_id , true);
377
+ }
378
+
379
+ //print_r($lp_custom_fields);exit;
380
+ return $selected_template;
381
+ }
382
+
383
+ //add filter to modify thumbnail preview
384
+ add_filter('lp_live_screenshot_url', 'lp_ab_testing_prepare_screenshot');
385
+ function lp_ab_testing_prepare_screenshot($link)
386
+ {
387
+ $variation_id = lp_ab_testing_get_current_variation_id();
388
+ $link = $link."?lp-variation-id=".$variation_id;
389
+ return $link;
390
+ }
391
+
392
+
393
+
394
+ add_filter("post_type_link", "lp_ab_append_variation_id_to_adminbar_link", 10,2);
395
+ function lp_ab_append_variation_id_to_adminbar_link($link, $post)
396
+ {
397
+ if( $post->post_type == 'landing-page' )
398
+ {
399
+ $current_variation_id = lp_ab_testing_get_current_variation_id();
400
+
401
+ if ($current_variation_id>0)
402
+ $link = $link."?lp-variation-id=".$current_variation_id;
403
+ }
404
+
405
+ return $link;
406
+ }
407
+
408
+ if(!defined('AUTOSAVE_INTERVAL')) {
409
+ define('AUTOSAVE_INTERVAL', 86400);
410
+ }
411
+
412
+ add_filter('wp_insert_post_data','lp_ab_testing_wp_insert_post_data',10,2);
413
+ function lp_ab_testing_wp_insert_post_data($data,$postarr)
414
+ {
415
+
416
+ //exit;
417
+ //$variation_id = lp_ab_testing_get_current_variation_id();
418
+ //echo $variation_id;exit;
419
+ if (isset($postarr['lp-variation-id'])&&$postarr['lp-variation-id']>0)
420
+ {
421
+ $postarr = array();
422
+ $data = array();
423
+
424
+ remove_action('save_post','lp_save_meta',10);
425
+ remove_action('save_post','lp_ab_testing_save_post',10);
426
+
427
+ $postID = $_POST['post_ID'];
428
+ if($parent_id = wp_is_post_revision($_POST['post_ID']))
429
+ {
430
+ $postID = $parent_id;
431
+ }
432
+
433
+ lp_ab_testing_save_post($postID);
434
+
435
+ }
436
+ else
437
+ {
438
+ //echo "here";exit;
439
+ //$this_data = json_encode($data);
440
+ //mail('hudson.atwell@gmail.com','test2',$this_data);
441
+ }
442
+
443
+ if (count($data)>1)
444
+ return $data;
445
+ }
446
+
447
+ add_action('save_post','lp_ab_testing_save_post');
448
+ function lp_ab_testing_save_post($postID)
449
+ {
450
+ global $post;
451
+
452
+ $var_final = (isset($_POST['lp-variation-id'])) ? $_POST['lp-variation-id'] : '0';
453
+ if ( isset($_POST['post_type']) && $_POST['post_type']=='landing-page')
454
+ {
455
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ||$_POST['post_type']=='revision')
456
+ {
457
+ return;
458
+ }
459
+
460
+ if($parent_id = wp_is_post_revision($postID))
461
+ {
462
+ $postID = $parent_id;
463
+ }
464
+
465
+
466
+ $this_variation = $var_final;
467
+ //echo $this_variation;
468
+ //print_r($_POST);exit;
469
+
470
+ //first add to varation list if not present.
471
+ $variations = get_post_meta($postID,'lp-ab-variations', true);
472
+ if ($variations)
473
+ {
474
+ $array_variations = explode(',',$variations);
475
+ if (!in_array($this_variation,$array_variations))
476
+ {
477
+ $array_variations[] = $this_variation;
478
+ }
479
+ }
480
+ else
481
+ {
482
+ if ($this_variation>0)
483
+ {
484
+ $array_variations[] = 0;
485
+ $array_variations[] = $this_variation;
486
+ }
487
+ else
488
+ {
489
+ $array_variations[] = $this_variation;
490
+ }
491
+ }
492
+
493
+ //print_r($array_variations);exit;
494
+ //update_post_meta($postID,'lp-ab-variations', "");
495
+ update_post_meta($postID,'lp-ab-variations', implode(',',$array_variations));
496
+ //add_post_meta($postID, 'lp_ab_variation_status-'.$this_variation , 1);
497
+
498
+ //echo $this_variation;exit;
499
+ if ($this_variation==0)
500
+ {
501
+ return;
502
+ }
503
+ //echo $this_variation;exit;
504
+ //print_r($_POST);
505
+
506
+ //next alter all custom fields to store correct varation and create custom fields for special inputs
507
+ $ignore_list = array('post_status','post_type','tax_input','post_author','user_ID','post_ID','catslist','post_title','samplepermalinknonce',
508
+ 'autosavenonce','action','autosave','mm','jj','aa','hh','mn','ss','_wp_http_referer','lp-variation-id','_wpnonce','originalaction','original_post_status',
509
+ 'referredby','_wp_original_http_referer','meta-box-order-nonce','closedpostboxesnonce','hidden_post_status','hidden_post_password','hidden_post_visibility','visibility',
510
+ 'post_password','hidden_mm','cur_mm','hidden_jj','cur_jj','hidden_aa','cur_aa','hidden_hh','cur_hh','hidden_mn','cur_mn','original_publish','save','newlanding_page_category','newlanding_page_category_parent',
511
+ '_ajax_nonce-add-landing_page_category','lp_lp_custom_fields_nonce','lp-selected-template','post_mime_type','ID','comment_status','ping_status');
512
+
513
+ //$special_list = array('content','post-content');
514
+ //print_r($_POST);exit;
515
+ //echo $this_variation;exit;
516
+ foreach ($_POST as $key=>$value)
517
+ {
518
+ //echo $key." : -{$this_variation} : $value<br>";
519
+ if (!in_array($key,$ignore_list)&&!strstr($key,'nonce'))
520
+ {
521
+ if ($key=='post_content')
522
+ $key = 'content';
523
+
524
+ if (!strstr($key,"-{$this_variation}"))
525
+ {
526
+ $new_array[$key.'-'.$this_variation] = $value;
527
+ }
528
+ else
529
+ {
530
+ //echo $key." : -{$this_variation}<br>";
531
+ $new_array[$key] = $value;
532
+ }
533
+ }
534
+ //echo $key." : -{$this_variation} : $value<br>";
535
+ }
536
+
537
+ //print_r($new_array);exit;
538
+
539
+ foreach($new_array as $key => $val)
540
+ {
541
+ $old = get_post_meta($postID, $key, true);
542
+ $new = $val;
543
+ //echo "$key : $old v. $new <br>";
544
+ //if (isset($new) && $new != $old ) {
545
+ update_post_meta($postID, $key, $new);
546
+ //} elseif ('' == $new && $old) {
547
+ //delete_post_meta($postID, $key, $old);
548
+ //}
549
+ }
550
+
551
+ }
552
+ }
553
+
554
+ }
555
+
556
+ /* PERFORM FRONT-END ONLY ACTIONS */
557
+ else
558
+ {
559
+
560
+ //prepare customizer meta data for ab varations
561
+ add_filter('lp_get_value','lp_ab_testing_prepare_variation_meta', 1 , 4);
562
+ function lp_ab_testing_prepare_variation_meta($return, $post, $key, $id)
563
+ {
564
+ if (isset($_REQUEST['lp-variation-id'])||isset($_COOKIE['lp-variation-id']))
565
+ {
566
+ (isset($_REQUEST['lp-variation-id'])) ? $variation_id = $_REQUEST['lp-variation-id'] : $variation_id = $_COOKIE['lp-variation-id'];
567
+ if ($variation_id>0)
568
+ return do_shortcode(get_post_meta($post->ID, $key.'-'.$id. '-' .$variation_id , true));
569
+ else
570
+ return $return;
571
+ }
572
+ else
573
+ {
574
+ return $return;
575
+ }
576
+ }
577
+
578
+ //prepare customizer, admin, and preview links for variations
579
+ add_filter('lp_customizer_customizer_link', 'lp_ab_append_variation_id_to_link');
580
+ add_filter('lp_customizer_admin_bar_link', 'lp_ab_append_variation_id_to_link');
581
+ add_filter('lp_customizer_preview_link','lp_ab_append_variation_id_to_link');
582
+
583
+ function lp_ab_append_variation_id_to_link($link)
584
+ {
585
+
586
+ $current_variation_id = lp_ab_testing_get_current_variation_id();
587
+
588
+ if ($current_variation_id>0)
589
+ $link = $link."&lp-variation-id=".$current_variation_id;
590
+
591
+ return $link;
592
+ }
593
+
594
+ }
595
+
596
+ /*PERFORM ACTIONS REQUIRED ON BOTH FRONT AND BACKEND */
597
+
598
+ add_filter('lp_content_area','lp_ab_testing_alter_content_area_admin', 10, 2);
599
+ function lp_ab_testing_alter_content_area_admin($content)
600
+ {
601
+ global $post;
602
+
603
+ $variation_id = lp_ab_testing_get_current_variation_id();
604
+
605
+ if ($variation_id>0)
606
+ {
607
+ $content = get_post_meta($post->ID,'content-'.$variation_id, true);
608
+ if ( !is_admin() )
609
+ {
610
+ $content = wpautop($content);
611
+ $content = do_shortcode($content);
612
+ }
613
+ }
614
+
615
+ return $content;
616
+ }
617
+
618
+ /* RETURN LETTER FROM ARRAY KEY */
619
+ function lp_ab_key_to_letter($key) {
620
+ $alphabet = array( 'A', 'B', 'C', 'D', 'E',
621
+ 'F', 'G', 'H', 'I', 'J',
622
+ 'K', 'L', 'M', 'N', 'O',
623
+ 'P', 'Q', 'R', 'S', 'T',
624
+ 'U', 'V', 'W', 'X', 'Y',
625
+ 'Z'
626
+ );
627
+
628
+ if (isset($alphabet[$key])) {
629
+ return $alphabet[$key];
630
+ }
631
+ }
632
+
633
+ /* GET CURRENT VARIATION ID */
634
+ function lp_ab_testing_get_current_variation_id()
635
+ {
636
+ if ( isset($_GET['ab-action']) &&is_admin())
637
+ {
638
+ return $_SESSION['lp_ab_test_open_variation'];
639
+ }
640
+
641
+ if (!isset($_SESSION['lp_ab_test_open_variation'])&&!isset($_REQUEST['lp-variation-id']))
642
+ {
643
+ $current_variation_id = 0;
644
+ }
645
+ //echo $_REQUEST['lp-variation-id'];
646
+ if (isset($_REQUEST['lp-variation-id']))
647
+ {
648
+ $_SESSION['lp_ab_test_open_variation'] = $_REQUEST['lp-variation-id'];
649
+ $current_variation_id = $_REQUEST['lp-variation-id'];
650
+ //echo "setting session $current_variation_id";
651
+ }
652
+
653
+ if (isset($_GET['message'])&&$_GET['message']==1&&isset( $_SESSION['lp_ab_test_open_variation'] ))
654
+ {
655
+ $current_variation_id = $_SESSION['lp_ab_test_open_variation'];
656
+
657
+ //echo "here:".$_SESSION['lp_ab_test_open_variation'];
658
+ }
659
+
660
+ if (isset($_GET['ab-action'])&&$_GET['ab-action']=='delete-variation')
661
+ {
662
+ $current_variation_id = 0;
663
+ $_SESSION['lp_ab_test_open_variation'] = 0;
664
+ }
665
+
666
+ if (!isset($current_variation_id))
667
+ $current_variation_id = 0 ;
668
+
669
+ return $current_variation_id;
670
+ }
671
+
672
+ //ready conversion area for displaying ab variations
673
+ add_filter('lp_conversion_area_pre_standardize','lp_ab_testing_prepare_conversion_area' , 10 , 2 );
674
+ function lp_ab_testing_prepare_conversion_area($content,$post=null)
675
+ {
676
+ $current_variation_id = lp_ab_testing_get_current_variation_id();
677
+
678
+ if (isset($post))
679
+ {
680
+ $post_id = $post->ID;
681
+ }
682
+ else if (isset($_REQUEST['post']))
683
+ {
684
+ $post_id = $_REQUEST['post'];
685
+ }
686
+ else if (isset($_REQUEST['lp_id']))
687
+ {
688
+ $post_id = $_REQUEST['lp_id'];
689
+ }
690
+
691
+
692
+ if ($current_variation_id>0)
693
+ $content = get_post_meta($post_id,'landing-page-myeditor-'.$current_variation_id, true);
694
+
695
+ return $content;
696
+ }
697
+
698
+ //ready conversion area for displaying ab variations
699
+ add_filter('lp_conversion_area_position','lp_ab_testing_lp_conversion_area_position' , 10 , 2 );
700
+ function lp_ab_testing_lp_conversion_area_position($position, $post = null, $key = 'default')
701
+ {
702
+
703
+ $current_variation_id = lp_ab_testing_get_current_variation_id();
704
+
705
+ if (isset($post))
706
+ {
707
+ $post_id = $post->ID;
708
+ }
709
+ else if (isset($_REQUEST['post']))
710
+ {
711
+ $post_id = $_REQUEST['post'];
712
+ }
713
+ else if (isset($_REQUEST['lp_id']))
714
+ {
715
+ $post_id = $_REQUEST['lp_id'];
716
+ }
717
+
718
+ if ($current_variation_id>0)
719
+ $position = get_post_meta($post->ID, "{$key}-conversion-area-placement-".$current_variation_id, true);
720
+
721
+ return $position;
722
+ }
723
+
724
+
725
+ add_filter('lp_main_headline','lp_ab_testing_prepare_headline', 10, 2);
726
+ function lp_ab_testing_prepare_headline($main_headline, $post = null)
727
+ {
728
+
729
+ $current_variation_id = lp_ab_testing_get_current_variation_id();
730
+
731
+ if (isset($post))
732
+ {
733
+ $post_id = $post->ID;
734
+ }
735
+ else if (isset($_REQUEST['post']))
736
+ {
737
+ $post_id = $_REQUEST['post'];
738
+ }
739
+ else if (isset($_REQUEST['lp_id']))
740
+ {
741
+ $post_id = $_REQUEST['lp_id'];
742
+ }
743
+ else if (isset($_REQUEST['post_id']))
744
+ {
745
+ $post_id = $_REQUEST['post_id'];
746
+ }
747
+
748
+
749
+ if ($current_variation_id>0)
750
+ $main_headline = get_post_meta($post_id,'lp-main-headline-'.$current_variation_id, true);
751
+
752
+ if (!$main_headline)
753
+ {
754
+ get_post_meta($post_id,'lp-main-headline', true);
755
+ }
756
+
757
+
758
+ return $main_headline;
759
+ }
760
+
761
+ add_action('init','lp_ab_testing_add_rewrite_rules');
762
+ function lp_ab_testing_add_rewrite_rules()
763
+ {
764
+ $this_path = LANDINGPAGES_PATH;
765
+ $this_path = explode('wp-content',$this_path);
766
+ $this_path = "wp-content".$this_path[1];
767
+
768
+ $slug = get_option( 'lp-main-landing-page-permalink-prefix', 'go' );
769
+ //echo $slug;exit;
770
+ add_rewrite_rule("$slug/([^/]*)?", $this_path."modules/module.redirect-ab-testing.php?permalink_name=$1 ",'top');
771
+ add_rewrite_rule("landing-page=([^/]*)?", $this_path.'modules/module.redirect-ab-testing.php?permalink_name=$1','top');
772
+
773
+ add_filter('mod_rewrite_rules', 'lp_ab_testing_modify_rules', 1);
774
+ function lp_ab_testing_modify_rules($rules)
775
+ {
776
+ if (!stristr($rules,'RewriteCond %{QUERY_STRING} !lp-variation-id'))
777
+ {
778
+ $rules_array = preg_split ('/$\R?^/m', $rules);
779
+ if (count($rules_array)<3)
780
+ {
781
+ $rules_array = explode("\n", $rules);
782
+ $rules_array = array_filter($rules_array);
783
+ }
784
+
785
+ //print_r($rules_array);exit;
786
+
787
+ $this_path = LANDINGPAGES_PATH;
788
+ $this_path = explode('wp-content',$this_path);
789
+ $this_path = "wp-content".$this_path[1];
790
+ $slug = get_option( 'lp-main-landing-page-permalink-prefix', 'go' );
791
+
792
+ $i = 0;
793
+ foreach ($rules_array as $key=>$val)
794
+ {
795
+
796
+ if (stristr($val,"RewriteRule ^{$slug}/([^/]*)? "))
797
+ {
798
+ $new_val = "RewriteCond %{QUERY_STRING} !lp-variation-id";
799
+ $rules_array[$i] = $new_val;
800
+ $i++;
801
+ $rules_array[$i] = $val;
802
+ $i++;
803
+ }
804
+ else
805
+ {
806
+ $rules_array[$i] = $val;
807
+ $i++;
808
+ }
809
+ }
810
+
811
+ $rules = implode("\r\n", $rules_array);
812
+ }
813
+
814
+ return $rules;
815
+ }
816
+
817
+ }
818
+
819
+
820
+ add_filter('lp_selected_template','lp_ab_testing_get_selected_template');//get correct selected template for each variation
821
+ function lp_ab_testing_get_selected_template($template)
822
+ {
823
+ global $post;
824
+
825
+ $current_variation_id = lp_ab_testing_get_current_variation_id();
826
+
827
+ if ($current_variation_id>0)
828
+ {
829
+ $new_template = get_post_meta($post->ID, 'lp-selected-template-'.$current_variation_id, true);
830
+ if ($new_template)
831
+ $template = $new_template;
832
+ }
833
+
834
+ return $template;
835
+ }
836
+
837
+ //prepare custom js and css for
838
+ add_filter('lp_custom_js_name','lp_ab_testing_prepare_name');
839
+ add_filter('lp_custom_css_name','lp_ab_testing_prepare_name');
840
+ function lp_ab_testing_prepare_name($id)
841
+ {
842
+ $current_variation_id = lp_ab_testing_get_current_variation_id();
843
+ //echo $current_variation_id;exit;
844
+ if ($current_variation_id>0)
845
+ {
846
+ $id = $id.'-'.$current_variation_id;
847
+ }
848
+
849
+ return $id;
850
+ }
851
+
852
+ add_action('wp_ajax_lp_ab_testing_prepare_variation', 'lp_ab_testing_prepare_variation_callback');
853
+ add_action('wp_ajax_nopriv_lp_ab_testing_prepare_variation', 'lp_ab_testing_prepare_variation_callback');
854
+
855
+ function lp_ab_testing_prepare_variation_callback()
856
+ {
857
+ if (!lp_determine_spider())
858
+ {
859
+ //echo "hello";
860
+ //PRINT trim($_POST['current_url']);
861
+ $page_id = lp_url_to_postid( trim($_POST['current_url']) );
862
+ //echo $page_id;
863
+ $variations = get_post_meta($page_id,'lp-ab-variations', true);
864
+ $marker = get_post_meta($page_id,'lp-ab-variations-marker', true);
865
+ if (!is_numeric($marker))
866
+ $marker = 0;
867
+
868
+ //echo "marker$marker";
869
+
870
+ if ($variations)
871
+ {
872
+ //echo $variations;
873
+ $variations = explode(',',$variations);
874
+ //print_r($variations);
875
+
876
+ $variation_id = $variations[$marker];
877
+
878
+ $marker++;
879
+
880
+ if ($marker>=count($variations))
881
+ {
882
+ //echo "here";
883
+ $marker = 0;
884
+ }
885
+
886
+ update_post_meta($page_id, 'lp-ab-variations-marker', $marker);
887
+
888
+ echo $variation_id;
889
+ die();
890
+ }
891
+
892
+ }
893
+ }
894
+
895
+
896
+ add_filter('the_content','lp_ab_testing_alter_content_area', 10, 2);
897
+ add_filter('get_the_content','lp_ab_testing_alter_content_area', 10, 2);
898
+ function lp_ab_testing_alter_content_area($content)
899
+ {
900
+ global $post;
901
+
902
+ if ( $post->post_type != 'landing-page' ) {
903
+ return $content;
904
+ }
905
+
906
+ $variation_id = lp_ab_testing_get_current_variation_id();
907
+
908
+ if ($variation_id>0)
909
+ {
910
+ $content = do_shortcode(get_post_meta($post->ID,'content-'.$variation_id, true));
911
+ }
912
+
913
+ return $content;
914
+ }
915
+
916
+ add_filter('wp_title','lp_ab_testing_alter_title_area', 9, 2);
917
+ add_filter('the_title','lp_ab_testing_alter_title_area', 10, 2);
918
+ add_filter('get_the_title','lp_ab_testing_alter_title_area', 10, 2);
919
+ function lp_ab_testing_alter_title_area( $content , $id = null)
920
+ {
921
+ global $post;
922
+
923
+ if (!isset($post))
924
+ return $content;
925
+
926
+ if ( ( $post->post_type!='landing-page'||is_admin()) || $id != $post->ID)
927
+ return $content;
928
+
929
+ return lp_main_headline($post, null, true);
930
+ }
931
+
932
+ add_action('lp_record_impression','lp_ab_testing_record_impression', 10, 2);
933
+ function lp_ab_testing_record_impression($page_id, $variation_id=0)
934
+ {
935
+ $impressions = get_post_meta($page_id,'lp-ab-variation-impressions-'.$variation_id, true);
936
+ if (!is_numeric($impressions))
937
+ $impressions = 1;
938
+ else
939
+ $impressions++;
940
+
941
+ update_post_meta($page_id,'lp-ab-variation-impressions-'.$variation_id, $impressions);
942
+ }
943
+
944
+
945
+ add_action('lp_launch_customizer_pre','lp_ab_testing_customizer_enqueue');
946
+ function lp_ab_testing_customizer_enqueue($post)
947
+ {
948
+ //echo 1; exit;
949
+ $permalink = get_permalink( $post->ID );
950
+ $randomstring = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10);
951
+
952
+ wp_enqueue_script( 'lp_ab_testing_customizer_js', LANDINGPAGES_URLPATH . 'js/customizer.ab-testing.js', array( 'jquery' ) );
953
+ wp_localize_script( 'lp_ab_testing_customizer_js', 'ab_customizer', array( 'lp_id' => $post->ID ,'permalink' => $permalink , 'randomstring' => $randomstring));
954
+ wp_enqueue_style('lp_ab_testing_customizer_css', LANDINGPAGES_URLPATH . 'css/customizer-ab-testing.css');
955
  }
modules/module.click-tracking.php CHANGED
@@ -23,9 +23,9 @@ function lp_click_callback() {
23
  string = "&wpl_id=" + lead_unique_key + "&l_type=wpluid";;
24
  } else {
25
  string = "";
26
- }
27
  var external = RegExp('^((f|ht)tps?:)?//(?!' + location.host + ')');
28
- jQuery('.link-click-tracking a').not("#wpadminbar a").each(function () {
29
  jQuery(this).attr("data-event-id", '<?php echo $id; ?>').attr("data-cta-varation", '<?php echo $variation;?>');
30
  var orignalurl = jQuery(this).attr("href");
31
  //jQuery("a[href*='http://']:not([href*='"+window.location.hostname+"'])"); // rewrite external links
@@ -55,7 +55,7 @@ function lp_click_track_redirect() {
55
  (isset($output['wpl_id'])) ? $lead_id = $output['wpl_id'] : $lead_id = "";
56
  (isset($output['wp-cta-v'])) ? $cta_variation = $output['wp-cta-v'] : $cta_variation = null;
57
  $pos = strpos($qs, 'lp_redirect');
58
- if (!(false === $pos)) {
59
  $link = substr($qs, $pos);
60
  $link = str_replace('lp_redirect=', '', $link); // clean url
61
 
@@ -98,8 +98,8 @@ function lp_click_track_redirect() {
98
  $append = false;
99
  }
100
  }
101
-
102
- // Save click!
103
  lp_store_click_data( $landing_page_id, $lead_ID, $cta_variation); // Store CTA data to CTA CPT
104
 
105
  if( $lead_ID && $append != false ) {
@@ -115,14 +115,14 @@ function lp_click_track_redirect() {
115
  // I'm outta here!
116
  exit(1);
117
  }
118
- }
119
  }
120
 
121
  function lp_store_click_data($landing_page_id, $lead_ID, $cta_variation){
122
- // If leads_triggered meta exists do this
123
  $event_trigger_log = get_post_meta($landing_page_id,'leads_triggered',true);
124
  $time = current_time( 'timestamp', 0 ); // Current wordpress time from settings
125
- $wordpress_date_time = date("Y-m-d G:i:s T", $time);
126
  $conversion_count = get_post_meta($landing_page_id,'lp-ab-variation-conversions-'.$cta_variation ,true);
127
  $conversion_count++;
128
  update_post_meta($landing_page_id, 'lp-ab-variation-conversions-'.$cta_variation, $conversion_count);
@@ -135,10 +135,10 @@ function lp_store_click_data($landing_page_id, $lead_ID, $cta_variation){
135
  } else {
136
  $current_count = 0;
137
  }
138
- $event_trigger_log[$lead_ID]['count'] = $current_count + 1;
139
  $event_trigger_log[$lead_ID]['datetime'] = $wordpress_date_time;
140
  $count = count($event_trigger_log[$lead_ID]['date']) + 1;
141
- $event_trigger_log[$lead_ID]['date'][$count] = $wordpress_date_time;
142
  $event_trigger_log = json_encode($event_trigger_log);
143
  update_post_meta($landing_page_id, 'leads_triggered', $event_trigger_log);
144
  } else {
@@ -146,7 +146,7 @@ function lp_store_click_data($landing_page_id, $lead_ID, $cta_variation){
146
  $event_trigger_log = array();
147
  $event_trigger_log[$lead_ID]['count'] = 1;
148
  $event_trigger_log[$lead_ID]['datetime'] = $wordpress_date_time;
149
- $event_trigger_log[$lead_ID]['date'][1] = $wordpress_date_time;
150
  $event_trigger_log = json_encode($event_trigger_log);
151
  update_post_meta($landing_page_id, 'leads_triggered', $event_trigger_log);
152
  }
@@ -158,19 +158,19 @@ function lp_store_click_data($landing_page_id, $lead_ID, $cta_variation){
158
  function lp_store_click_data_to_lead($landing_page_id, $lead_ID, $lp_variation) {
159
 
160
  $time = current_time( 'timestamp', 0 ); // Current wordpress time from settings
161
- $wordpress_date_time = date("Y-m-d G:i:s T", $time);
162
 
163
  if ( $lead_ID ) {
164
  $conversion_data = get_post_meta( $lead_ID, 'wpleads_conversion_data', TRUE );
165
  $individual_event_count = get_post_meta( $lead_ID, 'wpleads_landing_page_'.$landing_page_id, TRUE );
166
  $individual_event_count = ($individual_event_count != "") ? $individual_event_count : 0;
167
- $individual_event_count++;
168
- $meta = get_post_meta( $lead_ID, 'times', TRUE ); // replace times
169
  $meta++;
170
  $conversions_count = get_post_meta($lead_ID,'wpl-lead-conversion-count', true);
171
  $conversions_count++;
172
  if ($conversion_data) {
173
-
174
  $conversion_data = json_decode($conversion_data,true);
175
  $conversion_data[$meta]['id'] = $landing_page_id;
176
  $conversion_data[$meta]['variation'] = $lp_variation;
@@ -184,7 +184,7 @@ function lp_store_click_data_to_lead($landing_page_id, $lead_ID, $lp_variation)
184
  $conversion_data[1]['variation'] = $lp_variation;
185
  $conversion_data[1]['datetime'] = $wordpress_date_time;
186
  $conversion_data[1]['first_time'] = 1;
187
- // Add in exact link url clicked
188
  $conversion_data = json_encode($conversion_data);
189
  update_post_meta( $lead_ID, 'wpleads_conversion_data', $conversion_data );
190
  update_post_meta( $lead_ID, 'wpleads_landing_page_'.$landing_page_id, $individual_event_count );
23
  string = "&wpl_id=" + lead_unique_key + "&l_type=wpluid";;
24
  } else {
25
  string = "";
26
+ }
27
  var external = RegExp('^((f|ht)tps?:)?//(?!' + location.host + ')');
28
+ jQuery('.link-click-tracking a, .inbound-special-class').not("#wpadminbar a").each(function () {
29
  jQuery(this).attr("data-event-id", '<?php echo $id; ?>').attr("data-cta-varation", '<?php echo $variation;?>');
30
  var orignalurl = jQuery(this).attr("href");
31
  //jQuery("a[href*='http://']:not([href*='"+window.location.hostname+"'])"); // rewrite external links
55
  (isset($output['wpl_id'])) ? $lead_id = $output['wpl_id'] : $lead_id = "";
56
  (isset($output['wp-cta-v'])) ? $cta_variation = $output['wp-cta-v'] : $cta_variation = null;
57
  $pos = strpos($qs, 'lp_redirect');
58
+ if (!(false === $pos)) {
59
  $link = substr($qs, $pos);
60
  $link = str_replace('lp_redirect=', '', $link); // clean url
61
 
98
  $append = false;
99
  }
100
  }
101
+
102
+ // Save click!
103
  lp_store_click_data( $landing_page_id, $lead_ID, $cta_variation); // Store CTA data to CTA CPT
104
 
105
  if( $lead_ID && $append != false ) {
115
  // I'm outta here!
116
  exit(1);
117
  }
118
+ }
119
  }
120
 
121
  function lp_store_click_data($landing_page_id, $lead_ID, $cta_variation){
122
+ // If leads_triggered meta exists do this
123
  $event_trigger_log = get_post_meta($landing_page_id,'leads_triggered',true);
124
  $time = current_time( 'timestamp', 0 ); // Current wordpress time from settings
125
+ $wordpress_date_time = date("Y-m-d G:i:s T", $time);
126
  $conversion_count = get_post_meta($landing_page_id,'lp-ab-variation-conversions-'.$cta_variation ,true);
127
  $conversion_count++;
128
  update_post_meta($landing_page_id, 'lp-ab-variation-conversions-'.$cta_variation, $conversion_count);
135
  } else {
136
  $current_count = 0;
137
  }
138
+ $event_trigger_log[$lead_ID]['count'] = $current_count + 1;
139
  $event_trigger_log[$lead_ID]['datetime'] = $wordpress_date_time;
140
  $count = count($event_trigger_log[$lead_ID]['date']) + 1;
141
+ $event_trigger_log[$lead_ID]['date'][$count] = $wordpress_date_time;
142
  $event_trigger_log = json_encode($event_trigger_log);
143
  update_post_meta($landing_page_id, 'leads_triggered', $event_trigger_log);
144
  } else {
146
  $event_trigger_log = array();
147
  $event_trigger_log[$lead_ID]['count'] = 1;
148
  $event_trigger_log[$lead_ID]['datetime'] = $wordpress_date_time;
149
+ $event_trigger_log[$lead_ID]['date'][1] = $wordpress_date_time;
150
  $event_trigger_log = json_encode($event_trigger_log);
151
  update_post_meta($landing_page_id, 'leads_triggered', $event_trigger_log);
152
  }
158
  function lp_store_click_data_to_lead($landing_page_id, $lead_ID, $lp_variation) {
159
 
160
  $time = current_time( 'timestamp', 0 ); // Current wordpress time from settings
161
+ $wordpress_date_time = date("Y-m-d G:i:s T", $time);
162
 
163
  if ( $lead_ID ) {
164
  $conversion_data = get_post_meta( $lead_ID, 'wpleads_conversion_data', TRUE );
165
  $individual_event_count = get_post_meta( $lead_ID, 'wpleads_landing_page_'.$landing_page_id, TRUE );
166
  $individual_event_count = ($individual_event_count != "") ? $individual_event_count : 0;
167
+ $individual_event_count++;
168
+ $meta = get_post_meta( $lead_ID, 'times', TRUE ); // replace times
169
  $meta++;
170
  $conversions_count = get_post_meta($lead_ID,'wpl-lead-conversion-count', true);
171
  $conversions_count++;
172
  if ($conversion_data) {
173
+
174
  $conversion_data = json_decode($conversion_data,true);
175
  $conversion_data[$meta]['id'] = $landing_page_id;
176
  $conversion_data[$meta]['variation'] = $lp_variation;
184
  $conversion_data[1]['variation'] = $lp_variation;
185
  $conversion_data[1]['datetime'] = $wordpress_date_time;
186
  $conversion_data[1]['first_time'] = 1;
187
+ // Add in exact link url clicked
188
  $conversion_data = json_encode($conversion_data);
189
  update_post_meta( $lead_ID, 'wpleads_conversion_data', $conversion_data );
190
  update_post_meta( $lead_ID, 'wpleads_landing_page_'.$landing_page_id, $individual_event_count );
modules/module.global-settings.php CHANGED
@@ -12,8 +12,7 @@ if (isset($_GET['page'])&&($_GET['page']=='lp_global_settings'&&$_GET['page']=='
12
  }
13
 
14
 
15
- function lp_get_global_settings()
16
- {
17
  global $lp_global_settings;
18
 
19
  /* Setup Main Navigation Tab and Settings */
@@ -599,11 +598,11 @@ function lp_save_global_settings()
599
  if ($field['type']=='license-key')
600
  {
601
  $master_key = get_option('inboundnow_master_license_key' );
602
-
603
  if ($master_key) {
604
  $field['new_value'] = $master_key;
605
  }
606
-
607
  $api_params = array(
608
  'edd_action'=> 'activate_license',
609
  'license' => $field['new_value'],
@@ -617,7 +616,7 @@ function lp_save_global_settings()
617
  if ( is_wp_error( $response ) ) {
618
  break;
619
  }
620
-
621
 
622
  $license_data = json_decode( wp_remote_retrieve_body( $response ) );
623
 
@@ -632,7 +631,7 @@ function lp_save_global_settings()
632
  $master_key = get_option('inboundnow_master_license_key' );
633
 
634
  if ($master_key)
635
- {
636
  $bool = update_option($field['id'], $master_key );
637
  $license_status = update_option('lp_license_status-'.$field['slug'], '');
638
  }
12
  }
13
 
14
 
15
+ function lp_get_global_settings() {
 
16
  global $lp_global_settings;
17
 
18
  /* Setup Main Navigation Tab and Settings */
598
  if ($field['type']=='license-key')
599
  {
600
  $master_key = get_option('inboundnow_master_license_key' );
601
+
602
  if ($master_key) {
603
  $field['new_value'] = $master_key;
604
  }
605
+
606
  $api_params = array(
607
  'edd_action'=> 'activate_license',
608
  'license' => $field['new_value'],
616
  if ( is_wp_error( $response ) ) {
617
  break;
618
  }
619
+
620
 
621
  $license_data = json_decode( wp_remote_retrieve_body( $response ) );
622
 
631
  $master_key = get_option('inboundnow_master_license_key' );
632
 
633
  if ($master_key)
634
+ {
635
  $bool = update_option($field['id'], $master_key );
636
  $license_status = update_option('lp_license_status-'.$field['slug'], '');
637
  }
modules/module.javascript-frontend.php CHANGED
@@ -120,16 +120,14 @@ function lp_header_load(){
120
  if (isset($_GET['lp-variation-id']) && !isset($_GET['template-customize']) && !isset($_GET['iframe_window']) && !isset($_GET['live-preview-area'])) {
121
  do_action('landing_page_header_script');
122
  ?>
 
123
  <script type="text/javascript">
124
  //var inbound_param_overide = 'off';
125
  // Automation pass params to GA. Look for documentation
126
- if (typeof (inbound_param_overide) === "undefined" || inbound_param_overide === null || inbound_param_overide === "") {
127
- var inbound_param_overide = 'on';
128
- }
129
- var inbound_show_params = inbound_param_overide || true;
130
- if (typeof window.history.pushState == 'function' && inbound_show_params != 'off') {
131
  var current=window.location.href;var cleanparams=current.split("?");var clean_url=cleanparams[0];history.replaceState({},"landing page",clean_url);
132
  }</script>
 
133
  <?php }
134
  }
135
  }
120
  if (isset($_GET['lp-variation-id']) && !isset($_GET['template-customize']) && !isset($_GET['iframe_window']) && !isset($_GET['live-preview-area'])) {
121
  do_action('landing_page_header_script');
122
  ?>
123
+ <?php if(!defined('Inbound_Now_Disable_URL_CLEAN')) { ?>
124
  <script type="text/javascript">
125
  //var inbound_param_overide = 'off';
126
  // Automation pass params to GA. Look for documentation
127
+ if (typeof window.history.pushState == 'function') {
 
 
 
 
128
  var current=window.location.href;var cleanparams=current.split("?");var clean_url=cleanparams[0];history.replaceState({},"landing page",clean_url);
129
  }</script>
130
+ <?php } ?>
131
  <?php }
132
  }
133
  }
modules/module.landing-page-old.php ADDED
@@ -0,0 +1,636 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* LOAD COMMON FUNCTIONS FOR LANDING PAGES TEMPLATES */
4
+ add_action('lp_init', 'inbound_include_template_functions');
5
+ if (!function_exists('inbound_include_template_functions')) {
6
+ function inbound_include_template_functions(){
7
+ include_once(LANDINGPAGES_PATH.'shared/functions.templates.php');
8
+ }
9
+ }
10
+
11
+ /* LOAD TEMPLATE */
12
+ add_filter('single_template', 'lp_custom_template');
13
+ function lp_custom_template($single) {
14
+ global $wp_query, $post, $query_string;
15
+ //echo 2;exit;
16
+ if ($post->post_type == "landing-page")
17
+ {
18
+ $template = get_post_meta($post->ID, 'lp-selected-template', true);
19
+ $template = apply_filters('lp_selected_template',$template);
20
+
21
+
22
+ if (isset($template))
23
+ {
24
+
25
+ if (strstr($template,'-slash-'))
26
+ {
27
+ $template = str_replace('-slash-','/',$template);
28
+ }
29
+
30
+ $my_theme = wp_get_theme($template);
31
+
32
+ if ($my_theme->exists())
33
+ {
34
+ return "";
35
+ }
36
+ else if ($template!='default')
37
+ {
38
+ $template = str_replace('_','-',$template);
39
+ //echo LANDINGPAGES_URLPATH.'templates/'.$template.'/index.php'; exit;
40
+ if (file_exists(LANDINGPAGES_PATH.'templates/'.$template.'/index.php'))
41
+ {
42
+ //query_posts ($query_string . '&showposts=1');
43
+ return LANDINGPAGES_PATH.'templates/'.$template.'/index.php';
44
+ }
45
+ else
46
+ {
47
+ //query_posts ($query_string . '&showposts=1');
48
+ return LANDINGPAGES_UPLOADS_PATH.$template.'/index.php';
49
+ }
50
+ }
51
+ }
52
+ }
53
+
54
+ return $single;
55
+ }
56
+
57
+
58
+ /* LOAD & PRINT CUSTOM JS AND CSS */
59
+ add_action('wp_head','landing_pages_insert_custom_head');
60
+ function landing_pages_insert_custom_head()
61
+ {
62
+ global $post;
63
+
64
+ if (isset($post)&&'landing-page'==$post->post_type)
65
+ {
66
+
67
+ $custom_css_name = apply_filters('lp_custom_css_name','lp-custom-css');
68
+ $custom_js_name = apply_filters('lp_custom_js_name','lp-custom-js');
69
+ $custom_css = get_post_meta($post->ID, $custom_css_name, true);
70
+ $custom_js = get_post_meta($post->ID, $custom_js_name, true);
71
+
72
+ //Print Custom CSS
73
+ if (!stristr($custom_css,'<style'))
74
+ {
75
+ echo '<style type="text/css" id="lp_css_custom">'.$custom_css.'</style>';
76
+ }
77
+ else
78
+ {
79
+ echo $custom_css;
80
+ }
81
+ //Print Custom JS
82
+ if (!stristr($custom_js,'<script'))
83
+ {
84
+ echo '<script type="text/javascript" id="lp_js_custom">jQuery(document).ready(function($) {
85
+ '.$custom_js.' });</script>';
86
+ }
87
+ else
88
+ {
89
+ echo $custom_js;
90
+ }
91
+ }
92
+ }
93
+
94
+ /* FOR DEFAULT TEMPLATE & NATIVE THEME TEMPLATES PREPARE THE CONVERSION AREA */
95
+ add_filter('the_content','landing_pages_add_conversion_area', 20);
96
+ add_filter('get_the_content','landing_pages_add_conversion_area', 20);
97
+ function landing_pages_add_conversion_area($content)
98
+ {
99
+
100
+ if ('landing-page'==get_post_type() && !is_admin())
101
+ {
102
+
103
+ global $post;
104
+
105
+ remove_action('the_content', 'landing_pages_add_conversion_area');
106
+
107
+ $key = get_post_meta($post->ID, 'lp-selected-template', true);
108
+ $key = apply_filters('lp_selected_template',$key);
109
+
110
+ if (strstr($key,'-slash-'))
111
+ {
112
+ $key = str_replace('-slash-','/',$key);
113
+ }
114
+
115
+ $my_theme = wp_get_theme($key);
116
+ //echo $key;
117
+ if ($my_theme->exists()||$key=='default')
118
+ {
119
+
120
+ global $post;
121
+ $wrapper_class = "";
122
+
123
+ get_post_meta($post->ID, "default-conversion-area-placement", true);
124
+
125
+
126
+ $position = get_post_meta($post->ID, "{$key}-conversion-area-placement", true);
127
+
128
+ $position = apply_filters('lp_conversion_area_position', $position, $post, $key);
129
+
130
+ $_SESSION['lp_conversion_area_position'] = $position;
131
+
132
+ $conversion_area = lp_conversion_area(null,null,true,true);
133
+
134
+ $conversion_area = "<div id='lp_container' class='$wrapper_class'>".$conversion_area."</div>";
135
+
136
+ if ($position=='top')
137
+ {
138
+ $content = $conversion_area.$content;
139
+ }
140
+ else if ($position=='bottom')
141
+ {
142
+ $content = $content.$conversion_area;
143
+ }
144
+ else if ($position=='widget')
145
+ {
146
+ $content = $content;
147
+ }
148
+ else
149
+ {
150
+ $conversion_area = str_replace("id='lp_container'","id='lp_container' class='lp_form_$position' style='float:$position'",$conversion_area);
151
+ $content = $conversion_area.$content;
152
+
153
+ }
154
+
155
+ }
156
+
157
+ }
158
+
159
+ return $content;
160
+ }
161
+
162
+ /* DISPLAY LANDING PAGE CONVERSION AREA */
163
+ function lp_conversion_area($post = null, $content=null,$return=false, $doshortcode = true, $rebuild_attributes = true)
164
+ {
165
+ if (!isset($post))
166
+ global $post;
167
+
168
+ $wrapper_class = "";
169
+
170
+ $content = get_post_meta($post->ID, 'lp-conversion-area', true);
171
+
172
+ $content = apply_filters('lp_conversion_area_pre_standardize',$content, $post, $doshortcode);
173
+
174
+ $wrapper_class = lp_discover_important_wrappers($content);
175
+
176
+ if ($doshortcode)
177
+ {
178
+ $content = do_shortcode($content);
179
+ }
180
+
181
+ if ($rebuild_attributes)
182
+ {
183
+ //$content = lp_rebuild_attributes( $content, $wrapper_class );
184
+ }
185
+
186
+
187
+ $content = apply_filters('lp_conversion_area_post',$content, $post);
188
+
189
+ if(!$return)
190
+ {
191
+
192
+ $content = str_replace('<p><div id="inbound-form-wrapper"', '<div id="inbound-form-wrapper"', $content);
193
+ $content = preg_replace('/<p[^>]*><\/p[^>]*>/', '', $content); // remove empty p tags
194
+ $content = preg_replace('/<\/p>/', '', $content); // remove last empty p tag
195
+ echo do_shortcode($content);
196
+
197
+ }
198
+ else
199
+ {
200
+ return do_shortcode($content);
201
+ }
202
+
203
+ }
204
+
205
+ /* ADD SHORTCODE TO DISPLAY LANDING PAGE CONVERSION AREA */
206
+ add_shortcode( 'lp_conversion_area', 'lp_conversion_area_shortcode');
207
+ function lp_conversion_area_shortcode( $atts, $content = null )
208
+ {
209
+ extract(shortcode_atts(array(
210
+ 'id' => '',
211
+ 'align' => ''
212
+ //'style' => ''
213
+ ), $atts));
214
+
215
+
216
+ $conversion_area = lp_conversion_area($post = null, $content=null,$return=true, $doshortcode = true, $rebuild_attributes = true);
217
+
218
+
219
+ return $conversion_area;
220
+ }
221
+
222
+ /* DISPLAY MAIN HEADLINE OF CALLING TEMPLATE */
223
+ function lp_main_headline($post = null, $headline=null,$return=false)
224
+ {
225
+ if (!isset($post))
226
+ global $post;
227
+
228
+ if (!$headline)
229
+ {
230
+ $main_headline = lp_get_value($post, 'lp', 'main-headline');
231
+ $main_headline = apply_filters('lp_main_headline',$main_headline, $post);
232
+
233
+ if(!$return)
234
+ {
235
+ echo $main_headline;
236
+
237
+ }
238
+ else
239
+ {
240
+ return $main_headline;
241
+ }
242
+ }
243
+ else
244
+ {
245
+ $main_headline = apply_filters('lp_main_headline',$main_headline, $post);
246
+ if(!$return)
247
+ {
248
+ echo $headline;
249
+ }
250
+ else
251
+ {
252
+ return $headline;
253
+ }
254
+ }
255
+ }
256
+
257
+ /* DISPLAY MAIN CONTENT AREA OF LANDING PAGE TEMPLATE */
258
+ function lp_content_area($post = null, $content=null,$return=false )
259
+ {
260
+ if (!isset($post))
261
+ global $post;
262
+
263
+ if (!$content)
264
+ {
265
+ global $post;
266
+
267
+ if (!isset($post)&&isset($_REQUEST['post']))
268
+ {
269
+
270
+ $post = get_post($_REQUEST['post']);
271
+ }
272
+
273
+ else if (!isset($post)&&isset($_REQUEST['lp_id']))
274
+ {
275
+ $post = get_post($_REQUEST['lp_id']);
276
+ }
277
+
278
+ //var_dump($post);
279
+ $content_area = $post->post_content;
280
+
281
+ if (!is_admin()) {
282
+ $content_area = apply_filters('the_content', $content_area);
283
+ }
284
+
285
+ $content_area = apply_filters('lp_content_area',$content_area, $post);
286
+
287
+ if(!$return)
288
+ {
289
+ echo $content_area;
290
+
291
+ }
292
+ else
293
+ {
294
+ return $content_area;
295
+ }
296
+ }
297
+ else
298
+ {
299
+ if(!$return)
300
+ {
301
+ echo $content_area;
302
+ }
303
+ else
304
+ {
305
+ return $content_area;
306
+ }
307
+ }
308
+ }
309
+
310
+ /* ADD BODY CLASS TO LANDING PAGE TEMPLATE */
311
+ function lp_body_class()
312
+ {
313
+ global $post;
314
+ global $lp_data;
315
+ // Need to add in lp_right or lp_left classes based on the meta to float forms
316
+ // like $conversion_layout = lp_get_value($post, $key, 'conversion-area-placement');
317
+ if (get_post_meta($post->ID, 'lp-selected-template', true))
318
+ {
319
+ $lp_body_class = "template-" . get_post_meta($post->ID, 'lp-selected-template', true);
320
+ $postid = "page-id-" . get_the_ID();
321
+ echo 'class="';
322
+ echo $lp_body_class . " " . $postid . " wordpress-landing-page";
323
+ echo '"';
324
+ }
325
+ return $lp_body_class;
326
+ }
327
+
328
+ /* GET PARENT DIRECTORY OF CALLING TEMPLATE */
329
+ function lp_get_parent_directory($path)
330
+ {
331
+ if(stristr($_SERVER['SERVER_SOFTWARE'], 'Win32')){
332
+ $array = explode('\\',$path);
333
+ $count = count($array);
334
+ $key = $count -1;
335
+ $parent = $array[$key];
336
+ return $parent;
337
+ } else if(stristr($_SERVER['SERVER_SOFTWARE'], 'IIS')){
338
+ $array = explode('\\',$path);
339
+ $count = count($array);
340
+ $key = $count -1;
341
+ $parent = $array[$key];
342
+ return $parent;
343
+ }else {
344
+ $array = explode('/',$path);
345
+ $count = count($array);
346
+ $key = $count -1;
347
+ $parent = $array[$key];
348
+ return $parent;
349
+ }
350
+ }
351
+
352
+ /* GET META VALUE FOR LANDING PAGE TEMPLATE SETTING */
353
+ function lp_get_value($post, $key, $id)
354
+ {
355
+
356
+ if (isset($post))
357
+ {
358
+
359
+ $return = do_shortcode(get_post_meta($post->ID, $key.'-'.$id , true));
360
+ $return = apply_filters('lp_get_value',$return,$post,$key,$id);
361
+
362
+ return $return;
363
+ }
364
+ }
365
+
366
+ /* CALLBACK TO GENERATE DROPDOWN OF LANDING PAGES - MAY BE UNUSED */
367
+ function lp_generate_drowndown($select_id, $post_type, $selected = 0, $width = 400, $height = 230,$font_size = 13,$multiple=true)
368
+ {
369
+ $post_type_object = get_post_type_object($post_type);
370
+ $label = $post_type_object->label;
371
+
372
+ if ($multiple==true)
373
+ {
374
+ $multiple = "multiple='multiple'";
375
+ }
376
+ else
377
+ {
378
+ $multiple = "";
379
+ }
380
+
381
+ $posts = get_posts(array('post_type'=> $post_type, 'post_status'=> 'publish', 'suppress_filters' => false, 'posts_per_page'=>-1));
382
+ echo '<select name="'. $select_id .'" id="'.$select_id.'" class="lp-multiple-select" style="width:'.$width.'px;height:'.$height.'px;font-size:'.$font_size.'px;" '.$multiple.'>';
383
+ foreach ($posts as $post) {
384
+ echo '<option value="', $post->ID, '"', $selected == $post->ID ? ' selected="selected"' : '', '>', $post->post_title, '</option>';
385
+ }
386
+ echo '</select>';
387
+ }
388
+
389
+ /* REMOVE CUSTOM FIELDS METABOX FROM LANDING PAGE CPT */
390
+ add_action( 'in_admin_header', 'lp_in_admin_header');
391
+ function lp_in_admin_header()
392
+ {
393
+ global $post;
394
+ global $wp_meta_boxes;
395
+
396
+ if (isset($post)&&$post->post_type=='landing-page')
397
+ {
398
+ unset( $wp_meta_boxes[get_current_screen()->id]['normal']['core']['postcustom'] );
399
+ }
400
+ }
401
+
402
+ /* DETECTION FOR GRAVITY FORM CLASS AND OTHER IMPORTANT CLASSES */
403
+ function lp_discover_important_wrappers($content)
404
+ {
405
+ $wrapper_class = "";
406
+ if (strstr($content,'gform_wrapper'))
407
+ {
408
+ $wrapper_class = 'gform_wrapper';
409
+ }
410
+ return $wrapper_class;
411
+ }
412
+
413
+ /* ADDS IN TRACKING SUPPORT FOR LINKS FOUND IN CONVERSION AREA WHEN THERE ARE NO FORMS DETECTED */
414
+ function lp_rebuild_attributes( $content=null , $wrapper_class=null )
415
+ {
416
+ if (strstr($content,'<form'))
417
+ return $content;
418
+
419
+ // Standardize all links
420
+ $inputs = preg_match_all('/\<a(.*?)\>/s',$content, $matches);
421
+ if (!empty($matches[0]))
422
+ {
423
+ foreach ($matches[0] as $key => $value)
424
+ {
425
+ if ($key==0)
426
+ {
427
+ $new_value = $value;
428
+ $new_value = preg_replace('/ class=(["\'])(.*?)(["\'])/','class="$2 wpl-track-me-link"', $new_value);
429
+
430
+
431
+
432
+ $content = str_replace($value, $new_value, $content);
433
+ break;
434
+ }
435
+ }
436
+ }
437
+
438
+ $check_wrap = preg_match_all('/lp_container_noform/s',$content, $check);
439
+ if (empty($check[0]))
440
+ {
441
+ $content = "<div id='lp_container_noform' class='$wrapper_class link-click-tracking'>{$content}</div>";
442
+ }
443
+
444
+ return $content;
445
+ }
446
+
447
+ /* LEGACY CODE FOR ADDING LANDING PAGE TEMPLATE METABOX SETTINGS TO TEMPLATE METABOX */
448
+ function lp_add_option($key,$type,$id,$default=null,$label=null,$description=null, $options=null)
449
+ {
450
+ switch ($type)
451
+ {
452
+ case "colorpicker":
453
+ return array(
454
+ 'label' => $label,
455
+ 'description' => $description,
456
+ 'id' => $id,
457
+ 'type' => 'colorpicker',
458
+ 'default' => $default
459
+ );
460
+ break;
461
+ case "text":
462
+ return array(
463
+ 'label' => $label,
464
+ 'description' => $description,
465
+ 'id' => $id,
466
+ 'type' => 'text',
467
+ 'default' => $default
468
+ );
469
+ break;
470
+ case "license-key":
471
+ return array(
472
+ 'label' => $label,
473
+ 'description' => $description,
474
+ 'id' => $id,
475
+ 'type' => 'license-key',
476
+ 'default' => $default,
477
+ 'slug' => $id
478
+ );
479
+ break;
480
+ case "textarea":
481
+ return array(
482
+ 'label' => $label,
483
+ 'description' => $description,
484
+ 'id' => $id,
485
+ 'type' => 'textarea',
486
+ 'default' => $default
487
+ );
488
+ break;
489
+ case "wysiwyg":
490
+ return array(
491
+ 'label' => $label,
492
+ 'description' => $description,
493
+ 'id' => $id,
494
+ 'type' => 'wysiwyg',
495
+ 'default' => $default
496
+ );
497
+ break;
498
+ case "media":
499
+ return array(
500
+ 'label' => $label,
501
+ 'description' => $description,
502
+ 'id' => $id,
503
+ 'type' => 'media',
504
+ 'default' => $default
505
+ );
506
+ break;
507
+ case "checkbox":
508
+ return array(
509
+ 'label' => $label,
510
+ 'description' => $description,
511
+ 'id' => $id,
512
+ 'type' => 'checkbox',
513
+ 'default' => $default,
514
+ 'options' => $options
515
+ );
516
+ break;
517
+ case "radio":
518
+ return array(
519
+ 'label' => $label,
520
+ 'description' => $description,
521
+ 'id' =>$id,
522
+ 'type' => 'radio',
523
+ 'default' => $default,
524
+ 'options' => $options
525
+ );
526
+ break;
527
+ case "dropdown":
528
+ return array(
529
+ 'label' => $label,
530
+ 'description' => $description,
531
+ 'id' => $id,
532
+ 'type' => 'dropdown',
533
+ 'default' => $default,
534
+ 'options' => $options
535
+ );
536
+ break;
537
+ case "datepicker":
538
+ return array(
539
+ 'label' => $label,
540
+ 'description' => $description,
541
+ 'id' => $id,
542
+ 'type' => 'datepicker',
543
+ 'default' => $default
544
+ );
545
+ break;
546
+ case "default-content":
547
+ return array(
548
+ 'label' => $label,
549
+ 'description' => $description,
550
+ 'id' => $id,
551
+ 'type' => 'default-content',
552
+ 'default' => $default
553
+ );
554
+ break;
555
+ case "html":
556
+ return array(
557
+ 'label' => $label,
558
+ 'description' => $description,
559
+ 'id' => $id,
560
+ 'type' => 'html',
561
+ 'default' => $default
562
+ );
563
+ break;
564
+ case "custom-css":
565
+ return array(
566
+ 'label' => $label,
567
+ 'description' => $description,
568
+ 'id' => $id,
569
+ 'type' => 'turn-off-editor',
570
+ 'default' => $default // inline css
571
+ );
572
+ break;
573
+ case "description-block":
574
+ return array(
575
+ 'label' => $label,
576
+ 'description' => $description,
577
+ 'id' => $key.'-'.$id,
578
+ 'type' => 'description-block',
579
+ 'default' => $default
580
+ );
581
+ break;
582
+ }
583
+ }
584
+
585
+
586
+ function get_all_template_categories($extension_data) {
587
+
588
+ //$extension_data = lp_get_extension_data();
589
+ //$extension_data_cats = lp_get_extension_data_cats($extension_data);
590
+ //print_r($extension_data_cats);
591
+
592
+ $cat_array = array();
593
+ foreach ($extension_data as $name => $options) {
594
+ //echo $options['info'];
595
+ foreach ($options as $value) {
596
+ if ($value['category'] != "" && strlen ($value['category']) > 1 ){
597
+ $new_cat = explode(",", $value['category']);
598
+ foreach ($new_cat as $test => $zzz) {
599
+ $cat_array[] = trim($zzz);
600
+ }
601
+
602
+ }
603
+
604
+ }
605
+ }
606
+ echo "<pre>";
607
+ print_r(array_unique($cat_array));
608
+ echo "<pre>";
609
+ }
610
+
611
+ /* LEGACY CALLBACKS -- STILL USED BY SOME OLDER EXTENSIONS AND TEMPLATES */
612
+ function lp_list_feature()
613
+ {
614
+ return null;
615
+ }
616
+
617
+
618
+ function lp_global_config()
619
+ {
620
+ do_action('lp_global_config');
621
+ }
622
+
623
+ function lp_init()
624
+ {
625
+ do_action('lp_init');
626
+ }
627
+
628
+ function lp_head()
629
+ {
630
+ do_action('lp_head');
631
+ }
632
+
633
+ function lp_footer()
634
+ {
635
+ do_action('lp_footer');
636
+ }
modules/module.landing-page.php CHANGED
@@ -61,8 +61,8 @@ function landing_pages_insert_custom_head()
61
  {
62
  global $post;
63
 
64
- if (isset($post)&&'landing-page'==$post->post_type)
65
- {
66
 
67
  $custom_css_name = apply_filters('lp_custom_css_name','lp-custom-css');
68
  $custom_js_name = apply_filters('lp_custom_js_name','lp-custom-js');
@@ -178,11 +178,6 @@ function lp_conversion_area($post = null, $content=null,$return=false, $doshortc
178
  $content = do_shortcode($content);
179
  }
180
 
181
- if ($rebuild_attributes)
182
- {
183
- $content = lp_rebuild_attributes( $content, $wrapper_class );
184
- }
185
-
186
 
187
  $content = apply_filters('lp_conversion_area_post',$content, $post);
188
 
@@ -352,9 +347,10 @@ function lp_get_parent_directory($path)
352
  /* GET META VALUE FOR LANDING PAGE TEMPLATE SETTING */
353
  function lp_get_value($post, $key, $id)
354
  {
355
- //echo 1; exit;
356
  if (isset($post))
357
  {
 
358
  $return = do_shortcode(get_post_meta($post->ID, $key.'-'.$id , true));
359
  $return = apply_filters('lp_get_value',$return,$post,$key,$id);
360
 
@@ -632,4 +628,4 @@ function lp_head()
632
  function lp_footer()
633
  {
634
  do_action('lp_footer');
635
- }
61
  {
62
  global $post;
63
 
64
+ if (isset($post)&&'landing-page'==$post->post_type)
65
+ {
66
 
67
  $custom_css_name = apply_filters('lp_custom_css_name','lp-custom-css');
68
  $custom_js_name = apply_filters('lp_custom_js_name','lp-custom-js');
178
  $content = do_shortcode($content);
179
  }
180
 
 
 
 
 
 
181
 
182
  $content = apply_filters('lp_conversion_area_post',$content, $post);
183
 
347
  /* GET META VALUE FOR LANDING PAGE TEMPLATE SETTING */
348
  function lp_get_value($post, $key, $id)
349
  {
350
+
351
  if (isset($post))
352
  {
353
+
354
  $return = do_shortcode(get_post_meta($post->ID, $key.'-'.$id , true));
355
  $return = apply_filters('lp_get_value',$return,$post,$key,$id);
356
 
628
  function lp_footer()
629
  {
630
  do_action('lp_footer');
631
+ }
modules/module.metaboxes.php CHANGED
@@ -41,7 +41,7 @@ function lp_thumbnail_metabox() {
41
  <td>
42
  <?php
43
 
44
- echo "<a href='$permalink' target='_blank' ><img src='$thumbnail' style='width:250px;height:250px;' title='". __( 'Preveiw this theme' , 'landing-pages') ." , ({$template})'></a>";
45
  ?>
46
  </td>
47
  </tr>
41
  <td>
42
  <?php
43
 
44
+ echo "<a href='$permalink' target='_blank' ><img src='$thumbnail' style='width:250px;height:250px;' title='". __( 'Preview this theme' , 'landing-pages') ." , ({$template})'></a>";
45
  ?>
46
  </td>
47
  </tr>
modules/module.redirect-ab-testing.php CHANGED
@@ -15,20 +15,18 @@ else if ( file_exists ( './../../../../../wp-config.php' ) )
15
  include_once ( './../../../../../wp-config.php' );
16
  }
17
 
18
- $VariationRoation = new LP_Variation_Rotation;
19
-
20
  class LP_Variation_Rotation {
21
 
22
- private $permalink_name;
23
- private $post_id;
24
- private $last_loaded_variation;
25
- private $variations;
26
- private $marker;
27
- private $next_marker;
28
- private $destination_url;
29
 
30
  /* Exectutes Class */
31
- function __construct() {
32
 
33
  self::load_variables();
34
  //self::run_debug();
@@ -36,25 +34,25 @@ class LP_Variation_Rotation {
36
 
37
  }
38
 
39
- /* Loads Variables */
40
- function load_variables()
41
  {
42
- $this->permalink_name = (isset($_GET['permalink_name'])) ? $_GET['permalink_name'] : null;
43
- $this->post_id = $this->load_post_id();
44
- $this->last_loaded_variation = ( isset( $_COOKIE['lp-loaded-variation-'.$this->permalink_name] ) ) ? $_COOKIE['lp-loaded-variation-'.$this->permalink_name] : null;
45
- $this->variations = $this->load_variations();
46
- $this->marker = $this->load_marker();
47
- $this->next_marker = $this->discover_next_variation();
48
- $this->destination_url = $this->build_destination_url();
49
  }
50
 
51
  /* Debug Information - Prints Class Variable Data */
52
- private function run_debug() {
53
  print_r($this);exit;
54
  }
55
 
56
  /* Loads the ID of the Landing Page */
57
- private function load_post_id() {
58
  global $table_prefix;
59
 
60
  $query = "SELECT * FROM {$table_prefix}posts WHERE post_name='".mysql_real_escape_string($_GET['permalink_name'])."' AND post_type='landing-page' LIMIT 1";
@@ -68,11 +66,11 @@ class LP_Variation_Rotation {
68
  }
69
 
70
  /* Loads an Array of Active Variations Associated with Landing Page */
71
- private function load_variations() {
72
 
73
  $live_variations = array();
74
 
75
- $variations_string = get_post_meta( $this->post_id , 'lp-ab-variations' , true );
76
  $variations = explode(',',$variations_string);
77
  $variations = array_filter($variations,'is_numeric');
78
 
@@ -80,9 +78,9 @@ class LP_Variation_Rotation {
80
  foreach ($variations as $key=>$vid) {
81
 
82
  if ($vid==0) {
83
- $variation_status = get_post_meta( $pid , 'lp_ab_variation_status' , true );
84
  } else {
85
- $variation_status = get_post_meta( $pid , 'lp_ab_variation_status-'.$vid , true );
86
  }
87
 
88
  if (!is_numeric($variation_status) || $variation_status==1) {
@@ -95,46 +93,47 @@ class LP_Variation_Rotation {
95
  }
96
 
97
  /* Loads Variation ID of Last Variation Loaded */
98
- private function load_marker() {
99
 
100
- $marker = get_post_meta( $this->post_id , 'lp-ab-variations-marker' , true );
101
 
102
- if ( !is_numeric($marker) || !in_array( $marker , $this->variations ) ) {
103
 
104
- $marker = current($this->variations);
105
  }
106
 
107
  return $marker;
108
  }
109
 
110
  /* Discovers Next Variation in Line */
111
- private function discover_next_variation() {
112
 
113
  /* Set Pointer to Correct Location in Variations Array */
114
- while ( $this->marker != current( $this->variations) ) {
115
- next($this->variations);
116
  }
117
 
118
  /* Discover the next variation in the array */
119
- next($this->variations);
120
 
121
  /* If the pointer is empty then reset array */
122
- if ( !is_numeric(current( $this->variations ) ) ) {
123
- reset( $this->variations );
124
  }
125
 
126
  /* Save as Historical Data */
127
- update_post_meta( $this->post_id , 'lp-ab-variations-marker' , current( $this->variations ) );
128
 
129
- return current( $this->variations );
130
 
131
  }
132
 
133
  /* Builds Redirect URL & Stores Cookie Data */
134
- private function build_destination_url() {
135
 
136
  /* Load Base URL */
137
- $url = get_permalink($this->post_id);
 
138
 
139
  /* Keep GET Params */
140
  foreach ($_GET as $key=>$value) {
@@ -144,18 +143,20 @@ class LP_Variation_Rotation {
144
  }
145
 
146
  /* Build Final URL and Set Memory Cookies */
147
- $url = $url."?lp-variation-id=".$this->next_marker.$old_params;
148
 
149
  /* Set Memory Cookies */
150
- setcookie('lp-loaded-variation-'.$this->permalink_name , $url , time()+ 60 * 60 * 24 * 30 , "/" );
151
- setcookie( 'lp-variation-id' , $this->variation_id , time()+3600 , "/" );
152
 
153
  return $url;
154
  }
155
 
156
  /* Redirects to Correct Variation */
157
- private function redirect() {
158
  @header("HTTP/1.1 307 Temporary Redirect");
159
- @header("Location: ".$this->destination_url);
160
  }
161
- }
 
 
15
  include_once ( './../../../../../wp-config.php' );
16
  }
17
 
 
 
18
  class LP_Variation_Rotation {
19
 
20
+ static $permalink_name;
21
+ static $post_id;
22
+ static $last_loaded_variation;
23
+ static $variations;
24
+ static $marker;
25
+ static $next_marker;
26
+ static $destination_url;
27
 
28
  /* Exectutes Class */
29
+ public function __construct() {
30
 
31
  self::load_variables();
32
  //self::run_debug();
34
 
35
  }
36
 
37
+ /* Loads Static Variables */
38
+ private static function load_variables()
39
  {
40
+ self::$permalink_name = (isset($_GET['permalink_name'])) ? $_GET['permalink_name'] : null;
41
+ self::$post_id = self::load_post_id();
42
+ self::$last_loaded_variation = ( isset( $_COOKIE['lp-loaded-variation-'.self::$permalink_name] ) ) ? $_COOKIE['lp-loaded-variation-'.self::$permalink_name] : null;
43
+ self::$variations = self::load_variations();
44
+ self::$marker = self::load_marker();
45
+ self::$next_marker = self::discover_next_variation();
46
+ self::$destination_url = self::build_destination_url();
47
  }
48
 
49
  /* Debug Information - Prints Class Variable Data */
50
+ static function run_debug() {
51
  print_r($this);exit;
52
  }
53
 
54
  /* Loads the ID of the Landing Page */
55
+ static function load_post_id() {
56
  global $table_prefix;
57
 
58
  $query = "SELECT * FROM {$table_prefix}posts WHERE post_name='".mysql_real_escape_string($_GET['permalink_name'])."' AND post_type='landing-page' LIMIT 1";
66
  }
67
 
68
  /* Loads an Array of Active Variations Associated with Landing Page */
69
+ static function load_variations() {
70
 
71
  $live_variations = array();
72
 
73
+ $variations_string = get_post_meta( self::$post_id , 'lp-ab-variations' , true );
74
  $variations = explode(',',$variations_string);
75
  $variations = array_filter($variations,'is_numeric');
76
 
78
  foreach ($variations as $key=>$vid) {
79
 
80
  if ($vid==0) {
81
+ $variation_status = get_post_meta( self::$post_id , 'lp_ab_variation_status' , true );
82
  } else {
83
+ $variation_status = get_post_meta( self::$post_id , 'lp_ab_variation_status-'.$vid , true );
84
  }
85
 
86
  if (!is_numeric($variation_status) || $variation_status==1) {
93
  }
94
 
95
  /* Loads Variation ID of Last Variation Loaded */
96
+ static function load_marker() {
97
 
98
+ $marker = get_post_meta( self::$post_id , 'lp-ab-variations-marker' , true );
99
 
100
+ if ( !is_numeric($marker) || !in_array( $marker , self::$variations ) ) {
101
 
102
+ $marker = current(self::$variations);
103
  }
104
 
105
  return $marker;
106
  }
107
 
108
  /* Discovers Next Variation in Line */
109
+ static function discover_next_variation() {
110
 
111
  /* Set Pointer to Correct Location in Variations Array */
112
+ while ( self::$marker != current( self::$variations) ) {
113
+ next(self::$variations);
114
  }
115
 
116
  /* Discover the next variation in the array */
117
+ next(self::$variations);
118
 
119
  /* If the pointer is empty then reset array */
120
+ if ( !is_numeric(current( self::$variations ) ) ) {
121
+ reset( self::$variations );
122
  }
123
 
124
  /* Save as Historical Data */
125
+ update_post_meta( self::$post_id , 'lp-ab-variations-marker' , current( self::$variations ) );
126
 
127
+ return current( self::$variations );
128
 
129
  }
130
 
131
  /* Builds Redirect URL & Stores Cookie Data */
132
+ static function build_destination_url() {
133
 
134
  /* Load Base URL */
135
+ $url = get_permalink(self::$post_id);
136
+ $old_params = null;
137
 
138
  /* Keep GET Params */
139
  foreach ($_GET as $key=>$value) {
143
  }
144
 
145
  /* Build Final URL and Set Memory Cookies */
146
+ $url = $url."?lp-variation-id=".self::$next_marker.$old_params;
147
 
148
  /* Set Memory Cookies */
149
+ setcookie('lp-loaded-variation-'.self::$permalink_name , $url , time()+ 60 * 60 * 24 * 30 , "/" );
150
+ setcookie( 'lp-variation-id' , self::$next_marker , time()+3600 , "/" );
151
 
152
  return $url;
153
  }
154
 
155
  /* Redirects to Correct Variation */
156
+ static function redirect() {
157
  @header("HTTP/1.1 307 Temporary Redirect");
158
+ @header("Location: ".self::$destination_url);
159
  }
160
+ }
161
+
162
+ $VariationRoation = new LP_Variation_Rotation;
modules/module.utils.php CHANGED
@@ -161,7 +161,11 @@ function lp_fix_seo_title()
161
  add_filter( 'wp_nav_menu_args', 'lp_wp_nav_menu_args' );
162
  function lp_wp_nav_menu_args( $args = '' ) {
163
  global $post;
164
-
 
 
 
 
165
  $variations = get_post_meta($post->ID, 'lp-ab-variations', true);
166
  $var = (isset($_GET['lp-variation-id'])) ? $_GET['lp-variation-id'] : '';
167
  if ($var === "0"){
161
  add_filter( 'wp_nav_menu_args', 'lp_wp_nav_menu_args' );
162
  function lp_wp_nav_menu_args( $args = '' ) {
163
  global $post;
164
+
165
+ if (!isset($post)) {
166
+ return $args;
167
+ }
168
+
169
  $variations = get_post_meta($post->ID, 'lp-ab-variations', true);
170
  $var = (isset($_GET['lp-variation-id'])) ? $_GET['lp-variation-id'] : '';
171
  if ($var === "0"){
readme.txt CHANGED
@@ -7,7 +7,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  Tags: landing pages, inbound marketing, conversion pages, split testing, a b test, a b testing, a/b test, a/b testing, coming soon page, email list, landing page, list building, maintenance page, squeeze page, inbound now, landing-pages, splash pages, cpa, click tracking, goal tracking, analytics, free landing page templates
8
  Requires at least: 3.8
9
  Tested up to: 3.8
10
- Stable Tag: 1.5.0
11
 
12
  Create landing pages for your WordPress site. Monitor and improve conversion rates, run A/B split tests, customize your own templates and more.
13
 
@@ -45,9 +45,9 @@ http://www.youtube.com/watch?v=flEd0sRTFUo
45
 
46
  We built the landing page plugin as a framework! Need A/B testing out of the box implemented for your existing designs? Use WordPress Landing Pages to quickly spin up new landing pages that have all the functionality your clients will need.
47
 
48
- You can quickly take your existing designs and implement them using our <a href="http://docs.inboundnow.com/landing-pages/dev">templating framework</a>.
49
 
50
- The plugin is also fully extendable and has a number of <a href='http://docs.inboundnow.com/landing-pages/dev/core-hooks-filters'>actions, filters</a>, and hooks available for use. If a hook doesn't exist, simply ask and we can implement custom changes.
51
 
52
  <b>You can also follow us on <a href="https://github.com/inboundnow/landing-pages/">GitHub</a></b>
53
 
@@ -68,6 +68,9 @@ The plugin is also fully extendable and has a number of <a href='http://docs.inb
68
  4. Choose from a ton of pre-made templates, use your existing design, or design your own theme!
69
 
70
  == Changelog ==
 
 
 
71
  = 1.5.0 =
72
  * fixed field mapping bug
73
  * Added better compability for js conflicts
7
  Tags: landing pages, inbound marketing, conversion pages, split testing, a b test, a b testing, a/b test, a/b testing, coming soon page, email list, landing page, list building, maintenance page, squeeze page, inbound now, landing-pages, splash pages, cpa, click tracking, goal tracking, analytics, free landing page templates
8
  Requires at least: 3.8
9
  Tested up to: 3.8
10
+ Stable Tag: 1.5.1
11
 
12
  Create landing pages for your WordPress site. Monitor and improve conversion rates, run A/B split tests, customize your own templates and more.
13
 
45
 
46
  We built the landing page plugin as a framework! Need A/B testing out of the box implemented for your existing designs? Use WordPress Landing Pages to quickly spin up new landing pages that have all the functionality your clients will need.
47
 
48
+ You can quickly take your existing designs and implement them using our <a href="http://docs.inboundnow.com/section/developer/">templating framework</a>.
49
 
50
+ The plugin is also fully extendable and has a number of <a href='http://docs.inboundnow.com/guide/landing-page-core-hooks-filters/'>actions, filters</a>, and hooks available for use. If a hook doesn't exist, simply ask and we can implement custom changes.
51
 
52
  <b>You can also follow us on <a href="https://github.com/inboundnow/landing-pages/">GitHub</a></b>
53
 
68
  4. Choose from a ton of pre-made templates, use your existing design, or design your own theme!
69
 
70
  == Changelog ==
71
+ = 1.5.1 =
72
+ * Misc bug fixes
73
+
74
  = 1.5.0 =
75
  * fixed field mapping bug
76
  * Added better compability for js conflicts
shared/classes/form.class.php CHANGED
@@ -739,7 +739,7 @@ class InboundForms {
739
 
740
  }
741
  // Send Confirmation Email to Form Converter
742
- if ($notification_status === 'on' && $form_email) {
743
 
744
  $my_postid = $form_meta_data['post_id']; //This is page id or post id
745
  $content_post = get_post($my_postid);
739
 
740
  }
741
  // Send Confirmation Email to Form Converter
742
+ if ($notification_status == 'on' && isset($form_email)) {
743
 
744
  $my_postid = $form_meta_data['post_id']; //This is page id or post id
745
  $content_post = get_post($my_postid);
shared/languages/landing-pages.po CHANGED
@@ -670,7 +670,7 @@ msgid "Template Preview"
670
  msgstr ""
671
 
672
  #: modules/module.metaboxes.php:44
673
- msgid "Preveiw this theme"
674
  msgstr ""
675
 
676
  #: modules/module.metaboxes.php:59
670
  msgstr ""
671
 
672
  #: modules/module.metaboxes.php:44
673
+ msgid "Preview this theme"
674
  msgstr ""
675
 
676
  #: modules/module.metaboxes.php:59
shared/languages/landing-pages/landing-pages.po CHANGED
@@ -670,7 +670,7 @@ msgid "Template Preview"
670
  msgstr ""
671
 
672
  #: modules/module.metaboxes.php:44
673
- msgid "Preveiw this theme"
674
  msgstr ""
675
 
676
  #: modules/module.metaboxes.php:59
670
  msgstr ""
671
 
672
  #: modules/module.metaboxes.php:44
673
+ msgid "Preview this theme"
674
  msgstr ""
675
 
676
  #: modules/module.metaboxes.php:59
templates/countdown-lander/image.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
  // file: image.php
3
  // Dynamically Create a clear png for css background opacities
4
  header("Content-type: image/png");
@@ -8,7 +8,7 @@ $hex_value = $_GET['hex'];
8
  function HexToRGB($hex) {
9
  $hex = preg_replace("/#/", "", $hex);
10
  $color = array();
11
-
12
  if(strlen($hex) == 3) {
13
  $color['r'] = hexdec(substr($hex, 0, 1) . $r);
14
  $color['g'] = hexdec(substr($hex, 1, 1) . $g);
@@ -19,28 +19,28 @@ function HexToRGB($hex) {
19
  $color['g'] = hexdec(substr($hex, 2, 2));
20
  $color['b'] = hexdec(substr($hex, 4, 2));
21
  }
22
-
23
  return $color;
24
-
25
  }
26
 
27
  $RBG_array = HexToRGB($hex_value);
28
- $red = $RBG_array [r];
29
- $green = $RBG_array [g];
30
- $blue = $RBG_array [b];
31
-
32
- // Set the image
33
  $img = imagecreatetruecolor(10,10); // 10 x 10 px
34
- imagesavealpha($img, true);
35
 
36
- // Fill the image with transparent color
37
  $color = imagecolorallocatealpha($img,$red,$green,$blue,50); // 50 is the opacity
38
- imagefill($img, 0, 0, $color);
39
 
40
  // Return the image
41
- imagepng($img);
42
 
43
- // Destroy image
44
  imagedestroy($img);
45
 
46
  // usage in html: <image src="path-to-file/image.php?hex=HEXCOLOR">
1
+ <?php
2
  // file: image.php
3
  // Dynamically Create a clear png for css background opacities
4
  header("Content-type: image/png");
8
  function HexToRGB($hex) {
9
  $hex = preg_replace("/#/", "", $hex);
10
  $color = array();
11
+
12
  if(strlen($hex) == 3) {
13
  $color['r'] = hexdec(substr($hex, 0, 1) . $r);
14
  $color['g'] = hexdec(substr($hex, 1, 1) . $g);
19
  $color['g'] = hexdec(substr($hex, 2, 2));
20
  $color['b'] = hexdec(substr($hex, 4, 2));
21
  }
22
+
23
  return $color;
24
+
25
  }
26
 
27
  $RBG_array = HexToRGB($hex_value);
28
+ $red = (isset($RBG_array['r'])) ? $RBG_array['r'] : '0';
29
+ $green = (isset($RBG_array['g'])) ? $RBG_array['g'] : '0';
30
+ $blue = (isset($RBG_array['b'])) ? $RBG_array['b'] : '0';
31
+
32
+ // Set the image
33
  $img = imagecreatetruecolor(10,10); // 10 x 10 px
34
+ imagesavealpha($img, true);
35
 
36
+ // Fill the image with transparent color
37
  $color = imagecolorallocatealpha($img,$red,$green,$blue,50); // 50 is the opacity
38
+ imagefill($img, 0, 0, $color);
39
 
40
  // Return the image
41
+ imagepng($img);
42
 
43
+ // Destroy image
44
  imagedestroy($img);
45
 
46
  // usage in html: <image src="path-to-file/image.php?hex=HEXCOLOR">
tests/bootstrap.php CHANGED
@@ -9,7 +9,7 @@
9
 
10
  // Activates this plugin in WordPress so it can be tested.
11
  $GLOBALS['wp_tests_options'] = array(
12
- 'active_plugins' => array( 'plugin-slug/main-plugin-file.php' ),
13
  );
14
 
15
  // If the develop repo location is defined (as WP_DEVELOP_DIR), use that
9
 
10
  // Activates this plugin in WordPress so it can be tested.
11
  $GLOBALS['wp_tests_options'] = array(
12
+ 'active_plugins' => array( 'landing-pages/landing-pages.php' ),
13
  );
14
 
15
  // If the develop repo location is defined (as WP_DEVELOP_DIR), use that
tests/test_check_impressions.php ADDED
File without changes