Files
roi-theme/wp-content/plugins/advanced-ads/modules/one-click/modules/class-traffic-cop.php
root a22573bf0b Commit inicial - WordPress Análisis de Precios Unitarios
- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 21:04:30 -06:00

50 lines
1.0 KiB
PHP
Executable File

<?php
/**
* The class is responsible to wrap the google tags into traffic cop wrappers.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.48.0
*/
namespace AdvancedAds\Modules\OneClick;
use AdvancedAds\Framework\Utilities\Str;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Traffic Cop.
*/
class Traffic_Cop implements Integration_Interface {
/**
* Hook into WordPress
*
* @return void
*/
public function hooks(): void {
add_filter( 'pubguru_page_script_tag', [ $this, 'modify_script_tag' ], 30 );
}
/**
* Modify scrip if google tag found
*
* @param mixed $content Scrip tag.
*
* @return bool|string
*/
public function modify_script_tag( $content ) {
// Early bail!!
if ( ! Str::contains( 'googletag.display', $content ) ) {
return false;
}
$content = str_replace( '<script>', '<script>pg.atq.push(function() {', $content );
$content = str_replace( '</script>', '});</script>', $content );
return $content;
}
}