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,82 @@
<?php
/**
* Class BWFCRM_API_Create_API_Keys
*/
namespace BWFAN\Rest_API;
use WP_Error;
use WP_HTTP_Response;
use WP_REST_Response;
class Create_API_Keys extends \BWFCRM_API_Base {
public static $ins;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function __construct() {
parent::__construct();
$this->method = \WP_REST_Server::CREATABLE;
$this->route = 'create-api-key/(?P<user_id>[\\d]+)';
}
/**
* @return WP_Error|WP_HTTP_Response|WP_REST_Response
* processing the api request
*/
public function process_api_call() {
$user_id = $this->get_sanitized_arg( 'user_id', 'text_field' );
$permission = $this->get_sanitized_arg( 'permission', 'text_field' );
$description = $this->get_sanitized_arg( 'description', 'text_field' );
$status = $this->get_sanitized_arg( 'status', 'text_field' );
$user_data = get_user_by( 'ID', $user_id );
if ( empty( $user_id ) || empty( $user_data ) ) {
return $this->error_response( __( 'Required Parameter Missing : User ID not provided or user with this id does not exist', 'wp-marketing-automations-pro' ), null, 400 );
}
if ( empty( $permission ) ) {
return $this->error_response( __( 'Required Parameter Missing : No permission provided', 'wp-marketing-automations-pro' ), null, 400 );
}
if ( strlen( $description ) > 200 ) {
return $this->error_response( __( 'Description must be no longer than 200 characters', 'wp-marketing-automations-pro' ), null, 400 );
}
// creating array of data
$data = [
'uid' => $user_id,
'api_key' => md5( $user_id . time() ),
'created_by' => get_current_user_id() ? get_current_user_id() : 0,
'created_at' => current_time( 'mysql', 1 ),
'permission' => $permission,
];
// storing description in the array if provided
if ( ! empty( $description ) ) {
$data['description'] = $description;
}
// storing status in the array if provided : 1 - active | 2 - revoked, default - 1
if ( ! empty( $status ) ) {
$data['status'] = $status;
}
$insert = \BWFAN_Rest_API_DB_Model::insert( $data );
if ( is_wp_error( $insert ) ) {
return $this->error_response( __( 'API key not created', 'wp-marketing-automations-pro' ), $insert, 500 );
}
return $this->success_response( $data, __( 'API key created successfully', 'wp-marketing-automations-pro' ) );
}
}
\BWFCRM_API_Loader::register( 'BWFAN\Rest_API\Create_API_Keys' );

View File

@@ -0,0 +1,62 @@
<?php
/**
* Class BWFCRM_API_Delete_API_Keys
*/
namespace BWFAN\Rest_API;
use WP_Error;
use WP_HTTP_Response;
use WP_REST_Response;
class Delete_API_Keys extends \BWFCRM_API_Base {
public static $ins;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function __construct() {
parent::__construct();
$this->method = \WP_REST_Server::DELETABLE;
$this->route = '/delete-api-key/(?P<api_key_id>[\\d]+)';
}
/**
* @return WP_Error|WP_HTTP_Response|WP_REST_Response
* processing api request
*/
public function process_api_call() {
$api_key_id = $this->get_sanitized_arg( 'api_key_id', 'text_field' );
if ( empty( $api_key_id ) ) {
return $this->error_response( __( 'Required parameter missing : No API key ID provided', 'wp-marketing-automations-pro' ), null, 400 );
}
$data = [
'id' => $api_key_id,
];
// checking for api key existence by api key id
$api_key_exists = \BWFAN_Rest_API_DB_Model::fetch( array(), array( 'id' => $api_key_id ) );
if ( empty( $api_key_exists ) ) {
return $this->error_response( __( 'API key does not exist with ID #' . $api_key_id, 'wp-marketing-automations-pro' ), null, 400 );
}
$delete = \BWFAN_Rest_API_DB_Model::delete( $data );
if ( is_wp_error( $delete ) ) {
return $this->error_response( __( 'API key could not be deleted', 'wp-marketing-automations-pro' ), $delete, 500 );
}
return $this->success_response( $data, __( 'API key deleted successfully', 'wp-marketing-automations-pro' ) );
}
}
\BWFCRM_API_Loader::register( 'BWFAN\Rest_API\Delete_API_Keys' );

View File

@@ -0,0 +1,56 @@
<?php
/**
* Class BWFCRM_API_List_API_Keys_By_User_Id
*/
namespace BWFAN\Rest_API;
use WP_Error;
use WP_HTTP_Response;
use WP_REST_Response;
class List_API_Keys_By_User_Id extends \BWFCRM_API_Base {
public static $ins;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function __construct() {
parent::__construct();
$this->method = \WP_REST_Server::READABLE;
$this->route = 'get-api-keys-by-userid/(?P<user_id>[\\d]+)';
}
/**
* @return WP_Error|WP_HTTP_Response|WP_REST_Response
* processing the api request
*/
public function process_api_call() {
$limit = ! empty( $this->args['limit'] ) ? absint( $this->args['limit'] ) : 0;
$offset = ! empty( $this->args['offset'] ) ? absint( $this->args['offset'] ) : 0;
$user_id = $this->get_sanitized_arg( 'user_id', 'text_field' );
// checking for user existence
$user_data = get_user_by( 'ID', $user_id );
if ( empty( $user_id ) || empty( $user_data ) ) {
return $this->error_response( __( 'Required parameter missing : No user id provided or user with this id does not exist', 'wp-marketing-automations-pro' ), null, 400 );
}
$data = array( 'uid' => $user_id );
$fetch = \BWFAN_Rest_API_DB_Model::fetch( array(), $data, $limit, $offset );
if ( is_wp_error( $fetch ) ) {
return $this->error_response( __( 'API key listing failed', 'wp-marketing-automations-pro' ), $fetch, 500 );
}
return $this->success_response( $fetch, __( 'API key listed successfully', 'wp-marketing-automations-pro' ) );
}
}
\BWFCRM_API_Loader::register( 'BWFAN\Rest_API\List_API_Keys_By_User_Id' );

