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,90 @@
<?php // phpcs:ignoreFile
use AdvancedAds\Abstracts\Group;
use AdvancedAds\Utilities\WordPress;
class Advanced_Ads_Pro_Module_Grids_Admin {
public function __construct() {
// add new ad group type
add_action( 'advanced-ads-group-form-options', [ $this, 'group_options' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'load_admin_scripts' ], 10 );
}
/**
* render group options for grids
*
* @param Group $group Group instance.
*/
public function group_options( Group $group ) {
$options = $group->get_data();
$options = $options['options'] ?? [];
$columns = absint( $options['grid']['columns'] ?? 3 );
$rows = absint( $options['grid']['rows'] ?? 2 );
$inner_margin = isset( $options['grid']['inner_margin'] ) ? min( absint( $options['grid']['inner_margin'] ), 50 ) : 3;
$min_width = absint( $options['grid']['min_width'] ?? 250 );
$full_width_breakpoint = absint( $options['grid']['full_width_breakpoint'] ?? 0 );
$random = isset( $options['grid']['random'] ) ? 1 : 0;
// Size.
ob_start();
include dirname( __FILE__ ) . '/views/grid-option-size.php';
$option_content = ob_get_clean();
WordPress::render_option(
'group-pro-grid-size advads-group-type-grid',
__( 'Size', 'advanced-ads-pro' ),
$option_content );
// margin
ob_start();
include dirname( __FILE__ ) . '/views/grid-option-margin.php';
$option_content = ob_get_clean();
WordPress::render_option(
'group-pro-grid-margin advads-group-type-grid',
__('Inner margin', 'advanced-ads-pro' ),
$option_content );
// min width
WordPress::render_option(
'group-pro-grid-width advads-group-type-grid',
__('Min. width', 'advanced-ads-pro' ),
'<input style="width:4em;" type="number" min="0" name="advads-groups['.$group->get_id().'][options][grid][min_width]" value="'.$min_width.'"/> px',
__( 'Minimum width of a column in the grid.', 'advanced-ads-pro' ) );
// full width on mobile
WordPress::render_option(
'group-pro-grid-mobile advads-group-type-grid',
__('Full width', 'advanced-ads-pro' ),
'<input style="width:4em;" type="number" min="0" name="advads-groups['.$group->get_id().'][options][grid][full_width_breakpoint]" value="'.$full_width_breakpoint.'"/> px',
__( 'On browsers smaller than this, the columns show in full width below each other.', 'advanced-ads-pro' )
. ' ' . __( 'Set to 0 to disable this feature.', 'advanced-ads-pro' ) );
// random
ob_start();
?><input type="checkbox" name="advads-groups[<?php echo $group->get_id(); ?>][options][grid][random]"
<?php if ($random) : ?>
checked = "checked"
<?php endif; ?>
/><?php
$option_content = ob_get_clean();
WordPress::render_option(
'group-pro-grid-random advads-group-type-grid',
__('Random order', 'advanced-ads-pro' ),
$option_content );
}
/**
* load admin scripts needed for flash files
*/
public function load_admin_scripts() {
// load only on ad group page
$screen = get_current_screen();
if( isset( $screen->id ) && 'advanced-ads_page_advanced-ads-groups' === $screen->id ) {
wp_enqueue_script( 'advanced-ads-pro-grid-admin-group-script', plugins_url( 'assets/js/admin.js', __FILE__ ), ['jquery'], AAP_VERSION );
}
}
}

View File

@@ -0,0 +1,3 @@
<?php
new Advanced_Ads_Pro_Module_Grids_Admin();

View File

@@ -0,0 +1,7 @@
jQuery(document).ready(function($){
$('.advads-ad-group-form').each(function(){
if( 'grid' === $(this).find('.advads-ad-group-type input:checked').val()){
$(this).find('.advads-option-group-number').val('all').hide();
}
});
});

View File

