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,139 @@
<?php
/**
* Responsive Ads Admin.
*
* @package Advanced_Ads_Pro\Module
* @subpackage Responsive_Ads
* @author Advanced Ads <info@wpadvancedads.com>
*/
namespace Advanced_Ads_Pro\Module\Responsive_Ads;
use Advanced_Ads_Pro;
defined( 'ABSPATH' ) || exit;
/**
* Class Admin
*/
class Admin {
/**
* Hook into WordPress.
*/
public function hooks(): void {
add_action( 'advanced-ads-settings-init', [ $this, 'add_settings' ] );
}
/**
* Add settings for module
*
* @return void
*/
public function add_settings() {
$section_id = 'advanced_ads_responsive_setting_section';
add_settings_section(
$section_id,
__( 'Responsive Ads', 'advanced-ads-pro' ),
null,
Advanced_Ads_Pro::OPTION_KEY . '-settings'
);
add_settings_field(
'responsive-images',
esc_html__( 'Responsive Image Ads', 'advanced-ads-pro' ),
[ $this, 'render_setting_responsive_image_ads' ],
Advanced_Ads_Pro::OPTION_KEY . '-settings',
$section_id
);
add_settings_field(
'reload-ads-on-resize',
esc_html__( 'Reload ads on resize', 'advanced-ads-pro' ),
[ $this, 'render_settings_reload_ads_on_resize' ],
Advanced_Ads_Pro::OPTION_KEY . '-settings',
$section_id
);
add_settings_field(
'fallback-width',
esc_html__( 'Fallback width', 'advanced-ads-pro' ),
[ $this, 'render_settings_fallback_width' ],
Advanced_Ads_Pro::OPTION_KEY . '-settings',
$section_id
);
}
/**
* Render responsive image settings field
*/
public function render_setting_responsive_image_ads() {
$options = Advanced_Ads_Pro::get_instance()->get_options();
$force_responsive = isset( $options['responsive-ads']['force-responsive-images'] );
require $this->get_view_path() . '/setting_responsive_images.php';
}
/**
* Render setting to reload ads when screen resizes.
*/
public function render_settings_reload_ads_on_resize() {
$options = Advanced_Ads_Pro::get_instance()->get_options();
$cache_busting_enabled = isset( $options['cache-busting']['enabled'] ) && boolval( $options['cache-busting']['enabled'] );
$reload_ads_option_enabled = ! empty( $options['responsive-ads']['reload-ads-on-resize'] );
require $this->get_view_path() . '/setting_reload_ads.php';
}
/**
* Render setting to set fallback width.
*/
public function render_settings_fallback_width() {
$options = Advanced_Ads_Pro::get_instance()->get_options();
$width = ! empty( $options['responsive-ads']['fallback-width'] ) ? absint( $options['responsive-ads']['fallback-width'] ) : 768;
require $this->get_view_path() . '/setting_fallback_width.php';
}
/**
* Get view path for module
*
* @return string View folder path.
*/
private function get_view_path() {
return AAP_BASE_PATH . 'modules/responsive-ads/views';
}
/**
* Returns true if the Responsive addon is active.
* If the loading order of the plugins is not default,
* AAR_BASE_PATH could be undefined, even though the Responsive add-on is still installed.
* This is an approximation to that issue. If a user has renamed the plugin file, this will also fail.
*
* @return bool
*/
public function is_responsive_active(): bool {
$plugins = array_filter(
apply_filters( 'active_plugins', get_option( 'active_plugins' ) ),
static function ( $plugin ) {
$needle = 'responsive-ads.php';
$len = strlen( $needle );
return substr_compare( $plugin, $needle, -$len, $len ) === 0;
}
);
$active_by_string = ! empty( $plugins );
return defined( 'AAR_BASE_PATH' ) || $active_by_string;
}
/**
* Returns true if the Responsive addon is deprecated.
*
* @return true
*/
public function is_responsive_outdated(): bool {
return $this->is_responsive_active() && ! defined( 'AAR_AMP_ADSENSE_ONLY' );
}
}

View File