View File

@@ -0,0 +1,62 @@
<?php
/**
* Class BWFCRM_API_List_API_Keys
*/
namespace BWFAN\Rest_API;
class List_API_Keys extends \BWFCRM_API_Base {
public static $ins;
public $total_count = 0;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function __construct() {
parent::__construct();
$this->method = \WP_REST_Server::READABLE;
$this->route = '/get-api-keys';
}
/**
* @return \WP_Error|\WP_HTTP_Response|\WP_REST_Response
* prcessing the api request
*/
public function process_api_call() {
$limit = ! empty( $this->args['limit'] ) ? absint( $this->args['limit'] ) : 30;
$offset = ! empty( $this->args['offset'] ) ? absint( $this->args['offset'] ) : 0;
$search = ! empty( $this->args['search'] ) ? $this->args['search'] : '';
$fetch = \BWFAN_Rest_API_DB_Model::fetch( array(), array(), $limit, $offset, $search, true );
if ( is_wp_error( $fetch ) ) {
return $this->error_response( __( 'API key could not be listed', 'wp-marketing-automations-pro' ), $fetch, 500 );
}
$this->total_count = isset( $fetch['total'] ) ? intval( $fetch['total'] ) : 0;
$data = isset( $fetch['data'] ) ? $fetch['data'] : [];
// formatted returned data
$data = array_map( function ( $data ) {
if ( isset( $data['api_key'] ) ) {
$data['api_key'] = 'xxxx' . substr( $data['api_key'], - 6 );
}
return $data;
}, $data );
return $this->success_response( $data, __( 'API key listed successful', 'wp-marketing-automations-pro' ) );
}
public function get_result_total_count() {
return $this->total_count;
}
}
\BWFCRM_API_Loader::register( 'BWFAN\Rest_API\List_API_Keys' );

View File

@@ -0,0 +1,86 @@
<?php
/**
* Class BWFCRM_API_Update_API_Keys
*/
namespace BWFAN\Rest_API;
use WP_Error;
use WP_HTTP_Response;
use WP_REST_Response;
class Update_API_Keys extends \BWFCRM_API_Base {
public static $ins;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function __construct() {
parent::__construct();
$this->method = \WP_REST_Server::CREATABLE;
$this->route = '/update-api-key/(?P<api_key_id>[\\d]+)';
}
/**
* @return WP_Error|WP_HTTP_Response|WP_REST_Response
* processing the api request
*/
public function process_api_call() {
$api_key_id = $this->get_sanitized_arg( 'api_key_id', 'text_field' );
$permission = $this->get_sanitized_arg( 'permission', 'text_field' );
$description = $this->get_sanitized_arg( 'description', 'text_field' );
$status = $this->get_sanitized_arg( 'status', 'text_field' );
$update_api_key = $this->get_sanitized_arg( 'update_api_key', 'bool' );
if ( empty( $api_key_id ) ) {
return $this->error_response( __( 'Required parameter missing : No api key ID provided', 'wp-marketing-automations-pro' ), null, 400 );
}
if ( strlen( $description ) > 200 ) {
return $this->error_response( __( 'Description must be no longer than 200 characters', 'wp-marketing-automations-pro' ), null, 400 );
}
// checking for api key existence
$api_key_exists = \BWFAN_Rest_API_DB_Model::fetch( array(), array( 'id' => $api_key_id ) );
if ( empty( $api_key_exists ) ) {
return $this->error_response( __( 'API key does not exist with ID #' . $api_key_id, 'wp-marketing-automations-pro' ), null, 400 );
}
$where = array( 'id' => $api_key_id );
$data = [
'created_at' => current_time( 'mysql', 1 ),
];
// generate new api key, if opted to change the api key
if ( ! empty( $update_api_key ) && true === $update_api_key ) {
$data['api_key'] = md5( $api_key_exists[0]['uid'] . time() );
}
if ( ! empty( $permission ) ) {
$data['permission'] = $permission;
}
if ( ! empty( $description ) ) {
$data['description'] = $description;
}
if ( ! empty( $status ) ) {
$data['status'] = $status;
}
$update = \BWFAN_Rest_API_DB_Model::update( $data, $where );
if ( is_wp_error( $update ) ) {
return $this->error_response( __( 'API key update failed', 'wp-marketing-automations-pro' ), $update, 500 );
}
return $this->success_response( $data, __( 'API key updated successfully', 'wp-marketing-automations-pro' ) );
}
}
\BWFCRM_API_Loader::register( 'BWFAN\Rest_API\Update_API_Keys' );