ClickFunnels - Version 1.1.1

Version Description

Download this release

Release Info

Developer clickfunnels.com
Plugin Icon 128x128 ClickFunnels
Version 1.1.1
Comparing to
See all releases

Code changes from version 1.1.0 to 1.1.1

Files changed (6) hide show
  1. CF_API.php +34 -25
  2. admin.php +1 -1
  3. clickfunnels.php +58 -11
  4. css/admin.css +2 -1
  5. footer.php +1 -1
  6. readme.txt +7 -1
CF_API.php CHANGED
@@ -17,21 +17,33 @@ class CF_API {
17
  }
18
  return $funnels;
19
  }
20
- public function get_page_html( $funnel_id, $position = 0, $meta = "", $title = "", $desc = "", $social = "", $cf_iframe_url = "" ) {
21
  global $wp_query;
22
  if ($wp_query->is_404) {
23
  $wp_query->is_404 = false;
24
  }
25
  header("HTTP/1.1 200 OK");
26
 
27
-
 
 
 
 
28
 
29
  $newHTML = '<!DOCTYPE html>
30
  <html>
31
  <head>
 
32
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
33
  <meta content="utf-8" http-equiv="encoding">
34
- <!-- Powered by ClickFunnels.com -->
 
 
 
 
 
 
 
35
  <script>
36
  function getParameterByName(name) {
37
  name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
@@ -39,28 +51,25 @@ $newHTML = '<!DOCTYPE html>
39
  results = regex.exec(location.search);
40
  return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
41
  }
42
- $preview = getParameterByName("preview");
43
- console.log($preview);
44
- if( $preview == "" ){
45
- // do nothing
46
- } else if( $preview == "control" ){
47
- document.cookie = "lander-ab-tests-240861=lander_control";
48
- } else{
49
- document.cookie = "lander-ab-tests-240861=lander_" + $preview;
 
 
 
 
50
  }
51
  </script>
52
  <link href="https://assets3.clickfunnels.com/assets/lander.css" media="screen" rel="stylesheet"/>
53
- <script type="text/javascript" src="https://static.clickfunnels.com/clickfunnels/landers/tmp/'.$position.'.js"></script>
54
- '.urldecode( $meta ).'
55
- <meta content="'.$title.'" property="og:title">
56
- <meta content="'.$desc.'" property="og:description">
57
- <meta content="'.$social.'" property="og:image">
58
- <meta property="og:url" content="'.$cf_iframe_url.'">
59
- <meta property="og:type" content="website">
60
- <style>#IntercomDefaultWidget{display:none;}#Intercom{display:none;}</style>
61
- <meta name="nodo-proxy" content="html">
62
  </head>
63
  <body>
 
64
  </body>
65
  </html>';
66
 
@@ -68,16 +77,17 @@ $newHTML = '<!DOCTYPE html>
68
  return $newHTML;
69
  }
70
 
71
- public function get_page_iframe( $cf_iframe_url, $meta = "", $title = "", $desc = "", $social = "" ) {
72
  global $wp_query;
73
  if ($wp_query->is_404) {
74
  $wp_query->is_404 = false;
75
  }
76
  header("HTTP/1.1 200 OK");
77
 
 
 
 
78
 
79
-
80
- $baseURL = '<base target="_blank" />';
81
  $iframeVersion = '<!DOCTYPE html>
82
  <html>
83
  <head>
@@ -88,7 +98,7 @@ $iframeVersion = '<!DOCTYPE html>
88
  <meta content="'.$title.'" property="og:title">
89
  <meta content="'.$desc.'" property="og:description">
90
  <meta content="'.$social.'" property="og:image">
91
- <meta property="og:url" content="'.$cf_iframe_url.'">
92
  <meta property="og:type" content="website">
93
  <style>
94
  * {
@@ -119,7 +129,6 @@ $iframeVersion = '<!DOCTYPE html>
119
  $( window ).resize(function() {
120
  $(".video").height($(window).height());
121
  });
122
- $(".video").contents().find("head").append("hey");
123
  });
124
  </script>
125
  </head>
17
  }
18
  return $funnels;
19
  }
20
+ public function get_page_html( $funnel_id, $position = 0, $meta = "", $title = "", $desc = "", $social = "", $cf_iframe_url = "", $slug = "", $pageid = "" ) {
21
  global $wp_query;
22
  if ($wp_query->is_404) {
23
  $wp_query->is_404 = false;
24
  }
25
  header("HTTP/1.1 200 OK");
26
 
27
+ // if (strpos($position,'{|}') !== false) {
28
+ // $splittestkeys = explode( '{|}', $position );
29
+ // $number_of_tests = count($splittestkeys);
30
+ // $position = $splittestkeys[array_rand($splittestkeys)];
31
+ // }
32
 
33
  $newHTML = '<!DOCTYPE html>
34
  <html>
35
  <head>
36
+ <!-- Powered by ClickFunnels.com via WordPress -->
37
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
38
  <meta content="utf-8" http-equiv="encoding">
39
+ '.urldecode( $meta ).'
40
+ <meta content="'.$title.'" property="og:title">
41
+ <meta content="'.$desc.'" property="og:description">
42
+ <meta content="'.$social.'" property="og:image">
43
+ <meta property="og:url" content="'.get_option('clickfunnels_siteURL').'/'.get_post_meta( $pageid, "cf_slug" )[0].'">
44
+ <meta property="og:type" content="website">
45
+ <style>#IntercomDefaultWidget{display:none;}#Intercom{display:none;}</style>
46
+ <meta name="nodo-proxy" content="html">
47
  <script>
48
  function getParameterByName(name) {
49
  name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
51
  results = regex.exec(location.search);
52
  return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
53
  }
54
+ function getRandomizer(bottom, top) {
55
+ return function() {
56
+ return Math.floor( Math.random() * ( 1 + top - bottom ) ) + bottom;
57
+ }
58
+ }
59
+ $random = getRandomizer(0,1);
60
+ if ($random == 0){
61
+ document.cookie = "lander-ab-tests-'.$pageid.'=lander_control";
62
+ }
63
+ if ($random == 1){
64
+ $preview = getParameterByName("preview");
65
+ document.cookie = "lander-ab-tests-'.$pageid.'=lander_" + $preview;
66
  }
67
  </script>
68
  <link href="https://assets3.clickfunnels.com/assets/lander.css" media="screen" rel="stylesheet"/>
69
+ <script type="text/javascript" src="https://static.clickfunnels.com/clickfunnels/landers/tmp/'.$position.'.js"></script>
 
 
 
 
 
 
 
 
70
  </head>
71
  <body>
72
+
73
  </body>
74
  </html>';
75
 
77
  return $newHTML;
78
  }
79
 
80
+ public function get_page_iframe( $cf_iframe_url, $meta = "", $title = "", $desc = "", $social = "", $pageid = "" ) {
81
  global $wp_query;
82
  if ($wp_query->is_404) {
83
  $wp_query->is_404 = false;
84
  }
85
  header("HTTP/1.1 200 OK");
86
 
87
+ // if ($pageid == '') {
88
+ // $pageid = $cf_iframe_url;
89
+ // }
90
 
 
 
91
  $iframeVersion = '<!DOCTYPE html>
92
  <html>
93
  <head>
98
  <meta content="'.$title.'" property="og:title">
99
  <meta content="'.$desc.'" property="og:description">
100
  <meta content="'.$social.'" property="og:image">
101
+ <meta property="og:url" content="'.get_option('clickfunnels_siteURL').'/'.get_post_meta( $pageid, "cf_slug" )[0].'">
102
  <meta property="og:type" content="website">
103
  <style>
104
  * {
129
  $( window ).resize(function() {
130
  $(".video").height($(window).height());
131
  });
 
132
  });
133
  </script>
134
  </head>
admin.php CHANGED
@@ -1 +1 @@
1
- <?php
2
  $cf_thefunnel = get_post_meta( $_GET['post'], "cf_thefunnel", true );
3
  $cf_thepage = get_post_meta( $_GET['post'], "cf_thepage", true );
4
  $cf_iframe_check = get_post_meta( $_GET['post'], "cf_iframe_check", true );
5
  $cf_iframe_url = get_post_meta( $_GET['post'], "cf_iframe_url", true );
6
  $cf_seo_title = get_post_meta( $_GET['post'], "cf_seo_title", true );
7
  $cf_seo_desc = get_post_meta( $_GET['post'], "cf_seo_desc", true );
8
  $cf_seo_image = get_post_meta( $_GET['post'], "cf_seo_image", true );
9
  if ( !isset( $cf_page['page_id'] ) || $cf_page['page_id'] < 10 ) {
10
  $thepage = explode( "{#}", $cf_page );
11
  $savedData = $cf_page;
12
  }
13
  else {
14
  $thepage = explode( "{#}", $cf_page['page_id'] );
15
  $savedData = $cf_page['page_id'];
16
  }
17
  $cf_options = get_option( "cf_options" );
18
  jQuery(document).ready(function(){
19
  // Set Correct Options
20
  var thefunnel = jQuery('#cf_thefunnel').val();
21
  var specificFunnel = 'https://api.clickfunnels.com/funnels/'+thefunnel+'.json?email=<?php echo get_option( "clickfunnels_api_email" ); ?>&auth_token=<?php echo get_option( "clickfunnels_api_auth" ); ?>';
22
  jQuery('#cf_thepage').find('option').remove().end();
23
  jQuery('#loading').fadeIn();
24
  jQuery.getJSON(specificFunnel, function(data) {
25
  setTimeout(function() {
26
  jQuery('#loading').fadeOut();
27
  }, 2000);
28
  var is_selected = "";
29
  jQuery.each(data.funnel_steps, function() {
30
  if (this.pages != ''){
31
  if(this.pages[0].id == "<?php echo $thepage[2] ?>" && this.pages != '' ) {
32
  is_selected = "selected";
33
  jQuery('#cf_seo_tags').val(this.pages[0].metatags);
34
  } else {
35
  is_selected = "";
36
  }
37
  if ( this.wp_friendly == true && this.pages != '' ) {
38
  jQuery('#iframeURL').val('https://'+this.pages[0].url);
39
  jQuery('#cf_thepage').append('<option value="' + this.pages[0].key + '{#}' + this.pages[0].id + '{#}' + this.pages[0].funnel_step_id + '{#}' + encodeURI(this.pages[0].metatags) + '{#}<?php echo get_the_ID(); ?>{#}' + this.name +'{#}'+this.pages[0].url+'" '+is_selected+'>'+ this.name +'</option>');
40
  }
41
  }
42
  });
43
  }).done(function() {
44
  jQuery('#loading').fadeOut();
45
  var savedMeta = jQuery('#cf_thepage').val();
46
  if(savedMeta != undefined || savedMeta != null){
47
  savedMeta = savedMeta.split('{#}');
48
  jQuery('#jsmeta').val(savedMeta[3]);
49
  <?php if ( !empty( $_GET['action'] ) ) { ?>
50
  if (savedMeta[3] != jQuery('#oldmeta').val()){
51
  jQuery('#metaalreadyupdated').hide();
52
  jQuery('#showupdatemetalink').show();
53
  }
54
  <?php } ?>
55
  }
56
  <?php if ( empty( $_GET['action'] ) ) { ?>
57
  jQuery('#cf_thefunnel').prepend('<option value="" disabled selected>Select a Funnel</option>');
58
  <?php } ?>
59
  })
60
  .fail(function() {
61
  jQuery('#loading').fadeOut();
62
  })
63
  .always(function() {
64
  jQuery('#loading').fadeOut();
65
  });
66
  // Change Funnel Populate Dropdown
67
  jQuery( '#cf_thefunnel' ).change(function() {
68
  jQuery('#loading').fadeIn();
69
  var thefunnel = jQuery(this).val();
70
  var totalPages = 0;
71
  var specificFunnel = 'https://api.clickfunnels.com/funnels/'+thefunnel+'.json?email=<?php echo get_option( "clickfunnels_api_email" ); ?>&auth_token=<?php echo get_option( "clickfunnels_api_auth" ); ?>';
72
  jQuery('#cf_thepage').find('option').remove().end();
73
  jQuery.getJSON(specificFunnel, function(data) {
74
  setTimeout(function() {
75
  jQuery('#loading').fadeOut();
76
  }, 2000);
77
  // alert( specificFunnel);
78
  jQuery.each(data.funnel_steps, function() {
79
  if( this.wp_friendly == true && this.pages != '' ) {
80
  jQuery('#iframeURL').val('https://'+this.pages[0].url);
81
  jQuery('#cf_thepage').append('<option value="' + this.pages[0].key + '{#}' + this.pages[0].id + '{#}' + this.pages[0].funnel_step_id + '{#}' + encodeURI(this.pages[0].metatags) + '{#}<?php echo get_the_ID(); ?>{#}' + this.name +'{#}'+this.pages[0].url+'">'+ this.name +'</option>');
82
 
83
  totalPages += 1;
84
  }
85
  });
86
 
87
  }).done(function() {
88
  jQuery('#loading').fadeOut();
89
  var savedMeta = jQuery('#cf_thepage').val();
90
  if(savedMeta != undefined || savedMeta != null){
91
  savedMeta = savedMeta.split('{#}');
92
  jQuery('#previewiframe').attr('src', 'https://'+savedMeta[6]+'?preview=true');
93
  }
94
  jQuery('#cf_thepage').trigger('change');
95
 
96
  if (totalPages == 0) {
97
  jQuery('#noPageWarning').fadeIn();
98
  jQuery('#cf_thepage').fadeOut();
99
  }
100
  else {
101
  jQuery('#noPageWarning').hide();
102
  jQuery('#cf_thepage').fadeIn();
103
  }
104
  var theposition = jQuery('#cf_thepage').val();
105
  jQuery('#cf_data').val(thefunnel+'{#}'+theposition);
106
  var myString = thefunnel+'{#}'+theposition;
107
  var arr = myString.split('{#}');
108
  // jQuery('#loadPageforUpdate').attr('src', 'https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true');
109
  var do_ping = function() {
110
  ping('https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true').then(function(delta) {
111
  }).catch(function(error) {
112
  });
113
  };
114
  do_ping();
115
  })
116
  .fail(function() {
117
  jQuery('#loading').fadeOut();
118
  })
119
  .always(function() {
120
  jQuery('#loading').fadeOut();
121
  });
122
  setTimeout(function() {
123
 
124
  }, 3000);
125
 
126
  });
127
  var request_image = function(url) {
128
  return new Promise(function(resolve, reject) {
129
  var img = new Image();
130
  img.onload = function() { resolve(img); };
131
  img.onerror = function() { reject(url); };
132
  img.src = url + '?random-no-cache=' + Math.floor((1 + Math.random()) * 0x10000).toString(16);
133
  });
134
  };
135
  /**
136
  * Pings a url.
137
  * @param {String} url
138
  * @return {Promise} promise that resolves to a ping (ms, float).
139
  */
140
  var ping = function(url) {
141
  return new Promise(function(resolve, reject) {
142
  var start = (new Date()).getTime();
143
  var response = function() {
144
  var delta = ((new Date()).getTime() - start);
145
  // HACK: Use a fudge factor to correct the ping for HTTP bulk.
146
  delta /= 4;
147
  resolve(delta);
148
  };
149
  request_image(url).then(response).catch(response);
150
  // Set a timeout for max-pings, 5s.
151
  setTimeout(function() { reject(Error('Timeout')); }, 5000);
152
  });
153
  };
154
  function replaceText(inputText, tagName, tagReplace) {
155
  var regExp = new RegExp('\\[' + tagName+ '\\]([^\\[]*)\\[\/' + tagName + '\\]', 'g');
156
  return inputText.replace(regExp, tagReplace);
157
  }
158
  // Select New Page
159
  jQuery( '#cf_thepage' ).change(function() {
160
  jQuery('#loading').fadeOut();
161
  var thefunnel = jQuery('#cf_thefunnel').val();
162
  var theposition = jQuery(this).val();
163
  jQuery('#cf_data').val(thefunnel+'{#}'+theposition);
164
  if(theposition != undefined || theposition != null){
165
  var myString = thefunnel+'{#}'+theposition;
166
  var arr = myString.split('{#}');
167
  var arr2 = theposition.split('{#}');
168
  // Iframe
169
  jQuery('#iframeURL').val('https://'+arr2[6]);
170
  var myStr = arr2[3];
171
  // Browser title
172
  var subStr = myStr.match("%3Ctitle%3E(.*)%3C/title%3E");
173
 
174
  jQuery('#seoTitle').val(subStr[1].replace(/%20/g, ' '));
175
 
176
  // SEO Desc
177
  var subStr = myStr.match("description%22%20content=%22(.*)%22%3E%3Cmeta%20class=%22metaTagTop%22%20name=%22keywo");
178
  jQuery('#seoDesc').val(subStr[1].replace(/%20/g, ' '));
179
  // SEO Share Image
180
  var subStr = myStr.match("rty=%22og:image%22%20content=%22(.*)%22%20id=%22social-image%22%3E");
181
  jQuery('#seosocial').val(subStr[1]);
182
  // jQuery('#loadPageforUpdate').attr('src', 'https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true');
183
  var do_ping = function() {
184
  ping('https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true').then(function(delta) {
185
  }).catch(function(error) {
186
  });
187
  };
188
  do_ping();
189
  jQuery('#previewiframe').attr('src', 'https://'+arr[7]+'?preview=true');
190
  }
191
 
192
  });
193
  // Fade Out Message
194
  setTimeout(function() {
195
  jQuery('#message').fadeOut();
196
  }, 3500);
197
  // Savings
198
  jQuery('#publish').click(function() {
199
  jQuery('#saving').fadeIn();
200
  });
201
  jQuery('#delete').on('click', function () {
202
  return confirm('Are you sure you want to delete this page?');
203
  });
204
  jQuery('#cf_slug').bind('keyup keypress blur', function()
205
  {
206
  var myStr = jQuery(this).val()
207
  myStr=myStr.toLowerCase();
208
  myStr=myStr.replace(/\s/g , "-");
209
  jQuery('#cf_slug').val(myStr);
210
  });
211
  // Check Null and Resave v1.0.6
212
  <?php if ($thepage[1] == 'null') { ?>
213
  // jQuery('#autosaving').fadeIn();
214
  // setTimeout(function() {
215
  // jQuery('form').submit();
216
  // }, 2000);
217
  <?php } ?>
218
  jQuery('#showupdatemetalink').click(function() {
219
  jQuery('form').submit();
220
  });
221
 
222
  });
