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,179 @@
window.advads_geo_admin = window.advads_geo_admin || {};
advads_geo_admin.set_mode = function(index, mode){
if (mode == "latlon") {
jQuery( '#advads_geo_classic_' + index ).hide();
jQuery( '#advads_geo_latlon_' + index ).show();
} else {
jQuery( '#advads_geo_classic_' + index ).show();
jQuery( '#advads_geo_latlon_' + index ).hide();
jQuery( '#advads_geo_latlon_by_city_' + index ).hide();
}
}
advads_geo_admin.click_locname = function(index){
jQuery( '#advads_geo_latlon_by_city_' + index ).show();
jQuery( '#advads_geo_latlon_' + index ).hide();
}
advads_geo_admin.search_loc_close = function(index){
jQuery( '#advads_geo_latlon_by_city_' + index ).hide();
jQuery( '#advads_geo_latlon_' + index ).show();
}
advads_geo_admin.search_loc = function(index){
var city = jQuery( '#advads_geo_input_search_city_' + index ).val();
jQuery.get( {
url: 'https://nominatim.openstreetmap.org/search',
data: {format: 'json', q: city, linkedplaces: 0, hierarchy: 0},
dataType: 'json'
} )
.done( function(data){
advads_geo_admin.receive_search_results( index, data );
} )
.fail( function(jqXHR, textStatus, errorThrown){
jQuery( '#advads_geo_latlon_loading_' + index ).hide();
var container = jQuery( '#advads_geo_latlon_results_' + index );
// container[0].innerHTML = '';
var text = advads_geo_translation.could_not_retrieve_city + ' ' + advads_geo_translation.manual_geo_search;
container.append( jQuery( '<div class="advads-notice-inline advads-error"/>' ).html( text ) );
} );
jQuery( '#advads_geo_latlon_loading_' + index ).show();
}
advads_geo_admin.receive_search_results = function(index, data){
jQuery( '#advads_geo_latlon_results_' + index ).show();
jQuery( '#advads_geo_latlon_loading_' + index ).hide();
var container = jQuery( '#advads_geo_latlon_results_' + index );
container[0].innerHTML = '';
if (data.length > 1) {
var text = advads_geo_translation.found_results.replace( '\%1$d', data.length );
container.append( jQuery( '<div>' + text + '</div>' ) );
} else if (data.length == 0) {
container.append( jQuery( '<div>' + advads_geo_translation.no_results + '</div>' ) );
}
for (var i in data) {
var itm = data[i];
var elm = jQuery( '<div style="margin-bottom:5pt;cursor:pointer;" class="inline notice"><strong>' + itm.display_name + '</strong><font class="description">(' + itm.lat + ' / ' + itm.lon + ')</font></div>' )
.mouseover( function(){
jQuery( this ).addClass( 'updated' );
} ).mouseout( function(){
jQuery( this ).removeClass( 'updated' );
} );
elm[0].location = itm;
elm.click( function(){
var itm = jQuery( this )[0].location;
jQuery( '#advads_geo_input_search_city_' + index ).val( itm.display_name );
jQuery( '#advads_geo_input_lat_' + index ).val( itm.lat );
jQuery( '#advads_geo_input_lon_' + index ).val( itm.lon );
container[0].innerHTML = '';
advads_geo_admin.search_loc_close( index );
} );
container.append( elm );
}
};
( () => {
new MutationObserver( function ( mutations ) {
mutations.forEach( mutation => {
if ( mutation.type === 'childList' && mutation.addedNodes.length ) {
for ( const resetButton of document.getElementsByClassName( 'advads-condition-visitor-profile-reset' ) ) {
resetButton.addEventListener( 'click', e => {
window.Advanced_Ads_Admin.set_cookie( 'advanced_ads_visitor', '', 0, window.advads_geo_translation.COOKIEPATH, window.advads_geo_translation.COOKIE_DOMAIN );
e.target.closest( '.advads-condition-visitor-profile' ).remove();
} );
}
}
} );
} ).observe( document, {childList: true, subtree: true} );
} )();
// show/hide settings according to status of MaxMind license key and Database
// phpcs:disable Generic.Formatting.MultipleStatementAlignment.NotSameWarning -- WP PHPCS can't handle ES5 arrow functions alignment
( () => {
const license = document.getElementById( 'advanced-ads-geo-maxmind-licence' );
if ( ! license ) {
return;
}
if ( Boolean( license.dataset.customdb ) ) {
license.closest( 'tr' ).style.display = 'none';
return;
}
const licenseMissingWarning = document.getElementById( 'advanced-ads-geo-license-missing-warning' );
const dataBaseUpdate = document.getElementById( 'advanced-ads-geo-update-database' );
const hasDatabase = dataBaseUpdate.dataset.dbExists || false;
const licenseChange = event => {
const hasLicense = event.target.value.trim() !== '';
let nextSibling = license.closest( 'tr' ).nextElementSibling;
while ( nextSibling ) {
nextSibling.style.display = hasLicense || hasDatabase ? 'table-row' : 'none';
nextSibling = nextSibling.nextElementSibling;
}
licenseMissingWarning.style.display = hasLicense ? 'none' : 'block';
dataBaseUpdate.style.display = hasLicense ? 'block' : 'none';
};
license.addEventListener( 'keyup', licenseChange );
license.addEventListener( 'change', licenseChange );
license.dispatchEvent( new Event( 'change' ) );
} )();
// phpcs:enable
// manually update the database.
jQuery( $ => {
const $downloadButton = $( '#download_geolite' );
const $loader = $( '#advads-geo-loader' );
const $uploadError = $( '#advads-geo-upload-error' );
const $uploadSuccess = $( '#advads-geo-upload-success' );
const $noDbWarning = $( '#advanced-ads-geo-no-database-warning' );
$downloadButton.on( 'click', () => {
$downloadButton
.blur()
.attr( 'disabled', 'disabled' );
$loader.show();
// phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact -- moving each chain link into a new line improves readability immensely.
$.post( ajaxurl, {
action: 'advads_download_geolite_database',
license_key: $( '#advanced-ads-geo-maxmind-licence' ).val(),
locale: $( '[name="advanced-ads-pro[geo][locale]"]' ).val(),
nonce: window.advads_geo_translation.nonce
} )
.done( function ( result ) {
if ( ! $.isPlainObject( result ) ) {
return;
}
$uploadError.hide();
$uploadSuccess.html( result.data ).show();
$noDbWarning.remove();
$downloadButton.remove();
} )
.fail( function ( jqXHR, errorMessage ) {
let responseText;
try {
responseText = jQuery.parseJSON( jqXHR.responseText );
} catch ( e ) {
responseText = null;
}
errorMessage = responseText && responseText.data ? responseText.data : errorMessage;
$uploadError.html( errorMessage ).show();
$uploadSuccess.hide();
$downloadButton.attr( 'disabled', false );
} )
.always( function () {
$loader.hide();
} );
// phpcs:enable
} );
} );

