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,36 @@
<?php
namespace WPDRMS\ASP\Patterns;
use Closure;
/**
* Used in classes implementing JsonSerializable
*
* When using this trait the class is serialized by returning all public properties.
* Useful in Model classes when JSON representation of the Model needs to be sent to the front-end via REST.
*/
trait JsonSerializablePublicProperties {
/**
* Returns all public properties from the class
*
* @return Array<string, mixed>
*/
public function publicProperties(): array {
/**
* The get_object_vars($this) would return all properties, including private/protected
* This solution creates a closure then "calls" it with $this as the argument, outside
* of the scope of the current object.
*/
return Closure::fromCallable('get_object_vars')->__invoke($this);
}
public function jsonSerialize(): array {
return $this->publicProperties();
}
public function toJson(): string {
$res = wp_json_encode($this);
return $res === false ? '{}' : $res;
}
}

View File

@@ -0,0 +1,78 @@
<?php
namespace WPDRMS\ASP\Patterns;
use stdClass;
/**
* Trait to allow accessing class attributes via array keys,
* used with objects implementing ArrayAccess.
*
* Properties have to be declared in the implementing class, dynamic properties are not allowed
* to be accessed or created and will trigger a notice.
*
* Property visibility is not respected through array access, so private and protected
* properties can be read via $obj['property'].
*/
trait ObjectAsArrayTrait {
/**
* DO NOT ADD PROPERTIES!
* Classes implementing this trait might want to be casted to an array.
* If there is a private or protected property, then it will be casted to [*property] which goes to null.
*/
/**
* @param array<string, mixed> $args
*/
public function __construct( array $args = array() ) {
foreach ( $args as $property => $value ) {
if ( isset($this->{$property}) ) {
$this->{$property} = $value;
} else {
trigger_error("Property $property passed to constructor does not exist."); // @phpcs:ignore
}
}
}
public function offsetSet( $property, $value ): void {
if ( !is_null($property) && isset($this->{$property}) ) {
$this->{$property} = $value;
} else {
/**
* This will notify if a non existing property of the object was being accessed.
*/
trigger_error("Property $property does not exist."); // @phpcs:ignore
}
}
public function offsetExists( $property ): bool {
return isset($this->{$property});
}
public function offsetUnset( $property ): void {}
/**
* @param mixed $property
* @return mixed|null
* @noinspection PhpIssetCanBeReplacedWithCoalesceInspection
* @noinspection PhpLanguageLevelInspection
*/
#[\ReturnTypeWillChange]
public function &offsetGet( $property ) {
/**
* Mind, this is a return by reference, therefore:
*
* 1. This CAN'T be replaced with null coalesce
* 2. This CAN'T be simplified to ternary:
* return isset($this->{$property}) ? $this->{$property} : $this->null_ref;
* Reason being that ternary will return a value, not a reference and it violates
* the function return statement.
*/
if ( isset($this->{$property}) ) {
return $this->{$property};
} else {
$null = null;
return $null;
}
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace WPDRMS\ASP\Patterns;
/**
* This can be used in Abstract classes, can handle heritage by storing the singleton data in an array
*/
trait SingletonTrait {
/**
* Use a very unspecific name for this to prevent any conflicts of attribute names
*
* @var array<static>
*/
protected static $singleton__object_instances__array = array();
final public static function getInstance( ...$args ): self {
$class = get_called_class();
if ( !isset(static::$singleton__object_instances__array[ $class ]) ) {
static::$singleton__object_instances__array[ $class ] = new $class(...$args);
}
return static::$singleton__object_instances__array[ $class ];
}
final public static function instance( ...$args ): self {
return static::getInstance( ...$args );
}
private function __construct() {}
final public function __wakeup() {}
final public function __clone() {}
}