223
  if ( $cf_page != "" ) {
224
  $json = cf_get_file_contents( 'https://api.clickfunnels.com/funnels/'.$cf_thefunnel.'.json?email='.get_option( 'clickfunnels_api_email' ).'&auth_token='.get_option( 'clickfunnels_api_auth' ) );
225
  $cf_funnels_pages = json_decode( $json );
226
  }
227
  <h4><i class="fa fa-times"></i> Uh oh, your page did not save correctly.</h4>
228
  <h2>Saving and Reloading...</h2>
229
  <h1><i class="fa fa-cog fa-spin"></i></h1>
230
  <img src="<?php echo plugins_url( 'logo.png', __FILE__ ); ?>" alt="">
231
  <a href="https://www.app.clickfunnels.com/funnels" target="_blank" class=""><i class="fa fa-bars"></i> My Account</a>
232
  <br clear="all">
233
  <?php if ( !empty( $_GET['action'] ) ) { ?>
234
  <?php if ( $cf_type=='p' ) {?>
235
  <a style="margin-right: -3px;" href="https://www.clickfunnels.com/pages/<?php echo $thepage[2]; ?>" target="_blank" class="editThisPage"><i class="fa fa-edit"></i> Open Editor</a>
236
  <a style="margin-right: 10px;" href="https://www.clickfunnels.com/funnels/<?php echo $thepage[0]; ?>#<?php echo $thepage[3]; ?>" target="_blank" class="editThisPage"><i class="fa fa-cogs"></i> View Funnel</a>
237
  <a style="margin-right: 10px;" href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>" title="View Page" target="_blank" class="editThisPage"><i class="fa fa-search"></i> Preview</a>
238
  <h2><?php foreach ( $cf_funnels as $key=>$funnel ) { ?>
239
  <?php if ( $cf_thefunnel == $funnel->id ) { if(strlen($funnel->name) > 30) { echo substr($funnel->name,0,30).'...'; } else { echo $funnel->name;} } } ?></h2>
240
 
241
  <a href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>" title="View Page" target="_blank"> <?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?></a>
242
  <?php }?>
243
  <?php if ( $cf_type=='hp' ) {?>
244
  <a href="https://www.clickfunnels.com/pages/<?php echo $thepage[2]; ?>" target="_blank" class="editThisPage"><i class="fa fa-edit"></i> Launch in Editor</a>
245
  <a style="margin-right: 10px;" href="https://www.clickfunnels.com/funnels/<?php echo $thepage[0]; ?>#<?php echo $thepage[3]; ?>" target="_blank" class="editThisPage"><i class="fa fa-cogs"></i> Edit Funnel</a>
246
  <a style="margin-right: 10px;" href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>" title="View Page" target="_blank" class="editThisPage"><i class="fa fa-search"></i> View Page</a>
247
  <h2>Set as Home Page</h2>
248
  <a href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>" title="View Page" target="_blank"><i class="fa fa-search"></i> <?php echo get_option( 'clickfunnels_siteURL' ) ; ?></a>
249
  <?php }?>
250
  <?php if ( $cf_type=='np' ) {?>
251
  <a href="https://www.clickfunnels.com/pages/<?php echo $thepage[2]; ?>" target="_blank" class="editThisPage"><i class="fa fa-edit"></i> Launch in Editor</a>
252
  <a style="margin-right: 10px;" href="https://www.clickfunnels.com/funnels/<?php echo $thepage[0]; ?>#<?php echo $thepage[3]; ?>" target="_blank" class="editThisPage"><i class="fa fa-cogs"></i> Edit Funnel</a>
253
  <a style="margin-right: 10px;" href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>/invalid-url-404-testing" title="View Page" target="_blank" class="editThisPage"><i class="fa fa-search"></i> View Page</a>
254
  <h2>Set as 404 Page</h2>
255
  <a href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/invalid-url" title="View Page" target="_blank"><i class="fa fa-search"></i> <?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/invalid-url</a>
256
  <?php }?>
257
  <?php if ( $cf_type=='' ) {?>
258
  <h2>Page Undefined - Try saving your page again.</h2>
259
  <?php }?>
260
  <?php if ( $cf_type=='noapi' ) {?>
261
  <h2>No API Fallback</h2>
262
  <?php }?>
263
  <?php } else { ?>
264
  <h2 style="font-size: 17px;">Add ClickFunnels Page to Your Blog</h2>
265
  <?php } ?>
266
  <h4>You haven't setup your API settings. <a href="../wp-admin/edit.php?post_type=clickfunnels&page=cf_api">Click here to setup now.</a></h4>
267
  <iframe src="<?php echo $cf_iframe_url; ?>" style="width: 1280px;height: 750px;-ms-zoom: 0.20; -moz-transform: scale(0.20); -moz-transform-origin: 0 0; -o-transform: scale(0.20); -o-transform-origin: 0 0; -webkit-transform: scale(0.20); -webkit-transform-origin: 0 0;" frameborder="0" id="previewiframe"></iframe>
268
  </div>
269
  <input type="hidden" name="post_title" size="30" tabindex="1" value="ClickFunnels Page" id="title" autocomplete="off" />
270
  <input type="hidden" name="post_status" size="30" tabindex="1" value="publish" id="title" autocomplete="off" />
271
  <div class="bootstrap-wp" style=" border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;"><?php wp_nonce_field( "save_clickfunnel", "clickfunnel_nonce" ); ?>
272
  <div class="row-fluid form-horizontal">
273
  <br>
274
  <a style="float: right;position:relative;z-index: 999999;margin-right: 8px" class="btn pageSettings">Page Settings</a>
275
 
276
  <div class="control-group" style="margin-left: -10px; margin-bottom: 20px !important">
277
  <div data-target="cf_type" class="btn-group multichoice cf_header">
278
  <a data-value="p" class="btn <?php if ( $cf_type=='p' || $cf_type=='') {?> active btn-selected<?php }?>">Regular Page</a>
279
  <a data-value="hp" class="btn <?php if ( $cf_type=='hp' ) {?> active btn-selected<?php }?>">Home Page</a>
280
  <a data-value="np" class="btn <?php if ( $cf_type=='np' ) {?> active btn-selected<?php }?>">404 Page</a>
281
  <!-- <a data-value="shortcode" class="btn <?php if ( $cf_type=='shortcode' ) {?> active btn-selected<?php }?>">Shortcode</a> -->
282
  </div>
283
  <input type="hidden" id="cf_type" name="cf_type"/>
284
  </div>
285
  <div class="control-group cf_uses_api" style="">
286
  <label class="control-label" for="cf_thefunnel"> Choose Funnel <i class="fa fa-filter"></i></label>
287
  <div class="controls">
288
  <select class="input-xlarge" id="cf_thefunnel" name="cf_thefunnel_backup">
289
  <?php if ( empty( $cf_funnels ) ) { ?>
290
  <option value="0">No Funnels Found</option>
291
  <?php }
292
  else {
293
  foreach ( $cf_funnels as $key=>$funnel ) { ?>
294
  <option value="<?php echo $funnel->id;?>" <?php if ( $cf_thefunnel == $funnel->id ) { echo "selected"; } ?>><?php echo $funnel->name;?></option>
295
  <?php
296
  }
297
  } ?>
298
  </select>
299
  </div>
300
  </div>
301
  <div class="control-group cf_uses_api">
302
  <label class="control-label" for="cf_thepage"> Choose Page <i class="fa fa-file-o"></i></label>
303
  <div class="controls">
304
  <select class="input-xlarge" id="cf_thepage" name="cf_thepage" style="float: left;">
305
  <?php if ( empty( $cf_funnels_pages ) ) { ?>
306
  <option value="0">No Pages Found</option>
307
  <?php }
308
  else {
309
  foreach ( $cf_funnels_pages->funnel_steps as $key => $funnel ) { ?>
310
  <option value="<?php echo $funnel->position;?>" <?php if ( $cf_thepage == $funnel->position ) { echo "selected"; } ?>><?php echo $funnel->name;?></option>
311
  <?php
312
  }
313
  }
314
  ?>
315
  </select>
316
  <i class="fa fa-spinner fa-spin" id="loading"></i>
317
  </div>
318
  <div id="noPageWarning" style="font-size: 11px; margin-left: 160px;margin-top: -33px;float: left;padding-top: 10px;display: none;width: 100%; clear: both"><em>No compatible pages found for this funnel.</em></div>
319
  </div>
320
  <div class="control-group cf_no_api" >
321
  <label class="control-label" for="cf_iframe_check"> ClickFunnels URL <i class="fa fa-globe"></i></label>
322
  <div class="controls">
323
  <input type="text" class="input-xlarge" id="iframeURL" style="height: 30px;" value="<?php echo $cf_iframe_url; ?>" name="cf_iframe_url" />
324
  </div>
325
  </div>
326
  <div class="control-group cf_no_api" >
327
  <label class="control-label" for="cf_iframe_check"> Website Title <i class="fa fa-globe"></i></label>
328
  <div class="controls">
329
  <input type="text" class="input-xlarge" id="seoTitle" style="height: 30px;" value="<?php echo $cf_seo_title; ?>" name="cf_seo_title" />
330
  </div>
331
  </div>
332
  <div class="control-group cf_no_api" >
333
  <label class="control-label" for="cf_iframe_check"> Description <i class="fa fa-globe"></i></label>
334
  <div class="controls">
335
  <input type="text" class="input-xlarge" id="seoDesc" style="height: 30px;" value="<?php echo $cf_seo_desc; ?>" name="cf_seo_desc" />
336
  </div>
337
  </div>
338
  <div class="control-group cf_no_api" >
339
  <label class="control-label" for="cf_iframe_check"> Social Image URL <i class="fa fa-globe"></i></label>
340
  <div class="controls">
341
  <input type="text" class="input-xlarge" id="seosocial" style="height: 30px;" value="<?php echo $cf_seo_image; ?>" name="cf_seo_image" />
342
  </div>
343
  </div>
344
 
345
 
346
  <div class="control-group cf_uses_api" >
347
  <label class="control-label" for="cf_iframe_check"> Enable Split Tests <i class="fa fa-bar-chart"></i></label>
348
  <div class="controls">
349
  <select class="input-xlarge" id="cf_iframe_check" name="cf_iframe_check" style="float: left;">
350
  <option value="off">Just Show Selected Page</option>
351
  <option value="on" <?php if( $cf_iframe_check == 'on') { ?>selected <?php } ?>>Enable Split Tests and Custom Code</option>
352
  </select>
353
  <!-- <small style="float: left;font-size: 11px;padding: 5px;margin-left: 6px"><a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>">What is this?</a></small> -->
354
  </div>
355
  </div>
356
  <?php if ( !empty( $_GET['action'] ) ) { ?>
357
  <div class="control-group cf_uses_api" style="margin-bottom: 20px">
358
  <label class="control-label" for="cf_iframe_check"> Meta Data <i class="fa fa-info"></i></label>
359
  <a href="#" style="margin-left: 20px;margin-top: 5px;display: block;float: left;display: none" id="showupdatemetalink"><i class="fa fa-refresh"></i> Meta Data is Out Dated -- Click to Update</a>
360
  <span style="margin-left: 20px;margin-top: 5px;display: block;float: left" id="metaalreadyupdated"><i class="fa fa-check"></i> Meta Data is Up to Date</span>
361
  </div>
362
  <?php } else { ?>
363
  <div class="control-group cf_uses_api" style="margin-bottom: 20px">
364
  <label class="control-label" for="cf_iframe_check"> Meta Data <i class="fa fa-info"></i></label>
365
 
366
  <span style="margin-left: 20px;margin-top: 5px;display: block;float: left" id="metaalreadyupdated"><i class="fa fa-check"></i> Meta Data is Up to Date</span>
367
  </div>
368
  <?php } ?>
369
  <?php if ( $cf_type!="p" ) $display ="display:none"; else $display="";?>
370
  <div class="cf_url control-group" style="<?php echo $display;?>" >
371
  <label class="control-label" for="cf_slug"> Custom URL <i class="fa fa-globe"></i></label>
372
  <div id="cf-wp-path" class="controls ">
373
  <div class="input-prepend">
374
  <span class="add-on" style="font-size: 13px;padding: 4px 10px; background: #ECEEEF; color: #777; text-shadow: none; border: 1px solid #ccc"><?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/</span><input style="height:28px;width: 150px !important" type="textbox" value="<?php if ( isset( $cf_slug ) ) echo $cf_slug;?>" name="cf_slug" id="cf_slug" class="input-xlarge">
375
  <div style="color:red; display:none" id="cf_invalid_slug" style="width: 90%" >You must enter an URL</div>
376
  </div>
377
  </div>
378
  </div>
379
 
380
 
381
 
382
  <style>
383
  #hiddenStuff {display: none}
384
  </style>
385
  <div class="control-group" id="hiddenStuff" <?php if ( !empty( $_GET['cf'] ) ) { ?>style="display: block" <?php } ?>>
386
  <div class="controls">
387
  <strong>Funnel ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[0]; ?>" /> <br></strong>
388
  <strong>Page Key: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[1]; ?>" /><br></strong>
389
  <strong>Page ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[2]; ?>" /><br></strong>
390
  <strong>Funnel Step ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[3]; ?>" /><br></strong>
391
  <strong>Saved Meta: <input type="text" style="font-weight: normal;width: 300px;" id="oldmeta" value="<?php echo $thepage[4]; ?>" /><br></strong>
392
  <strong>JS Meta: <input type="text" style="font-weight: normal;width: 300px;" id="jsmeta" value="" /><br></strong>
393
  <strong>Post ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[5]; ?>" /><br></strong>
394
  <strong>Page Name: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[6]; ?>" /><br></strong>
395
  <strong>Use iframe?: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $cf_iframe_check; ?>" /><br></strong>
396
  <strong>Iframe URL: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $cf_iframe_url; ?>" /><br></strong>
397
  <textarea name="cf_thefunnel" id="cf_data" style="width: 400px;height: 300px; font-size: 13px;"><?php echo $savedData; ?></textarea>
398
  </div>
399
  </div>
400
 
401
  <!-- <div style="background: #fafafa;border-top: 1px solid #eee;padding: 10px;text-align: center;margin: 10px 0px;margin-bottom: 20px" >
402
  <strong style="color: #777"> Running split tests or custom code on your page? Check here
403
  <input type="checkbox" id="useIframe" value="on" <?php if( $cf_iframe_check == 'on') { ?>checked <?php } ?> style="margin: 0 3px;width: 18px;height: 18px;" name="cf_iframe_check"> to activate settings.</strong>
404
  <small style="display: block;font-size: 11px;opacity: .5"><a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>">Why do you have to activate settings?</a></small>
405
  <input type="text" style="display: none;" id="iframeURL" value="<?php echo $cf_iframe_url; ?>" name="cf_iframe_url" />
406
  </div> -->
407
  <!-- <div class="p_text helpinfo" <?php if ( $cf_type!='p' ) {?> style="display: none" <?php }?>>
408
  <h4><i class="fa fa-question-circle"></i> Set as a Page</h4>
409
  <p>Choose any ClickFunnels page to be shown using a custom URL just select any funnel to refresh the list of pages. Create a custom URL and hit 'Save/Publish' to start sending traffic. <a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>">Need more help?</a> </p>
410
  <p style="font-size: 11px;opacity: .7;"><i class="fa fa-exclamation-triangle"></i> If you change META data in editor, refresh page and hit 'Save Changes' to update meta data.</p>
411
  </div>
412
  <div class="hp_text helpinfo" <?php if ( $cf_type!='hp' ) {?> style="display: none" <?php }?>>
413
  <h4><i class="fa fa-question-circle"></i> Set as Home Page</h4>
414
  <p> Replace your homepage with a specific ClickFunnels page. You can show any page that you want, this will replace any other homepage settings you may have.</p>
415
  <p style="font-size: 11px;opacity: .7"><i class="fa fa-exclamation-triangle"></i> If you change META data in editor, refresh page and hit 'Save Changes' to update meta data.</p>
416
  </div>
417
  <div class="np_text helpinfo" <?php if ( $cf_type!='np' ) {?> style="display: none" <?php }?>>
418
  <h4><i class="fa fa-question-circle"></i> Set as 404 Page</h4>
419
  <p> Show a specific page to be shown on any "Page not Found" such as a misspelled URL or a deleted blog post. Very good place for a squeeze page to get the most out of your traffic.</p>