@@ -0,0 +1,87 @@
<?php
/**
* This class is responsible to model grid groups.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.48.0
*/
namespace AdvancedAds\Pro\Modules\Grids;
use AdvancedAds\Abstracts\Group;
use AdvancedAds\Interfaces\Group_Interface;
defined( 'ABSPATH' ) || exit;
/**
* Grid group.
*/
class Group_Grid extends Group implements Group_Interface {
/**
* Get columns.
*
* @param string $context What the value is for. Valid values are view and edit.
*
* @return int
*/
public function get_columns( $context = 'view' ): int {
return $this->get_prop( 'columns', $context );
}
/**
* Get rows.
*
* @param string $context What the value is for. Valid values are view and edit.
*
* @return int
*/
public function get_rows( $context = 'view' ): int {
return $this->get_prop( 'rows', $context );
}
/**
* Get inner margin.
*
* @param string $context What the value is for. Valid values are view and edit.
*
* @return int
*/
public function get_inner_margin( $context = 'view' ): int {
return $this->get_prop( 'inner_margin', $context );
}
/**
* Get min width.
*
* @param string $context What the value is for. Valid values are view and edit.
*
* @return int
*/
public function get_min_width( $context = 'view' ): int {
return $this->get_prop( 'min_width', $context );
}
/**
* Get full width breakpoint.
*
* @param string $context What the value is for. Valid values are view and edit.
*
* @return int
*/
public function get_full_width_breakpoint( $context = 'view' ): int {
return $this->get_prop( 'full_width_breakpoint', $context );
}
/**
* Is grid display random.
*
* @param string $context What the value is for. Valid values are view and edit.
*
* @return bool
*/
public function is_random( $context = 'view' ): bool {
return $this->get_prop( 'random', $context );
}
}

View File

@@ -0,0 +1,38 @@
<?php
/**
* Modules Grids Type Grid.
*
* @package AdvancedAds\Pro
* @author Advanced Ads <info@wpadvancedads.com>
* @since 2.26.0
*/
namespace AdvancedAds\Pro\Modules\Grids;
use AdvancedAds\Groups\Types\Grid as TypeGrid;
defined( 'ABSPATH' ) || exit;
/**
* Type Grid.
*/
class Type_Grid extends TypeGrid {
/**
* Get the class name of the object as a string.
*
* @return string
*/
public function get_classname(): string {
return Group_Grid::class;
}
/**
* Check if this group type requires premium.
*
* @return bool True if premium is required; otherwise, false.
*/
public function is_premium(): bool {
return false;
}
}

View File

