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,307 @@
<?php
/**
* Traits Entity.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.48.2
*/
namespace AdvancedAds\Traits;
use AdvancedAds\Abstracts\Group;
use AdvancedAds\Abstracts\Placement;
defined( 'ABSPATH' ) || exit;
/**
* Traits Entity.
*/
trait Entity {
/**
* Entity parent object.
*
* @var Group|Placement|null
*/
private $parent = null;
/* Getter ------------------- */
/**
* Get the parent entity name.
*
* @return int
*/
public function get_parent_entity_name(): string {
if ( $this->is_parent_group() ) {
return _x( 'Ad Group', 'ad group singular name', 'advanced-ads' );
}
if ( $this->is_parent_placement() ) {
return _x( 'Placement', 'ad placement singular name', 'advanced-ads' );
}
return __( 'Unknown', 'advanced-ads' );
}
/**
* Get title.
*
* @param string $context What the value is for. Valid values are view and edit.
*
* @return string
*/
public function get_title( $context = 'view' ): string {
return $this->get_prop( 'title', $context ) ?? '';
}
/**
* Get slug.
*
* @param string $context What the value is for. Valid values are view and edit.
*
* @return string
*/
public function get_slug( $context = 'view' ): string {
return $this->get_prop( 'slug', $context ) ?? '';
}
/**
* Get content.
*
* @param string $context What the value is for. Valid values are view and edit.
*
* @return string
*/
public function get_content( $context = 'view' ): string {
return $this->get_prop( 'content', $context );
}
/**
* Get status.
*
* @param string $context What the value is for. Valid values are view and edit.
*
* @return string
*/
public function get_status( $context = 'view' ): string {
return $this->get_prop( 'status', $context );
}
/**
* Get type.
*
* @param string $context What the value is for. Valid values are view and edit.
*
* @return string
*/
public function get_type( $context = 'view' ): string {
return $this->get_prop( 'type', $context );
}
/**
* Get author ID.
*
* @param string $context What the value is for. Valid values are view and edit.
*
* @return int The author ID.
*/
public function get_author_id( $context = 'view' ): int {
return absint( $this->get_prop( 'author_id', $context ) ) ?? 0;
}
/**
* Get parent object.
*
* @return Group|Placement|null
*/
public function get_parent() {
return $this->parent;
}
/**
* Get placement that is its parent or grandparent if any.
*
* @return Placement|false
*/
public function get_root_placement() {
if ( $this->is_parent_placement() ) {
return $this->get_parent();
}
if ( $this->has_parent() && $this->get_parent()->is_parent_placement() ) {
return $this->get_parent()->get_parent();
}
return false;
}
/* Setter ------------------- */
/**
* Set title.
*
* @param string $title Entity title.
*
* @return void
*/
public function set_title( $title ): void {
$this->set_prop( 'title', $title );
}
/**
* Set slug.
*
* @param string $slug Entity slug.
*
* @return void
*/
public function set_slug( $slug ): void {
$this->set_prop( 'slug', sanitize_text_field( wp_unslash( $slug ) ) );
}
/**
* Set content.
*
* @param string $content Entity content.
*
* @return void
*/
public function set_content( $content ): void {
$this->set_prop( 'content', $content );
}
/**
* Set status.
*
* @param string $status Entity status.
*
* @return void
*/
public function set_status( $status ): void {
$this->set_prop( 'status', $status );
}
/**
* Set author ID.
*
* @param int $author_id The author ID.
*
* @return void
*/
public function set_author_id( $author_id ): void {
$this->set_prop( 'author_id', absint( $author_id ) );
}
/**
* Set type.
*
* @param string $type Entity type.
*
* @return void
*/
public function set_type( $type ): void {
$this->set_prop( 'type', $type );
}
/**
* Set parent object.
*
* @param Group|Placement|null $item Parent object.
*
* @return void
*/
public function set_parent( $item ): void {
$this->parent = $item;
}
/* Conditional ------------------- */
/**
* Check if the entity has parent.
*
* @return bool
*/
public function has_parent(): bool {
return null !== $this->parent;
}
/**
* Check the status.
*
* @param string|array $status Status to check.
*
* @return bool
*/
public function is_status( $status ): bool {
return $this->get_status() === $status || ( is_array( $status ) && in_array( $this->get_status(), $status, true ) );
}
/**
* Check the type.
*
* @param string|string[] $type Type to check.
*
* @return bool
*/
public function is_type( $type ): bool {
return $this->get_type() === $type || ( is_array( $type ) && in_array( $this->get_type(), $type, true ) );
}
/**
* Check if the entity is a group.
*
* @return bool
*/
public function is_parent_group(): bool {
return $this->parent && is_a_group( $this->parent );
}
/**
* Check if the entity is a placement.
*
* @return bool
*/
public function is_parent_placement(): bool {
return $this->parent && is_a_placement( $this->parent );
}
/* Additional Methods ----------- */
/**
* Outputs the entity.
*
* @return string The output of the entity.
*/
public function output(): string {
/**
* Allow developers to modify the output and short-circuit the function.
*
* @param string $pre_output The pre-output value of the entity.
* @param object $this The current instance of the entity.
*
* @return string The modified pre-output value.
*/
$pre_output = apply_filters( "advanced-ads-{$this->object_type}-pre-output", null, $this );
if ( null !== $pre_output ) {
return $pre_output;
}
do_action( "advanced-ads-{$this->object_type}-before-output", $this );
if ( ! $this->can_display() ) {
return '';
}
$output = $this->prepare_output();
do_action( "advanced-ads-{$this->object_type}-output-ready", $this, $output );
return apply_filters(
"advanced-ads-{$this->object_type}-output",
$output,
$this
);
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* Extras functionality needed to be on the root level.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.48.2
*/
namespace AdvancedAds\Traits;
use Advanced_Ads;
use AdvancedAds\Constants;
use AdvancedAds\Utilities\Sanitize;
defined( 'ABSPATH' ) || exit;
/**
* Trait Extras.
*/
trait Extras {
/**
* Frontend prefix for classes and IDs.
*
* @var string
*/
private $frontend_prefix = null;
/**
* Get frontend prefix for classes and IDs.
*
* @return string
*/
public function get_frontend_prefix(): string {
// Early bail!!
if ( null !== $this->frontend_prefix ) {
return $this->frontend_prefix;
}
$options = Advanced_Ads::get_instance()->options();
if ( ! isset( $options['front-prefix'] ) ) {
if ( isset( $options['id-prefix'] ) ) {
// deprecated: keeps widgets working that previously received an id based on the front-prefix.
$frontend_prefix = $options['id-prefix'];
} else {
$frontend_prefix = preg_match( '/[A-Za-z][A-Za-z0-9_]{4}/', wp_parse_url( get_home_url(), PHP_URL_HOST ), $result )
? $result[0] . '-'
: Constants::DEFAULT_FRONTEND_PREFIX;
}
} else {
$frontend_prefix = $options['front-prefix'];
}
/**
* Applying the filter here makes sure that it is the same frontend prefix for all
* calls on this page impression
*
* @param string $frontend_prefix
*/
$this->frontend_prefix = (string) apply_filters( 'advanced-ads-frontend-prefix', $frontend_prefix );
$this->frontend_prefix = Sanitize::frontend_prefix( $frontend_prefix );
return $this->frontend_prefix;
}
}

View File

@@ -0,0 +1,93 @@
<?php
/**
* Traits Wrapper.
*
* @package AdvancedAds
* @author Advanced Ads <info@wpadvancedads.com>
* @since 1.48.2
*/
namespace AdvancedAds\Traits;
use AdvancedAds\Framework\Utilities\HTML;
defined( 'ABSPATH' ) || exit;
/**
* Traits Wrapper.
*/
trait Wrapper {
/**
* Get the wrapper ID for the entity.
*
* @param string $context What the value is for. Valid values are view and edit.
*
* @return string
*/
public function get_wrapper_id( $context = 'view' ): string {
return (string) $this->get_prop( 'wrapper-id', $context );
}
/**
* Get the wrapper classes for the entity.
*
* @param string $context What the value is for. Valid values are view and edit.
*
* @return string
*/
public function get_wrapper_class( $context = 'view' ): string {
return $this->get_prop( 'wrapper-class', $context );
}
/**
* Set wrapper id.
*
* @param string $wrapper_id Entity wrapper id.
*
* @return void
*/
public function set_wrapper_id( $wrapper_id ): void {
$this->set_prop( 'wrapper-id', sanitize_key( $wrapper_id ) );
}
/**
* Set wrapper class.
*
* @param string $wrapper_class Entity wrapper class.
*
* @return void
*/
public function set_wrapper_class( $wrapper_class ): void {
$this->set_prop( 'wrapper-class', sanitize_text_field( $wrapper_class ) );
}
/**
* Creates a wrapper element with the specified tag, attributes, and content.
*
* @param string $tag The HTML tag for the wrapper element.
* @param array $attrs Optional. An array of attributes to add to the wrapper element. Default is an empty array.
* @param string $content Optional. The content to be placed inside the wrapper element. Default is an empty string.
*
* @return string The generated wrapper element.
*/
public function create_wrapper( $tag, $attrs = [], $content = '' ) {
$attrs = HTML::build_attributes( $attrs );
return "<{$tag} {$attrs}>{$content}</{$tag}>";
}
/**
* Get the wrapper attributes.
*
* @return array
*/
public function get_wrapper_attributes(): array {
$attrs = [];
$attrs['id'] = $this->get_wrapper_id();
$attrs['class'] = $this->get_wrapper_class();
return $attrs;
}
}

View File

@@ -0,0 +1,4 @@
<?php
/**
* Silence is golden.
*/