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

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="140" overflow="visible"><path fill="#edfbff" d="M0 0h80v140H0z"/><g fill="#f2fcff"><path d="M0 0l40.066 23.312L80 0zm40.066 70L80 46.688v46.691z"/><path d="M0 93.379V46.688L40.066 70z"/></g><path fill="#e8faff" d="M80 0L40.066 23.312V70L80 46.688z"/><path fill="#f2fcff" d="M0 140l40.066-23.379L80 140z"/><path fill="#e8faff" d="M40.066 70L0 93.379V140l40.066-23.379z"/></svg>

After

Width:  |  Height:  |  Size: 435 B

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

@@ -0,0 +1,206 @@
<?php
/**
* PEF module
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
*/
namespace AdvancedAds\Modules\ProductExperimentationFramework;
/**
* Module main class
*/
class Module {
/**
* User meta key where the dismiss flag is stored.
*
* @var string
*/
const USER_META = 'advanced_ads_pef_dismiss';
/**
* Sum of all weights
*
* @var int
*/
private $weight_sum = 0;
/**
* ID => weight association
*
* @var int[]
*/
private $weights = [];
/**
* Whether the PEF can be displayed based on user meta
*
* @var bool
*/
private $can_display = true;
/**
* Return the singleton. Create it if needed
*
* @return Module
*/
public static function get_instance(): Module {
static $instance;
if ( null === $instance ) {
$instance = new self();
}
return $instance;
}
/**
* Singleton design
*/
private function __construct() {
add_action( 'admin_init', [ $this, 'admin_init' ] );
}
/**
* Initialization
*
* @return void
*/
public function admin_init(): void {
$meta = get_user_meta( get_current_user_id(), self::USER_META, true );
if ( $meta && $this->get_minor_version( ADVADS_VERSION ) === $this->get_minor_version( $meta ) ) {
$this->can_display = false;
return;
}
$this->collect_weights();
add_action( 'wp_ajax_advanced_ads_pef', [ $this, 'dismiss' ] );
}
/**
* Ajax action to hie PEF for the current user until next plugin update
*
* @return void
*/
public function dismiss(): void {
if ( ! check_ajax_referer( 'advanced_ads_pef' ) ) {
wp_send_json_error( 'Unauthorized', 401 );
}
update_user_meta( get_current_user_id(), self::USER_META, ADVADS_VERSION );
wp_send_json_success( 'OK', 200 );
}
/**
* Get a random feature based on weights and a random number
*
* @return array
*/
public function get_winner_feature(): array {
$random_weight = wp_rand( 1, $this->weight_sum );
$current_weight = 0;
foreach ( $this->get_features() as $id => $feature ) {
$current_weight += $this->weights[ $id ];
if ( $random_weight <= $current_weight ) {
return array_merge(
[
'id' => $id,
'weight' => $this->weights[ $id ],
],
$this->get_features()[ $id ]
);
}
}
}
/**
* Render PEF
*
* @param string $screen the screen on which PEF is displayed, used in the utm_campaign parameter.
*
* @return void
*/
public function render( $screen ): void { // phpcs:ignore
// Early bail!!
if ( ! $this->can_display ) {
return;
}
$winner = $this->get_winner_feature();
require_once DIR . '/views/template.php';
}
/**
* Get minor part of a version
*
* @param string $version version to get the minor part from.
*
* @return string
*/
public function get_minor_version( $version ): string {
return explode( '.', $version )[1] ?? '0';
}
/**
* Build the link for the winner feature with all its utm parameters
*
* @param array $winner the winner feature.
* @param string $screen the screen on which it was displayed.
*
* @return string
*/
public function build_link( $winner, $screen ): string {
$utm_source = 'advanced-ads';
$utm_medium = 'link';
$utm_campaign = sprintf( '%s-aa-labs', $screen );
$utm_term = sprintf(
'b%s-w%d-%d',
str_replace( '.', '-', ADVADS_VERSION ),
$winner['weight'],
$this->weight_sum
);
$utm_content = $winner['id'];
return sprintf(
'https://wpadvancedads.com/advanced-ads-labs/?utm_source=%s&utm_medium=%s&utm_campaign=%s&utm_term=%s&utm_content=%s',
$utm_source,
$utm_medium,
$utm_campaign,
$utm_term,
$utm_content
);
}
/**
* Set the features/banners
*
* @return array
*/
public function get_features(): array {
return [
'labs-amazon-integration' => [
'subheading' => __( 'FROM THE ADVANCED ADS LABS:', 'advanced-ads' ),
'heading' => __( 'The Amazon Integration', 'advanced-ads' ),
'weight' => 1,
'text' => __( 'Our latest product concept puts Amazon affiliate marketing at your fingertips—right within Advanced Ads. It offers features like direct product import via Amazon API, multiple product display formats, and efficient ad tracking. We aim to create a one-stop solution for featuring Amazon products on your site without resorting to expensive third-party plugins.', 'advanced-ads' ),
'cta' => __( 'Are you interested in this product concept?', 'advanced-ads' ),
'cta_button' => __( 'Yes, I want to know more!', 'advanced-ads' ),
],
];
}
/**
* Collect feature ID with their weight as recorded in the class constant. Also calculate the weight sum
*/
private function collect_weights() {
if ( 0 !== $this->weight_sum ) {
return;
}
foreach ( $this->get_features() as $id => $feature ) {
$this->weights[ $id ] = (int) $feature['weight'];
$this->weight_sum += $this->weights[ $id ];
}
}
}

