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,249 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Class TVD_Content_Sets_Controller
*
* @project: thrive-dashboard
*/
class TVD_Content_Sets_Controller extends WP_REST_Controller {
/**
* @var string Base name
*/
public $rest_base = 'content-sets';
protected $version = 1;
protected $namespace = 'tss/v';
/**
* Register routes function
*/
public function register_routes() {
register_rest_route( $this->namespace . $this->version, $this->rest_base . '/normalize-rule', array(
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'normalize_rule' ),
'permission_callback' => array( $this, 'permission_check' ),
'args' => array(
'content_type' => array(
'type' => 'string',
'required' => true,
'enum' => array(
'post',
'term',
'archive',
\TVD\Content_Sets\Rule::HIDDEN_POST_TYPE_SEARCH_RESULTS,
\TVD\Content_Sets\Rule::HIDDEN_POST_TYPE_BLOG,
),
),
'content' => array(
'type' => 'string',
'required' => true,
),
'field' => array(
'type' => 'string',
'required' => true,
),
'operator' => array(
'type' => 'string',
'required' => true,
),
'value' => array(
'type' => array( 'string', 'array' ),
'default' => '',
),
),
),
) );
register_rest_route( $this->namespace . $this->version, $this->rest_base, array(
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'create_item' ),
'permission_callback' => array( $this, 'permission_check' ),
'args' => array(
'post_title' => array(
'type' => 'string',
'required' => true,
),
'post_content' => array(
'type' => 'array',
'required' => true,
),
),
),
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'search_items' ),
'permission_callback' => array( $this, 'permission_check' ),
'args' => array(
'content_type' => array(
'type' => 'string',
'required' => true,
'enum' => array( 'post', 'term', 'archive' ),
),
'content' => array(
'type' => 'string',
'required' => true,
),
'field' => array(
'type' => 'string',
'required' => true,
),
'operator' => array(
'type' => 'string',
'required' => true,
),
'value' => array(
'type' => array( 'string', 'array' ),
'default' => '',
),
'query_string' => array(
'type' => 'string',
'required' => true,
),
),
),
) );
register_rest_route( $this->namespace . $this->version, $this->rest_base . '/(?P<ID>.+)', array(
array(
'methods' => WP_REST_Server::DELETABLE,
'callback' => array( $this, 'delete_item' ),
'permission_callback' => array( $this, 'permission_check' ),
'args' => array(
'ID' => array(
'type' => 'integer',
'required' => true,
),
),
),
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'update_item' ),
'permission_callback' => array( $this, 'permission_check' ),
'args' => array(
'ID' => array(
'type' => 'integer',
'required' => true,
),
'post_title' => array(
'type' => 'string',
'required' => true,
),
'post_content' => array(
'type' => 'array',
'required' => true,
),
),
),
) );
}
/**
* rename this into search posts/ search items
*
* @param WP_REST_Request $request
*
* @return WP_REST_Response
*/
public function search_items( $request ) {
$rule = \TVD\Content_Sets\Rule::factory( $request->get_params() );
$paged = false;
if ( $request->get_param( 'page' ) ) {
$paged = (int) $request->get_param( 'page' );
$per_page = (int) $request->get_param( 'per_page' ) ?: 150;
}
return new WP_REST_Response( $rule->get_items( $request->get_param( 'query_string' ), $paged, $per_page ), 200 );
}
/**
* @param WP_REST_Request $request
*
* @return WP_Error|WP_REST_Response
*/
public function create_item( $request ) {
$set = new \TVD\Content_Sets\Set( $request->get_params() );
$new_set_id = $set->create();
$cache_plugin = tve_dash_detect_cache_plugin();
if ( $cache_plugin ) {
tve_dash_cache_plugin_clear( $cache_plugin );
}
if ( ! empty( $new_set_id ) ) {
return new WP_REST_Response( \TVD\Content_Sets\Set::get_items(), 200 );
}
return new WP_Error( 'cant-create', __( 'The request contains invalid rules', 'thrive-dash' ), array( 'status' => 422 ) );
}
/**
* @param WP_REST_Request $request
*
* @return WP_REST_Response
*/
public function delete_item( $request ) {
$set = new \TVD\Content_Sets\Set( $request->get_param( 'ID' ) );
$response = $set->delete();
return new WP_REST_Response( $response, 200 );
}
/**
* @param WP_REST_Request $request
*
* @return WP_Error|WP_REST_Response
*/
public function update_item( $request ) {
$set = new \TVD\Content_Sets\Set( $request->get_params() );
$set_id = $set->update();
$cache_plugin = tve_dash_detect_cache_plugin();
if ( $cache_plugin ) {
tve_dash_cache_plugin_clear( $cache_plugin );
}
if ( ! empty( $set_id ) ) {
return new WP_REST_Response( ! empty( $request->get_param( 'return_one' ) ) ? $set->jsonSerialize() : \TVD\Content_Sets\Set::get_items(), 200 );
}
return new WP_Error( 'cant-update', __( 'The request contains invalid rules', 'thrive-dash' ), array( 'status' => 422 ) );
}
/**
* Normalizing a rule so that the rule contains all information
*
* Mainly this is for content_label rule key.
*
* @param WP_REST_Request $request
*
* @return WP_REST_Response
*/
public function normalize_rule( $request ) {
$rule = \TVD\Content_Sets\Rule::factory( $request->get_params() );
return new WP_REST_Response( $rule, 200 );
}
/**
* If the user has access to the admin pages, then he is allowed to perform any operation on the scripts.
*
* @return bool
*/
public function permission_check() {
return current_user_can( TVE_DASH_CAPABILITY );
}
}

