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>
This commit is contained in:
root
2025-11-03 21:04:30 -06:00
commit a22573bf0b
24068 changed files with 4993111 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
<?php // phpcs:ignore WordPress.Files.FileName
/**
* Logic to render options for ads, groups and placements
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
*/
/**
* Class Advanced_Ads_Adblock_Finder_Admin
*/
class Advanced_Ads_Adblock_Finder_Admin {
/**
* Advanced_Ads_Adblock_Finder_Admin constructor.
*/
public function __construct() {
add_filter( 'advanced-ads-setting-tabs', [ $this, 'add_tabs' ], 50 );
add_action( 'advanced-ads-settings-init', [ $this, 'settings_init' ], 9 );
}
/**
* Add tabs to the settings page.
*
* @param array $tabs setting tabs.
*
* @return array
*/
public function add_tabs( array $tabs ): array {
$tabs['adblocker'] = [
'page' => ADVADS_SETTINGS_ADBLOCKER,
'group' => ADVADS_SETTINGS_ADBLOCKER,
'tabid' => 'adblocker',
'title' => __( 'Ad Blocker', 'advanced-ads' ),
];
return $tabs;
}
/**
* Add settings to settings page.
*/
public function settings_init() {
register_setting( ADVADS_SETTINGS_ADBLOCKER, ADVADS_SETTINGS_ADBLOCKER );
add_settings_section(
'advanced_ads_adblocker_setting_section',
__( 'Ad Blocker', 'advanced-ads' ),
'__return_empty_string',
ADVADS_SETTINGS_ADBLOCKER
);
add_settings_field(
'GA-tracking-id',
__( 'Ad blocker counter', 'advanced-ads' ),
[ $this, 'render_settings_ga' ],
ADVADS_SETTINGS_ADBLOCKER,
'advanced_ads_adblocker_setting_section'
);
}
/**
* Render input for the Google Analytics Tracking ID.
*/
public function render_settings_ga() {
$options = Advanced_Ads::get_instance()->get_adblocker_options();
$ga_uid = isset( $options['ga-UID'] ) ? $options['ga-UID'] : '';
include_once __DIR__ . '/views/setting-ga.php';
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* Input for Google Analytics property ID.
*
* @package AdvancedAds
* @var string $ga_uid Google Analytics property ID
*/
?>
<label>
<input type="text" name="<?php echo esc_attr( ADVADS_SETTINGS_ADBLOCKER ); ?>[ga-UID]" value="<?php echo esc_attr( $ga_uid ); ?>"/>
<?php esc_html_e( 'Google Analytics Tracking ID', 'advanced-ads' ); ?>
</label>
<p class="description">
<?php
printf(
/* translators: %s is demo GA4 ID. */
esc_html__(
'Enter your Google Analytics property ID (e.g. %s) above to track the page views of visitors who use an ad blocker.',
'advanced-ads'
),
'<code>G-A12BC3D456</code>'
);
?>
</p>

View File

@@ -0,0 +1,13 @@
<?php
// Module configuration.
$path = dirname( __FILE__ );
return [
'classmap' => [
'Advanced_Ads_Adblock_Finder' => $path . '/public/public.php',
'Advanced_Ads_Adblock_Finder_Admin' => $path . '/admin/admin.php',
],
'textdomain' => null,
];

View File

@@ -0,0 +1,9 @@
<?php
class_exists( 'Advanced_Ads', false ) || exit();
if ( ! is_admin() ) {
new Advanced_Ads_Adblock_Finder;
} elseif ( ! wp_doing_ajax() ) {
new Advanced_Ads_Adblock_Finder_Admin;
}

View File

@@ -0,0 +1,62 @@
/**
* Check if an ad blocker is enabled.
*
* @param function callback A callback function that is executed after the check has been done.
* The 'isEnabled' (bool) variable is passed as the callback's first argument.
*/
window.advanced_ads_check_adblocker = (function (callback) {
let pendingCallbacks = [];
let isEnabled = null;
function RAF(RAF_callback) {
const fn =
window.requestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
function (RAF_callback) {
return setTimeout(RAF_callback, 16);
};
fn.call(window, RAF_callback);
}
RAF(function () {
// Create a bait.
const ad = document.createElement('div');
ad.innerHTML = '&nbsp;';
ad.setAttribute('class', 'ad_unit ad-unit text-ad text_ad pub_300x250');
ad.setAttribute(
'style',
'width: 1px !important; height: 1px !important; position: absolute !important; left: 0px !important; top: 0px !important; overflow: hidden !important;'
);
document.body.appendChild(ad);
RAF(function () {
const styles = window.getComputedStyle?.(ad);
const mozBinding = styles?.getPropertyValue('-moz-binding');
isEnabled =
(styles && styles.getPropertyValue('display') === 'none') ||
(typeof mozBinding === 'string' &&
mozBinding.indexOf('about:') !== -1);
// Call pending callbacks.
for (var i = 0, length = pendingCallbacks.length; i < length; i++) {
pendingCallbacks[i](isEnabled);
}
pendingCallbacks = [];
});
});
return function (callback) {
if ('undefined' === typeof advanced_ads_adblocker_test) {
isEnabled = true;
}
if (isEnabled === null) {
pendingCallbacks.push(callback);
return;
}
// Run the callback immediately
callback(isEnabled);
};
})();

View File

@@ -0,0 +1 @@
window.advanced_ads_check_adblocker=function(){var t=[],n=null;function e(t){var n=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(t){return setTimeout(t,16)};n.call(window,t)}return e((function(){var i=document.createElement("div");i.innerHTML="&nbsp;",i.setAttribute("class","ad_unit ad-unit text-ad text_ad pub_300x250"),i.setAttribute("style","width: 1px !important; height: 1px !important; position: absolute !important; left: 0px !important; top: 0px !important; overflow: hidden !important;"),document.body.appendChild(i),e((function(){var e,o,a=null===(e=(o=window).getComputedStyle)||void 0===e?void 0:e.call(o,i),d=null==a?void 0:a.getPropertyValue("-moz-binding");n=a&&"none"===a.getPropertyValue("display")||"string"==typeof d&&-1!==d.indexOf("about:");for(var r=0,u=t.length;r<u;r++)t[r](n);t=[]}))})),function(e){"undefined"==typeof advanced_ads_adblocker_test&&(n=!0),null!==n?e(n):t.push(e)}}();

View File

@@ -0,0 +1,49 @@
function AdvAdsAdBlockCounterGA( UID ) {
this.UID = UID;
this.analyticsObject = typeof gtag === 'function';
var self = this;
this.count = function () {
gtag( 'event', 'AdBlock', {
'event_category': 'Advanced Ads',
'event_label': 'Yes',
'non_interaction': true,
'send_to': self.UID
} );
};
// pseudo-constructor
( function () {
if ( ! self.analyticsObject ) {
// No one has requested gtag.js at this point, require it.
var script = document.createElement( 'script' );
script.src = 'https://www.googletagmanager.com/gtag/js?id=' + UID;
script.async = true;
document.body.appendChild( script );
window.dataLayer = window.dataLayer || [];
window.gtag = function () {
dataLayer.push( arguments );
};
self.analyticsObject = true;
gtag( 'js', new Date() );
}
var config = {'send_page_view': false, 'transport_type': 'beacon'};
if ( window.advanced_ads_ga_anonymIP ) {
config.anonymize_ip = true;
}
gtag( 'config', UID, config );
} )();
return this;
}
advanced_ads_check_adblocker( function ( is_enabled ) {
// Send data to Google Analytics if an ad blocker was detected.
if ( is_enabled ) {
new AdvAdsAdBlockCounterGA( advanced_ads_ga_UID ).count();
}
} );

View File

@@ -0,0 +1 @@
window.advanced_ads_check_adblocker=function(){var t=[],n=null;function e(t){var n=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(t){return setTimeout(t,16)};n.call(window,t)}return e((function(){var a=document.createElement("div");a.innerHTML="&nbsp;",a.setAttribute("class","ad_unit ad-unit text-ad text_ad pub_300x250"),a.setAttribute("style","width: 1px !important; height: 1px !important; position: absolute !important; left: 0px !important; top: 0px !important; overflow: hidden !important;"),document.body.appendChild(a),e((function(){var e,o,i=null===(e=(o=window).getComputedStyle)||void 0===e?void 0:e.call(o,a),d=null==i?void 0:i.getPropertyValue("-moz-binding");n=i&&"none"===i.getPropertyValue("display")||"string"==typeof d&&-1!==d.indexOf("about:");for(var c=0,r=t.length;c<r;c++)t[c](n);t=[]}))})),function(e){"undefined"==typeof advanced_ads_adblocker_test&&(n=!0),null!==n?e(n):t.push(e)}}(),(()=>{function t(t){this.UID=t,this.analyticsObject="function"==typeof gtag;var n=this;return this.count=function(){gtag("event","AdBlock",{event_category:"Advanced Ads",event_label:"Yes",non_interaction:!0,send_to:n.UID})},function(){if(!n.analyticsObject){var e=document.createElement("script");e.src="https://www.googletagmanager.com/gtag/js?id="+t,e.async=!0,document.body.appendChild(e),window.dataLayer=window.dataLayer||[],window.gtag=function(){dataLayer.push(arguments)},n.analyticsObject=!0,gtag("js",new Date)}var a={send_page_view:!1,transport_type:"beacon"};window.advanced_ads_ga_anonymIP&&(a.anonymize_ip=!0),gtag("config",t,a)}(),this}advanced_ads_check_adblocker((function(n){n&&new t(advanced_ads_ga_UID).count()}))})();

View File

@@ -0,0 +1,71 @@
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Ad block finder module frontend helper class
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
*/
use AdvancedAds\Options;
use AdvancedAds\Utilities\Conditional;
use AdvancedAds\Framework\Utilities\Arr;
/**
* Class Advanced_Ads_Adblock_Finder
*/
class Advanced_Ads_Adblock_Finder {
/**
* Advanced_Ads_Adblock_Finder constructor.
*/
public function __construct() {
add_action( 'wp_footer', [ $this, 'print_adblock_check_js' ], 9 );
}
/**
* Print the appropriate script into wp_footer.
*
* Don't print anything on AMP pages.
* Print minimal script if Advanced Ads Pro module "Ads for ad blockers" is active.
*/
public function print_adblock_check_js() {
if ( Conditional::is_amp() ) {
return;
}
$options = Advanced_Ads::get_instance()->get_adblocker_options();
$minified = ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG;
$ad_blocker_options = Options::instance()->get( 'adblocker' );
// if ad blocker counter is active.
if ( ! empty( $options['ga-UID'] ) ) {
printf(
'<script>(function(){var advanced_ads_ga_UID="%s",advanced_ads_ga_anonymIP=!!%d;%s})();</script>',
esc_attr( $options['ga-UID'] ),
esc_attr(
! defined( 'ADVANCED_ADS_DISABLE_ANALYTICS_ANONYMIZE_IP' ) ||
! ADVANCED_ADS_DISABLE_ANALYTICS_ANONYMIZE_IP
),
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped,WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- escaping could break the script and we're getting the contents of a local file
$minified
? file_get_contents( __DIR__ . '/ga-adblock-counter.min.js' )
: file_get_contents( __DIR__ . '/adblocker-enabled.js' ) . file_get_contents( __DIR__ . '/ga-adblock-counter.js' )
// phpcs:enable
);
} elseif (
defined( 'AAP_SLUG' )
&& (
Options::instance()->get( 'adblocker.ads-for-adblockers.enabled' )
|| ( Arr::has( $ad_blocker_options, 'method' ) && 'nothing' !== $ad_blocker_options['method'] )
)
) {
// if Advanced Ads Pro module "Ads for ad blockers" is active but no tracking.
// or if method is not "nothing".
printf(
'<script>%s</script>',
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped,WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- escaping could break the script and we're getting the contents of a local file
file_get_contents( __DIR__ . '/adblocker-enabled' . ( $minified ? '.min' : '' ) . '.js' )
);
}
}
}