@@ -0,0 +1,179 @@
<?php // phpcs:ignore WordPress.Files.FileName
use AdvancedAds\Abstracts\Group;
use AdvancedAds\Abstracts\Types;
use AdvancedAds\Pro\Modules\Grids\Type_Grid;
/**
* Class Grids
*/
class Advanced_Ads_Pro_Module_Grids {
/**
* The constructor.
*/
public function __construct() {
add_filter( 'advanced-ads-group-types-manager', [ $this, 'add_group_type' ] );
add_filter( 'advanced-ads-group-output-ad-ids', [ $this, 'output_ad_ids' ], 10, 5 );
add_filter( 'advanced-ads-group-grid-displayed-ad-count', [ $this, 'adjust_ad_group_displayed_ad_count' ], 10, 2 );
add_filter( 'advanced-ads-group-ad-count', [ $this, 'adjust_ad_group_number' ], 10, 2 );
add_filter( 'advanced-ads-group-output-array', [ $this, 'output_markup' ], 10, 2 );
add_filter( 'advanced-ads-pro-passive-cb-group-data', [ $this, 'add_grid_markup_passive' ], 10, 3 );
}
/**
* Add grid group type
*
* @param Types $manager Group types manager.
*
* @return void
*/
public function add_group_type( $manager ): void {
$manager->register_type( Type_Grid::class );
}
/**
* Get ids from ads in the order they should be displayed
*
* @param array $ordered_ad_ids Ad ids in the order from the main plugin.
* @param string $type Group type.
* @param array $ads Array with ad objects.
* @param array $weights Array with ad weights.
* @param Group $group Group instance.
*
* @return array $ad_ids
*/
public function output_ad_ids( $ordered_ad_ids, $type, $ads, $weights, $group ) {
// For some reason a client had an issue with $group not being the correct class.
if ( ! is_a_group( $group ) ) {
return $ordered_ad_ids;
}
if ( 'grid' === $type ) {
if ( $group->get_prop( 'random' ) ) {
return $group->shuffle_ads();
} else {
return array_keys( $weights );
}
}
return $ordered_ad_ids;
}
/**
* Adjust the ad group number if the ad type is a grid.
*
* @param int|string $ad_count The number of ads, is an integer or string 'all'.
* @param Group $group Group instance.
*
* @return int|string The number of ads, either an integer or string 'all'.
*/
public function adjust_ad_group_number( $ad_count, $group ) {
if ( $group->is_type( 'grid' ) ) {
return $group->get_columns() * $group->get_rows();
}
return $ad_count;
}
/**
* Adjust ad count in group page for grid groups
*
* @param int $displayed_ad_count Displayed ad count from the base plugin.
* @param Group $group Group instance.
*
* @return int
*/
public function adjust_ad_group_displayed_ad_count( $displayed_ad_count, $group ) {
return $group->get_columns() * $group->get_rows();
}
/**
* Add extra output markup for grid
*
* @param array $ad_content Array with ad contents.
* @param Group $group Group instance.
*
* @return array $ad_content with extra markup
*/
public function output_markup( array $ad_content, Group $group ) {
if ( count( $ad_content ) <= 1 || ! $group->is_type( 'grid' ) ) {
return $ad_content;
}
$i = 1;
$markup = $this->get_grid_markup( $group );
foreach ( $ad_content as $_key => $_content ) {
foreach ( $markup['each'] as $_column_index => $_format ) {
if ( 'all' === $_column_index || 0 === $i % $_column_index ) {
$ad_content[ $_key ] = sprintf( $_format, $_content );
break;
}
}
++$i;
}
array_unshift( $ad_content, $markup['before'] );
array_push( $ad_content, $markup['after'] );
return $ad_content;
}
/**
* Add grid markup to passive cache-busting.
*
* @param array $group_data Group data.
* @param Group $group Group instance.
* @param string $element_id Element ID.
*/
public function add_grid_markup_passive( $group_data, Group $group, $element_id ) {
if ( $element_id && $group->is_type( 'grid' ) ) {
$group_data['random'] = $group->get_prop( 'grid.random' );
$group_data['group_wrap'][] = $this->get_grid_markup( $group );
}
return $group_data;
}
/**
* Get markup to inject around each ad and around entire set of ads.
*
* @param Group $group Group instance.
*
* @return array
*/
public function get_grid_markup( Group $group ) {
$columns = $group->get_columns();
$prefix = wp_advads()->get_frontend_prefix();
$grid_id = $prefix . 'grid-' . $group->get_id();
$min_width = $group->get_prop( 'min_width' );
$full_width_breakpoint = absint( $group->get_prop( 'full_width_breakpoint' ) ) ?? false;
$inner_margin = absint( $group->get_prop( 'inner_margin' ) );
$width = absint( ( 100 - ( $columns - 1 ) * $inner_margin ) / $columns );
// Generate styles.
$css = "<style>#$grid_id{list-style:none;margin:0;padding:0;overflow:hidden;}"
. "#$grid_id>li{float:left;width:$width%;min-width:{$min_width}px;list-style:none;margin:0 $inner_margin% $inner_margin% 0;;padding:0;overflow:hidden;}"
. "#$grid_id>li.last{margin-right:0;}"
. "#$grid_id>li.last+li{clear:both;}";
// Add media query if there was a full width breakpoint set.
if ( ! empty( $full_width_breakpoint ) ) {
$css .= "@media only screen and (max-width:{$full_width_breakpoint}px) {#$grid_id>li{width:100%;}}";
}
$css .= '</style>';
return [
'before' => '<ul id="' . $grid_id . '">',
'after' => '</ul>' . $css,
'each' => [
$columns => '<li class="last">%s</li>',
'all' => '<li>%s</li>',
],
'min_ads' => 2,
];
}
}

View File

@@ -0,0 +1,3 @@
<?php
new Advanced_Ads_Pro_Module_Grids;

View File

@@ -0,0 +1,3 @@
<label>
<input style="width:4em;" type="number" name="advads-groups[<?php echo $group->get_id(); ?>][options][grid][inner_margin]" value="<?php echo $inner_margin; // phpcs:ignore ?>" min="0" max="50"/> %
</label>

View File

@@ -0,0 +1,20 @@
<?php
/**
* Render group option size.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
*
* phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
*/
?>
<label><select name="advads-groups[<?php echo $group->get_id(); ?>][options][grid][columns]">
<?php for ( $i = 1; $i <= 10; $i++ ) : ?>
<option value="<?php echo $i; ?>"<?php selected( $i, $columns ); ?>><?php echo $i; ?></option>
<?php endfor; ?>
</select><?php esc_html_e( 'columns', 'advanced-ads-pro' ); ?> x </label><label><select name="advads-groups[<?php echo $group->get_id(); ?>][options][grid][rows]">
<?php for ( $i = 1; $i <= 50; $i++ ) : ?>
<option value="<?php echo $i; ?>"<?php selected( $i, $rows ); ?>><?php echo $i; ?></option>
<?php endfor; ?>
</select><?php esc_html_e( 'rows', 'advanced-ads-pro' ); ?></label>