420
  <p style="font-size: 11px;opacity: .7"><i class="fa fa-exclamation-triangle"></i> If you change META data in editor, refresh page and hit 'Save Changes' to update meta data.</p>
421
  </div> -->
422
  <div class="row-fluid" id="apiFooter">
423
  <?php if ( get_option( 'clickfunnels_api_email' ) == "" || get_option( 'clickfunnels_api_auth' ) == "" ) { ?>
424
  <button id="publish" name="publish" disabled class="button button-primary " style="float: right; ">
425
  <?php if ( !empty( $_GET['action'] ) ) { echo "<i class='fa fa-save'></i> Save Changes"; } else { echo "<i class='fa fa-save'></i> Publish Page"; } ?>
426
  </button>
427
  <?php } else { ?>
428
  <button id="publish" name="publish" class="button button-primary " style="float: right; ">
429
  <?php if ( !empty( $_GET['action'] ) ) { echo "<i class='fa fa-save'></i> Save Changes"; } else { echo "<i class='fa fa-save'></i> Publish Page"; } ?>
430
  </button>
431
  <?php } ?>
432
  <div id="saving" style="float: right;display: none; padding-right: 10px;opacity: .6;padding-top: 5px;">
433
  <i class="fa fa-spinner fa-spin"></i>
434
  <span>Saving...</span>
435
  </div>
436
  <a class="button button-secondary" style="float: left; margin-right: 10px" type="submit" href="<?php echo admin_url( 'edit.php?post_type=clickfunnels' );?>"><i class="fa fa-file-text-o"></i> Pages</a>
437
  <a class="button button-secondary" style="float: left; margin-right: 10px" type="submit" href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=cf_api' );?>"><i class="fa fa-cog"></i> Settings</a>
438
  <a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>" class="button button-default" style="float: left;margin-right: 10px"><i class="fa fa-life-ring"></i> Support</a>
439
  <?php if ( !empty( $delete_link ) ) {?>
440
  <a class="button button-secondary" id="delete" type="submit" href="<?php echo $delete_link;?>"><i class="fa fa-trash"></i> Delete Page</a>
441
  <?php }?>
442
  </div>
443
  </div>
444
  </div>
445
  (function($) {
446
  setTimeout(function() {
447
  $('#cf_thepage').trigger( "change" );
448
  }, 1500);
449
  })(jQuery);
 
450
  $cf_thefunnel = get_post_meta( $_GET['post'], "cf_thefunnel", true );
451
  $cf_thepage = get_post_meta( $_GET['post'], "cf_thepage", true );
452
  $cf_iframe_check = get_post_meta( $_GET['post'], "cf_iframe_check", true );
453
  $cf_iframe_url = get_post_meta( $_GET['post'], "cf_iframe_url", true );
454
  $cf_seo_title = get_post_meta( $_GET['post'], "cf_seo_title", true );
455
  $cf_seo_desc = get_post_meta( $_GET['post'], "cf_seo_desc", true );
456
  $cf_seo_image = get_post_meta( $_GET['post'], "cf_seo_image", true );
457
 
458
  if ( !isset( $cf_page['page_id'] ) || $cf_page['page_id'] < 10 ) {
459
  $thepage = explode( "{#}", $cf_page );
460
  $savedData = $cf_page;
461
  }
462
  else {
463
  $thepage = explode( "{#}", $cf_page['page_id'] );
464
  $savedData = $cf_page['page_id'];
465
  }
466
  $cf_options = get_option( "cf_options" );
467
  jQuery(document).ready(function(){
468
  // Set Correct Options
469
  var thefunnel = jQuery('#cf_thefunnel').val();
470
  var specificFunnel = 'https://api.clickfunnels.com/funnels/'+thefunnel+'.json?email=<?php echo get_option( "clickfunnels_api_email" ); ?>&auth_token=<?php echo get_option( "clickfunnels_api_auth" ); ?>';
471
  jQuery('#cf_thepage').find('option').remove().end();
472
  jQuery('#loading').fadeIn();
473
  jQuery.getJSON(specificFunnel, function(data) {
474
  setTimeout(function() {
475
  jQuery('#loading').fadeOut();
476
  }, 2000);
477
  var is_selected = "";
478
  jQuery.each(data.funnel_steps, function() {
479
  if (this.pages != ''){
480
  if(this.pages[0].id == "<?php echo $thepage[2] ?>" && this.pages != '' ) {
481
  is_selected = "selected";
482
  jQuery('#cf_seo_tags').val(this.pages[0].metatags);
483
  } else {
484
  is_selected = "";
485
  }
486
  if ( this.wp_friendly == true && this.pages != '' ) {
487
  var baseurl = this.pages[0].published_url.split('.com/');
488
  var baseurlnew = baseurl[0]+'.com/'+this.path;
489
  jQuery('#iframeURL').val(baseurlnew);
490
  // Check if has split tests
491
  var splittestkeys = 'none';
492
  // if (this.pages.length == 2) {
493
  // splittestkeys = this.pages[0].key + '{|}' + this.pages[1].key;
494
  // }
495
  // else if (this.pages.length == 3) {
496
  // splittestkeys = this.pages[0].key + '{|}' + this.pages[1].key+ '{|}' + this.pages[2].key;
497
  // }
498
 
499
  pageKey = this.pages[0].key;
500
 
501
  jQuery('#cf_thepage').append('<option value="' + pageKey + '{#}' + this.pages[0].id + '{#}' + this.pages[0].funnel_step_id + '{#}' + encodeURI(this.pages[0].metatags) + '{#}<?php echo get_the_ID(); ?>{#}' + this.name +'{#}'+baseurlnew+'" '+is_selected+'>'+ this.name +'</option>');
502
  }
503
  }
504
  });
505
  }).done(function() {
506
  jQuery('#loading').fadeOut();
507
  var savedMeta = jQuery('#cf_thepage').val();
508
  if(savedMeta != undefined || savedMeta != null){
509
  savedMeta = savedMeta.split('{#}');
510
  jQuery('#jsmeta').val(savedMeta[3]);
511
  <?php if ( !empty( $_GET['action'] ) ) { ?>
512
  if (savedMeta[3] != jQuery('#oldmeta').val()){
513
  jQuery('#metaalreadyupdated').hide();
514
  jQuery('#showupdatemetalink').show();
515
  }
516
  <?php } ?>
517
  }
518
  <?php if ( empty( $_GET['action'] ) ) { ?>
519
  jQuery('#cf_thefunnel').prepend('<option value="" disabled selected>Select a Funnel</option>');
520
  <?php } ?>
521
  })
522
  .fail(function() {
523
  jQuery('#loading').fadeOut();
524
  })
525
  .always(function() {
526
  jQuery('#loading').fadeOut();
527
  });
528
  // Change Funnel Populate Dropdown
529
  jQuery( '#cf_thefunnel' ).change(function() {
530
  jQuery('#loading').fadeIn();
531
  var thefunnel = jQuery(this).val();
532
  var totalPages = 0;
533
  var specificFunnel = 'https://api.clickfunnels.com/funnels/'+thefunnel+'.json?email=<?php echo get_option( "clickfunnels_api_email" ); ?>&auth_token=<?php echo get_option( "clickfunnels_api_auth" ); ?>';
534
  jQuery('#cf_thepage').find('option').remove().end();
535
  jQuery.getJSON(specificFunnel, function(data) {
536
  setTimeout(function() {
537
  jQuery('#loading').fadeOut();
538
  }, 2000);
539
  // alert( specificFunnel);
540
  jQuery.each(data.funnel_steps, function() {
541
  if( this.wp_friendly == true && this.pages != '' ) {
542
  if (this.pages.length > 1) {
543
  jQuery('#usingSplitTests').show();
544
  } else {
545
  jQuery('#usingSplitTests').hide();
546
  }
547
 
548
  var baseurl = this.pages[0].published_url.split('.com/');
549
  var baseurlnew = baseurl[0]+'.com/'+this.path;
550
  jQuery('#iframeURL').val(baseurlnew);
551
  jQuery('#cf_thepage').append('<option value="' + this.pages[0].key + '{#}' + this.pages[0].id + '{#}' + this.pages[0].funnel_step_id + '{#}' + encodeURI(this.pages[0].metatags) + '{#}<?php echo get_the_ID(); ?>{#}' + this.name +'{#}'+baseurlnew+'">'+ this.name +'</option>');
552
 
553
 
554
  totalPages += 1;
555
  }
556
  });
557
 
558
  }).done(function() {
559
  jQuery('#loading').fadeOut();
560
  var savedMeta = jQuery('#cf_thepage').val();
561
  if(savedMeta != undefined || savedMeta != null){
562
  savedMeta = savedMeta.split('{#}');
563
  jQuery('#previewiframe').attr('src', savedMeta[6]+'?preview=true');
564
  }
565
  jQuery('#cf_thepage').trigger('change');
566
 
567
  if (totalPages == 0) {
568
  jQuery('#noPageWarning').fadeIn();
569
  jQuery('#cf_thepage').fadeOut();
570
  }
571
  else {
572
  jQuery('#noPageWarning').hide();
573
  jQuery('#cf_thepage').fadeIn();
574
  }
575
  var theposition = jQuery('#cf_thepage').val();
576
  jQuery('#cf_data').val(thefunnel+'{#}'+theposition);
577
  var myString = thefunnel+'{#}'+theposition;
578
  var arr = myString.split('{#}');
579
  // jQuery('#loadPageforUpdate').attr('src', 'https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true');
580
  var do_ping = function() {
581
  ping('https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true').then(function(delta) {
582
  }).catch(function(error) {
583
  });
584
  };
585
  do_ping();
586
  })
587
  .fail(function() {
588
  jQuery('#loading').fadeOut();
589
  })
590
  .always(function() {
591
  jQuery('#loading').fadeOut();
592
  });
593
  setTimeout(function() {
594
 
595
  }, 3000);
596
 
597
  });
598
  var request_image = function(url) {
599
  return new Promise(function(resolve, reject) {
600
  var img = new Image();
601
  img.onload = function() { resolve(img); };
602
  img.onerror = function() { reject(url); };
603
  img.src = url + '?random-no-cache=' + Math.floor((1 + Math.random()) * 0x10000).toString(16);
604
  });
605
  };
606
  /**
607
  * Pings a url.
608
  * @param {String} url
609
  * @return {Promise} promise that resolves to a ping (ms, float).
610
  */
611
  var ping = function(url) {
612
  return new Promise(function(resolve, reject) {
613
  var start = (new Date()).getTime();
614
  var response = function() {
615
  var delta = ((new Date()).getTime() - start);
616
  // HACK: Use a fudge factor to correct the ping for HTTP bulk.
617
  delta /= 4;
618
  resolve(delta);
619
  };
620
  request_image(url).then(response).catch(response);
621
  // Set a timeout for max-pings, 5s.
622
  setTimeout(function() { reject(Error('Timeout')); }, 5000);
623
  });
624
  };
625
  function replaceText(inputText, tagName, tagReplace) {
626
  var regExp = new RegExp('\\[' + tagName+ '\\]([^\\[]*)\\[\/' + tagName + '\\]', 'g');
627
  return inputText.replace(regExp, tagReplace);
628
  }
629
  // Select New Page
630
  jQuery( '#cf_thepage' ).change(function() {
631
  jQuery('#loading').fadeOut();
632
  var thefunnel = jQuery('#cf_thefunnel').val();
633
  var theposition = jQuery(this).val();
634
  jQuery('#cf_data').val(thefunnel+'{#}'+theposition);
635
  if(theposition != undefined || theposition != null){
636
  var myString = thefunnel+'{#}'+theposition;
637
  var arr = myString.split('{#}');
638
  var arr2 = theposition.split('{#}');
639
  // Iframe
640
  jQuery('#iframeURL').val(arr2[6]);
641
  var myStr = arr2[3];
642
  // Browser title
643
  var subStr = myStr.match("%3Ctitle%3E(.*)%3C/title%3E");
644
 
645
  jQuery('#seoTitle').val(subStr[1].replace(/%20/g, ' '));
646
 
647
  // SEO Desc
648
  var subStr = myStr.match("description%22%20content=%22(.*)%22%3E%3Cmeta%20class=%22metaTagTop%22%20name=%22keywo");
649
  jQuery('#seoDesc').val(subStr[1].replace(/%20/g, ' '));
650
  // SEO Share Image
651
  var subStr = myStr.match("rty=%22og:image%22%20content=%22(.*)%22%20id=%22social-image%22%3E");
652
  jQuery('#seosocial').val(subStr[1]);
653
  // jQuery('#loadPageforUpdate').attr('src', 'https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true');
654
  var do_ping = function() {
655
  ping('https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true').then(function(delta) {
656
  }).catch(function(error) {
657
  });
658
  };
659
  do_ping();
660
  jQuery('#previewiframe').attr('src', arr[7]+'?preview=true');
661
  }
662
 
663
  });
664
  // Fade Out Message
665
  setTimeout(function() {
666
  jQuery('#message').fadeOut();
667
  }, 3500);
668
  // Savings
669
  jQuery('#publish').click(function() {
670
  jQuery('#saving').fadeIn();
671
  });
672
  jQuery('#delete').on('click', function () {
673
  return confirm('Are you sure you want to delete this page?');
674
  });
675
  jQuery('#cf_slug').bind('keyup keypress blur', function()
676
  {
677
  var myStr = jQuery(this).val()
678
  myStr=myStr.toLowerCase();
679
  myStr=myStr.replace(/\s/g , "-");
680
  jQuery('#cf_slug').val(myStr);
681
  });
682
  // Check Null and Resave v1.0.6
683
  <?php if ($thepage[1] == 'null') { ?>
684
  // jQuery('#autosaving').fadeIn();
685
  // setTimeout(function() {
686
  // jQuery('form').submit();
687
  // }, 2000);
688
  <?php } ?>
689
  jQuery('#showupdatemetalink').click(function() {
690
  jQuery('form').submit();
691
  });
692
 
693
  });
694
  if ( $cf_page != "" ) {
695
  $json = get_file_content( 'https://api.clickfunnels.com/funnels/'.$cf_thefunnel.'.json?email='.get_option( 'clickfunnels_api_email' ).'&auth_token='.get_option( 'clickfunnels_api_auth' ) );
696
  $cf_funnels_pages = json_decode( $json );
697
  }
698
  <h4><i class="fa fa-times"></i> Uh oh, your page did not save correctly.</h4>
699
  <h2>Saving and Reloading...</h2>
700
  <h1><i class="fa fa-cog fa-spin"></i></h1>
701
  <img src="<?php echo plugins_url( 'logo.png', __FILE__ ); ?>" alt="">
702
  <a href="https://www.app.clickfunnels.com/funnels" target="_blank" class=""><i class="fa fa-bars"></i> My Account</a>
703
  <br clear="all">
704
  <?php if ( !empty( $_GET['action'] ) ) { ?>
705
  <?php if ( $cf_type=='p' ) {?>
706
  <a style="margin-right: -3px;" href="https://www.clickfunnels.com/pages/<?php echo $thepage[2]; ?>" target="_blank" class="editThisPage"><i class="fa fa-edit"></i> Open Editor</a>
707
  <a style="margin-right: 10px;" href="https://www.clickfunnels.com/funnels/<?php echo $thepage[0]; ?>#<?php echo $thepage[3]; ?>" target="_blank" class="editThisPage"><i class="fa fa-cogs"></i> View Funnel</a>
708
  <a style="margin-right: 10px;" href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>" title="View Page" target="_blank" class="editThisPage"><i class="fa fa-search"></i> Preview</a>
709
  <h2><?php foreach ( $cf_funnels as $key=>$funnel ) { ?>
710
  <?php if ( $cf_thefunnel == $funnel->id ) { if(strlen($funnel->name) > 30) { echo substr($funnel->name,0,30).'...'; } else { echo $funnel->name;} } } ?></h2>
711
 
712
  <a href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>" title="View Page" target="_blank"> <?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?></a>
713
  <?php }?>
714
  <?php if ( $cf_type=='hp' ) {?>
715
  <a href="https://www.clickfunnels.com/pages/<?php echo $thepage[2]; ?>" target="_blank" class="editThisPage"><i class="fa fa-edit"></i> Launch in Editor</a>
716
  <a style="margin-right: 10px;" href="https://www.clickfunnels.com/funnels/<?php echo $thepage[0]; ?>#<?php echo $thepage[3]; ?>" target="_blank" class="editThisPage"><i class="fa fa-cogs"></i> Edit Funnel</a>
717
  <a style="margin-right: 10px;" href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>" title="View Page" target="_blank" class="editThisPage"><i class="fa fa-search"></i> View Page</a>
718
  <h2>Set as Home Page</h2>
719
  <a href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>" title="View Page" target="_blank"><i class="fa fa-search"></i> <?php echo get_option( 'clickfunnels_siteURL' ) ; ?></a>
720
  <?php }?>
721
  <?php if ( $cf_type=='np' ) {?>
722
  <a href="https://www.clickfunnels.com/pages/<?php echo $thepage[2]; ?>" target="_blank" class="editThisPage"><i class="fa fa-edit"></i> Launch in Editor</a>
723
  <a style="margin-right: 10px;" href="https://www.clickfunnels.com/funnels/<?php echo $thepage[0]; ?>#<?php echo $thepage[3]; ?>" target="_blank" class="editThisPage"><i class="fa fa-cogs"></i> Edit Funnel</a>
724
  <a style="margin-right: 10px;" href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>/invalid-url-404-testing" title="View Page" target="_blank" class="editThisPage"><i class="fa fa-search"></i> View Page</a>
725
  <h2>Set as 404 Page</h2>
726
  <a href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/invalid-url" title="View Page" target="_blank"><i class="fa fa-search"></i> <?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/invalid-url</a>
727
  <?php }?>
728
  <?php if ( $cf_type=='' ) {?>
729
  <h2>Page Undefined - Try saving your page again.</h2>
730
  <?php }?>
731
  <?php if ( $cf_type=='noapi' ) {?>
732
  <h2>No API Fallback</h2>
733
  <?php }?>
734
  <?php } else { ?>
735
  <h2 style="font-size: 17px;">Add ClickFunnels Page to Your Blog</h2>
736
  <?php } ?>
