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,58 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\Conditions;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
if ( ! class_exists( 'Autocomplete', false ) ) {
require_once __DIR__ . '/class-autocomplete.php';
}
/**
* This is used by Product_Access in Apprentice
* Because the field name there is called 'Has access to Apprentice Product(s)', it doesn't make sense to have the condition visible, so we hide it.
*/
class Autocomplete_Hidden extends Autocomplete {
/**
* @return string
*/
public static function get_key() {
return 'autocomplete_hidden';
}
public function apply( $data ) {
$field_values = $data['field_value'];
$haystack = $this->get_value();
if ( is_array( $field_values ) ) {
$result = ! empty( array_intersect( $field_values, $haystack ) );
} else {
$result = in_array( $field_values, $haystack, true );
}
return $result;
}
public static function get_operators() {
return [
'autocomplete' => [
'label' => 'is',
],
];
}
public static function is_hidden() {
return true;
}
public static function get_control_type() {
return Autocomplete::get_key(); /* use the 'autocomplete' control because the functionality is the same */
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\Conditions;
use TCB\ConditionalDisplay\Condition;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class Autocomplete extends Condition {
/**
* @return string
*/
public static function get_key() {
return 'autocomplete';
}
/**
* @return string
*/
public static function get_label() {
return esc_html__( 'Autocomplete', 'thrive-cb' );
}
public static function get_display_size() {
return 'full';
}
public function apply( $data ) {
$result = false;
$compared_values = $this->get_value();
if ( ! empty( $compared_values ) ) {
$field_values = $data['field_value'];
if ( is_array( $field_values ) ) {
$result = ! empty( array_intersect( $field_values, $compared_values ) );
} else {
$result = in_array( $field_values, $compared_values );
}
}
return $this->get_operator() === 'autocomplete' ? $result : ! $result;
}
public static function get_operators() {
return [
'autocomplete' => [
'label' => 'is',
],
'autocomplete_exclude' => [
'label' => 'is not',
],
];
}
public static function get_control_type() {
return static::get_key();
}
}

View File

@@ -0,0 +1,66 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\Conditions;
use TCB\ConditionalDisplay\Condition;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class Checkbox extends Condition {
/**
* @return string
*/
public static function get_key() {
return 'checkbox';
}
/**
* @return string
*/
public static function get_label() {
return esc_html__( 'Checkbox', 'thrive-cb' );
}
public function apply( $data ) {
$field_values = $data['field_value'];
$haystack = $this->get_value();
if ( is_array( $field_values ) ) {
$result = ! empty( array_intersect( $field_values, $haystack ) );
} else {
$result = in_array( $field_values, $haystack );
}
return $this->get_operator() === 'contains' ? $result : ! $result;
}
public static function get_operators() {
return [
'contains' => [
'label' => esc_html__( 'is', 'thrive-cb' ),
],
'not_contains' => [
'label' => esc_html__( 'is not', 'thrive-cb' ),
],
];
}
public static function get_control_type() {
return static::get_key();
}
public static function get_display_size() {
return 'full';
}
public static function has_options_to_preload() {
return true;
}
}

View File

@@ -0,0 +1,85 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\Conditions;
use TCB\ConditionalDisplay\Condition;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class Date_And_Time_Picker extends Condition {
/**
* @return string
*/
public static function get_key() {
return 'date_and_time';
}
/**
* @return string
*/
public static function get_label() {
return esc_html__( 'Date and time comparison', 'thrive-cb' );
}
public function apply( $data ) {
$formatted_field_value = strtotime( $data['field_value'] );
$formatted_compared_value = strtotime( $this->get_value() );
switch ( $this->get_operator() ) {
case 'before':
$result = $formatted_field_value < $formatted_compared_value;
break;
case 'after':
$result = $formatted_field_value > $formatted_compared_value;
break;
case 'equals':
$result = strtotime( date( 'Y/m/d', $formatted_field_value ) ) === strtotime( date( 'Y/m/d', $formatted_compared_value ) );
break;
default:
$result = false;
}
return $result;
}
public static function get_operators() {
return [
'equals' => [
'label' => 'equals',
],
'before' => [
'label' => 'before',
],
'after' => [
'label' => 'after',
],
];
}
public static function get_control_type() {
return 'date-and-time';
}
public static function get_display_size() {
return 'medium';
}
/**
* @return array
*/
public static function get_validation_data() {
return [
'min_minutes' => 0,
'max_minutes' => 59,
'min_hours' => 0,
'max_hours' => 23,
];
}
}

View File

@@ -0,0 +1,95 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\Conditions;
use TCB\ConditionalDisplay\Condition;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class Date_And_Time_With_Intervals extends Date_And_Time_Picker {
/**
* @return string
*/
public static function get_key() {
return 'date_and_time_with_intervals';
}
public function apply( $data ) {
$result = false;
if ( ! empty( $data['field_value'] ) ) {
$now = current_time( 'timestamp' );
switch ( $this->get_operator() ) {
case 'more':
$result = $now > strtotime( $data['field_value'] ) + $this->get_added_time();
break;
case 'less':
$result = strtotime( $data['field_value'] ) > $now - $this->get_added_time();
break;
default:
$result = parent::apply( $data );
}
}
return $result;
}
public static function get_operators() {
return array_merge(
[
'more' => [
'label' => 'more than',
],
'less' => [
'label' => 'less than',
],
],
parent::get_operators()
);
}
private function get_added_time() {
$um = $this->get_um();
$value = (int) $this->get_value();
switch ( $um ) {
case 'days':
$result = $value * DAY_IN_SECONDS;
break;
case 'hours':
$result = $value * HOUR_IN_SECONDS;
break;
case 'minutes':
$result = $value * MINUTE_IN_SECONDS;
break;
case 'months':
$result = $value * MONTH_IN_SECONDS;
break;
case 'years':
$result = $value * YEAR_IN_SECONDS;
break;
default:
$result = 0;
}
return $result;
}
/**
* @return array
*/
public static function get_validation_data() {
return array_merge( parent::get_validation_data(), [
'min_interval' => 1,
'max_interval' => 1000,
] );
}
}

View File

@@ -0,0 +1,79 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\Conditions;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class Date extends Date_And_Time_Picker {
/**
* @return string
*/
public static function get_key() {
return 'date';
}
/**
* @return string
*/
public static function get_label() {
return esc_html__( 'Date comparison', 'thrive-cb' );
}
public function apply( $data ) {
$result = false;
$field_value = $data['field_value'];
if ( ! empty( $field_value ) ) {
$formatted_field_value = strtotime( $data['field_value'] );
$formatted_compared_value = strtotime( $this->get_value() );
switch ( $this->get_operator() ) {
case 'equals':
$result = strtotime( date( 'Y/m/d', $formatted_field_value ) )
===
strtotime( date( 'Y/m/d', $formatted_compared_value ) );
break;
case 'between':
/* reduce the format to date-only */
$formatted_start_interval = strtotime( date( 'Y/m/d', $formatted_compared_value ) );
$formatted_end_interval = strtotime( date( 'Y/m/d', strtotime( $this->get_extra() ) ) );
$formatted_field_value = strtotime( date( 'Y/m/d', $formatted_field_value ) );
$result = $formatted_field_value >= $formatted_start_interval &&
$formatted_field_value <= $formatted_end_interval;
break;
default:
$result = parent::apply( $data );
}
}
return $result;
}
public static function get_operators() {
return array_merge( parent::get_operators(), [
'between' => [
'label' => 'between',
],
] );
}
public static function get_control_type() {
return static::get_key();
}
/**
* @return array
*/
public static function get_validation_data() {
return [];
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\Conditions;
use TCB\ConditionalDisplay\Condition;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class Dropdown extends Condition {
/**
* @return string
*/
public static function get_key() {
return 'dropdown';
}
/**
* @return string
*/
public static function get_label() {
return esc_html__( 'Dropdown', 'thrive-cb' );
}
public function apply( $data ) {
$field_value = $data['field_value'];
$compared_value = $this->get_value();
if ( is_numeric( $field_value ) ) {
$compared_value = (int) $compared_value;
}
return $field_value === $compared_value;
}
public static function get_operators() {
return [
'equals' => [
'label' => '=',
],
];
}
public static function get_control_type() {
return static::get_key();
}
public static function is_hidden() {
return true;
}
}

View File

@@ -0,0 +1,73 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\Conditions;
use TCB\ConditionalDisplay\Condition;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class Number_Comparison extends Condition {
/**
* @return string
*/
public static function get_key() {
return 'number_comparison';
}
/**
* @return string
*/
public static function get_label() {
return esc_html__( 'Number comparison', 'thrive-cb' );
}
public function apply( $data ) {
$field_number = (float) $data['field_value'];
$compared_number = (float) $this->get_value();
switch ( $this->get_operator() ) {
case 'less_than':
$result = $field_number < $compared_number;
break;
case 'more_than':
$result = $field_number > $compared_number;
break;
case 'equal':
$result = $field_number == $compared_number;
break;
default:
$result = false;
}
return $result;
}
public static function get_operators() {
return [
'less_than' => [
'label' => 'is less than',
],
'more_than' => [
'label' => 'is more than',
],
'equal' => [
'label' => 'is equal to',
],
];
}
public static function get_control_type() {
return 'input-number';
}
public static function get_display_size() {
return 'medium';
}
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\Conditions;
use TCB\ConditionalDisplay\Condition;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class Number_Equals extends Condition {
/**
* @return string
*/
public static function get_key() {
return 'number_equals';
}
/**
* @return string
*/
public static function get_label() {
return esc_html__( 'Number equals', 'thrive-cb' );
}
public function apply( $data ) {
$a = (int) $data['field_value'];
$b = (int) $this->get_value();
return $a === $b;
}
public static function get_operators() {
return [
'equals' => [
'label' => '=',
],
];
}
public static function get_control_type() {
return 'input-number';
}
public static function is_hidden() {
return true;
}
}

View File

@@ -0,0 +1,102 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\Conditions;
use TCB\ConditionalDisplay\Condition;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class String_Comparison extends Condition {
/**
* @return string
*/
public static function get_key() {
return 'string_comparison';
}
public static function get_control_type() {
return 'string-comparison';
}
/**
* @return string
*/
public static function get_label() {
return esc_html__( 'String comparison', 'thrive-cb' );
}
public function apply( $data ) {
$string_data = $this->get_value();
$string_name = $string_data['string_name'];
$string_operator = $string_data['string_operator'];
$string_value = $string_data['string_value'];
$field_string = isset( $data['field_value'] ) && isset( $data['field_value'][ $string_name ] ) ? sanitize_text_field( urldecode( $data['field_value'][ $string_name ] ) ) : '';
switch ( $string_operator ) {
case 'equals':
$result = $field_string === $string_value;
break;
case 'contains':
$result = strpos( $field_string, $string_value ) !== false;
break;
case 'not_contains':
$result = strpos( $field_string, $string_value ) === false;
break;
case 'exists':
$result = ! empty( $field_string );
break;
default:
$result = false;
}
return $result;
}
public static function get_operators() {
/* The operators are added dynamically, but we keep an array with one element so this will be considered a singular condition */
return [
[
'value' => 'equals',
'label' => 'Equals',
],
];
}
public static function get_extra_operators() {
return [
[
'value' => 'equals',
'label' => __( 'Equals' ),
],
[
'value' => 'contains',
'label' => __( 'Contains' ),
],
[
'value' => 'not_contains',
'label' => __( 'Does not Contain' ),
],
[
'value' => 'exists',
'label' => __( 'Exists' ),
],
];
}
public static function get_display_size() {
return 'medium';
}
public static function is_hidden() {
return true;
}
}

View File

@@ -0,0 +1,49 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\Conditions;
use TCB\ConditionalDisplay\Condition;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class String_Contains extends Condition {
/**
* @return string
*/
public static function get_key() {
return 'string_contains';
}
/**
* @return string
*/
public static function get_label() {
return esc_html__( 'String contains', 'thrive-cb' );
}
public function apply( $data ) {
$haystack = $data['field_value'];
$needle = $this->get_value();
return strpos( $haystack, $needle ) !== false;
}
public static function get_operators() {
return [
'contains' => [
'label' => '=',
],
];
}
public static function is_hidden() {
return true;
}
}

View File

@@ -0,0 +1,49 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\Conditions;
use TCB\ConditionalDisplay\Condition;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class String_Equals extends Condition {
/**
* @return string
*/
public static function get_key() {
return 'string_equals';
}
/**
* @return string
*/
public static function get_label() {
return esc_html__( 'String equals', 'thrive-cb' );
}
public function apply( $data ) {
$a = $data['field_value'];
$b = $this->get_value();
return strcmp( $a, $b ) === 0;
}
public static function get_operators() {
return [
'equals' => [
'label' => '=',
],
];
}
public static function is_hidden() {
return true;
}
}

View File

@@ -0,0 +1,75 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\Conditions;
use TCB\ConditionalDisplay\Condition;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class Time extends Date_And_Time_Picker {
/**
* @return string
*/
public static function get_key() {
return 'time';
}
/**
* @return string
*/
public static function get_label() {
return esc_html__( 'Time comparison', 'thrive-cb' );
}
public function apply( $data ) {
$compared_value = $this->get_value();
$formatted_field_value = strtotime( $data['field_value'] );
$formatted_compared_value = strtotime( $compared_value['hours'] . ':' . $compared_value['minutes'] );
switch ( $this->get_operator() ) {
case 'before':
$result = $formatted_field_value <= $formatted_compared_value;
break;
case 'after':
$result = $formatted_field_value >= $formatted_compared_value;
break;
case 'between':
$formatted_start_interval = $formatted_compared_value;
$formatted_end_interval = strtotime( $this->get_extra()['hours'] . ':' . $this->get_extra()['minutes'] );
$result = $formatted_field_value >= $formatted_start_interval &&
$formatted_field_value <= $formatted_end_interval;
break;
default:
$result = false;
}
return $result;
}
public static function get_control_type() {
return static::get_key();
}
public static function get_operators() {
return [
'before' => [
'label' => 'before',
],
'after' => [
'label' => 'after',
],
'between' => [
'label' => 'between',
],
];
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\Conditions;
use TCB\ConditionalDisplay\Condition;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class URL_Comparison extends Condition {
/**
* @return string
*/
public static function get_key() {
return 'url_comparison';
}
/**
* @return string
*/
public static function get_label() {
return esc_html__( 'URL comparison', 'thrive-cb' );
}
public function apply( $data ) {
$field_value = $data['field_value'];
$compared_value = $this->get_value();
if ( strpos( $compared_value, '*' ) === false ) {
$result = strcmp( $field_value, $compared_value ) === 0;
} else {
/* if a wildcard '*' is found, convert it into the regex format then run a preg_match */
$compared_value = str_replace( '\*', '.*', preg_quote( $compared_value, '/' ) );
preg_match_all( '/' . $compared_value . '/m', $field_value, $matches, PREG_SET_ORDER );
$result = ! empty( $matches );
}
return $result;
}
public static function get_operators() {
return [
'equals' => [
'label' => '=',
],
];
}
public static function is_hidden() {
return true;
}
}