@@ -0,0 +1,86 @@
<?php
/**
* Responsive Ads Common.
*
* @package Advanced_Ads_Pro\Module
* @subpackage Responsive_Ads
* @author Advanced Ads <info@wpadvancedads.com>
*/
namespace Advanced_Ads_Pro\Module\Responsive_Ads;
use Advanced_Ads_Pro;
use AdvancedAds\Framework\Utilities\Params;
defined( 'ABSPATH' ) || exit;
/**
* Class Common
*/
class Common {
/**
* Hook into WordPress.
*/
public function hooks(): void {
add_filter( 'advanced-ads-visitor-conditions', [ $this, 'visitor_conditions' ] );
}
/**
* Add visitor condition
*
* @param array $conditions Hold visitor conditions.
*
* @return array
*/
public function visitor_conditions( $conditions ) {
if ( ! defined( 'ADVANCED_ADS_RESPONSIVE_DISABLE_BROWSER_WIDTH' ) ) {
$conditions['device_width'] = [
'label' => esc_html__( 'browser width', 'advanced-ads-pro' ),
'description' => esc_html__( 'Display ads based on the browser width.', 'advanced-ads-pro' ),
'metabox' => [ 'Advanced_Ads_Visitor_Conditions', 'metabox_number' ],
'check' => [ $this, 'check_browser_width' ],
];
}
return $conditions;
}
/**
* Check browser width in frontend
*
* @param array $options Options of the condition.
*
* @return bool True if ad/group can be displayed.
*/
public function check_browser_width( $options = [] ) {
if ( defined( 'ADVANCED_ADS_RESPONSIVE_DISABLE_BROWSER_WIDTH' ) ) {
return true;
}
if ( ! isset( $options['operator'], $options['value'] ) ) {
return true;
}
$browser_width = 0;
$ads_visitor = Params::cookie( 'advanced_ads_visitor' );
if ( ! empty( $ads_visitor ) ) {
$browser_width = json_decode( stripslashes( $ads_visitor ), true ); // phpcs:ignore
$browser_width = $browser_width['browser_width'] ?? 0;
} else {
$responsive_options = Advanced_Ads_Pro::get_instance()->get_options();
$browser_width = ! empty( $responsive_options['responsive-ads']['fallback-width'] ) ? absint( $responsive_options['responsive-ads']['fallback-width'] ) : 768;
}
$value = absint( $options['value'] );
$operator = $options['operator'];
$operators = [
'is_equal' => $value === $browser_width,
'is_higher' => $value <= $browser_width,
'is_lower' => $value >= $browser_width,
];
return $operators[ $operator ] ?? true;
}
}

View File

@@ -0,0 +1,69 @@
<?php
/**
* Responsive Ads Frontend.
*
* @package Advanced_Ads_Pro\Module
* @subpackage Responsive_Ads
* @author Advanced Ads <info@wpadvancedads.com>
*/
namespace Advanced_Ads_Pro\Module\Responsive_Ads;
use Advanced_Ads_Pro;
defined( 'ABSPATH' ) || exit;
/**
* Class Frontend
*/
class Frontend {
/**
* Hook into WordPress.
*/
public function hooks(): void {
$options = Advanced_Ads_Pro::get_instance()->get_options();
if ( isset( $options['responsive-ads']['force-responsive-images'] ) && $options['responsive-ads']['force-responsive-images'] ) {
add_filter( 'advanced-ads-ad-image-tag-style', [ $this, 'force_responsive_images' ] );
}
add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ], 15 );
}
/**
* Force responsive image by adding styles
*
* @param string $image_styles Existing image styles.
*
* @return string New image styles
*/
public function force_responsive_images( $image_styles ) {
return $image_styles . ' max-width: 100%; height: auto;';
}
/**
* Enqueue options.
*
* @return void
*/
public function register_scripts() {
if ( function_exists( 'advads_is_amp' ) && advads_is_amp() ) {
return;
}
if ( ! defined( 'ADVADS_SLUG' ) || defined( 'ADVANCED_ADS_RESPONSIVE_DISABLE_BROWSER_WIDTH' ) ) {
return;
}
$options = Advanced_Ads_Pro::get_instance()->get_options();
wp_localize_script(
'advanced-ads-pro/cache_busting',
'advanced_ads_responsive',
[
'reload_on_resize' => ! empty( $options['responsive-ads']['reload-ads-on-resize'] ) ? 1 : 0,
]
);
}
}

