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,212 @@
<?php // phpcs:ignoreFile
use AdvancedAds\Abstracts\Ad;
use AdvancedAds\Framework\Utilities\Params;
/**
* Admin class for privacy settings.
*/
class Advanced_Ads_Privacy_Admin {
/**
* Singleton instance of the plugin
*
* @var Advanced_Ads_Privacy_Admin
*/
protected static $instance;
/**
* Initialize the module
*/
private function __construct() {
add_action( 'advanced-ads-settings-init', [ $this, 'settings_init' ], 20 );
add_filter( 'advanced-ads-setting-tabs', [ $this, 'setting_tabs' ], 20 );
add_action( 'advanced-ads-ad-params-after', [ $this, 'render_ad_options' ], 20 );
add_action( 'advanced-ads-ad-pre-save', [ $this, 'save_ad_options' ], 10, 2 );
}
/**
* Return an instance of Advanced_Ads_Privacy_Admin
*
* @return Advanced_Ads_Privacy_Admin
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Add tracking settings tab.
*
* @param array $tabs existing setting tabs.
*
* @return array $tabs setting tabs with AdSense tab attached
* @since 1.8.30
*/
public function setting_tabs( array $tabs ) {
$tabs['privacy'] = [
'page' => ADVADS_PRIVACY_SLUG . '-settings',
'group' => ADVADS_PRIVACY_SLUG,
'tabid' => 'privacy',
'title' => __( 'Privacy', 'advanced-ads' ),
];
return $tabs;
}
/**
* Add settings to settings page
*/
public function settings_init() {
register_setting( ADVADS_PRIVACY_SLUG, Advanced_Ads_Privacy::OPTION_KEY, [ $this, 'sanitize_settings' ] );
/**
* Allow Ad Admin to save privacy options.
*
* @param array $settings Array with allowed options.
*
* @return array
*/
add_filter(
'advanced-ads-ad-admin-options',
function ( $options ) {
$options[] = ADVADS_PRIVACY_SLUG;
return $options;
}
);
add_settings_section(
ADVADS_PRIVACY_SLUG . '_settings_section',
'',
'__return_empty_string',
ADVADS_PRIVACY_SLUG . '-settings'
);
add_settings_field(
'enable-privacy-module',
__( 'Enable Privacy module', 'advanced-ads' ),
[ $this, 'render_settings_enable_module' ],
ADVADS_PRIVACY_SLUG . '-settings',
ADVADS_PRIVACY_SLUG . '_settings_section',
[ 'label_for' => Advanced_Ads_Privacy::OPTION_KEY . '_enabled' ]
);
}
/**
* Sanitize settings.
*
* @param array $options Privacy options.
*
* @return array
*/
public function sanitize_settings( $options ) {
$options['custom-cookie-name'] = isset( $options['custom-cookie-name'] ) ? trim( $options['custom-cookie-name'] ) : '';
$options['custom-cookie-value'] = isset( $options['custom-cookie-value'] ) ? trim( $options['custom-cookie-value'] ) : '';
return $options;
}
/**
* Render enable module setting
*/
public function render_settings_enable_module() {
$options = Advanced_Ads_Privacy::get_instance()->options();
$module_enabled = isset( $options['enabled'] );
$methods = [
'' => [
'label' => __( 'Show all ads even without consent', 'advanced-ads' ),
],
'custom' => [
'label' => __( 'Cookie', 'advanced-ads' ),
'manual_url' => 'https://wpadvancedads.com/manual/ad-cookie-consent/?utm_source=advanced-ads&utm_medium=link&utm_campaign=privacy-tab',
],
'iab_tcf_20' => [
'label' => __( 'IAB Transparency and Consent Framework (TCF) integration', 'advanced-ads' ),
'manual_url' => 'https://wpadvancedads.com/manual/tcf-consent-wordpress/?utm_source=advanced-ads&utm_medium=link&utm_campaign=privacy-tab',
],
];
$current_method = isset( $options['consent-method'] ) ? $options['consent-method'] : '';
$custom_cookie_name = isset( $options['custom-cookie-name'] ) ? $options['custom-cookie-name'] : '';
$custom_cookie_value = isset( $options['custom-cookie-value'] ) ? $options['custom-cookie-value'] : '';
$show_non_personalized_adsense = isset( $options['show-non-personalized-adsense'] );
$link_default_attrs = [
'href' => 'https://wpadvancedads.com/add-ons/advanced-ads-pro/?utm_source=advanced-ads&utm_medium=link&utm_campaign=privacy-cache',
'target' => '_blank',
];
$pro_link_attrs = apply_filters( 'advanced-ads-privacy-custom-link-attributes', $link_default_attrs );
if ( ! array_key_exists( 'href', $pro_link_attrs ) ) {
$pro_link_attrs = wp_parse_args( $pro_link_attrs, $link_default_attrs );
}
$opening_link_to_pro = sprintf(
'<a %s>',
implode(
' ',
array_map(
function ( $key, $value ) {
return sprintf( '%s="%s"', $key, esc_attr( $value ) );
},
array_keys( $pro_link_attrs ),
$pro_link_attrs
)
)
);
wp_enqueue_script( Advanced_Ads_Privacy::OPTION_KEY, ADVADS_PRIVACY_BASE_URL . 'admin/assets/js/privacy.js', [ 'jquery' ], '1.19.1', true );
wp_localize_script( Advanced_Ads_Privacy::OPTION_KEY, 'advads_privacy', [ 'option_key' => Advanced_Ads_Privacy::OPTION_KEY ] );
require ADVADS_PRIVACY_BASE_PATH . 'admin/views/setting-general.php';
}
/**
* Add options to ad edit page
*
* @param Ad $ad Ad object.
*/
public function render_ad_options( Ad $ad ) {
if ( empty( $ad->get_id() ) ) {
return;
}
$privacy = Advanced_Ads_Privacy::get_instance();
$privacy_options = $privacy->options();
// module is not enabled.
if ( ! isset( $privacy_options['enabled'] ) ) {
return;
}
// Don't add override option if the ad is adsense, image or dummy.
$skip_option = $ad->is_type( 'adsense' ) || ! $privacy->ad_type_needs_consent( $ad->get_type() );
if ( (bool) apply_filters( 'advanced-ads-ad-privacy-hide-ignore-consent', $skip_option, $ad, $privacy_options ) ) {
return;
}
$ignore_consent = isset( $ad->get_data()['privacy']['ignore-consent'] );
include ADVADS_PRIVACY_BASE_PATH . 'admin/views/setting-ad-ignore-consent.php';
}
/**
* Save ad options.
*
* @param Ad $ad Ad instance.
* @param array $post_data Post data array.
*
* @return void
*/
public function save_ad_options( Ad $ad, $post_data ): void {
if ( wp_verify_nonce( sanitize_key( Params::get( '_wpnonce' ) ), 'bulk-posts' ) || wp_verify_nonce( sanitize_key( Params::post( '_inline_edit' ) ), 'inlineeditnonce' ) ) {
// Don't mess with bulk and quick edit.
return;
}
if ( isset( $post_data['privacy'] ) ) {
$ad->set_prop( 'privacy', wp_unslash( $post_data['privacy'] ) );
} else {
$ad->unset_prop( 'privacy' );
}
}
}

