PluginProbe
Visual Website Optimizer / 2.8
Visual Website Optimizer v2.8
trunk 1.0 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.10 All 37 releases
← All changes | visual-website-optimizer.php +52 -172 3.92.8 View file →
@@ -1,13 +1,13 @@
1 1 <?php
2 2 /*
3 3 Plugin Name: VWO
4 4 Plugin URI: https://vwo.com/
5 -Description: VWO is the all-in-one platform that helps you conduct visitor research, build an optimization roadmap, and run continuous experimentation. Simply enable the plugin and start running tests on your Wordpress website without doing any other code changes. Visit <a href="https://vwo.com/">VWO</a> for more details.
6 -Author: VWO
7 -Version: 3.9
5 +Description: VWO is the all-in-one platform that helps you conduct visitor research, build an optimization roadmap, and run continuous experimentation. Simply enable the plugin and start running tests on your Wordpress website without doing any other code changes. Visit <a href="https://vwo.com/">Visual Website Optimizer</a> for more details.
6 +Author: Wingify
7 +Version: 2.8
8 8 visual-website-optimizer.php
9 -Author URI: https://vwo.com/
9 +Author URI: https://wingify.com
10 10
11 11 This relies on the actions being present in the themes header.php and footer.php
12 12 * header.php code before the closing </head> tag
13 13 * wp_head();
@@ -17,96 +17,39 @@
17 17 //------------------------------------------------------------------------//
18 18 //---Config---------------------------------------------------------------//
19 19 //------------------------------------------------------------------------//
20 20
21 -/**
22 - * Generate Common Code
23 - * @param type $vwo_id integer
24 - * @return type string
25 - */
26 -function get_vwo_clhf_script_common_code($vwo_clicks = 10) {
27 - ob_start();
28 - ?>
29 - <!-- Start VWO Common Smartcode -->
30 - <script <?php echo vwo_clhf_ignore_js_attr(); ?> type='text/javascript'>
31 - var _vwo_clicks = <?php echo $vwo_clicks ?>;
32 - </script>
33 - <!-- End VWO Common Smartcode -->
34 - <?php
35 - $script_code = ob_get_clean();
36 - return $script_code;
37 -}
21 +$clhf_header_script_sync = '
22 +<!-- Start VWO Code -->
23 +<script type=\'text/javascript\'>
24 +var _vis_opt_account_id = VWO_ID;
25 +var _vis_opt_protocol = ((\'https:\' == document.location.protocol) ? \'https://\' : \'http://\');
26 +document.write(\'<s\' + \'cript src="\' + _vis_opt_protocol + \'dev.visualwebsiteoptimizer.com/deploy/js_visitor_settings.php?v=1&a=\'+_vis_opt_account_id+\'&url=\'+encodeURIComponent(document.URL)+\'&random=\'+Math.random()+\'" type="text/javascript">\' + \'<\/s\' + \'cript>\');
27 +</script>
28 +<script type=\'text/javascript\'>
29 +if(typeof(_vis_opt_settings_loaded) == "boolean") { document.write(\'<s\' + \'cript src="\' + _vis_opt_protocol + \'d5phz18u4wuww.cloudfront.net/vis_opt.js" type="text/javascript">\' + \'<\/s\' + \'cript>\'); }
30 +</script>
31 +<script type=\'text/javascript\'>
32 +if(typeof(_vis_opt_settings_loaded) == "boolean" && typeof(_vis_opt_top_initialize) == "function"){ _vis_opt_top_initialize();
33 +vwo_$(document).ready(function() { _vis_opt_bottom_initialize(); }); }
34 +</script>
35 +<!-- End VWO Code -->
36 +';
38 37
39 -/**
40 - * Get ignore js field setting
41 - * @return type boolean
42 - */
43 -function get_vwo_clhf_ignore_js(){
44 - $ignore_js = get_option('ignore_js');
45 - $ignore_js = ($ignore_js == '1') ? true : false;
46 - return $ignore_js;
47 -}
38 +$clhf_header_script_async = '
39 +<!-- Start VWO Asynchronous Code -->
40 +<script type=\'text/javascript\'>
41 +var _vwo_code=(function(){
42 +var account_id=VWO_ID,
43 +settings_tolerance=SETTINGS_TOLERANCE,
44 +library_tolerance=LIBRARY_TOLERANCE,
45 +use_existing_jquery=false,
46 +f=false,d=document;return{use_existing_jquery:function(){return use_existing_jquery;},library_tolerance:function(){return library_tolerance;},finish:function(){if(!f){f=true;var a=d.getElementById(\'_vis_opt_path_hides\');if(a)a.parentNode.removeChild(a);}},finished:function(){return f;},load:function(a){var b=d.createElement(\'script\');b.src=a;b.type=\'text/javascript\';b.innerText;b.onerror=function(){_vwo_code.finish();};d.getElementsByTagName(\'head\')[0].appendChild(b);},init:function(){settings_timer=setTimeout(\'_vwo_code.finish()\',settings_tolerance);this.load(\'//dev.visualwebsiteoptimizer.com/j.php?a=\'+account_id+\'&u=\'+encodeURIComponent(d.URL)+\'&r=\'+Math.random());var a=d.createElement(\'style\'),b=\'body{opacity:0 !important;filter:alpha(opacity=0) !important;background:none !important;}\',h=d.getElementsByTagName(\'head\')[0];a.setAttribute(\'id\',\'_vis_opt_path_hides\');a.setAttribute(\'type\',\'text/css\');if(a.styleSheet)a.styleSheet.cssText=b;else a.appendChild(d.createTextNode(b));h.appendChild(a);return settings_timer;}};}());_vwo_settings_timer=_vwo_code.init();
47 +</script>
48 +<!-- End VWO Asynchronous Code -->
49 +';
48 50
49 -/**
50 - * Get ignore js script attribute value
51 - * @return type boolean
52 - */
53 -function vwo_clhf_ignore_js_attr(){
54 - $ignore_js = get_vwo_clhf_ignore_js();
55 - $js_attr = '';
56 - if(function_exists('get_vwo_clhf_ignore_js') && $ignore_js){
57 - $js_attr = 'data-cfasync="false"';
58 - }
59 - return $js_attr;
60 -}
61 51
62 -/**
63 - * Generate Synchronous Code
64 - * @param type $vwo_id integer
65 - * @return type string
66 - */
67 -function get_vwo_clhf_script_sync_code($vwo_id = 0) {
68 - ob_start();
69 - ?>
70 - <!-- Start VWO Smartcode -->
71 - <script <?php echo vwo_clhf_ignore_js_attr();?> src="https://dev.visualwebsiteoptimizer.com/lib/<?php echo $vwo_id ?>.js"></script>
72 - <!-- End VWO Smartcode -->
73 - <?php
74 - $sync_script = ob_get_clean();
75 - return $sync_script;
76 -}
77 -
78 -/**
79 - * Generate Asynchronous Code
80 - * @param type $vwo_id integer
81 - * @param type $settings_tolerance integer
82 - * @param type $library_tolerance integer
83 - * @param type $use_existing_jquery string
84 - * @return type string
85 - */
86 -function get_vwo_clhf_script_async_code($vwo_id, $settings_tolerance, $library_tolerance, $use_existing_jquery) {
87 - ob_start();
88 -?>
89 - <!-- Start VWO Async Smartcode -->
90 - <script <?php echo vwo_clhf_ignore_js_attr(); ?> type='text/javascript'>
91 - /* Fix: wp-rocket (application/ld+json) */
92 - window._vwo_code = window._vwo_code || (function(){
93 - var account_id= <?php echo $vwo_id ?>,
94 - settings_tolerance= <?php echo $settings_tolerance ?>,
95 - library_tolerance= <?php echo $library_tolerance ?>,
96 - use_existing_jquery= <?php echo ($use_existing_jquery) ? 'true' : 'false'; ?>,
97 - is_spa=1,
98 - hide_element='body',
99 - /* DO NOT EDIT BELOW THIS LINE */
100 - f=false,d=document,code={use_existing_jquery:function(){return use_existing_jquery;},library_tolerance:function(){return library_tolerance;},finish:function(){if(!f){f=true;var a=d.getElementById('_vis_opt_path_hides');if(a)a.parentNode.removeChild(a);}},finished:function(){return f;},load:function(a){var b=d.createElement('script');b.src=a;b.type='text/javascript';b.innerText;b.onerror=function(){_vwo_code.finish();};d.getElementsByTagName('head')[0].appendChild(b);},init:function(){
101 - window.settings_timer=setTimeout('_vwo_code.finish()',settings_tolerance);var a=d.createElement('style'),b=hide_element?hide_element+'{opacity:0 !important;filter:alpha(opacity=0) !important;background:none !important;}':'',h=d.getElementsByTagName('head')[0];a.setAttribute('id','_vis_opt_path_hides');a.setAttribute('type','text/css');if(a.styleSheet)a.styleSheet.cssText=b;else a.appendChild(d.createTextNode(b));h.appendChild(a);this.load('https://dev.visualwebsiteoptimizer.com/j.php?a='+account_id+'&u='+encodeURIComponent(d.URL)+'&f='+(+is_spa)+'&r='+Math.random());return settings_timer; }};window._vwo_settings_timer = code.init(); return code; }());
102 - </script>
103 - <!-- End VWO Async Smartcode -->
104 - <?php
105 - $async_script = ob_get_clean();
106 - return $async_script;
107 -}
108 -
109 52 //------------------------------------------------------------------------//
110 53 //---Hook-----------------------------------------------------------------//
111 54 //------------------------------------------------------------------------//
112 55 add_action( 'wp_head', 'vwo_clhf_headercode',1 );
@@ -125,68 +68,43 @@
125 68
126 69 // whitelist settings
127 70 function vwo_clhf_register_mysettings(){
128 71 register_setting('clhf_vwo_options','vwo_id','intval');
129 - register_setting('clhf_vwo_options','code_type');
130 - register_setting('clhf_vwo_options','vwo_clicks');
131 - register_setting('clhf_vwo_options','ignore_js','boolval');
72 + register_setting('clhf_vwo_options','code_type');
132 73 register_setting('clhf_vwo_options','settings_tolerance','intval');
133 74 register_setting('clhf_vwo_options','library_tolerance','intval');
134 - register_setting('clhf_vwo_options','use_existing_jquery','boolval');
135 75 }
136 76
137 77 //------------------------------------------------------------------------//
138 78 //---Output Functions-----------------------------------------------------//
139 79 //------------------------------------------------------------------------//
140 -function vwo_clhf_headercode() {
141 - // runs in the header
142 - $vwo_id = get_option('vwo_id');
143 - $code_type = get_option('code_type');
144 -
145 - if ($vwo_id) {
146 - if(empty(get_option('vwo_clicks'))){
147 - update_option('vwo_clicks', '10' );
148 - }
149 - $vwo_clicks = get_option('vwo_clicks');
150 - //common script code
151 - echo get_vwo_clhf_script_common_code($vwo_clicks);
152 - if ($code_type == 'SYNC') {
153 - //sync script code
154 - echo get_vwo_clhf_script_sync_code($vwo_id); // only output if options were saved
155 - } else {
80 +function vwo_clhf_headercode(){
81 + // runs in the header
82 + global $clhf_header_script_sync, $clhf_header_script_async;
83 + $vwo_id = get_option('vwo_id');
84 + $code_type = get_option('code_type');
85 + if($vwo_id){
86 + if($code_type == 'SYNC')
87 + echo str_replace('VWO_ID', $vwo_id, $clhf_header_script_sync); // only output if options were saved
88 + else {
89 + $settings_tolerance = get_option('settings_tolerance');
90 + if(!is_numeric($settings_tolerance)) $settings_tolerance = 2000;
156 91
157 - $settings_tolerance = get_option('settings_tolerance');
158 - if (!is_numeric($settings_tolerance))
159 - $settings_tolerance = 2000;
92 + $library_tolerance = get_option('library_tolerance');
93 + if(!is_numeric($library_tolerance)) $library_tolerance = 2500;
160 94
161 - $library_tolerance = get_option('library_tolerance');
162 - if (!is_numeric($library_tolerance))
163 - $library_tolerance = 2500;
164 -
165 - $use_existing_jquery = get_option('use_existing_jquery');
166 - $use_existing_jquery = ($use_existing_jquery == 1) ? true : false;
167 -
168 - //async script code
169 - echo get_vwo_clhf_script_async_code($vwo_id, $settings_tolerance, $library_tolerance, $use_existing_jquery);
170 - }
171 - }
95 + $clhf_header_script_async = str_replace('VWO_ID', $vwo_id, $clhf_header_script_async);
96 + $clhf_header_script_async = str_replace('SETTINGS_TOLERANCE', $settings_tolerance, $clhf_header_script_async);
97 + echo str_replace('LIBRARY_TOLERANCE', $library_tolerance, $clhf_header_script_async);
98 + }
99 + }
172 100 }
173 -
174 101 //------------------------------------------------------------------------//
175 102 //---Page Output Functions------------------------------------------------//
176 103 //------------------------------------------------------------------------//
177 104 // options page
178 105 function vwo_clhf_plugin_options() {
179 - //Set value for checkbox by default
180 - $ignore_js_options = get_option('ignore_js');
181 - $show_ignore_js = $ignore_js_options;
182 - if( $ignore_js_options === false ) {
183 - // nothing is set, so apply the default here
184 - $show_ignore_js = 1;
185 - update_option('ignore_js', '1');
186 - }
187 -
188 - echo '<div class="wrap">';?>
106 + echo '<div class="wrap">';?>
189 107 <h2>VWO</h2>
190 108 <p>You need to have a <a href="https://vwo.com/">VWO</a> account in order to use this plugin. This plugin inserts the neccessary code into your Wordpress site automatically without you having to touch anything. In order to use the plugin, you need to enter your VWO Account ID:</p>
191 109 <form method="post" action="options.php">
192 110 <?php settings_fields( 'clhf_vwo_options' ); ?>
@@ -194,12 +112,8 @@
194 112 <tr valign="top">
195 113 <th scope="row">Your VWO Account ID</th>
196 114 <td><input type="text" name="vwo_id" value="<?php echo get_option('vwo_id'); ?>" /></td>
197 115 </tr>
198 - <tr valign="top">
199 - <th scope="row">No. of Heatmap Clicks</th>
200 - <td><input type="number" name="vwo_clicks" value="<?php echo get_option('vwo_clicks') ? get_option('vwo_clicks'):10 ; ?>" min="3"/></td>
201 - </tr>
202 116 <tr valign="top">
203 117 <th scope="row">Code (default: Asynchronous)</th>
204 118 <td>
205 119 <input style="vertical-align: text-top;" type="radio" onclick="selectCodeType();" name="code_type" id="code_type_async" value="ASYNC" <?php if(get_option('code_type')!='SYNC') echo "checked"; ?> /> Asynchronous&nbsp;&nbsp;&nbsp;
@@ -214,16 +128,8 @@
214 128 <tr valign="top" id='asyncOnly2' <?php if(get_option('code_type')=='SYNC') echo "style='display:none;'" ?>>
215 129 <th scope="row">Library Timeout</th>
216 130 <td style="vertical-align: middle;"><input type="text" name="library_tolerance" value="<?php echo get_option('library_tolerance')?get_option('library_tolerance'):2500; ?>" />ms (default: 2500)</td>
217 131 </tr>
218 - <tr valign="top" id='asyncOnly3' <?php if(get_option('code_type')=='SYNC') echo "style='display:none;'" ?>>
219 - <th scope="row">Use Existing jQuery</th>
220 - <td style="vertical-align: middle;"><input type="checkbox" name="use_existing_jquery" value="1" <?php if(get_option('use_existing_jquery') == true) echo "checked"; ?>/>Yes</td>
221 - </tr>
222 - <tr valign="top">
223 - <th scope="row">Skip Deferred Execution</th>
224 - <td style="vertical-align: middle;"><input type="checkbox" name="ignore_js" value="1" <?php if($show_ignore_js == true) echo "checked"; ?>/>Yes</td>
225 - </tr>
226 132 </table>
227 133
228 134 <script type="text/javascript">
229 135 function selectCodeType() {
@@ -233,14 +139,12 @@
233 139
234 140 if(code_type == 'ASYNC') {
235 141 document.getElementById('asyncOnly1').style.display = 'table-row';
236 142 document.getElementById('asyncOnly2').style.display = 'table-row';
237 - document.getElementById('asyncOnly3').style.display = 'table-row';
238 143 }
239 144 else {
240 145 document.getElementById('asyncOnly1').style.display = 'none';
241 146 document.getElementById('asyncOnly2').style.display = 'none';
242 - document.getElementById('asyncOnly3').style.display = 'none';
243 147 }
244 148 }
245 149 </script>
246 150 <p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
@@ -257,29 +161,5 @@
257 161 if (!$clhf_option || $clhf_option < 1){
258 162 echo "<div id='vwo-warning' class='updated fade'><p><strong>VWO is almost ready.</strong> You must <a href=\"options-general.php?page=clhf_vwo_options\">enter your Account ID</a> for it to work.</p></div>";
259 163 }
260 164 }
261 -
262 -
263 -add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'vwo_clhf_add_plugin_page_settings_link');
264 -/**
265 - * Function to add Settings Links on Plugin page
266 - * @param array $links
267 - * @return string
268 - */
269 -function vwo_clhf_add_plugin_page_settings_link( $links ) {
270 - $links[] = '<a href="' .
271 - admin_url( 'options-general.php?page=clhf_vwo_options' ) .
272 - '">' . __('Settings') . '</a>';
273 - return $links;
274 -}
275 -
276 -function disable_vwo_in_divi_builder(){
277 - if (has_action('wp_head', 'vwo_clhf_headercode') && function_exists('et_core_is_fb_enabled') && et_core_is_fb_enabled()){
278 - remove_action('wp_head', 'vwo_clhf_headercode', 1);
279 - }
280 - return;
281 -}
282 -
283 -add_action('wp_head', 'disable_vwo_in_divi_builder', 0);
284 -
285 165 ?>