View File

@@ -0,0 +1,18 @@
<?php
/**
* PEF module main file
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
*/
namespace AdvancedAds\Modules\ProductExperimentationFramework;
const DIR = __DIR__;
const FILE = __FILE__;
if ( ! is_admin() ) {
return;
}
Module::get_instance();

View File

@@ -0,0 +1,138 @@
<?php
/**
* Final output for the Product Experimentation
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
*
* @var array $winner the winner feature.
* @var string $screen the screen where it's displayed.
*/
?>
<style>
#support #advads_overview_pef {
max-width: 998px;
}
#advads_overview_pef {
border: 1px solid #0474a2;
border-radius: 5px;
margin: 22px 0;
color: #1b193a;
}
#advads_overview_pef div.aa_overview_pef_upper {
padding: 44px 44px 44px 208px;
background: url(<?php echo esc_url( trailingslashit( plugin_dir_url( \AdvancedAds\Modules\ProductExperimentationFramework\FILE ) ) ) . '/assets/aa-pef-bg.svg'; ?>) top left / 40px auto repeat;
border-radius: 5px 5px 0 0;
color: inherit;
}
#advads_overview_pef p.aa_overview_pef_dismiss {
position: absolute;
top: 22px;
right: 22px;
margin: 0;
text-align: right;
color: inherit;
}
#advads_overview_pef p.aa_overview_pef_dismiss a {
display: block;
text-decoration: none;
color: #1b193a;
}
#advads_overview_pef p.aa_overview_pef_subhead {
margin: 0 0 11px;
font-size: 18px;
line-height: 18px;
text-transform: uppercase;
font-weight: bold;
color: inherit;
}
#advads_overview_pef p.aa_overview_pef_subhead:before {
content: "";
position: absolute;
top: 44px;
left: 44px;
width: 120px;
height: 164px;
background: url(<?php echo esc_url( trailingslashit( plugin_dir_url( \AdvancedAds\Modules\ProductExperimentationFramework\FILE ) ) ) . '/assets/aa-pef-amazon-deco.svg'; ?>) center/contain no-repeat;
}
#advads_overview_pef h3.aa_overview_pef_head {
margin: 0 0 44px;
font-size: 36px;
line-height: 36px;
font-weight: bold;
color: inherit;
}
#advads_overview_pef p.aa_overview_pef_copy {
margin: 0 0 44px;
font-size: 18px;
line-height: 22px;
font-weight: normal;
color: inherit;
}
#advads_overview_pef p.aa_overview_pef_copy:last-child {
margin-bottom: 0;
}
#advads_overview_pef div.aa_overview_pef_lower {
padding: 22px 44px 22px 208px;
color: inherit;
}
#advads_overview_pef p.aa_overview_pef_cta {
margin: 0;
font-size: 18px;
font-weight: bold;
color: inherit;
}
#advads_overview_pef a.aa_overview_pef_button {
display: inline-block;
margin-left: 22px;
padding: 8px 22px;
font-size: 18px;
font-weight: bold;
border-radius: 5px;
color: #fff;
background: #1b193a;
text-decoration: none;
}
</style>
<script>
jQuery( document ).on( 'click', '.aa_overview_pef_dismiss', function ( ev ) {
ev.preventDefault();
wp.ajax.post(
'advanced_ads_pef',
{
_ajax_nonce: '<?php echo esc_js( wp_create_nonce( 'advanced_ads_pef' ) ); ?>',
version: '<?php echo esc_js( ADVADS_VERSION ); ?>'
}
).done( function () {
jQuery( '#advads_overview_pef' ).remove();
} );
} );
</script>
<div id="advads_overview_pef" class="postbox position-full">
<div class="aa_overview_pef_upper">
<p class="aa_overview_pef_dismiss"><a class="dashicons dashicons-dismiss" href="#"></a></p>
<p class="aa_overview_pef_subhead"><?php echo esc_html( $winner['subheading'] ); ?></p>
<h3 class="aa_overview_pef_head"><?php echo esc_html( $winner['heading'] ); ?></h3>
<p class="aa_overview_pef_copy"><?php echo wp_kses_post( $winner['text'] ); ?></p>
</div>
<div class="aa_overview_pef_lower">
<p class="aa_overview_pef_cta">
<?php echo esc_html( $winner['cta'] ); ?>
<a class="aa_overview_pef_button" href="<?php echo esc_url( $this->build_link( $winner, $screen ) ); ?>" target="_blank">
<?php echo esc_html( $winner['cta_button'] ); ?>
</a>
</p>
</div>
</div>