View File

@@ -0,0 +1,15 @@
;(function ($) {
var $cookieName = $('[name="' + window.advads_privacy.option_key + '[custom-cookie-name]'),
$method = $('[name="' + window.advads_privacy.option_key + '[consent-method]"]:checked');
// set required if radios change.
$('[name="' + window.advads_privacy.option_key + '[consent-method]"]').on('change', function () {
$method = $('[name="' + window.advads_privacy.option_key + '[consent-method]"]:checked');
$cookieName.prop('required', $method.val() === 'custom');
});
// if enabled status changes, set required.
$('[name="' + window.advads_privacy.option_key + '[enabled]"]').on('change', function () {
$cookieName.prop('required', ($(this).is(':checked') ? $method.val() === 'custom' : false));
});
})(jQuery);

View File

@@ -0,0 +1,25 @@
<?php
/**
* Single ad section for overriding privacy settings.
* Not used if privacy not activated or method is 'iab_tcf_20' and ad type 'adsense'.
*
* @var bool $ignore_consent Whether to override privacy setting for this ad.
*/
?>
<div class="advads-option-list">
<span class="label"><?php esc_html_e( 'privacy', 'advanced-ads' ); ?></span>
<div id="advanced-ads-ad-parameters-privacy">
<label>
<input name="advanced_ad[privacy][ignore-consent]" type="checkbox" <?php checked( $ignore_consent ); ?>/>
<?php
printf(
/* Translators: 1: a tag with link to general privacy settings, 2: closing a tag */
esc_html__( 'Ignore %1$sgeneral Privacy settings%2$s and display the ad even without consent.', 'advanced-ads' ),
'<a onclick="event.stopPropagation();" href="' . esc_url( admin_url( 'admin.php?page=advanced-ads-settings#top#privacy' ) ) . '">',
'</a>'
);
?>
</label>
</div>
</div>
<hr/>

View File