737
  <h4>You haven't setup your API settings. <a href="../wp-admin/edit.php?post_type=clickfunnels&page=cf_api">Click here to setup now.</a></h4>
738
  <iframe src="<?php echo $cf_iframe_url; ?>" style="width: 1280px;height: 750px;-ms-zoom: 0.20; -moz-transform: scale(0.20); -moz-transform-origin: 0 0; -o-transform: scale(0.20); -o-transform-origin: 0 0; -webkit-transform: scale(0.20); -webkit-transform-origin: 0 0;" frameborder="0" id="previewiframe"></iframe>
739
  </div> -->
740
  <input type="hidden" name="post_title" size="30" tabindex="1" value="ClickFunnels Page" id="title" autocomplete="off" />
741
  <input type="hidden" name="post_status" size="30" tabindex="1" value="publish" id="title" autocomplete="off" />
742
  <div class="bootstrap-wp" style=" border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;"><?php wp_nonce_field( "save_clickfunnel", "clickfunnel_nonce" ); ?>
743
  <div class="row-fluid form-horizontal">
744
  <br>
745
  <a style="float: right;position:relative;z-index: 999999;margin-right: 8px" class="btn pageSettings">Page Settings</a>
746
 
747
  <div class="control-group" style="margin-left: -10px; margin-bottom: 20px !important">
748
  <div data-target="cf_type" class="btn-group multichoice cf_header">
749
  <a data-value="p" class="btn <?php if ( $cf_type=='p' || $cf_type=='') {?> active btn-selected<?php }?>">Regular Page</a>
750
  <a data-value="hp" class="btn <?php if ( $cf_type=='hp' ) {?> active btn-selected<?php }?>">Home Page</a>
751
  <a data-value="np" class="btn <?php if ( $cf_type=='np' ) {?> active btn-selected<?php }?>">404 Page</a>
752
  <!-- <a data-value="shortcode" class="btn <?php if ( $cf_type=='shortcode' ) {?> active btn-selected<?php }?>">Shortcode</a> -->
753
  </div>
754
  <input type="hidden" id="cf_type" name="cf_type"/>
755
  </div>
756
  <div class="control-group cf_uses_api" style="">
757
  <label class="control-label" for="cf_thefunnel"> Choose Funnel <i class="fa fa-filter"></i></label>
758
  <div class="controls">
759
  <select class="input-xlarge" id="cf_thefunnel" name="cf_thefunnel_backup">
760
  <?php if ( empty( $cf_funnels ) ) { ?>
761
  <option value="0">No Funnels Found</option>
762
  <?php }
763
  else {
764
  foreach ( $cf_funnels as $key=>$funnel ) { ?>
765
  <option value="<?php echo $funnel->id;?>" <?php if ( $cf_thefunnel == $funnel->id ) { echo "selected"; } ?>><?php echo $funnel->name;?></option>
766
  <?php
767
  }
768
  } ?>
769
  </select>
770
  </div>
771
  </div>
772
  <div id="usingSplitTests" style="display: none">
773
  Using split tests
774
  </div>
775
  <div class="control-group cf_uses_api">
776
  <label class="control-label" for="cf_thepage"> Choose Page <i class="fa fa-file-o"></i></label>
777
  <div class="controls">
778
  <select class="input-xlarge" id="cf_thepage" name="cf_thepage" style="float: left;">
779
  <?php if ( empty( $cf_funnels_pages ) ) { ?>
780
  <option value="0">No Pages Found</option>
781
  <?php }
782
  else {
783
  foreach ( $cf_funnels_pages->funnel_steps as $key => $funnel ) { ?>
784
  <option value="<?php echo $funnel->position;?>" <?php if ( $cf_thepage == $funnel->position ) { echo "selected"; } ?>><?php echo $funnel->name;?></option>
785
  <?php
786
  }
787
  }
788
  ?>
789
  </select>
790
  <i class="fa fa-spinner fa-spin" id="loading"></i>
791
  </div>
792
  <div id="noPageWarning" style="font-size: 11px; margin-left: 160px;margin-top: -33px;float: left;padding-top: 10px;display: none;width: 100%; clear: both"><em>No compatible pages found for this funnel.</em></div>
793
  </div>
794
  <div class="control-group cf_no_api" >
795
  <label class="control-label" for="cf_iframe_check"> ClickFunnels URL <i class="fa fa-globe"></i></label>
796
  <div class="controls">
797
  <input type="text" class="input-xlarge" id="iframeURL" style="height: 30px;" value="<?php echo $cf_iframe_url; ?>" name="cf_iframe_url" />
798
  </div>
799
  </div>
800
  <div class="control-group cf_no_api" >
801
  <label class="control-label" for="cf_iframe_check"> Website Title <i class="fa fa-globe"></i></label>
802
  <div class="controls">
803
  <input type="text" class="input-xlarge" id="seoTitle" style="height: 30px;" value="<?php echo $cf_seo_title; ?>" name="cf_seo_title" />
804
  </div>
805
  </div>
806
  <div class="control-group cf_no_api" >
807
  <label class="control-label" for="cf_iframe_check"> Description <i class="fa fa-globe"></i></label>
808
  <div class="controls">
809
  <input type="text" class="input-xlarge" id="seoDesc" style="height: 30px;" value="<?php echo $cf_seo_desc; ?>" name="cf_seo_desc" />
810
  </div>
811
  </div>
812
  <div class="control-group cf_no_api" >
813
  <label class="control-label" for="cf_iframe_check"> Social Image URL <i class="fa fa-globe"></i></label>
814
  <div class="controls">
815
  <input type="text" class="input-xlarge" id="seosocial" style="height: 30px;" value="<?php echo $cf_seo_image; ?>" name="cf_seo_image" />
816
  </div>
817
  </div>
818
 
819
 
820
  <div class="control-group cf_uses_api" >
821
  <label class="control-label" for="cf_iframe_check"> Cookie Split Tests <i class="fa fa-bar-chart"></i></label>
822
  <div class="controls">
823
  <select class="input-xlarge" id="cf_iframe_check" name="cf_iframe_check" style="float: left;">
824
  <option value="off">Show random cookied version</option>