View File

@@ -0,0 +1,148 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden
}
class TVD_Fields_Controller extends TVD_REST_Controller {
/**
* @var string Base name
*/
public $base = 'fields';
/**
* Register Routes
*/
public function register_routes() {
register_rest_route( static::$namespace . static::$version, '/' . $this->base, array(
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'add_field' ),
'permission_callback' => array( $this, 'fields_permissions_check' ),
'args' => array(),
),
) );
register_rest_route( static::$namespace . static::$version, '/' . $this->base . '/(?P<id>[\d]+)', array(
array(
'methods' => WP_REST_Server::DELETABLE,
'callback' => array( $this, 'delete_field' ),
'permission_callback' => array( $this, 'fields_permissions_check' ),
'args' => array(),
),
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'edit_field' ),
'permission_callback' => array( $this, 'fields_permissions_check' ),
'args' => array(),
),
) );
register_rest_route( static::$namespace . static::$version, '/' . $this->base . '/save_fields/', array(
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'save_fields' ),
'permission_callback' => array( $this, 'fields_permissions_check' ),
'args' => array(),
),
) );
}
/**
* Add multiple fields at once
*
* @param $request WP_REST_Request
*
* @return WP_Error|WP_REST_Response
*/
public function save_fields( $request ) {
$models = $request->get_param( 'models' );
$response = array();
foreach ( $models as $model ) {
$data = TVD_Smart_DB::save_field( $model, empty( $model['id'] )? 'insert': 'update' );
if ( $data ) {
$response[] = $data;
} else {
return new WP_Error( 'error', __( 'Something went wrong while saving the fields, please refresh and try again. If the problem persists please contact our support team.', 'thrive-dash' ) );
}
}
return new WP_REST_Response( $response, 200 );
}
/**
* @param $request WP_REST_Request
*
* @return WP_Error|WP_REST_Response
*/
public function add_field( $request ) {
$model = $request->get_params();
$model = TVD_Smart_DB::save_field( $model, 'insert' );
if ( $model ) {
return new WP_REST_Response( $model, 200 );
}
return new WP_Error( 'no-results', __( 'The group was not added, please try again !', 'thrive-dash' ) );
}
/**
* Delete a group and all it's fields
*
* @param $request
*
* @return WP_Error|WP_REST_Response
*/
public function delete_field( $request ) {
$id = $request->get_param( 'id' );
$result = TVD_Smart_DB::delete_field( $id );
if ( $result ) {
return new WP_REST_Response( true, 200 );
}
return new WP_Error( 'no-results', __( 'No field was deleted!', 'thrive-dash' ) );
}
/**
* Edit a group
*
* @param $request WP_REST_Request
*
* @return WP_Error|WP_REST_Response
*/
public function edit_field( $request ) {
$model = $request->get_params();
$model = TVD_Smart_DB::save_field( $model, 'update' );
if ( $model ) {
return new WP_REST_Response( $model, 200 );
}
return new WP_Error( 'no-results', __( 'No group was updated!', 'thrive-dash' ) );
}
/**
* Permissions check
*
* @param $request
*
* @return bool
*/
public function fields_permissions_check( $request ) {
return current_user_can( TVE_DASH_CAPABILITY );
}
}

View File

@@ -0,0 +1,116 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden
}
class TVD_Groups_Controller extends TVD_REST_Controller {
/**
* @var string Base name
*/
public $base = 'groups';
/**
* Register Routes
*/
public function register_routes() {
register_rest_route( static::$namespace . static::$version, '/' . $this->base, array(
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'add_group' ),
'permission_callback' => array( $this, 'groups_permissions_check' ),
'args' => array(),
),
) );
register_rest_route( static::$namespace . static::$version, '/' . $this->base . '/(?P<id>[\d]+)', array(
array(
'methods' => WP_REST_Server::DELETABLE,
'callback' => array( $this, 'delete_group' ),
'permission_callback' => array( $this, 'groups_permissions_check' ),
'args' => array(),
),
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'edit_group' ),
'permission_callback' => array( $this, 'groups_permissions_check' ),
'args' => array(),
),
) );
}
/**
* Add a group
*
* @param $request WP_REST_Request
*
* @return WP_Error|WP_REST_Response
*/
public function add_group( $request ) {
$model = $request->get_params();
$model = TVD_Smart_DB::insert_group( $model );
if ( $model ) {
return new WP_REST_Response( $model, 200 );
}
return new WP_Error( 'no-results', __( 'The group was not added, please try again !', 'thrive-dash' ) );
}
/**
* Delete a group and all it's fields
*
* @param $request
*
* @return WP_Error|WP_REST_Response
*/
public function delete_group( $request ) {
$id = $request->get_param( 'id' );
$result = TVD_Smart_DB::delete_group( $id );
if ( $result ) {
return new WP_REST_Response( true, 200 );
}
return new WP_Error( 'no-results', __( 'No group was deleted!', 'thrive-dash' ) );
}
/**
* Edit a group
*
* @param $request WP_REST_Request
*
* @return WP_Error|WP_REST_Response
*/
public function edit_group( $request ) {
$model = $request->get_params();
$model = TVD_Smart_DB::update_group( $model );
if ( $model ) {
return new WP_REST_Response( $model, 200 );
}
return new WP_Error( 'no-results', __( 'No group was updated!', 'thrive-dash' ) );
}
/**
* Permissions check
*
* @param $request
*
* @return bool
*/
public function groups_permissions_check( $request ) {
return current_user_can( TVE_DASH_CAPABILITY );
}
}