@@ -0,0 +1,115 @@
<?php
/**
* Enable Privacy Module.
*
* @since 1.47.0
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
*
* @var bool $module_enabled Whether the privacy module is enabled.
* @var array $methods Available privacy methods.
* @var string $current_method Currently chosen method.
* @var string $custom_cookie_name Name of custom cookie, if this setting is chosen.
* @var string $custom_cookie_value (Partial) Value of custom cookie, if this setting is chosen.
* @var bool $show_non_personalized_adsense Whether to show non-personalized ads until custom cookie consent is given.
* @var string $opening_link_to_pro Opening link tag for link to Pro (either upsell or settings).
*/
use AdvancedAds\Compatibility\Compatibility;
use AdvancedAds\Tracking\Helpers;
use AdvancedAds\Utilities\Conditional;
?>
<input name="<?php echo esc_attr( Advanced_Ads_Privacy::OPTION_KEY ); ?>[enabled]" id="<?php echo esc_attr( Advanced_Ads_Privacy::OPTION_KEY ); ?>_enabled" type="checkbox" <?php checked( $module_enabled ); ?> class="advads-has-sub-settings"/>
<label for="<?php echo esc_attr( Advanced_Ads_Privacy::OPTION_KEY ); ?>_enabled">
<?php esc_html_e( 'Show ads only to users who give their permission to cookies and ads.', 'advanced-ads' ); ?>
</label>
<div class="advads-sub-settings">
<h4><?php esc_html_e( 'Consent method', 'advanced-ads' ); ?></h4>
<ul>
<?php
foreach ( $methods as $method => $options ) :
$checked = checked( $method, $current_method, false );
?>
<li>
<label>
<input type="radio" name="<?php echo esc_attr( Advanced_Ads_Privacy::OPTION_KEY ); ?>[consent-method]" value="<?php echo esc_attr( $method ); ?>" <?php echo esc_attr( $checked ); ?> />
<?php
echo esc_html( $options['label'] );
if ( ! empty( $options['manual_url'] ) ) :
?>
&ndash; <a href="<?php echo esc_url( $options['manual_url'] ); ?>" target="_blank" class="advads-manual-link">
<?php esc_html_e( 'Manual', 'advanced-ads' ); ?>
</a>
<?php endif; ?>
</label>
<?php if ( 'custom' === $method ) : ?>
<div style="margin: 10px 24px;">
<label>
<?php esc_html_e( 'Cookie name', 'advanced-ads' ); ?>
<input type="text" name="<?php echo esc_attr( Advanced_Ads_Privacy::OPTION_KEY ); ?>[custom-cookie-name]" value="<?php echo esc_attr( $custom_cookie_name ); ?>" placeholder="<?php esc_attr_e( 'Name', 'advanced-ads' ); ?>" <?php echo $method === $current_method ? 'required' : ''; ?>/>
</label>
<label>
<?php esc_html_e( 'contains', 'advanced-ads' ); ?>
<?php esc_html_e( 'value', 'advanced-ads' ); ?>
<input type="text" name="<?php echo esc_attr( Advanced_Ads_Privacy::OPTION_KEY ); ?>[custom-cookie-value]" value="<?php echo esc_attr( $custom_cookie_value ); ?>" placeholder="<?php esc_attr_e( 'Value', 'advanced-ads' ); ?>"/>
</label>
<label style="display: block; margin-top: 5px; margin-bottom: 7px;">
<input type="checkbox" name="<?php echo esc_attr( Advanced_Ads_Privacy::OPTION_KEY ); ?>[show-non-personalized-adsense]" <?php checked( $show_non_personalized_adsense ); ?> />
<?php esc_html_e( 'Show non-personalized AdSense ads until consent is given.', 'advanced-ads' ); ?>
</label>
<?php if ( Compatibility::borlabs_cookie_adsense_auto_ads_code_exists() ) : ?>
<p class="description">
<?php require GADSENSE_BASE_PATH . 'admin/views/borlabs-cookie-auto-ads-warning.php'; ?>
</p>
<?php endif; ?>
</div>
<?php if ( apply_filters( 'advanced-ads-privacy-custom-show-warning', ! empty( $checked ) && Conditional::has_cache_plugins() ) ) : ?>
<p class="description" style="margin: 5px 0 10px 23px;">
<span class="advads-notice-inline advads-error"><?php esc_html_e( 'It seems that a caching plugin is activated.', 'advanced-ads' ); ?></span>
<br>
<?php
esc_html_e( 'Your users consent might get cached and show ads to users who didnt give their consent yet. ', 'advanced-ads' );
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- attributes already escaped.
echo $opening_link_to_pro;
esc_html_e( 'Cache-busting in Advanced Ads Pro solves that.', 'advanced-ads' );
echo '</a>';
?>
</p>
<?php endif; ?>
<?php elseif ( 'iab_tcf_20' === $method ) : ?>
<?php if ( apply_filters( 'advanced-ads-privacy-tcf-show-warning', ! empty( $checked ) ) ) : ?>
<p class="description" style="margin: 5px 0 10px 23px;">
<?php
esc_html_e( 'Ads are loaded after the user gives their consent and reloads the page.', 'advanced-ads' );
echo ' ';
printf(
/* Translators: 1: opening link tag with link to Advanced Ads Pro 2: closing link tag */
esc_html__( 'Install %1$sAdvanced Ads Pro%2$s to reload the ads instantly without an additional page request.', 'advanced-ads' ),
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- attributes already escaped.
$opening_link_to_pro,
'</a>'
);
?>
</p>
<?php endif; ?>
<?php
if ( method_exists( Helpers::class, 'has_tcf_conflict' ) ) :
if ( Helpers::has_tcf_conflict() ) :
?>
<p class="advads-notice-inline advads-error">
<?php esc_html_e( 'The selected tracking method is not compatible with the TCF 2.0 integration.', 'advanced-ads' ); ?>
</p>
<?php
endif;
endif;
?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>