825
  <option value="on" <?php if( $cf_iframe_check == 'on') { ?>selected <?php } ?>>Show page in iframe (don't cookie)</option>
826
  </select>
827
  <!-- <small style="float: left;font-size: 11px;padding: 5px;margin-left: 6px"><a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>">What is this?</a></small> -->
828
  </div>
829
  </div>
830
  <?php if ( !empty( $_GET['action'] ) ) { ?>
831
  <div class="control-group cf_uses_api" style="margin-bottom: 20px">
832
  <label class="control-label" for="cf_iframe_check"> Meta Data <i class="fa fa-info"></i></label>
833
  <a href="#" style="margin-left: 20px;margin-top: 5px;display: block;float: left;display: none" id="showupdatemetalink"><i class="fa fa-refresh"></i> Meta Data is Out Dated -- Click to Update</a>
834
  <span style="margin-left: 20px;margin-top: 5px;display: block;float: left" id="metaalreadyupdated"><i class="fa fa-check"></i> Meta Data is Up to Date</span>
835
  </div>
836
  <?php } else { ?>
837
  <div class="control-group cf_uses_api" style="margin-bottom: 20px">
838
  <label class="control-label" for="cf_iframe_check"> Meta Data <i class="fa fa-info"></i></label>
839
 
840
  <span style="margin-left: 20px;margin-top: 5px;display: block;float: left" id="metaalreadyupdated"><i class="fa fa-check"></i> Meta Data is Up to Date</span>
841
  </div>
842
  <?php } ?>
843
  <?php if ( $cf_type!="p" ) $display ="display:none"; else $display="";?>
844
  <div class="cf_url control-group" style="<?php echo $display;?>" >
845
  <label class="control-label" for="cf_slug"> Custom URL <i class="fa fa-globe"></i></label>
846
  <div id="cf-wp-path" class="controls ">
847
  <div class="input-prepend">
848
  <span class="add-on" style="font-size: 13px;padding: 4px 10px; background: #ECEEEF; color: #777; text-shadow: none; border: 1px solid #ccc"><?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/</span><input style="height:28px;width: 150px !important" type="textbox" value="<?php if ( isset( $cf_slug ) ) echo $cf_slug;?>" name="cf_slug" id="cf_slug" class="input-xlarge">
849
  <div style="color:red; display:none" id="cf_invalid_slug" style="width: 90%" >You must enter an URL</div>
850
  </div>
851
  </div>
852
  </div>
853
 
854
 
855
 
856
  <style>
857
  #hiddenStuff {display: none}
858
  </style>
859
  <div class="control-group" id="hiddenStuff" <?php if ( !empty( $_GET['cf'] ) ) { ?>style="display: block" <?php } ?>>
860
  <div class="controls">
861
  <strong>Funnel ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[0]; ?>" /> <br></strong>
862
  <strong>Page Key: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[1]; ?>" /><br></strong>
863
  <strong>Page ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[2]; ?>" /><br></strong>
864
  <strong>Funnel Step ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[3]; ?>" /><br></strong>
865
  <strong>Saved Meta: <input type="text" style="font-weight: normal;width: 300px;" id="oldmeta" value="<?php echo $thepage[4]; ?>" /><br></strong>
866
  <strong>JS Meta: <input type="text" style="font-weight: normal;width: 300px;" id="jsmeta" value="" /><br></strong>
867
  <strong>Post ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[5]; ?>" /><br></strong>
868
  <strong>Page Name: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[6]; ?>" /><br></strong>
869
  <strong>Use iframe?: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $cf_iframe_check; ?>" /><br></strong>
870
  <strong>Iframe URL: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $cf_iframe_url; ?>" /><br></strong>
871
  <textarea name="cf_thefunnel" id="cf_data" style="width: 400px;height: 300px; font-size: 13px;"><?php echo $savedData; ?></textarea>
872
  </div>
873
  </div>
874
 
875
  <!-- <div style="background: #fafafa;border-top: 1px solid #eee;padding: 10px;text-align: center;margin: 10px 0px;margin-bottom: 20px" >
876
  <strong style="color: #777"> Running split tests or custom code on your page? Check here
877
  <input type="checkbox" id="useIframe" value="on" <?php if( $cf_iframe_check == 'on') { ?>checked <?php } ?> style="margin: 0 3px;width: 18px;height: 18px;" name="cf_iframe_check"> to activate settings.</strong>
878
  <small style="display: block;font-size: 11px;opacity: .5"><a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>">Why do you have to activate settings?</a></small>
879
  <input type="text" style="display: none;" id="iframeURL" value="<?php echo $cf_iframe_url; ?>" name="cf_iframe_url" />
880
  </div> -->
881
  <!-- <div class="p_text helpinfo" <?php if ( $cf_type!='p' ) {?> style="display: none" <?php }?>>
882
  <h4><i class="fa fa-question-circle"></i> Set as a Page</h4>
883
  <p>Choose any ClickFunnels page to be shown using a custom URL just select any funnel to refresh the list of pages. Create a custom URL and hit 'Save/Publish' to start sending traffic. <a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>">Need more help?</a> </p>
884
  <p style="font-size: 11px;opacity: .7;"><i class="fa fa-exclamation-triangle"></i> If you change META data in editor, refresh page and hit 'Save Changes' to update meta data.</p>
885
  </div>
886
  <div class="hp_text helpinfo" <?php if ( $cf_type!='hp' ) {?> style="display: none" <?php }?>>
887
  <h4><i class="fa fa-question-circle"></i> Set as Home Page</h4>
888
  <p> Replace your homepage with a specific ClickFunnels page. You can show any page that you want, this will replace any other homepage settings you may have.</p>
889
  <p style="font-size: 11px;opacity: .7"><i class="fa fa-exclamation-triangle"></i> If you change META data in editor, refresh page and hit 'Save Changes' to update meta data.</p>
890
  </div>
891
  <div class="np_text helpinfo" <?php if ( $cf_type!='np' ) {?> style="display: none" <?php }?>>
892
  <h4><i class="fa fa-question-circle"></i> Set as 404 Page</h4>
893
  <p> Show a specific page to be shown on any "Page not Found" such as a misspelled URL or a deleted blog post. Very good place for a squeeze page to get the most out of your traffic.</p>
894
  <p style="font-size: 11px;opacity: .7"><i class="fa fa-exclamation-triangle"></i> If you change META data in editor, refresh page and hit 'Save Changes' to update meta data.</p>
895
  </div> -->
896
  <div class="row-fluid" id="apiFooter">
897
  <?php if ( get_option( 'clickfunnels_api_email' ) == "" || get_option( 'clickfunnels_api_auth' ) == "" ) { ?>
898
  <button id="publish" name="publish" disabled class="button button-primary " style="float: right; ">
899
  <?php if ( !empty( $_GET['action'] ) ) { echo "<i class='fa fa-save'></i> Save Changes"; } else { echo "<i class='fa fa-save'></i> Publish Page"; } ?>
900
  </button>
901
  <?php } else { ?>
902
  <button id="publish" name="publish" class="button button-primary " style="float: right; ">
903
  <?php if ( !empty( $_GET['action'] ) ) { echo "<i class='fa fa-save'></i> Save Changes"; } else { echo "<i class='fa fa-save'></i> Publish Page"; } ?>
904
  </button>
905
  <?php } ?>
906
  <div id="saving" style="float: right;display: none; padding-right: 10px;opacity: .6;padding-top: 5px;">
907
  <i class="fa fa-spinner fa-spin"></i>
908
  <span>Saving...</span>
909
  </div>
910
  <a class="button button-secondary" style="float: left; margin-right: 10px" type="submit" href="<?php echo admin_url( 'edit.php?post_type=clickfunnels' );?>"><i class="fa fa-file-text-o"></i> Pages</a>
911
  <a class="button button-secondary" style="float: left; margin-right: 10px" type="submit" href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=cf_api' );?>"><i class="fa fa-cog"></i> Settings</a>
912
  <a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>" class="button button-default" style="float: left;margin-right: 10px"><i class="fa fa-life-ring"></i> Support</a>
913
  <?php if ( !empty( $delete_link ) ) {?>
914
  <a class="button button-secondary" id="delete" type="submit" href="<?php echo $delete_link;?>"><i class="fa fa-trash"></i> Delete Page</a>
915
  <?php }?>
916
  </div>
917
  </div>
918
  </div>
919
  (function($) {
920
  setTimeout(function() {
921
  $('#cf_thepage').trigger( "change" );
922
  }, 1500);
923
  })(jQuery);
 
1
  $cf_thefunnel = get_post_meta( $_GET['post'], "cf_thefunnel", true );
2
  $cf_thepage = get_post_meta( $_GET['post'], "cf_thepage", true );
3
  $cf_iframe_check = get_post_meta( $_GET['post'], "cf_iframe_check", true );
4
  $cf_iframe_url = get_post_meta( $_GET['post'], "cf_iframe_url", true );
5
  $cf_seo_title = get_post_meta( $_GET['post'], "cf_seo_title", true );
6
  $cf_seo_desc = get_post_meta( $_GET['post'], "cf_seo_desc", true );
7
  $cf_seo_image = get_post_meta( $_GET['post'], "cf_seo_image", true );
8
  if ( !isset( $cf_page['page_id'] ) || $cf_page['page_id'] < 10 ) {
9
  $thepage = explode( "{#}", $cf_page );
10
  $savedData = $cf_page;
11
  }
12
  else {
13
  $thepage = explode( "{#}", $cf_page['page_id'] );
14
  $savedData = $cf_page['page_id'];
15
  }
16
  $cf_options = get_option( "cf_options" );
17
  jQuery(document).ready(function(){
18
  // Set Correct Options
19
  var thefunnel = jQuery('#cf_thefunnel').val();
20
  var specificFunnel = 'https://api.clickfunnels.com/funnels/'+thefunnel+'.json?email=<?php echo get_option( "clickfunnels_api_email" ); ?>&auth_token=<?php echo get_option( "clickfunnels_api_auth" ); ?>';
21
  jQuery('#cf_thepage').find('option').remove().end();
22
  jQuery('#loading').fadeIn();
23
  jQuery.getJSON(specificFunnel, function(data) {
24
  setTimeout(function() {
25
  jQuery('#loading').fadeOut();
26
  }, 2000);
27
  var is_selected = "";
28
  jQuery.each(data.funnel_steps, function() {
29
  if (this.pages != ''){
30
  if(this.pages[0].id == "<?php echo $thepage[2] ?>" && this.pages != '' ) {
31
  is_selected = "selected";
32
  jQuery('#cf_seo_tags').val(this.pages[0].metatags);
33
  } else {
34
  is_selected = "";
35
  }
36
  if ( this.wp_friendly == true && this.pages != '' ) {
37
  jQuery('#iframeURL').val('https://'+this.pages[0].url);
38
  jQuery('#cf_thepage').append('<option value="' + this.pages[0].key + '{#}' + this.pages[0].id + '{#}' + this.pages[0].funnel_step_id + '{#}' + encodeURI(this.pages[0].metatags) + '{#}<?php echo get_the_ID(); ?>{#}' + this.name +'{#}'+this.pages[0].url+'" '+is_selected+'>'+ this.name +'</option>');
39
  }
40
  }
41
  });
42
  }).done(function() {
43
  jQuery('#loading').fadeOut();
44
  var savedMeta = jQuery('#cf_thepage').val();
45
  if(savedMeta != undefined || savedMeta != null){
46
  savedMeta = savedMeta.split('{#}');
47
  jQuery('#jsmeta').val(savedMeta[3]);
48
  <?php if ( !empty( $_GET['action'] ) ) { ?>
49
  if (savedMeta[3] != jQuery('#oldmeta').val()){
50
  jQuery('#metaalreadyupdated').hide();
51
  jQuery('#showupdatemetalink').show();
52
  }
53
  <?php } ?>
54
  }
55
  <?php if ( empty( $_GET['action'] ) ) { ?>
56
  jQuery('#cf_thefunnel').prepend('<option value="" disabled selected>Select a Funnel</option>');
57
  <?php } ?>
58
  })
59
  .fail(function() {
60
  jQuery('#loading').fadeOut();
61
  })
62
  .always(function() {
63
  jQuery('#loading').fadeOut();
64
  });
65
  // Change Funnel Populate Dropdown
66
  jQuery( '#cf_thefunnel' ).change(function() {
67
  jQuery('#loading').fadeIn();
68
  var thefunnel = jQuery(this).val();
69
  var totalPages = 0;
70
  var specificFunnel = 'https://api.clickfunnels.com/funnels/'+thefunnel+'.json?email=<?php echo get_option( "clickfunnels_api_email" ); ?>&auth_token=<?php echo get_option( "clickfunnels_api_auth" ); ?>';
71
  jQuery('#cf_thepage').find('option').remove().end();
72
  jQuery.getJSON(specificFunnel, function(data) {
73
  setTimeout(function() {
74
  jQuery('#loading').fadeOut();
75
  }, 2000);
76
  // alert( specificFunnel);
77
  jQuery.each(data.funnel_steps, function() {
78
  if( this.wp_friendly == true && this.pages != '' ) {
79
  jQuery('#iframeURL').val('https://'+this.pages[0].url);
80
  jQuery('#cf_thepage').append('<option value="' + this.pages[0].key + '{#}' + this.pages[0].id + '{#}' + this.pages[0].funnel_step_id + '{#}' + encodeURI(this.pages[0].metatags) + '{#}<?php echo get_the_ID(); ?>{#}' + this.name +'{#}'+this.pages[0].url+'">'+ this.name +'</option>');
81
 
82
  totalPages += 1;
83
  }
84
  });
85
 
86
  }).done(function() {
87
  jQuery('#loading').fadeOut();
88
  var savedMeta = jQuery('#cf_thepage').val();
89
  if(savedMeta != undefined || savedMeta != null){
90
  savedMeta = savedMeta.split('{#}');
91
  jQuery('#previewiframe').attr('src', 'https://'+savedMeta[6]+'?preview=true');
92
  }
93
  jQuery('#cf_thepage').trigger('change');
94
 
95
  if (totalPages == 0) {
96
  jQuery('#noPageWarning').fadeIn();
97
  jQuery('#cf_thepage').fadeOut();
98
  }
99
  else {
100
  jQuery('#noPageWarning').hide();
101
  jQuery('#cf_thepage').fadeIn();
102
  }
103
  var theposition = jQuery('#cf_thepage').val();
104
  jQuery('#cf_data').val(thefunnel+'{#}'+theposition);
105
  var myString = thefunnel+'{#}'+theposition;
106
  var arr = myString.split('{#}');
107
  // jQuery('#loadPageforUpdate').attr('src', 'https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true');
108
  var do_ping = function() {
109
  ping('https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true').then(function(delta) {
110
  }).catch(function(error) {
111
  });
112
  };
113
  do_ping();
114
  })
115
  .fail(function() {
116
  jQuery('#loading').fadeOut();
117
  })
118
  .always(function() {
119
  jQuery('#loading').fadeOut();
120
  });
121
  setTimeout(function() {
122
 
123
  }, 3000);
124
 
125
  });
126
  var request_image = function(url) {
127
  return new Promise(function(resolve, reject) {
128
  var img = new Image();
129
  img.onload = function() { resolve(img); };
130
  img.onerror = function() { reject(url); };
131
  img.src = url + '?random-no-cache=' + Math.floor((1 + Math.random()) * 0x10000).toString(16);
132
  });
133
  };
134
  /**
135
  * Pings a url.
136
  * @param {String} url
137
  * @return {Promise} promise that resolves to a ping (ms, float).
138
  */
139
  var ping = function(url) {
140
  return new Promise(function(resolve, reject) {
141
  var start = (new Date()).getTime();
142
  var response = function() {
143
  var delta = ((new Date()).getTime() - start);
144
  // HACK: Use a fudge factor to correct the ping for HTTP bulk.
145
  delta /= 4;
146
  resolve(delta);
147
  };
148
  request_image(url).then(response).catch(response);
149
  // Set a timeout for max-pings, 5s.
150
  setTimeout(function() { reject(Error('Timeout')); }, 5000);
151
  });
152
  };
153
  function replaceText(inputText, tagName, tagReplace) {
154
  var regExp = new RegExp('\\[' + tagName+ '\\]([^\\[]*)\\[\/' + tagName + '\\]', 'g');
155
  return inputText.replace(regExp, tagReplace);
156
  }
157
  // Select New Page
158
  jQuery( '#cf_thepage' ).change(function() {
159
  jQuery('#loading').fadeOut();
160
  var thefunnel = jQuery('#cf_thefunnel').val();
161
  var theposition = jQuery(this).val();
162
  jQuery('#cf_data').val(thefunnel+'{#}'+theposition);
163
  if(theposition != undefined || theposition != null){
164
  var myString = thefunnel+'{#}'+theposition;
165
  var arr = myString.split('{#}');
166
  var arr2 = theposition.split('{#}');
167
  // Iframe
168
  jQuery('#iframeURL').val('https://'+arr2[6]);
169
  var myStr = arr2[3];
170
  // Browser title
171
  var subStr = myStr.match("%3Ctitle%3E(.*)%3C/title%3E");
172
 
173
  jQuery('#seoTitle').val(subStr[1].replace(/%20/g, ' '));
174
 
175
  // SEO Desc
176
  var subStr = myStr.match("description%22%20content=%22(.*)%22%3E%3Cmeta%20class=%22metaTagTop%22%20name=%22keywo");
177
  jQuery('#seoDesc').val(subStr[1].replace(/%20/g, ' '));
178
  // SEO Share Image
179
  var subStr = myStr.match("rty=%22og:image%22%20content=%22(.*)%22%20id=%22social-image%22%3E");
180
  jQuery('#seosocial').val(subStr[1]);
181
  // jQuery('#loadPageforUpdate').attr('src', 'https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true');
182
  var do_ping = function() {
183
  ping('https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true').then(function(delta) {
184
  }).catch(function(error) {
185
  });
186
  };
187
  do_ping();
188
  jQuery('#previewiframe').attr('src', 'https://'+arr[7]+'?preview=true');
189
  }
190
 
191
  });
192
  // Fade Out Message
193
  setTimeout(function() {
194
  jQuery('#message').fadeOut();
195
  }, 3500);
196
  // Savings
197
  jQuery('#publish').click(function() {
198
  jQuery('#saving').fadeIn();
199
  });
200
  jQuery('#delete').on('click', function () {
201
  return confirm('Are you sure you want to delete this page?');
202
  });
203
  jQuery('#cf_slug').bind('keyup keypress blur', function()
204
  {
205
  var myStr = jQuery(this).val()
206
  myStr=myStr.toLowerCase();
207
  myStr=myStr.replace(/\s/g , "-");
208
  jQuery('#cf_slug').val(myStr);
209
  });
210
  // Check Null and Resave v1.0.6
211
  <?php if ($thepage[1] == 'null') { ?>
212
  // jQuery('#autosaving').fadeIn();
213
  // setTimeout(function() {
214
  // jQuery('form').submit();
215
  // }, 2000);
216
  <?php } ?>
217
  jQuery('#showupdatemetalink').click(function() {
218
  jQuery('form').submit();
219
  });
220
 
221
  });
222
  if ( $cf_page != "" ) {
223
  $json = cf_get_file_contents( 'https://api.clickfunnels.com/funnels/'.$cf_thefunnel.'.json?email='.get_option( 'clickfunnels_api_email' ).'&auth_token='.get_option( 'clickfunnels_api_auth' ) );
224
  $cf_funnels_pages = json_decode( $json );
225
  }
226
  <h4><i class="fa fa-times"></i> Uh oh, your page did not save correctly.</h4>
227
  <h2>Saving and Reloading...</h2>
228
  <h1><i class="fa fa-cog fa-spin"></i></h1>
229
  <img src="<?php echo plugins_url( 'logo.png', __FILE__ ); ?>" alt="">
230
  <a href="https://www.app.clickfunnels.com/funnels" target="_blank" class=""><i class="fa fa-bars"></i> My Account</a>
231
  <br clear="all">
232
  <?php if ( !empty( $_GET['action'] ) ) { ?>
233
  <?php if ( $cf_type=='p' ) {?>
234
  <a style="margin-right: -3px;" href="https://www.clickfunnels.com/pages/<?php echo $thepage[2]; ?>" target="_blank" class="editThisPage"><i class="fa fa-edit"></i> Open Editor</a>
235
  <a style="margin-right: 10px;" href="https://www.clickfunnels.com/funnels/<?php echo $thepage[0]; ?>#<?php echo $thepage[3]; ?>" target="_blank" class="editThisPage"><i class="fa fa-cogs"></i> View Funnel</a>
236
  <a style="margin-right: 10px;" href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>" title="View Page" target="_blank" class="editThisPage"><i class="fa fa-search"></i> Preview</a>
237
  <h2><?php foreach ( $cf_funnels as $key=>$funnel ) { ?>
238
  <?php if ( $cf_thefunnel == $funnel->id ) { if(strlen($funnel->name) > 30) { echo substr($funnel->name,0,30).'...'; } else { echo $funnel->name;} } } ?></h2>
239
 
240
  <a href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>" title="View Page" target="_blank"> <?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?></a>
241
  <?php }?>
242
  <?php if ( $cf_type=='hp' ) {?>
243
  <a href="https://www.clickfunnels.com/pages/<?php echo $thepage[2]; ?>" target="_blank" class="editThisPage"><i class="fa fa-edit"></i> Launch in Editor</a>
244
  <a style="margin-right: 10px;" href="https://www.clickfunnels.com/funnels/<?php echo $thepage[0]; ?>#<?php echo $thepage[3]; ?>" target="_blank" class="editThisPage"><i class="fa fa-cogs"></i> Edit Funnel</a>
245
  <a style="margin-right: 10px;" href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>" title="View Page" target="_blank" class="editThisPage"><i class="fa fa-search"></i> View Page</a>
246
  <h2>Set as Home Page</h2>
247
  <a href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>" title="View Page" target="_blank"><i class="fa fa-search"></i> <?php echo get_option( 'clickfunnels_siteURL' ) ; ?></a>
248
  <?php }?>
249
  <?php if ( $cf_type=='np' ) {?>
250
  <a href="https://www.clickfunnels.com/pages/<?php echo $thepage[2]; ?>" target="_blank" class="editThisPage"><i class="fa fa-edit"></i> Launch in Editor</a>
251
  <a style="margin-right: 10px;" href="https://www.clickfunnels.com/funnels/<?php echo $thepage[0]; ?>#<?php echo $thepage[3]; ?>" target="_blank" class="editThisPage"><i class="fa fa-cogs"></i> Edit Funnel</a>
252
  <a style="margin-right: 10px;" href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>/invalid-url-404-testing" title="View Page" target="_blank" class="editThisPage"><i class="fa fa-search"></i> View Page</a>
253
  <h2>Set as 404 Page</h2>
254
  <a href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/invalid-url" title="View Page" target="_blank"><i class="fa fa-search"></i> <?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/invalid-url</a>
255
  <?php }?>
256
  <?php if ( $cf_type=='' ) {?>
257
  <h2>Page Undefined - Try saving your page again.</h2>
258
  <?php }?>
259
  <?php if ( $cf_type=='noapi' ) {?>
260
  <h2>No API Fallback</h2>
261
  <?php }?>
262
  <?php } else { ?>
263
  <h2 style="font-size: 17px;">Add ClickFunnels Page to Your Blog</h2>
264
  <?php } ?>
265
  <h4>You haven't setup your API settings. <a href="../wp-admin/edit.php?post_type=clickfunnels&page=cf_api">Click here to setup now.</a></h4>
266
  <iframe src="<?php echo $cf_iframe_url; ?>" style="width: 1280px;height: 750px;-ms-zoom: 0.20; -moz-transform: scale(0.20); -moz-transform-origin: 0 0; -o-transform: scale(0.20); -o-transform-origin: 0 0; -webkit-transform: scale(0.20); -webkit-transform-origin: 0 0;" frameborder="0" id="previewiframe"></iframe>
267
  </div>
268
  <input type="hidden" name="post_title" size="30" tabindex="1" value="ClickFunnels Page" id="title" autocomplete="off" />
269
  <input type="hidden" name="post_status" size="30" tabindex="1" value="publish" id="title" autocomplete="off" />
270
  <div class="bootstrap-wp" style=" border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;"><?php wp_nonce_field( "save_clickfunnel", "clickfunnel_nonce" ); ?>
271
  <div class="row-fluid form-horizontal">
272
  <br>
273
  <a style="float: right;position:relative;z-index: 999999;margin-right: 8px" class="btn pageSettings">Page Settings</a>
274
 
275
  <div class="control-group" style="margin-left: -10px; margin-bottom: 20px !important">
276
  <div data-target="cf_type" class="btn-group multichoice cf_header">
277
  <a data-value="p" class="btn <?php if ( $cf_type=='p' || $cf_type=='') {?> active btn-selected<?php }?>">Regular Page</a>
278
  <a data-value="hp" class="btn <?php if ( $cf_type=='hp' ) {?> active btn-selected<?php }?>">Home Page</a>
279
  <a data-value="np" class="btn <?php if ( $cf_type=='np' ) {?> active btn-selected<?php }?>">404 Page</a>
280
  <!-- <a data-value="shortcode" class="btn <?php if ( $cf_type=='shortcode' ) {?> active btn-selected<?php }?>">Shortcode</a> -->
281
  </div>
282
  <input type="hidden" id="cf_type" name="cf_type"/>
283
  </div>
284
  <div class="control-group cf_uses_api" style="">
285
  <label class="control-label" for="cf_thefunnel"> Choose Funnel <i class="fa fa-filter"></i></label>
286
  <div class="controls">
287
  <select class="input-xlarge" id="cf_thefunnel" name="cf_thefunnel_backup">
288
  <?php if ( empty( $cf_funnels ) ) { ?>
289
  <option value="0">No Funnels Found</option>
290
  <?php }
291
  else {
292
  foreach ( $cf_funnels as $key=>$funnel ) { ?>
293
  <option value="<?php echo $funnel->id;?>" <?php if ( $cf_thefunnel == $funnel->id ) { echo "selected"; } ?>><?php echo $funnel->name;?></option>
294
  <?php
295
  }
296
  } ?>
297
  </select>
298
  </div>
299
  </div>
300
  <div class="control-group cf_uses_api">
301
  <label class="control-label" for="cf_thepage"> Choose Page <i class="fa fa-file-o"></i></label>
302
  <div class="controls">
303
  <select class="input-xlarge" id="cf_thepage" name="cf_thepage" style="float: left;">
304
  <?php if ( empty( $cf_funnels_pages ) ) { ?>
305
  <option value="0">No Pages Found</option>
306
  <?php }
307
  else {
308
  foreach ( $cf_funnels_pages->funnel_steps as $key => $funnel ) { ?>
309
  <option value="<?php echo $funnel->position;?>" <?php if ( $cf_thepage == $funnel->position ) { echo "selected"; } ?>><?php echo $funnel->name;?></option>
310
  <?php
311
  }
312
  }
313
  ?>
314
  </select>
315
  <i class="fa fa-spinner fa-spin" id="loading"></i>
316
  </div>
317
  <div id="noPageWarning" style="font-size: 11px; margin-left: 160px;margin-top: -33px;float: left;padding-top: 10px;display: none;width: 100%; clear: both"><em>No compatible pages found for this funnel.</em></div>
318
  </div>
319
  <div class="control-group cf_no_api" >
320
  <label class="control-label" for="cf_iframe_check"> ClickFunnels URL <i class="fa fa-globe"></i></label>
321
  <div class="controls">
322
  <input type="text" class="input-xlarge" id="iframeURL" style="height: 30px;" value="<?php echo $cf_iframe_url; ?>" name="cf_iframe_url" />
323
  </div>
324
  </div>
325
  <div class="control-group cf_no_api" >
326
  <label class="control-label" for="cf_iframe_check"> Website Title <i class="fa fa-globe"></i></label>
327
  <div class="controls">
328
  <input type="text" class="input-xlarge" id="seoTitle" style="height: 30px;" value="<?php echo $cf_seo_title; ?>" name="cf_seo_title" />
329
  </div>
330
  </div>
331
  <div class="control-group cf_no_api" >
332
  <label class="control-label" for="cf_iframe_check"> Description <i class="fa fa-globe"></i></label>
333
  <div class="controls">
334
  <input type="text" class="input-xlarge" id="seoDesc" style="height: 30px;" value="<?php echo $cf_seo_desc; ?>" name="cf_seo_desc" />
335
  </div>
336
  </div>
337
  <div class="control-group cf_no_api" >
338
  <label class="control-label" for="cf_iframe_check"> Social Image URL <i class="fa fa-globe"></i></label>
339
  <div class="controls">
340
  <input type="text" class="input-xlarge" id="seosocial" style="height: 30px;" value="<?php echo $cf_seo_image; ?>" name="cf_seo_image" />
341
  </div>
342
  </div>
343
 
344
 
345
  <div class="control-group cf_uses_api" >
346
  <label class="control-label" for="cf_iframe_check"> Enable Split Tests <i class="fa fa-bar-chart"></i></label>
347
  <div class="controls">
348
  <select class="input-xlarge" id="cf_iframe_check" name="cf_iframe_check" style="float: left;">
349
  <option value="off">Just Show Selected Page</option>
350
  <option value="on" <?php if( $cf_iframe_check == 'on') { ?>selected <?php } ?>>Enable Split Tests and Custom Code</option>
351
  </select>
352
  <!-- <small style="float: left;font-size: 11px;padding: 5px;margin-left: 6px"><a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>">What is this?</a></small> -->
353
  </div>
354
  </div>
355
  <?php if ( !empty( $_GET['action'] ) ) { ?>
356
  <div class="control-group cf_uses_api" style="margin-bottom: 20px">
357
  <label class="control-label" for="cf_iframe_check"> Meta Data <i class="fa fa-info"></i></label>
358
  <a href="#" style="margin-left: 20px;margin-top: 5px;display: block;float: left;display: none" id="showupdatemetalink"><i class="fa fa-refresh"></i> Meta Data is Out Dated -- Click to Update</a>
359
  <span style="margin-left: 20px;margin-top: 5px;display: block;float: left" id="metaalreadyupdated"><i class="fa fa-check"></i> Meta Data is Up to Date</span>
360
  </div>
361
  <?php } else { ?>
362
  <div class="control-group cf_uses_api" style="margin-bottom: 20px">
363
  <label class="control-label" for="cf_iframe_check"> Meta Data <i class="fa fa-info"></i></label>
364
 
365
  <span style="margin-left: 20px;margin-top: 5px;display: block;float: left" id="metaalreadyupdated"><i class="fa fa-check"></i> Meta Data is Up to Date</span>
366
  </div>
367
  <?php } ?>
368
  <?php if ( $cf_type!="p" ) $display ="display:none"; else $display="";?>
369
  <div class="cf_url control-group" style="<?php echo $display;?>" >
370
  <label class="control-label" for="cf_slug"> Custom URL <i class="fa fa-globe"></i></label>
371
  <div id="cf-wp-path" class="controls ">
372
  <div class="input-prepend">
373
  <span class="add-on" style="font-size: 13px;padding: 4px 10px; background: #ECEEEF; color: #777; text-shadow: none; border: 1px solid #ccc"><?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/</span><input style="height:28px;width: 150px !important" type="textbox" value="<?php if ( isset( $cf_slug ) ) echo $cf_slug;?>" name="cf_slug" id="cf_slug" class="input-xlarge">
374
  <div style="color:red; display:none" id="cf_invalid_slug" style="width: 90%" >You must enter an URL</div>
375
  </div>
376
  </div>
377
  </div>
378
 
379
 
380
 
381
  <style>
382
  #hiddenStuff {display: none}
383
  </style>
384
  <div class="control-group" id="hiddenStuff" <?php if ( !empty( $_GET['cf'] ) ) { ?>style="display: block" <?php } ?>>
385
  <div class="controls">
386
  <strong>Funnel ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[0]; ?>" /> <br></strong>
387
  <strong>Page Key: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[1]; ?>" /><br></strong>
388
  <strong>Page ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[2]; ?>" /><br></strong>
389
  <strong>Funnel Step ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[3]; ?>" /><br></strong>
390
  <strong>Saved Meta: <input type="text" style="font-weight: normal;width: 300px;" id="oldmeta" value="<?php echo $thepage[4]; ?>" /><br></strong>
391
  <strong>JS Meta: <input type="text" style="font-weight: normal;width: 300px;" id="jsmeta" value="" /><br></strong>
392
  <strong>Post ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[5]; ?>" /><br></strong>
393
  <strong>Page Name: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[6]; ?>" /><br></strong>
394
  <strong>Use iframe?: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $cf_iframe_check; ?>" /><br></strong>
395
  <strong>Iframe URL: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $cf_iframe_url; ?>" /><br></strong>
396
  <textarea name="cf_thefunnel" id="cf_data" style="width: 400px;height: 300px; font-size: 13px;"><?php echo $savedData; ?></textarea>
397
  </div>
398
  </div>
399
 
400
  <!-- <div style="background: #fafafa;border-top: 1px solid #eee;padding: 10px;text-align: center;margin: 10px 0px;margin-bottom: 20px" >
401
  <strong style="color: #777"> Running split tests or custom code on your page? Check here
402
  <input type="checkbox" id="useIframe" value="on" <?php if( $cf_iframe_check == 'on') { ?>checked <?php } ?> style="margin: 0 3px;width: 18px;height: 18px;" name="cf_iframe_check"> to activate settings.</strong>
403
  <small style="display: block;font-size: 11px;opacity: .5"><a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>">Why do you have to activate settings?</a></small>
404
  <input type="text" style="display: none;" id="iframeURL" value="<?php echo $cf_iframe_url; ?>" name="cf_iframe_url" />
405
  </div> -->
406
  <!-- <div class="p_text helpinfo" <?php if ( $cf_type!='p' ) {?> style="display: none" <?php }?>>
407
  <h4><i class="fa fa-question-circle"></i> Set as a Page</h4>
408
  <p>Choose any ClickFunnels page to be shown using a custom URL just select any funnel to refresh the list of pages. Create a custom URL and hit 'Save/Publish' to start sending traffic. <a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>">Need more help?</a> </p>
409
  <p style="font-size: 11px;opacity: .7;"><i class="fa fa-exclamation-triangle"></i> If you change META data in editor, refresh page and hit 'Save Changes' to update meta data.</p>
410
  </div>
411
  <div class="hp_text helpinfo" <?php if ( $cf_type!='hp' ) {?> style="display: none" <?php }?>>
412
  <h4><i class="fa fa-question-circle"></i> Set as Home Page</h4>
413
  <p> Replace your homepage with a specific ClickFunnels page. You can show any page that you want, this will replace any other homepage settings you may have.</p>
414
  <p style="font-size: 11px;opacity: .7"><i class="fa fa-exclamation-triangle"></i> If you change META data in editor, refresh page and hit 'Save Changes' to update meta data.</p>
415
  </div>
416
  <div class="np_text helpinfo" <?php if ( $cf_type!='np' ) {?> style="display: none" <?php }?>>
417
  <h4><i class="fa fa-question-circle"></i> Set as 404 Page</h4>
418
  <p> Show a specific page to be shown on any "Page not Found" such as a misspelled URL or a deleted blog post. Very good place for a squeeze page to get the most out of your traffic.</p>
419
  <p style="font-size: 11px;opacity: .7"><i class="fa fa-exclamation-triangle"></i> If you change META data in editor, refresh page and hit 'Save Changes' to update meta data.</p>
420
  </div> -->
421
  <div class="row-fluid" id="apiFooter">
422
  <?php if ( get_option( 'clickfunnels_api_email' ) == "" || get_option( 'clickfunnels_api_auth' ) == "" ) { ?>
423
  <button id="publish" name="publish" disabled class="button button-primary " style="float: right; ">
424
  <?php if ( !empty( $_GET['action'] ) ) { echo "<i class='fa fa-save'></i> Save Changes"; } else { echo "<i class='fa fa-save'></i> Publish Page"; } ?>
425
  </button>
426
  <?php } else { ?>
427
  <button id="publish" name="publish" class="button button-primary " style="float: right; ">
428
  <?php if ( !empty( $_GET['action'] ) ) { echo "<i class='fa fa-save'></i> Save Changes"; } else { echo "<i class='fa fa-save'></i> Publish Page"; } ?>
429
  </button>
430
  <?php } ?>
431
  <div id="saving" style="float: right;display: none; padding-right: 10px;opacity: .6;padding-top: 5px;">
432
  <i class="fa fa-spinner fa-spin"></i>
433
  <span>Saving...</span>
434
  </div>
435
  <a class="button button-secondary" style="float: left; margin-right: 10px" type="submit" href="<?php echo admin_url( 'edit.php?post_type=clickfunnels' );?>"><i class="fa fa-file-text-o"></i> Pages</a>
436
  <a class="button button-secondary" style="float: left; margin-right: 10px" type="submit" href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=cf_api' );?>"><i class="fa fa-cog"></i> Settings</a>
437
  <a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>" class="button button-default" style="float: left;margin-right: 10px"><i class="fa fa-life-ring"></i> Support</a>
438
  <?php if ( !empty( $delete_link ) ) {?>
439
  <a class="button button-secondary" id="delete" type="submit" href="<?php echo $delete_link;?>"><i class="fa fa-trash"></i> Delete Page</a>
440
  <?php }?>
441
  </div>
442
  </div>
443
  </div>
444
  (function($) {
445
  setTimeout(function() {
446
  $('#cf_thepage').trigger( "change" );
447
  }, 1500);
448
  })(jQuery);
449
+
450
  $cf_thefunnel = get_post_meta( $_GET['post'], "cf_thefunnel", true );
451
  $cf_thepage = get_post_meta( $_GET['post'], "cf_thepage", true );
452
  $cf_iframe_check = get_post_meta( $_GET['post'], "cf_iframe_check", true );
453
  $cf_iframe_url = get_post_meta( $_GET['post'], "cf_iframe_url", true );
454
  $cf_seo_title = get_post_meta( $_GET['post'], "cf_seo_title", true );
455
  $cf_seo_desc = get_post_meta( $_GET['post'], "cf_seo_desc", true );
456
  $cf_seo_image = get_post_meta( $_GET['post'], "cf_seo_image", true );
457
 
458
  if ( !isset( $cf_page['page_id'] ) || $cf_page['page_id'] < 10 ) {
459
  $thepage = explode( "{#}", $cf_page );
460
  $savedData = $cf_page;
461
  }
462
  else {
463
  $thepage = explode( "{#}", $cf_page['page_id'] );
464
  $savedData = $cf_page['page_id'];
465
  }
466
  $cf_options = get_option( "cf_options" );
467
  jQuery(document).ready(function(){
468
  // Set Correct Options
469
  var thefunnel = jQuery('#cf_thefunnel').val();
470
  var specificFunnel = 'https://api.clickfunnels.com/funnels/'+thefunnel+'.json?email=<?php echo get_option( "clickfunnels_api_email" ); ?>&auth_token=<?php echo get_option( "clickfunnels_api_auth" ); ?>';
471
  jQuery('#cf_thepage').find('option').remove().end();
472
  jQuery('#loading').fadeIn();
473
  jQuery.getJSON(specificFunnel, function(data) {
474
  setTimeout(function() {
475
  jQuery('#loading').fadeOut();
476
  }, 2000);
477
  var is_selected = "";
478
  jQuery.each(data.funnel_steps, function() {
479
  if (this.pages != ''){
480
  if(this.pages[0].id == "<?php echo $thepage[2] ?>" && this.pages != '' ) {
481
  is_selected = "selected";
482
  jQuery('#cf_seo_tags').val(this.pages[0].metatags);
483
  } else {
484
  is_selected = "";
485
  }
486
  if ( this.wp_friendly == true && this.pages != '' ) {
487
  var baseurl = this.pages[0].published_url.split('.com/');
488
  var baseurlnew = baseurl[0]+'.com/'+this.path;
489
  jQuery('#iframeURL').val(baseurlnew);
490
  // Check if has split tests
491
  var splittestkeys = 'none';
492
  // if (this.pages.length == 2) {
493
  // splittestkeys = this.pages[0].key + '{|}' + this.pages[1].key;
494
  // }
495
  // else if (this.pages.length == 3) {
496
  // splittestkeys = this.pages[0].key + '{|}' + this.pages[1].key+ '{|}' + this.pages[2].key;
497
  // }
498
 
499
  pageKey = this.pages[0].key;
500
 
501
  jQuery('#cf_thepage').append('<option value="' + pageKey + '{#}' + this.pages[0].id + '{#}' + this.pages[0].funnel_step_id + '{#}' + encodeURI(this.pages[0].metatags) + '{#}<?php echo get_the_ID(); ?>{#}' + this.name +'{#}'+baseurlnew+'" '+is_selected+'>'+ this.name +'</option>');
502
  }
503
  }
504
  });
505
  }).done(function() {
506
  jQuery('#loading').fadeOut();
507
  var savedMeta = jQuery('#cf_thepage').val();
508
  if(savedMeta != undefined || savedMeta != null){
509
  savedMeta = savedMeta.split('{#}');
510
  jQuery('#jsmeta').val(savedMeta[3]);
511
  <?php if ( !empty( $_GET['action'] ) ) { ?>
512
  if (savedMeta[3] != jQuery('#oldmeta').val()){
513
  jQuery('#metaalreadyupdated').hide();
514
  jQuery('#showupdatemetalink').show();
515
  }
516
  <?php } ?>
517
  }
518
  <?php if ( empty( $_GET['action'] ) ) { ?>
519
  jQuery('#cf_thefunnel').prepend('<option value="" disabled selected>Select a Funnel</option>');
520
  <?php } ?>
521
  })
522
  .fail(function() {
523
  jQuery('#loading').fadeOut();
524
  })
525
  .always(function() {
526
  jQuery('#loading').fadeOut();
527
  });
528
  // Change Funnel Populate Dropdown
529
  jQuery( '#cf_thefunnel' ).change(function() {
530
  jQuery('#loading').fadeIn();
531
  var thefunnel = jQuery(this).val();
532
  var totalPages = 0;
533
  var specificFunnel = 'https://api.clickfunnels.com/funnels/'+thefunnel+'.json?email=<?php echo get_option( "clickfunnels_api_email" ); ?>&auth_token=<?php echo get_option( "clickfunnels_api_auth" ); ?>';
534
  jQuery('#cf_thepage').find('option').remove().end();
535
  jQuery.getJSON(specificFunnel, function(data) {
536
  setTimeout(function() {
537
  jQuery('#loading').fadeOut();
538
  }, 2000);
539
  // alert( specificFunnel);
540
  jQuery.each(data.funnel_steps, function() {
541
  if( this.wp_friendly == true && this.pages != '' ) {
542
  if (this.pages.length > 1) {
543
  jQuery('#usingSplitTests').show();
544
  } else {
545
  jQuery('#usingSplitTests').hide();
546
  }
547
 
548
  var baseurl = this.pages[0].published_url.split('.com/');
549
  var baseurlnew = baseurl[0]+'.com/'+this.path;
550
  jQuery('#iframeURL').val(baseurlnew);
551
  jQuery('#cf_thepage').append('<option value="' + this.pages[0].key + '{#}' + this.pages[0].id + '{#}' + this.pages[0].funnel_step_id + '{#}' + encodeURI(this.pages[0].metatags) + '{#}<?php echo get_the_ID(); ?>{#}' + this.name +'{#}'+baseurlnew+'">'+ this.name +'</option>');
552
 
553
 
554
  totalPages += 1;
555
  }
556
  });
557
 
558
  }).done(function() {
559
  jQuery('#loading').fadeOut();
560
  var savedMeta = jQuery('#cf_thepage').val();
561
  if(savedMeta != undefined || savedMeta != null){
562
  savedMeta = savedMeta.split('{#}');
563
  jQuery('#previewiframe').attr('src', savedMeta[6]+'?preview=true');
564
  }
565
  jQuery('#cf_thepage').trigger('change');
566
 
567
  if (totalPages == 0) {
568
  jQuery('#noPageWarning').fadeIn();
569
  jQuery('#cf_thepage').fadeOut();
570
  }
571
  else {
572
  jQuery('#noPageWarning').hide();
573
  jQuery('#cf_thepage').fadeIn();
574
  }
575
  var theposition = jQuery('#cf_thepage').val();
576
  jQuery('#cf_data').val(thefunnel+'{#}'+theposition);
577
  var myString = thefunnel+'{#}'+theposition;
578
  var arr = myString.split('{#}');
579
  // jQuery('#loadPageforUpdate').attr('src', 'https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true');
580
  var do_ping = function() {
581
  ping('https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true').then(function(delta) {
582
  }).catch(function(error) {
583
  });
584
  };
585
  do_ping();
586
  })
587
  .fail(function() {
588
  jQuery('#loading').fadeOut();
589
  })
590
  .always(function() {
591
  jQuery('#loading').fadeOut();
592
  });
593
  setTimeout(function() {
594
 
595
  }, 3000);
596
 
597
  });
598
  var request_image = function(url) {
599
  return new Promise(function(resolve, reject) {
600
  var img = new Image();
601
  img.onload = function() { resolve(img); };
602
  img.onerror = function() { reject(url); };
603
  img.src = url + '?random-no-cache=' + Math.floor((1 + Math.random()) * 0x10000).toString(16);
604
  });
605
  };
606
  /**
607
  * Pings a url.
608
  * @param {String} url
609
  * @return {Promise} promise that resolves to a ping (ms, float).
610
  */
611
  var ping = function(url) {
612
  return new Promise(function(resolve, reject) {
613
  var start = (new Date()).getTime();
614
  var response = function() {
615
  var delta = ((new Date()).getTime() - start);
616
  // HACK: Use a fudge factor to correct the ping for HTTP bulk.
617
  delta /= 4;
618
  resolve(delta);
619
  };
620
  request_image(url).then(response).catch(response);
621
  // Set a timeout for max-pings, 5s.
622
  setTimeout(function() { reject(Error('Timeout')); }, 5000);
623
  });
624
  };
625
  function replaceText(inputText, tagName, tagReplace) {
626
  var regExp = new RegExp('\\[' + tagName+ '\\]([^\\[]*)\\[\/' + tagName + '\\]', 'g');
627
  return inputText.replace(regExp, tagReplace);
628
  }
629
  // Select New Page
630
  jQuery( '#cf_thepage' ).change(function() {
631
  jQuery('#loading').fadeOut();
632
  var thefunnel = jQuery('#cf_thefunnel').val();
633
  var theposition = jQuery(this).val();
634
  jQuery('#cf_data').val(thefunnel+'{#}'+theposition);
635
  if(theposition != undefined || theposition != null){
636
  var myString = thefunnel+'{#}'+theposition;
637
  var arr = myString.split('{#}');
638
  var arr2 = theposition.split('{#}');
639
  // Iframe
640
  jQuery('#iframeURL').val(arr2[6]);
641
  var myStr = arr2[3];
642
  // Browser title
643
  var subStr = myStr.match("%3Ctitle%3E(.*)%3C/title%3E");
644
 
645
  jQuery('#seoTitle').val(subStr[1].replace(/%20/g, ' '));
646
 
647
  // SEO Desc
648
  var subStr = myStr.match("description%22%20content=%22(.*)%22%3E%3Cmeta%20class=%22metaTagTop%22%20name=%22keywo");
649
  jQuery('#seoDesc').val(subStr[1].replace(/%20/g, ' '));
650
  // SEO Share Image
651
  var subStr = myStr.match("rty=%22og:image%22%20content=%22(.*)%22%20id=%22social-image%22%3E");
652
  jQuery('#seosocial').val(subStr[1]);
653
  // jQuery('#loadPageforUpdate').attr('src', 'https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true');
654
  var do_ping = function() {
655
  ping('https://api.clickfunnels.com/s3_proxy/'+arr[1]+'?preview=true').then(function(delta) {
656
  }).catch(function(error) {
657
  });
658
  };
659
  do_ping();
660
  jQuery('#previewiframe').attr('src', arr[7]+'?preview=true');
661
  }
662
 
663
  });
664
  // Fade Out Message
665
  setTimeout(function() {
666
  jQuery('#message').fadeOut();
667
  }, 3500);
668
  // Savings
669
  jQuery('#publish').click(function() {
670
  jQuery('#saving').fadeIn();
671
  });
672
  jQuery('#delete').on('click', function () {
673
  return confirm('Are you sure you want to delete this page?');
674
  });
675
  jQuery('#cf_slug').bind('keyup keypress blur', function()
676
  {
677
  var myStr = jQuery(this).val()
678
  myStr=myStr.toLowerCase();
679
  myStr=myStr.replace(/\s/g , "-");
680
  jQuery('#cf_slug').val(myStr);
681
  });
682
  // Check Null and Resave v1.0.6
683
  <?php if ($thepage[1] == 'null') { ?>
684
  // jQuery('#autosaving').fadeIn();
685
  // setTimeout(function() {
686
  // jQuery('form').submit();
687
  // }, 2000);
688
  <?php } ?>
689
  jQuery('#showupdatemetalink').click(function() {
690
  jQuery('form').submit();
691
  });
692
 
693
  });
694
  if ( $cf_page != "" ) {
695
  $json = get_file_content( 'https://api.clickfunnels.com/funnels/'.$cf_thefunnel.'.json?email='.get_option( 'clickfunnels_api_email' ).'&auth_token='.get_option( 'clickfunnels_api_auth' ) );
696
  $cf_funnels_pages = json_decode( $json );
697
  }
698
  <h4><i class="fa fa-times"></i> Uh oh, your page did not save correctly.</h4>
699
  <h2>Saving and Reloading...</h2>
700
  <h1><i class="fa fa-cog fa-spin"></i></h1>
701
  <img src="<?php echo plugins_url( 'logo.png', __FILE__ ); ?>" alt="">
702
  <a href="https://www.app.clickfunnels.com/funnels" target="_blank" class=""><i class="fa fa-bars"></i> My Account</a>
703
  <br clear="all">
704
  <?php if ( !empty( $_GET['action'] ) ) { ?>
705
  <?php if ( $cf_type=='p' ) {?>
706
  <a style="margin-right: -3px;" href="https://www.clickfunnels.com/pages/<?php echo $thepage[2]; ?>" target="_blank" class="editThisPage"><i class="fa fa-edit"></i> Open Editor</a>
707
  <a style="margin-right: 10px;" href="https://www.clickfunnels.com/funnels/<?php echo $thepage[0]; ?>#<?php echo $thepage[3]; ?>" target="_blank" class="editThisPage"><i class="fa fa-cogs"></i> View Funnel</a>
708
  <a style="margin-right: 10px;" href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>" title="View Page" target="_blank" class="editThisPage"><i class="fa fa-search"></i> Preview</a>
709
  <h2><?php foreach ( $cf_funnels as $key=>$funnel ) { ?>
710
  <?php if ( $cf_thefunnel == $funnel->id ) { if(strlen($funnel->name) > 30) { echo substr($funnel->name,0,30).'...'; } else { echo $funnel->name;} } } ?></h2>
711
 
712
  <a href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>" title="View Page" target="_blank"> <?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?></a>
713
  <?php }?>
714
  <?php if ( $cf_type=='hp' ) {?>
715
  <a href="https://www.clickfunnels.com/pages/<?php echo $thepage[2]; ?>" target="_blank" class="editThisPage"><i class="fa fa-edit"></i> Launch in Editor</a>
716
  <a style="margin-right: 10px;" href="https://www.clickfunnels.com/funnels/<?php echo $thepage[0]; ?>#<?php echo $thepage[3]; ?>" target="_blank" class="editThisPage"><i class="fa fa-cogs"></i> Edit Funnel</a>
717
  <a style="margin-right: 10px;" href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>" title="View Page" target="_blank" class="editThisPage"><i class="fa fa-search"></i> View Page</a>
718
  <h2>Set as Home Page</h2>
719
  <a href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>" title="View Page" target="_blank"><i class="fa fa-search"></i> <?php echo get_option( 'clickfunnels_siteURL' ) ; ?></a>
720
  <?php }?>
721
  <?php if ( $cf_type=='np' ) {?>
722
  <a href="https://www.clickfunnels.com/pages/<?php echo $thepage[2]; ?>" target="_blank" class="editThisPage"><i class="fa fa-edit"></i> Launch in Editor</a>
723
  <a style="margin-right: 10px;" href="https://www.clickfunnels.com/funnels/<?php echo $thepage[0]; ?>#<?php echo $thepage[3]; ?>" target="_blank" class="editThisPage"><i class="fa fa-cogs"></i> Edit Funnel</a>
724
  <a style="margin-right: 10px;" href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/<?php echo $cf_slug; ?>/invalid-url-404-testing" title="View Page" target="_blank" class="editThisPage"><i class="fa fa-search"></i> View Page</a>
725
  <h2>Set as 404 Page</h2>
726
  <a href="<?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/invalid-url" title="View Page" target="_blank"><i class="fa fa-search"></i> <?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/invalid-url</a>
727
  <?php }?>
728
  <?php if ( $cf_type=='' ) {?>
729
  <h2>Page Undefined - Try saving your page again.</h2>
730
  <?php }?>
731
  <?php if ( $cf_type=='noapi' ) {?>
732
  <h2>No API Fallback</h2>
733
  <?php }?>
734
  <?php } else { ?>
735
  <h2 style="font-size: 17px;">Add ClickFunnels Page to Your Blog</h2>
736
  <?php } ?>
737
  <h4>You haven't setup your API settings. <a href="../wp-admin/edit.php?post_type=clickfunnels&page=cf_api">Click here to setup now.</a></h4>
738
  <iframe src="<?php echo $cf_iframe_url; ?>" style="width: 1280px;height: 750px;-ms-zoom: 0.20; -moz-transform: scale(0.20); -moz-transform-origin: 0 0; -o-transform: scale(0.20); -o-transform-origin: 0 0; -webkit-transform: scale(0.20); -webkit-transform-origin: 0 0;" frameborder="0" id="previewiframe"></iframe>
739
  </div> -->
740
  <input type="hidden" name="post_title" size="30" tabindex="1" value="ClickFunnels Page" id="title" autocomplete="off" />
741
  <input type="hidden" name="post_status" size="30" tabindex="1" value="publish" id="title" autocomplete="off" />
742
  <div class="bootstrap-wp" style=" border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;"><?php wp_nonce_field( "save_clickfunnel", "clickfunnel_nonce" ); ?>
743
  <div class="row-fluid form-horizontal">
744
  <br>
745
  <a style="float: right;position:relative;z-index: 999999;margin-right: 8px" class="btn pageSettings">Page Settings</a>
746
 
747
  <div class="control-group" style="margin-left: -10px; margin-bottom: 20px !important">
748
  <div data-target="cf_type" class="btn-group multichoice cf_header">
749
  <a data-value="p" class="btn <?php if ( $cf_type=='p' || $cf_type=='') {?> active btn-selected<?php }?>">Regular Page</a>
750
  <a data-value="hp" class="btn <?php if ( $cf_type=='hp' ) {?> active btn-selected<?php }?>">Home Page</a>
751
  <a data-value="np" class="btn <?php if ( $cf_type=='np' ) {?> active btn-selected<?php }?>">404 Page</a>
752
  <!-- <a data-value="shortcode" class="btn <?php if ( $cf_type=='shortcode' ) {?> active btn-selected<?php }?>">Shortcode</a> -->
753
  </div>
754
  <input type="hidden" id="cf_type" name="cf_type"/>
755
  </div>
756
  <div class="control-group cf_uses_api" style="">
757
  <label class="control-label" for="cf_thefunnel"> Choose Funnel <i class="fa fa-filter"></i></label>
758
  <div class="controls">
759
  <select class="input-xlarge" id="cf_thefunnel" name="cf_thefunnel_backup">
760
  <?php if ( empty( $cf_funnels ) ) { ?>
761
  <option value="0">No Funnels Found</option>
762
  <?php }
763
  else {
764
  foreach ( $cf_funnels as $key=>$funnel ) { ?>
765
  <option value="<?php echo $funnel->id;?>" <?php if ( $cf_thefunnel == $funnel->id ) { echo "selected"; } ?>><?php echo $funnel->name;?></option>
766
  <?php
767
  }
768
  } ?>
769
  </select>
770
  </div>
771
  </div>
772
  <div id="usingSplitTests" style="display: none">
773
  Using split tests
774
  </div>
775
  <div class="control-group cf_uses_api">
776
  <label class="control-label" for="cf_thepage"> Choose Page <i class="fa fa-file-o"></i></label>
777
  <div class="controls">
778
  <select class="input-xlarge" id="cf_thepage" name="cf_thepage" style="float: left;">
779
  <?php if ( empty( $cf_funnels_pages ) ) { ?>
780
  <option value="0">No Pages Found</option>
781
  <?php }
782
  else {
783
  foreach ( $cf_funnels_pages->funnel_steps as $key => $funnel ) { ?>
784
  <option value="<?php echo $funnel->position;?>" <?php if ( $cf_thepage == $funnel->position ) { echo "selected"; } ?>><?php echo $funnel->name;?></option>
785
  <?php
786
  }
787
  }
788
  ?>
789
  </select>
790
  <i class="fa fa-spinner fa-spin" id="loading"></i>
791
  </div>
792
  <div id="noPageWarning" style="font-size: 11px; margin-left: 160px;margin-top: -33px;float: left;padding-top: 10px;display: none;width: 100%; clear: both"><em>No compatible pages found for this funnel.</em></div>
793
  </div>
794
  <div class="control-group cf_no_api" >
795
  <label class="control-label" for="cf_iframe_check"> ClickFunnels URL <i class="fa fa-globe"></i></label>
796
  <div class="controls">
797
  <input type="text" class="input-xlarge" id="iframeURL" style="height: 30px;" value="<?php echo $cf_iframe_url; ?>" name="cf_iframe_url" />
798
  </div>
799
  </div>
800
  <div class="control-group cf_no_api" >
801
  <label class="control-label" for="cf_iframe_check"> Website Title <i class="fa fa-globe"></i></label>
802
  <div class="controls">
803
  <input type="text" class="input-xlarge" id="seoTitle" style="height: 30px;" value="<?php echo $cf_seo_title; ?>" name="cf_seo_title" />
804
  </div>
805
  </div>
806
  <div class="control-group cf_no_api" >
807
  <label class="control-label" for="cf_iframe_check"> Description <i class="fa fa-globe"></i></label>
808
  <div class="controls">
809
  <input type="text" class="input-xlarge" id="seoDesc" style="height: 30px;" value="<?php echo $cf_seo_desc; ?>" name="cf_seo_desc" />
810
  </div>
811
  </div>
812
  <div class="control-group cf_no_api" >
813
  <label class="control-label" for="cf_iframe_check"> Social Image URL <i class="fa fa-globe"></i></label>
814
  <div class="controls">
815
  <input type="text" class="input-xlarge" id="seosocial" style="height: 30px;" value="<?php echo $cf_seo_image; ?>" name="cf_seo_image" />
816
  </div>
817
  </div>
818
 
819
 
820
  <div class="control-group cf_uses_api" >
821
  <label class="control-label" for="cf_iframe_check"> Cookie Split Tests <i class="fa fa-bar-chart"></i></label>
822
  <div class="controls">
823
  <select class="input-xlarge" id="cf_iframe_check" name="cf_iframe_check" style="float: left;">
824
  <option value="off">Show random cookied version</option>
825
  <option value="on" <?php if( $cf_iframe_check == 'on') { ?>selected <?php } ?>>Show page in iframe (don't cookie)</option>
826
  </select>
827
  <!-- <small style="float: left;font-size: 11px;padding: 5px;margin-left: 6px"><a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>">What is this?</a></small> -->
828
  </div>
829
  </div>
830
  <?php if ( !empty( $_GET['action'] ) ) { ?>
831
  <div class="control-group cf_uses_api" style="margin-bottom: 20px">
832
  <label class="control-label" for="cf_iframe_check"> Meta Data <i class="fa fa-info"></i></label>
833
  <a href="#" style="margin-left: 20px;margin-top: 5px;display: block;float: left;display: none" id="showupdatemetalink"><i class="fa fa-refresh"></i> Meta Data is Out Dated -- Click to Update</a>
834
  <span style="margin-left: 20px;margin-top: 5px;display: block;float: left" id="metaalreadyupdated"><i class="fa fa-check"></i> Meta Data is Up to Date</span>
835
  </div>
836
  <?php } else { ?>
837
  <div class="control-group cf_uses_api" style="margin-bottom: 20px">
838
  <label class="control-label" for="cf_iframe_check"> Meta Data <i class="fa fa-info"></i></label>
839
 
840
  <span style="margin-left: 20px;margin-top: 5px;display: block;float: left" id="metaalreadyupdated"><i class="fa fa-check"></i> Meta Data is Up to Date</span>
841
  </div>
842
  <?php } ?>
843
  <?php if ( $cf_type!="p" ) $display ="display:none"; else $display="";?>
844
  <div class="cf_url control-group" style="<?php echo $display;?>" >
845
  <label class="control-label" for="cf_slug"> Custom URL <i class="fa fa-globe"></i></label>
846
  <div id="cf-wp-path" class="controls ">
847
  <div class="input-prepend">
848
  <span class="add-on" style="font-size: 13px;padding: 4px 10px; background: #ECEEEF; color: #777; text-shadow: none; border: 1px solid #ccc"><?php echo get_option( 'clickfunnels_siteURL' ) ; ?>/</span><input style="height:28px;width: 150px !important" type="textbox" value="<?php if ( isset( $cf_slug ) ) echo $cf_slug;?>" name="cf_slug" id="cf_slug" class="input-xlarge">
849
  <div style="color:red; display:none" id="cf_invalid_slug" style="width: 90%" >You must enter an URL</div>
850
  </div>
851
  </div>
852
  </div>
853
 
854
 
855
 
856
  <style>
857
  #hiddenStuff {display: none}
858
  </style>
859
  <div class="control-group" id="hiddenStuff" <?php if ( !empty( $_GET['cf'] ) ) { ?>style="display: block" <?php } ?>>
860
  <div class="controls">
861
  <strong>Funnel ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[0]; ?>" /> <br></strong>
862
  <strong>Page Key: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[1]; ?>" /><br></strong>
863
  <strong>Page ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[2]; ?>" /><br></strong>
864
  <strong>Funnel Step ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[3]; ?>" /><br></strong>
865
  <strong>Saved Meta: <input type="text" style="font-weight: normal;width: 300px;" id="oldmeta" value="<?php echo $thepage[4]; ?>" /><br></strong>
866
  <strong>JS Meta: <input type="text" style="font-weight: normal;width: 300px;" id="jsmeta" value="" /><br></strong>
867
  <strong>Post ID: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[5]; ?>" /><br></strong>
868
  <strong>Page Name: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $thepage[6]; ?>" /><br></strong>
869
  <strong>Use iframe?: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $cf_iframe_check; ?>" /><br></strong>
870
  <strong>Iframe URL: <input type="text" style="font-weight: normal;width: 300px;" value="<?php echo $cf_iframe_url; ?>" /><br></strong>
871
  <textarea name="cf_thefunnel" id="cf_data" style="width: 400px;height: 300px; font-size: 13px;"><?php echo $savedData; ?></textarea>
872
  </div>
873
  </div>
874
 
875
  <!-- <div style="background: #fafafa;border-top: 1px solid #eee;padding: 10px;text-align: center;margin: 10px 0px;margin-bottom: 20px" >
876
  <strong style="color: #777"> Running split tests or custom code on your page? Check here
877
  <input type="checkbox" id="useIframe" value="on" <?php if( $cf_iframe_check == 'on') { ?>checked <?php } ?> style="margin: 0 3px;width: 18px;height: 18px;" name="cf_iframe_check"> to activate settings.</strong>
878
  <small style="display: block;font-size: 11px;opacity: .5"><a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>">Why do you have to activate settings?</a></small>
879
  <input type="text" style="display: none;" id="iframeURL" value="<?php echo $cf_iframe_url; ?>" name="cf_iframe_url" />
880
  </div> -->
881
  <!-- <div class="p_text helpinfo" <?php if ( $cf_type!='p' ) {?> style="display: none" <?php }?>>
882
  <h4><i class="fa fa-question-circle"></i> Set as a Page</h4>
883
  <p>Choose any ClickFunnels page to be shown using a custom URL just select any funnel to refresh the list of pages. Create a custom URL and hit 'Save/Publish' to start sending traffic. <a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>">Need more help?</a> </p>
884
  <p style="font-size: 11px;opacity: .7;"><i class="fa fa-exclamation-triangle"></i> If you change META data in editor, refresh page and hit 'Save Changes' to update meta data.</p>
885
  </div>
886
  <div class="hp_text helpinfo" <?php if ( $cf_type!='hp' ) {?> style="display: none" <?php }?>>
887
  <h4><i class="fa fa-question-circle"></i> Set as Home Page</h4>
888
  <p> Replace your homepage with a specific ClickFunnels page. You can show any page that you want, this will replace any other homepage settings you may have.</p>
889
  <p style="font-size: 11px;opacity: .7"><i class="fa fa-exclamation-triangle"></i> If you change META data in editor, refresh page and hit 'Save Changes' to update meta data.</p>
890
  </div>
891
  <div class="np_text helpinfo" <?php if ( $cf_type!='np' ) {?> style="display: none" <?php }?>>
892
  <h4><i class="fa fa-question-circle"></i> Set as 404 Page</h4>
893
  <p> Show a specific page to be shown on any "Page not Found" such as a misspelled URL or a deleted blog post. Very good place for a squeeze page to get the most out of your traffic.</p>
894
  <p style="font-size: 11px;opacity: .7"><i class="fa fa-exclamation-triangle"></i> If you change META data in editor, refresh page and hit 'Save Changes' to update meta data.</p>
895
  </div> -->
896
  <div class="row-fluid" id="apiFooter">
897
  <?php if ( get_option( 'clickfunnels_api_email' ) == "" || get_option( 'clickfunnels_api_auth' ) == "" ) { ?>
898
  <button id="publish" name="publish" disabled class="button button-primary " style="float: right; ">
899
  <?php if ( !empty( $_GET['action'] ) ) { echo "<i class='fa fa-save'></i> Save Changes"; } else { echo "<i class='fa fa-save'></i> Publish Page"; } ?>
900
  </button>
901
  <?php } else { ?>
902
  <button id="publish" name="publish" class="button button-primary " style="float: right; ">
903
  <?php if ( !empty( $_GET['action'] ) ) { echo "<i class='fa fa-save'></i> Save Changes"; } else { echo "<i class='fa fa-save'></i> Publish Page"; } ?>
904
  </button>
905
  <?php } ?>
906
  <div id="saving" style="float: right;display: none; padding-right: 10px;opacity: .6;padding-top: 5px;">
907
  <i class="fa fa-spinner fa-spin"></i>
908
  <span>Saving...</span>
909
  </div>
910
  <a class="button button-secondary" style="float: left; margin-right: 10px" type="submit" href="<?php echo admin_url( 'edit.php?post_type=clickfunnels' );?>"><i class="fa fa-file-text-o"></i> Pages</a>
911
  <a class="button button-secondary" style="float: left; margin-right: 10px" type="submit" href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=cf_api' );?>"><i class="fa fa-cog"></i> Settings</a>
912
  <a href="<?php echo admin_url( 'edit.php?post_type=clickfunnels&page=clickfunnels_support' );?>" class="button button-default" style="float: left;margin-right: 10px"><i class="fa fa-life-ring"></i> Support</a>
913
  <?php if ( !empty( $delete_link ) ) {?>
914
  <a class="button button-secondary" id="delete" type="submit" href="<?php echo $delete_link;?>"><i class="fa fa-trash"></i> Delete Page</a>
915
  <?php }?>
916
  </div>
917
  </div>
918
  </div>
919
  (function($) {
920
  setTimeout(function() {
921
  $('#cf_thepage').trigger( "change" );
922
  }, 1500);
923
  })(jQuery);
clickfunnels.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: ClickFunnels
4
  * Plugin URI: https://www.clickfunnels.com
5
  * Description: Connect to your ClickFunnels account with simple authorization key and show any ClickFunnels page as your homepage or as 404 error pages or simply choose any of your pages and make clean URLs to your ClickFunnels pages. Don't have an account? <a target="_blank" href="https://www.clickfunnels.com">Sign up for your 2 week <em>free</em> trial now.</a>
6
- * Version: 1.1.0
7
  * Author: Etison, LLC
8
  * Author URI: https://www.clickfunnels.com
9
  */
@@ -72,13 +72,13 @@ class ClickFunnels {
72
  // echo $thepage[0] . "<br/> position:"; // funnel ID
73
  // echo $thepage[1]; // page position
74
 
75
- echo $this->get_page_html( $thepage[0], $thepage[1], $thepage[4], $thepage[5] );
76
  exit();
77
  } else if ( is_404() ) {
78
  $page = $this->get_404();
79
  if ( !empty( $page['post_id'] ) ) {
80
  $thepage = explode( "{#}", $page['page_id'] );
81
- echo $this->get_page_html( $thepage[0], $thepage[1], $thepage[4], $thepage[5] );
82
  exit();
83
  }
84
  else if (get_option( 'clickfunnels_404Redirect' ) == 'yesRedirect') {
@@ -89,7 +89,7 @@ class ClickFunnels {
89
  $page = $this->get_home();
90
  if ( !empty( $page['post_id'] ) ) {
91
  $thepage = explode( "{#}", $page['page_id'] );
92
- echo $this->get_page_html( $thepage[0], $thepage[1], $thepage[4], $thepage[5] );
93
  exit();
94
  }
95
  }
@@ -194,10 +194,10 @@ class ClickFunnels {
194
  return $cf_funnels;
195
  }
196
  }
197
- public function get_page_html( $funnel_id, $position, $meta, $postid ) {
198
  $page_html = get_transient( "cf_page_html_{$funnel_id}" );
199
  if (get_post_meta( $postid, "cf_iframe_check", true ) == 'on') {
200
- $page_html = $this->api->get_page_iframe( get_post_meta( $postid, "cf_iframe_url", true ), $meta, get_post_meta( $postid, "cf_seo_title", true ), get_post_meta( $postid, "cf_seo_desc", true ), get_post_meta( $postid, "cf_seo_image", true ) );
201
  return $page_html;
202
  }
203
  else {
@@ -205,7 +205,7 @@ class ClickFunnels {
205
  return $page_html;
206
  }
207
  else {
208
- $page_html = $this->api->get_page_html( $funnel_id, $position, $meta, get_post_meta( $postid, "cf_seo_title", true ), get_post_meta( $postid, "cf_seo_desc", true), get_post_meta( $postid, "cf_seo_image", true ), get_post_meta( $postid, "cf_iframe_url", true ) );
209
  return $page_html;
210
  }
211
  }
@@ -483,16 +483,17 @@ add_action('admin_enqueue_scripts', 'clickfunnels_loadjquery');
483
  $api = new CF_API();
484
  $click = new ClickFunnels( $api );
485
 
486
- function cf_get_file_contents ($url) {
487
- if (function_exists('curl_exec')){
 
 
 
488
  $conn = curl_init($url);
489
  curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, true);
490
  curl_setopt($conn, CURLOPT_FRESH_CONNECT, true);
491
  curl_setopt($conn, CURLOPT_RETURNTRANSFER, 1);
492
  $url_get_contents_data = (curl_exec($conn));
493
  curl_close($conn);
494
- }elseif(function_exists('file_get_contents')){
495
- $url_get_contents_data = file_get_contents($url);
496
  }elseif(function_exists('fopen') && function_exists('stream_get_contents')){
497
  $handle = fopen ($url, "r");
498
  $url_get_contents_data = stream_get_contents($handle);
@@ -503,6 +504,52 @@ return $url_get_contents_data;
503
  }
504
 
505
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
506
 
507
 
508
 
3
  * Plugin Name: ClickFunnels
4
  * Plugin URI: https://www.clickfunnels.com
5
  * Description: Connect to your ClickFunnels account with simple authorization key and show any ClickFunnels page as your homepage or as 404 error pages or simply choose any of your pages and make clean URLs to your ClickFunnels pages. Don't have an account? <a target="_blank" href="https://www.clickfunnels.com">Sign up for your 2 week <em>free</em> trial now.</a>
6
+ * Version: 1.1.1
7
  * Author: Etison, LLC
8
  * Author URI: https://www.clickfunnels.com
9
  */
72
  // echo $thepage[0] . "<br/> position:"; // funnel ID
73
  // echo $thepage[1]; // page position
74
 
75
+ echo $this->get_page_html( $thepage[0], $thepage[1], $thepage[4], $thepage[5], $socialurl,$thepage[0] );
76
  exit();
77
  } else if ( is_404() ) {
78
  $page = $this->get_404();
79
  if ( !empty( $page['post_id'] ) ) {
80
  $thepage = explode( "{#}", $page['page_id'] );
81
+ echo $this->get_page_html( $thepage[0], $thepage[1], $thepage[4], $thepage[5], $socialurl,$thepage[0] );
82
  exit();
83
  }
84
  else if (get_option( 'clickfunnels_404Redirect' ) == 'yesRedirect') {
89
  $page = $this->get_home();
90
  if ( !empty( $page['post_id'] ) ) {
91
  $thepage = explode( "{#}", $page['page_id'] );
92
+ echo $this->get_page_html( $thepage[0], $thepage[1], $thepage[4], $thepage[5], $socialurl,$thepage[0] );
93
  exit();
94
  }
95
  }
194
  return $cf_funnels;
195
  }
196
  }
197
+ public function get_page_html( $funnel_id, $position, $meta, $postid, $socialurl,$thepage ) {
198
  $page_html = get_transient( "cf_page_html_{$funnel_id}" );
199
  if (get_post_meta( $postid, "cf_iframe_check", true ) == 'on') {
200
+ $page_html = $this->api->get_page_iframe( get_post_meta( $postid, "cf_iframe_url", true ), $meta, get_post_meta( $postid, "cf_seo_title", true ), get_post_meta( $postid, "cf_seo_desc", true ), get_post_meta( $postid, "cf_seo_image", true ), $postid );
201
  return $page_html;
202
  }
203
  else {
205
  return $page_html;
206
  }
207
  else {
208
+ $page_html = $this->api->get_page_html( $funnel_id, $position, $meta, get_post_meta( $postid, "cf_seo_title", true ), get_post_meta( $postid, "cf_seo_desc", true), get_post_meta( $postid, "cf_seo_image", true ), get_post_meta( $postid, "cf_iframe_url", true ), $socialurl,$thepage );
209
  return $page_html;
210
  }
211
  }
483
  $api = new CF_API();
484
  $click = new ClickFunnels( $api );
485
 
486
+ function cf_get_file_contents ($url) {
487
+ if(function_exists('file_get_contents')){
488
+ $url_get_contents_data = file_get_contents($url);
489
+ }
490
+ elseif (function_exists('curl_exec')){
491
  $conn = curl_init($url);
492
  curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, true);
493
  curl_setopt($conn, CURLOPT_FRESH_CONNECT, true);
494
  curl_setopt($conn, CURLOPT_RETURNTRANSFER, 1);
495
  $url_get_contents_data = (curl_exec($conn));
496
  curl_close($conn);
 
 
497
  }elseif(function_exists('fopen') && function_exists('stream_get_contents')){
498
  $handle = fopen ($url, "r");
499
  $url_get_contents_data = stream_get_contents($handle);
504
  }
505
 
506
 
507
+ function get_file_content($url, $forceCURL = false)
508
+ {
509
+ $internalServerURL = 'http://' . $_SERVER['SERVER_NAME'];
510
+ $internalSecureServerURL = 'https://' . $_SERVER['SERVER_NAME'];
511
+
512
+ $externalURL = strpos('http', $url) === 0 && !(strpos($internalServerURL, $url) === 0 || strpos($internalSecureServerURL, $url) === 0);
513
+
514
+ if($externalURL && !ini_get('allow_url_fopen'))
515
+ {
516
+ return 'ERROR: Reading content from external URLs is not allowed on this server. Please contact your administrator or provider to resolve this issue!';
517
+ }
518
+
519
+ if(!defined('CONTENTMETHOD'))
520
+ {
521
+ $contentMethod = false;
522
+ if(file_get_contents(__FILE__))
523
+ {
524
+ $contentMethod = 'file';
525
+ }
526
+ else if(function_exists('curl_version'))
527
+ {
528
+ $contentMethod = 'curl';
529
+ }
530
+ define('CONTENTMETHOD', $contentMethod);
531
+ }
532
+ if(!CONTENTMETHOD)
533
+ {
534
+ return false;
535
+ }
536
+ $content = '';
537
+ if(CONTENTMETHOD === 'file' && !$forceCURL)
538
+ {
539
+ $content = file_get_contents($url);
540
+ }
541
+ else
542
+ {
543
+ $ch = curl_init();
544
+ curl_setopt($ch, CURLOPT_URL, $url);
545
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
546
+ $content = curl_exec($ch);
547
+ curl_close($ch);
548
+ }
549
+ return $content;
550
+ }
551
+
552
+
553
 
554
 
555
 
css/admin.css CHANGED
@@ -295,7 +295,8 @@
295
  text-align: right;
296
  }
297
  .bootstrap-wp .input-xlarge {
298
- width: 290px !important;
 
299
  }
300
  .cf_no_api {
301
  display: none;
295
  text-align: right;
296
  }
297
  .bootstrap-wp .input-xlarge {
298
+ width: 576px !important;
299
+ margin-right: 20px;
300
  }
301
  .cf_no_api {
302
  display: none;
footer.php CHANGED
@@ -1,5 +1,5 @@
1
  <div class="copyrightInfo">
2
- <p><strong style="float: right;margin-right: 20px;font-weight: 200">Running version 1.1.0</strong> Copyright 2015+ &copy; Eitson, LLC</p>
3
  </div>
4
  <style>
5
  .copyrightInfo {
1
  <div class="copyrightInfo">
2
+ <p><strong style="float: right;margin-right: 20px;font-weight: 200">Running version 1.1.1</strong> Copyright 2015+ &copy; Eitson, LLC</p>
3
  </div>
4
  <style>
5
  .copyrightInfo {
readme.txt CHANGED
@@ -6,7 +6,7 @@ Author URI: https://profiles.wordpress.org/clickfunnelscom
6
  Tags: landing pages, clickfunnels, funnels, sales funnel, optin, internet marketing
7
  Requires at least: 3.0
8
  Tested up to: 4.3.1
9
- Stable tag: 1.1.0
10
 
11
  Connect your ClickFunnels pages to your WordPress blog. Create custom pages, set as homepage or 404 page with easy setup.
12
 
@@ -98,6 +98,12 @@ By re-selecting the page it will ping the server which should refresh your page.
98
 
99
  Stay current with the latest version of the plugin:
100
 
 
 
 
 
 
 
101
  = Version 1.1.0 =
102
 
103
  * Added mini preview of chosen page
6
  Tags: landing pages, clickfunnels, funnels, sales funnel, optin, internet marketing
7
  Requires at least: 3.0
8
  Tested up to: 4.3.1
9
+ Stable tag: 1.1.1
10
 
11
  Connect your ClickFunnels pages to your WordPress blog. Create custom pages, set as homepage or 404 page with easy setup.
12
 
98
 
99
  Stay current with the latest version of the plugin:
100
 
101
+ = Version 1.1.1 =
102
+
103
+ * Added WordPress URL to social meta data (facebook open graph)
104
+ * Fix split tests and cookies
105
+ * New function for curl, file_get_contents fallback
106
+
107
  = Version 1.1.0 =
108
 
109
  * Added mini preview of chosen page