View File

@@ -0,0 +1,94 @@
<?php
/**
* Render the database update form.
*
* @package AdvancedAds\Pro\Modules\Geo
* @author Advanced Ads <info@wpadvancedads.com>
*
* @var bool $correct_databases
* @var string|false $last_update
* @var int $next_update
* @var bool $use_filters
*/
if ( $correct_databases ) : ?>
<p>
<?php esc_html_e( 'Geo Databases found.', 'advanced-ads-pro' ); ?>
</p>
<?php endif; ?>
<?php if ( $use_filters ) : ?>
<div class="advads-notice-inline advads-idea">
<p><?php esc_html_e( 'You are currently using filter hooks to load custom database files.', 'advanced-ads-pro' ); ?></p>
</div>
<?php
return;
endif;
?>
<p id="advanced-ads-geo-license-missing-warning" style="display: none;">
<span class="advads-notice-inline advads-error">
<?php esc_html_e( 'The MaxMind license key is missing.', 'advanced-ads-pro' ); ?>
</span>
<?php
printf(
/* translators: 1: opening <a>-tag to Advanced Ads manual, 2: closing <a>-tag */
esc_html__( 'Please read the %1$sinstallation instructions%2$s.', 'advanced-ads-pro' ),
'<a href="https://wpadvancedads.com/manual/geo-targeting-condition/#Enabling_Geo-Targeting" target="_blank">',
'</a>'
);
?>
</p>
<div id="advanced-ads-geo-update-database" <?php echo $correct_databases ? esc_attr( 'data-db-exists' ) : ''; ?>>
<?php if ( ! $correct_databases ) : ?>
<div id="advanced-ads-geo-no-database-warning">
<p class="advads-notice-inline advads-error">
<?php esc_html_e( 'Geo Databases not found.', 'advanced-ads-pro' ); ?>
</p>
<p>
<?php esc_html_e( 'In order to use Geo Targeting, please download the geo location databases by clicking on the button below.', 'advanced-ads-pro' ); ?>
</p>
</div>
<?php endif; ?>
<?php if ( ! $correct_databases || $this->is_update_available() ) : ?>
<button type="button" id="download_geolite" class="button-secondary">
<?php esc_html_e( 'Update geo location databases', 'advanced-ads-pro' ); ?> (~66MB)
</button>
<span class="advads-loader" id="advads-geo-loader" style="display: none;"></span>
<p class="advads-notice-inline advads-error hidden" id="advads-geo-upload-error"></p>
<p class="advads-notice-inline advads-check hidden" id="advads-geo-upload-success"></p>
<?php endif; ?>
</div>
<?php
if ( $correct_databases ) :
if ( $last_update ) :
?>
<p class="advads-notice-inline advads-check">
<?php
printf(
/* translators: Timestamp in the localized date_format */
esc_html__( 'Last update: %s', 'advanced-ads-pro' ),
esc_html( date_i18n( get_option( 'date_format' ), $last_update ) )
);
?>
</p>
<?php endif; ?>
<p>
<?php
printf(
/* translators: Timestamp in the localized date_format */
esc_html__( 'Next possible update on %s.', 'advanced-ads-pro' ),
esc_html( date_i18n( get_option( 'date_format' ), $next_update ) )
);
?>
</p>
<p class="description">
<?php esc_html_e( 'The databases are updated on the first Tuesday (midnight, GMT) of each month.', 'advanced-ads-pro' ); ?>
</p>
<?php
endif;

