Skip to content

Commit

Permalink
Add pixelyoursite integration
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyc committed Aug 22, 2024
1 parent d5add75 commit b032e4e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/Integrations/PixelYourSite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace GeneroWP\GeneroCmp\Integrations;

use GeneroWP\GeneroCmp\Models\Consent;
use GeneroWP\GeneroCmp\Plugin;

/**
* https://wordpress.org/plugins/pixelyoursite/
*/
class PixelYourSite
{
public function __construct(
protected Plugin $plugin,
) {
add_filter('script_loader_tag', [$this, 'scriptLoaderTag'], 10, 2);
add_filter('pys_disable_externalID_by_gdpr', '__return_true');
}

public function scriptLoaderTag(string $tag, string $handle): string
{
if ($handle === 'pys') {
$tag = str_replace(
'<script ',
sprintf('<script type="text/plain" data-gds-cmp-consent="%s"', implode(' ', [Consent::STATISTICS, Consent::MARKETING])),
$tag,
);
}
return $tag;
}
}
2 changes: 2 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use GeneroWP\GeneroCmp\Integrations\FacebookForWooCommerce;
use GeneroWP\GeneroCmp\Integrations\GoogleAppsLogin;
use GeneroWP\GeneroCmp\Integrations\Gravityforms;
use GeneroWP\GeneroCmp\Integrations\PixelYourSite;
use GeneroWP\GeneroCmp\Integrations\Polylang;
use GeneroWP\GeneroCmp\Integrations\Redirection;
use GeneroWP\GeneroCmp\Integrations\TiktokForBusiness;
Expand Down Expand Up @@ -70,6 +71,7 @@ public function initializeIntegrations(): void
new Redirection($this);
new WpTiktokFeed($this);
new ElfsightInstagramFeed($this);
new PixelYourSite($this);
}

/**
Expand Down

0 comments on commit b032e4e

Please sign in to comment.