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,198 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\RestApi;
use TCB\ConditionalDisplay\Condition;
use TCB\ConditionalDisplay\Entity;
use TCB\ConditionalDisplay\Field;
use TCB\ConditionalDisplay\PostTypes\Conditional_Display_Group;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Class General_Data
*
* @package TCB\ConditionalDisplay\RestApi
*/
class General_Data {
const REST_NAMESPACE = 'tcb/v1';
const REST_ROUTE = 'conditional-display/';
public static function register_routes() {
register_rest_route( static::REST_NAMESPACE, static::REST_ROUTE . 'groups', [
[
'methods' => \WP_REST_Server::READABLE,
'callback' => [ __CLASS__, 'get_groups' ],
'permission_callback' => [ __CLASS__, 'route_permission' ],
'args' => [
'groups' => [
'type' => 'array',
'required' => true,
],
],
],
] );
register_rest_route( static::REST_NAMESPACE, static::REST_ROUTE . 'fields', [
[
'methods' => \WP_REST_Server::READABLE,
'callback' => [ __CLASS__, 'get_fields' ],
'permission_callback' => [ __CLASS__, 'route_permission' ],
'args' => [
'entity' => [
'type' => 'string',
'required' => true,
],
],
],
] );
register_rest_route( static::REST_NAMESPACE, static::REST_ROUTE . 'conditions', [
[
'methods' => \WP_REST_Server::READABLE,
'callback' => [ __CLASS__, 'get_conditions' ],
'permission_callback' => [ __CLASS__, 'route_permission' ],
'args' => [
'field' => [
'type' => 'string',
'required' => true,
],
],
],
] );
register_rest_route( static::REST_NAMESPACE, static::REST_ROUTE . 'field-options', [
[
'methods' => \WP_REST_Server::READABLE,
'callback' => [ __CLASS__, 'get_field_options' ],
'permission_callback' => [ __CLASS__, 'route_permission' ],
'args' => [
'field' => [
'type' => 'string',
'required' => true,
],
],
],
] );
}
/**
* @param $request \WP_REST_Request
*
* @return array
*/
public static function get_groups( $request ) {
$group_keys = $request->get_param( 'groups' );
$query_vars = $request->get_param( 'query_vars' );
if ( ! empty( $query_vars ) ) {
tve_set_query_vars_data( $query_vars );
}
if ( is_array( $group_keys ) ) {
foreach ( $group_keys as $display_group_key ) {
$display_group = Conditional_Display_Group::get_instance( $display_group_key );
if ( $display_group !== null ) {
$display_group->localize( false, true );
}
}
$groups = array_values( $GLOBALS['conditional_display_preview'] );
} else {
$groups = [];
}
return $groups;
}
/**
* @param $request \WP_REST_Request
*
* @return \WP_REST_Response
*/
public static function get_fields( $request ) {
$entity_key = $request->get_param( 'entity' );
$field_data = [];
$entity = Entity::get();
$fields = $entity[ $entity_key ]::get_fields();
if ( ! empty( $fields ) ) {
foreach ( $fields as $field_key ) {
$field_class = Field::get()[ $field_key ];
$field_data[ $field_key ] = $field_class::get_data_to_localize();
}
}
return new \WP_REST_Response( $field_data );
}
/**
* @param \WP_REST_Request
*
* @return \WP_REST_Response
*/
public static function get_conditions( $request ) {
$field_key = $request->get_param( 'field' );
$condition_data = [];
$field = Field::get();
if ( ! empty( $field[ $field_key ] ) ) {
$conditions = $field[ $field_key ]::get_conditions();
if ( ! empty( $conditions ) ) {
foreach ( $conditions as $condition_key ) {
$condition_class = Condition::get()[ $condition_key ];
$condition_data[ $condition_key ] = $condition_class::get_data_to_localize();
}
}
}
return new \WP_REST_Response( $condition_data );
}
/**
* @param \WP_REST_Request
*
* @return \WP_REST_Response
*/
public static function get_field_options( $request ) {
$options = [];
$field_key = $request->get_param( 'field' );
if ( ! empty( Field::get()[ $field_key ] ) ) {
$selected_values = $request->get_param( 'values' );
$search = $request->get_param( 'search' );
$field = Field::get();
$options = $field[ $field_key ]::get_options( $selected_values, $search );
}
return new \WP_REST_Response( $options );
}
/**
* Check if a given request has access to route
*
* @return \WP_Error|bool
*/
public static function route_permission() {
$post_id = isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : null;
return \TCB_Product::has_external_access( $post_id );
}
}

View File

