Skip to content

Commit

Permalink
PLANET-7676 Added snippet for VWO Anti Flickering
Browse files Browse the repository at this point in the history
- Added code to prevent flickering when A/B testing using VWO
  • Loading branch information
Osong-Michael committed Jan 22, 2025
1 parent 6cc0386 commit 9510438
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/MasterSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,21 @@ function (): void {
10
);

// Add VWO Anti Flicker script
add_action(
'wp_head',
function (): void {
$enable_vwo = planet4_get_option('enable_vwo') === 'on';

if (!$enable_vwo) {
return;
}

echo '<script>vwo_$("body").vwoCss({"visibility":"visible !important"});</script>' . PHP_EOL;
},
10
);

AuthorPage::hooks();
Search\Search::hooks();
Sendgrid::hooks();
Expand Down
2 changes: 1 addition & 1 deletion src/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ public function __construct()
[
'name' => __('VWO A/B testing', 'planet4-master-theme-backend'),
'desc' => __(
'Adds a Content Security Policy exception for VWO.',
'Adds a Content Security Policy exception for VWO and enables its anti-flicker mechanism. Do not enable this if you are A/B testing with other tools.',
'planet4-master-theme-backend'
),
'id' => 'enable_vwo',
Expand Down

0 comments on commit 9510438

Please sign in to comment.