View File

@@ -0,0 +1,15 @@
<?php
/**
* @var string $locale
*/
?>
<select name="<?php echo Advanced_Ads_Pro::OPTION_KEY . '[' . Advanced_Ads_Geo_Plugin::OPTIONS_SLUG . '][locale]'; ?>">
<?php
foreach ( Advanced_Ads_Geo_Api::$locales as $_key => $_value ) {
?>
<option value="<?php echo $_key; ?>" <?php selected( $_key, $locale ); ?>><?php echo $_value; ?></option>
<?php
}
?>
</select>
<p class="description"><?php _e( 'Choose the language of the state/region or city entered. If the language is not available in the geo location database, it will check against the English version.', 'advanced-ads-pro' ); ?></p>

View File

@@ -0,0 +1,24 @@
<?php
/**
* View for the MaxMind license key setting.
*
* @package AdvancedAds\Pro\Modules\Geo
* @author Advanced Ads <info@wpadvancedads.com>
*
* @var string $license_key
* @var bool $use_filters
*/
printf(
'<input id="advanced-ads-geo-maxmind-licence" name="%s" type="text" data-customdb="%s" value="%s" />',
esc_attr( Advanced_Ads_Pro::OPTION_KEY . '[' . Advanced_Ads_Geo_Plugin::OPTIONS_SLUG . '][maxmind-license-key]' ),
$use_filters ? 'true' : '',
esc_attr( $license_key )
);
?>
<p class="description">
<a target="_blank" class="advads-external-link" rel="noopener" href="https://support.maxmind.com/hc/en-us/articles/4407111582235-Generate-a-License-Key">
<?php esc_attr_e( 'Manual', 'advanced-ads-pro' ); ?>
</a>
</p>

View File

@@ -0,0 +1,12 @@
<?php
/**
* @var array $methods
* @var string $method
*/
foreach ( $methods as $_key => $_method ) :
?>
<label>
<input type="radio" name="<?php echo Advanced_Ads_Pro::OPTION_KEY . '[' . Advanced_Ads_Geo_Plugin::OPTIONS_SLUG . '][method]'; ?>" value="<?php echo $_key; ?>" <?php checked( $_key, $method ); ?>/>
<?php echo $_method['description']; ?></label><br/>
<?php
endforeach;

View File

@@ -0,0 +1,22 @@
<?php
/**
* Show the visitor information saved to the `advanced_ads_visitor` cookie.
*
* @var Advanced_Ads_Geo_Visitor_Profile $visitor_profile
*/
?>
<p class="advads-condition-visitor-profile">
<strong><?php esc_html_e( 'Location based on your visitor profile cookie:', 'advanced-ads-pro' ); ?></strong>
<br>
<?php printf( '%s, %s, %s', esc_html( $visitor_profile->get_country() ), esc_html( $visitor_profile->region ), esc_html( $visitor_profile->city ) ); ?>
<br>
<?php esc_html_e( 'Coordinates', 'advanced-ads-pro' ); ?>: (<?php echo (float) $visitor_profile->lat; ?> / <?php echo (float) $visitor_profile->lon; ?>)
<br>
<button class="advads-condition-visitor-profile-reset" class="hide-if-no-js" type="button">
<?php esc_html_e( 'Reset Visitor Profile', 'advanced-ads-pro' ); ?>
</button>
</p>