View File

@@ -0,0 +1,44 @@
<?php
/**
* Responsive Ads Module bootstrap
*
* @package Advanced_Ads_Pro\Module
* @subpackage Responsive_Ads
* @author Advanced Ads <info@wpadvancedads.com>
*/
use Advanced_Ads_Pro\Module\Responsive_Ads\Admin;
use Advanced_Ads_Pro\Module\Responsive_Ads\Common;
use Advanced_Ads_Pro\Module\Responsive_Ads\Frontend;
defined( 'ABSPATH' ) || exit;
if ( ( new Admin() )->is_responsive_active() ) {
$notices = get_option( 'advanced-ads-notices' );
if ( ! array_key_exists( 'pro_responsive_migration', $notices['closed'] ?? [] ) ) {
Advanced_Ads_Admin_Notices::get_instance()->add_to_queue( 'pro_responsive_migration' );
}
}
if ( ( new Admin() )->is_responsive_outdated() ) {
return;
}
/**
* Common
*/
( new Common() )->hooks();
/**
* Start admin.
*/
if ( is_admin() ) {
( new Admin() )->hooks();
return;
}
/**
* Start frontend.
*/
( new Frontend() )->hooks();

View File

@@ -0,0 +1,16 @@
<?php
/**
* Responsive Ads fallback browser width template
*
* @var int $width Fallback width.
*
* @package Advanced_Ads_Pro\Module
* @subpackage Responsive_Ads
* @author Advanced Ads <info@wpadvancedads.com>
*/
$setting_name = Advanced_Ads_Pro::OPTION_KEY . '[responsive-ads][fallback-width]';
?>
<input type="number" name="<?php echo esc_attr( $setting_name ); ?>" value="<?php echo esc_attr( $width ); ?>" class="small-text" /> px.
<a href="https://wpadvancedads.com/manual/display-ads-by-browser-width/?utm_source=advanced-ads&utm_medium=link&utm_campaign=settings-fallback-with#Fallback_width" target="_blank" class="advads-manual-link"><?php esc_html_e( 'Manual', 'advanced-ads-pro' ); ?></a>

View File

@@ -0,0 +1,31 @@
<?php
/**
* Responsive Ads reload setting template
*
* @package Advanced_Ads_Pro\Module
* @subpackage Responsive_Ads
* @author Advanced Ads <info@wpadvancedads.com>
*/
$setting_name = Advanced_Ads_Pro::OPTION_KEY . '[responsive-ads][reload-ads-on-resize]';
?>
<input id="aa-pro-reload-ads-on-resize" type="checkbox" name="<?php echo esc_attr( $setting_name ); ?>" value="1"<?php checked( $reload_ads_option_enabled ); ?><?php disabled( ! $cache_busting_enabled ); ?> />
<label for="aa-pro-reload-ads-on-resize">
<?php
esc_html_e( 'Reload ads when the screen resizes.', 'advanced-ads-pro' );
if ( ! $cache_busting_enabled ) {
echo ' ';
esc_html_e( 'You need to enable cache-busting in order to use this feature.', 'advanced-ads-pro' );
}
?>
</label>
<script>
(function($) {
const cacheSwitch = $('#advanced-ads-pro-cache-busting-enabled');
const reloadSwitch = $('#aa-pro-reload-ads-on-resize');
cacheSwitch.on( 'change', function() {
reloadSwitch.prop( 'disabled', ! cacheSwitch.is(':checked') )
})
})(jQuery)
</script>

View File

@@ -0,0 +1,16 @@
<?php
/**
* Responsive Ads setting template
*
* @package Advanced_Ads_Pro\Module
* @subpackage Responsive_Ads
* @author Advanced Ads <info@wpadvancedads.com>
*/
$setting_name = Advanced_Ads_Pro::OPTION_KEY . '[responsive-ads][force-responsive-images]';
?>
<input type="checkbox" id="aa-pro-responsive-images-force" name="<?php echo esc_attr( $setting_name ); ?>" value="1" <?php checked( $force_responsive ); ?> />
<label for="aa-pro-responsive-images-force">
<?php esc_html_e( 'Check this option if the size of image ads is not adjusted responsively by your theme.', 'advanced-ads-pro' ); ?>
</label>