@@ -0,0 +1,182 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-visual-editor
*/
namespace TCB\ConditionalDisplay\RestApi;
use TCB\ConditionalDisplay\PostTypes\Global_Conditional_Set;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Class Global_Sets
*
* @package TCB\ConditionalDisplay\RestApi
*/
class Global_Sets {
const REST_NAMESPACE = 'tcb/v1';
const REST_ROUTE = 'conditional-display/global-set';
public static function register_routes() {
register_rest_route( static::REST_NAMESPACE, static::REST_ROUTE, [
[
'methods' => \WP_REST_Server::CREATABLE,
'callback' => [ __CLASS__, 'update_global_set' ],
'permission_callback' => [ __CLASS__, 'route_permission' ],
'args' => [
'label' => [
'type' => 'string',
'required' => true,
],
'rules' => [
'type' => 'array',
'required' => true,
],
],
],
] );
register_rest_route( static::REST_NAMESPACE, static::REST_ROUTE . '/(?P<id>[\d]+)', [
[
'methods' => \WP_REST_Server::READABLE,
'callback' => [ __CLASS__, 'get_global_set_data' ],
'permission_callback' => [ __CLASS__, 'route_permission' ],
],
[
'methods' => \WP_REST_Server::EDITABLE,
'callback' => [ __CLASS__, 'update_global_set' ],
'permission_callback' => [ __CLASS__, 'route_permission' ],
'args' => [
'label' => [
'type' => 'string',
'required' => true,
],
'rules' => [
'type' => 'array',
'required' => true,
],
],
],
[
'methods' => \WP_REST_Server::DELETABLE,
'callback' => [ __CLASS__, 'remove_global_set' ],
'permission_callback' => [ __CLASS__, 'route_permission' ],
],
] );
register_rest_route( static::REST_NAMESPACE, static::REST_ROUTE . '/get-all', [
[
'methods' => \WP_REST_Server::READABLE,
'callback' => [ __CLASS__, 'get_global_sets' ],
'permission_callback' => [ __CLASS__, 'route_permission' ],
'args' => [
'search' => [
'type' => 'string',
'required' => false,
],
],
],
] );
}
/**
* @param \WP_REST_Request
*
* @return \WP_REST_Response
*/
public static function get_global_set_data( $request ) {
$data = [];
$post_id = $request->get_param( 'id' );
$global_set = Global_Conditional_Set::get_instance( $post_id );
if ( ! empty( $global_set->get_post() ) ) {
$data = [
'id' => $post_id,
'rules' => $global_set->get_rules(),
'label' => $global_set->get_label(),
];
}
return new \WP_REST_Response( $data );
}
/**
* @param \WP_REST_Request
*
* @return \WP_REST_Response
*/
public static function get_global_sets( $request ) {
$searched_keyword = $request->get_param( 'search' );
$global_sets = Global_Conditional_Set::get_sets_by_name( $searched_keyword );
return new \WP_REST_Response( $global_sets );
}
/**
* @param \WP_REST_Request
*
* @return \WP_REST_Response|\WP_Error
*/
public static function update_global_set( $request ) {
$post_id = $request->get_param( 'id' );
$label = $request->get_param( 'label' );
$sets_with_this_label = Global_Conditional_Set::get_sets_by_name( $label, true );
if (
! empty( $sets_with_this_label ) &&
(
empty( $post_id ) || /* case 1: no post ID means we're adding a new global set and the label already exists */
count( $sets_with_this_label ) > 1 /* case 2: if there is a post ID: the only global set found for this label should be the current one */
)
) {
return new \WP_Error( 'tcb_error', __( 'A global set with this name already exists!', 'thrive-cb' ), [ 'status' => 409 ] );
}
$rules = $request->get_param( 'rules' );
if ( empty( $post_id ) ) {
$global_set = Global_Conditional_Set::get_instance();
$post_id = $global_set->create( $rules, $label );
} else {
$global_set = Global_Conditional_Set::get_instance( $post_id );
$global_set->update( $rules, $label );
}
return new \WP_REST_Response( $post_id );
}
/**
*
* @param \WP_REST_Request
*
* @return \WP_REST_Response
*/
public static function remove_global_set( $request ) {
$post_id = $request->get_param( 'id' );
$global_set = Global_Conditional_Set::get_instance( $post_id );
$global_set->remove();
return new \WP_REST_Response( $post_id );
}
/**
* Check if a given request has access to route
*
* @return \WP_Error|bool
*/
public static function route_permission() {
$post_id = isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : null;
return \TCB_Product::has_external_access( $post_id );
}
}