PluginProbe
Visual Website Optimizer / 2.1
Visual Website Optimizer v2.1
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 +66 -144 3.32.1 View file →
@@ -1,13 +1,12 @@
1 1 <?php
2 2 /*
3 -Plugin Name: VWO
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.3
8 -visual-website-optimizer.php
9 -Author URI: https://vwo.com/
3 +Plugin Name: Visual Website Optimizer
4 +Plugin URI: http://visualwebsiteoptimizer.com/
5 +Description: Visual Website Optimizer is the world's easiest to use A/B, split and multivariate testing tool. Simply enable the plugin and start running tests on your Wordpress website without doing any other code changes. Visit <a href="http://visualwebsiteoptimizer.com/">Visual Website Optimizer</a> for more details.
6 +Author: Andy Bailey
7 +Version: 2.1
8 +Author URI: http://fiddyp.co.uk
10 9
11 10 This relies on the actions being present in the themes header.php and footer.php
12 11 * header.php code before the closing </head> tag
13 12 * wp_head();
@@ -17,79 +16,46 @@
17 16 //------------------------------------------------------------------------//
18 17 //---Config---------------------------------------------------------------//
19 18 //------------------------------------------------------------------------//
20 19
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 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 -}
20 +$clhf_header_script_sync = '
21 +<!-- Start Visual Website Optimizer Code -->
22 +<script type=\'text/javascript\'>
23 +var _vis_opt_account_id = VWO_ID;
24 +var _vis_opt_protocol = ((\'https:\' == document.location.protocol) ? \'https://\' : \'http://\');
25 +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>\');
26 +</script>
27 +<script type=\'text/javascript\'>
28 +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>\'); }
29 +</script>
30 +<script type=\'text/javascript\'>
31 +if(typeof(_vis_opt_settings_loaded) == "boolean" && typeof(_vis_opt_top_initialize) == "function"){ _vis_opt_top_initialize();
32 +vwo_$(document).ready(function() { _vis_opt_bottom_initialize(); }); }
33 +</script>
34 +<!-- End Visual Website Optimizer Code -->
35 +';
38 36
39 -/**
40 - * Generate Synchronous Code
41 - * @param type $vwo_id integer
42 - * @return type string
43 - */
44 -function get_vwo_clhf_script_sync_code($vwo_id = 0) {
45 - ob_start();
46 - ?>
47 - <!-- Start VWO Smartcode -->
48 - <script src="https://dev.visualwebsiteoptimizer.com/lib/<?php echo $vwo_id ?>.js"></script>
49 - <!-- End VWO Smartcode -->
50 - <?php
51 - $sync_script = ob_get_clean();
52 - return $sync_script;
53 -}
37 +$clhf_header_script_async = '
38 +<!-- Start Visual Website Optimizer Asynchronous Code -->
39 +<script type=\'text/javascript\'>
40 +var _vwo_code=(function(){
41 +var account_id=VWO_ID,
42 +settings_tolerance=SETTINGS_TOLERANCE,
43 +library_tolerance=LIBRARY_TOLERANCE,
44 +use_existing_jquery=false,
45 +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();
46 +</script>
47 +<!-- End Visual Website Optimizer Asynchronous Code -->
48 +';
54 49
55 -/**
56 - * Generate Asynchronous Code
57 - * @param type $vwo_id integer
58 - * @param type $settings_tolerance integer
59 - * @param type $library_tolerance integer
60 - * @param type $use_existing_jquery string
61 - * @return type string
62 - */
63 -function get_vwo_clhf_script_async_code($vwo_id = 0, $settings_tolerance, $library_tolerance, $use_existing_jquery) {
64 - ob_start();
65 -?>
66 - <!-- Start VWO Async Smartcode -->
67 - <script type='text/javascript'>
68 - window._vwo_code = window._vwo_code || (function(){
69 - var account_id= <?php echo $vwo_id ?>,
70 - settings_tolerance= <?php echo $settings_tolerance ?>,
71 - library_tolerance= <?php echo $library_tolerance ?>,
72 - use_existing_jquery= <?php echo ($use_existing_jquery) ? 'true' : 'false'; ?>,
73 - is_spa=1,
74 - hide_element='body',
75 - /* DO NOT EDIT BELOW THIS LINE */
76 - 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(){
77 - 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; }());
78 - </script>
79 - <!-- End VWO Async Smartcode -->
80 - <?php
81 - $async_script = ob_get_clean();
82 - return $async_script;
83 -}
84 50
85 51 //------------------------------------------------------------------------//
86 52 //---Hook-----------------------------------------------------------------//
87 53 //------------------------------------------------------------------------//
88 -add_action( 'wp_head', 'vwo_clhf_headercode',1 );
89 -add_action( 'admin_menu', 'vwo_clhf_plugin_menu' );
90 -add_action( 'admin_init', 'vwo_clhf_register_mysettings' );
91 -add_action( 'admin_notices','vwo_clhf_warn_nosettings');
54 +add_action ( 'wp_head', 'clhf_headercode',1 );
55 +add_action( 'admin_menu', 'clhf_plugin_menu' );
56 +add_action( 'admin_init', 'clhf_register_mysettings' );
57 +add_action( 'admin_notices','clhf_warn_nosettings');
92 58
93 59
94 60 //------------------------------------------------------------------------//
95 61 //---Functions------------------------------------------------------------//
@@ -94,67 +60,48 @@
94 60 //------------------------------------------------------------------------//
95 61 //---Functions------------------------------------------------------------//
96 62 //------------------------------------------------------------------------//
97 63 // options page link
98 -function vwo_clhf_plugin_menu() {
99 - add_options_page('Visual Website Optimizer', 'VWO', 'create_users', 'clhf_vwo_options', 'vwo_clhf_plugin_options');
64 +function clhf_plugin_menu() {
65 + add_options_page('Visual Website Optimizer', 'VWO', 'create_users', 'clhf_vwo_options', 'clhf_plugin_options');
100 66 }
101 67
102 68 // whitelist settings
103 -function vwo_clhf_register_mysettings(){
69 +function clhf_register_mysettings(){
104 70 register_setting('clhf_vwo_options','vwo_id','intval');
105 - register_setting('clhf_vwo_options','code_type');
106 - register_setting('clhf_vwo_options','vwo_clicks');
71 + register_setting('clhf_vwo_options','code_type');
107 72 register_setting('clhf_vwo_options','settings_tolerance','intval');
108 73 register_setting('clhf_vwo_options','library_tolerance','intval');
109 - register_setting('clhf_vwo_options','use_existing_jquery','boolval');
110 74 }
111 75
112 76 //------------------------------------------------------------------------//
113 77 //---Output Functions-----------------------------------------------------//
114 78 //------------------------------------------------------------------------//
115 -function vwo_clhf_headercode() {
116 - // runs in the header
117 - $vwo_id = get_option('vwo_id');
118 - $code_type = get_option('code_type');
119 -
120 - if ($vwo_id) {
121 - if(empty(get_option('vwo_clicks'))){
122 - update_option('vwo_clicks', '10' );
123 - }
124 - $vwo_clicks = get_option('vwo_clicks');
125 - //common script code
126 - echo get_vwo_clhf_script_common_code($vwo_clicks);
127 - if ($code_type == 'SYNC') {
128 - //sync script code
129 - echo get_vwo_clhf_script_sync_code($vwo_id); // only output if options were saved
130 - } else {
131 -
132 - $settings_tolerance = get_option('settings_tolerance');
133 - if (!is_numeric($settings_tolerance))
134 - $settings_tolerance = 2000;
135 -
136 - $library_tolerance = get_option('library_tolerance');
137 - if (!is_numeric($library_tolerance))
138 - $library_tolerance = 2500;
139 -
140 - $use_existing_jquery = get_option('use_existing_jquery');
141 - $use_existing_jquery = ($use_existing_jquery == 1) ? true : false;
142 -
143 - //async script code
144 - echo get_vwo_clhf_script_async_code($vwo_id, $settings_tolerance, $library_tolerance, $use_existing_jquery);
145 - }
146 - }
79 +function clhf_headercode(){
80 + // runs in the header
81 + global $clhf_header_script_sync, $clhf_header_script_async;
82 + $vwo_id = get_option('vwo_id');
83 + $code_type = get_option('code_type');
84 + if($vwo_id){
85 + if($code_type == 'SYNC')
86 + echo str_replace('VWO_ID', $vwo_id, $clhf_header_script_sync); // only output if options were saved
87 + else {
88 + $settings_tolerance = get_option('settings_tolerance');
89 + $library_tolerance = get_option('library_tolerance');
90 + $clhf_header_script_async = str_replace('VWO_ID', $vwo_id, $clhf_header_script_async);
91 + $clhf_header_script_async = str_replace('SETTINGS_TOLERANCE', $settings_tolerance, $clhf_header_script_async);
92 + echo str_replace('LIBRARY_TOLERANCE', $library_tolerance, $clhf_header_script_async);
93 + }
94 + }
147 95 }
148 -
149 96 //------------------------------------------------------------------------//
150 97 //---Page Output Functions------------------------------------------------//
151 98 //------------------------------------------------------------------------//
152 99 // options page
153 -function vwo_clhf_plugin_options() {
100 +function clhf_plugin_options() {
154 101 echo '<div class="wrap">';?>
155 - <h2>VWO</h2>
156 - <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>
102 + <h2>Visual Website Optimizer</h2>
103 + <p>You need to have a <a href="http://visualwebsiteoptimizer.com/">Visual Website Optimizer</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>
157 104 <form method="post" action="options.php">
158 105 <?php settings_fields( 'clhf_vwo_options' ); ?>
159 106 <table class="form-table">
160 107 <tr valign="top">
@@ -160,18 +107,14 @@
160 107 <tr valign="top">
161 108 <th scope="row">Your VWO Account ID</th>
162 109 <td><input type="text" name="vwo_id" value="<?php echo get_option('vwo_id'); ?>" /></td>
163 110 </tr>
164 - <tr valign="top">
165 - <th scope="row">No. of Heatmap Clicks</th>
166 - <td><input type="number" name="vwo_clicks" value="<?php echo get_option('vwo_clicks') ? get_option('vwo_clicks'):10 ; ?>" min="3"/></td>
167 - </tr>
168 111 <tr valign="top">
169 112 <th scope="row">Code (default: Asynchronous)</th>
170 113 <td>
171 114 <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;
172 115 <input style="vertical-align: text-top;" type="radio" onclick="selectCodeType();" name="code_type" id="code_type_sync" value="SYNC" <?php if(get_option('code_type')=='SYNC') echo "checked"; ?> /> Synchronous
173 - &nbsp;<a href="https://vwo.com/blog/asynchronous-code" target="_blank">[Help]</a>
116 + &nbsp;<a href="http://visualwebsiteoptimizer.com/split-testing-blog/asynchronous-code" target="_blank">[Help]</a>
174 117 </td>
175 118 </tr>
176 119 <tr valign="top" id='asyncOnly1' <?php if(get_option('code_type')=='SYNC') echo "style='display:none;'" ?>>
177 120 <th scope="row">Settings Timeout</th>
@@ -178,14 +121,10 @@
178 121 <td style="vertical-align: middle;"><input type="text" name="settings_tolerance" value="<?php echo get_option('settings_tolerance')?get_option('settings_tolerance'):2000; ?>" />ms (default: 2000)</td>
179 122 </tr>
180 123 <tr valign="top" id='asyncOnly2' <?php if(get_option('code_type')=='SYNC') echo "style='display:none;'" ?>>
181 124 <th scope="row">Library Timeout</th>
182 - <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>
125 + <td style="vertical-align: middle;"><input type="text" name="library_tolerance" value="<?php echo get_option('library_tolerance')?get_option('library_tolerance'):1500; ?>" />ms (default: 1500)</td>
183 126 </tr>
184 - <tr valign="top" id='asyncOnly3' <?php if(get_option('code_type')=='SYNC') echo "style='display:none;'" ?>>
185 - <th scope="row">Use Existing jQuery</th>
186 - <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>
187 - </tr>
188 127 </table>
189 128
190 129 <script type="text/javascript">
191 130 function selectCodeType() {
@@ -195,44 +134,27 @@
195 134
196 135 if(code_type == 'ASYNC') {
197 136 document.getElementById('asyncOnly1').style.display = 'table-row';
198 137 document.getElementById('asyncOnly2').style.display = 'table-row';
199 - document.getElementById('asyncOnly3').style.display = 'table-row';
200 138 }
201 139 else {
202 140 document.getElementById('asyncOnly1').style.display = 'none';
203 141 document.getElementById('asyncOnly2').style.display = 'none';
204 - document.getElementById('asyncOnly3').style.display = 'none';
205 142 }
206 143 }
207 144 </script>
208 145 <p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
209 - <p>Your Account ID (a number) can be found in <i>Settings</i> area (top-right) after you <a href="https://app.vwo.com">login</a> into your VWO account.</p>
146 + <p>Your Account ID (a number) can be found in <i>Settings</i> area (top-right) after you <a href="https://v2.visualwebsiteoptimizer.com">login</a> into your Visual Website Optimizer account.</p>
210 147 <?php
211 148 echo '</div>';
212 149 }
213 150
214 -function vwo_clhf_warn_nosettings(){
151 +function clhf_warn_nosettings(){
215 152 if (!is_admin())
216 153 return;
217 154
218 155 $clhf_option = get_option("vwo_id");
219 156 if (!$clhf_option || $clhf_option < 1){
220 - 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>";
157 + echo "<div id='vwo-warning' class='updated fade'><p><strong>Visual Website Optimizer 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>";
221 158 }
222 159 }
223 -
224 -
225 -add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'vwo_clhf_add_plugin_page_settings_link');
226 -/**
227 - * Function to add Settings Links on Plugin page
228 - * @param array $links
229 - * @return string
230 - */
231 -function vwo_clhf_add_plugin_page_settings_link( $links ) {
232 - $links[] = '<a href="' .
233 - admin_url( 'options-general.php?page=clhf_vwo_options' ) .
234 - '">' . __('Settings') . '</a>';
235 - return $links;
236 -}
237 -
238 160 ?>