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,68 @@
<?php
class BWFAN_API_Download_Export_File extends BWFAN_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 = '/export/download/';
}
public function process_api_call() {
$type = $this->get_sanitized_arg( 'type', 'text_field' );
$user_id = $this->get_sanitized_arg( 'user_id', 'text_field' );
$user_data = get_user_meta( $user_id, 'bwfan_single_export_status', true );
if ( ! isset( $user_data[ $type ] ) || ! isset( $user_data[ $type ]['url'] ) ) {
$this->response_code = 404;
$response = __( 'Unable to download the exported file', 'wp-marketing-automations' );
return $this->error_response( $response );
}
$filename = $user_data[ $type ]['url'];
if ( file_exists( $filename ) ) {
// Define header information
header( 'Content-Description: File Transfer' );
header( 'Content-Type: application/octet-stream' );
header( 'Cache-Control: no-cache, must-revalidate' );
header( 'Expires: 0' );
header( 'Content-Disposition: attachment; filename="' . basename( $filename ) . '"' );
header( 'Content-Length: ' . filesize( $filename ) );
header( 'Pragma: public' );
// Clear system output buffer
flush();
// Read the size of the file
readfile( $filename );
exit;
}
wp_die();
}
/**
* Rest api permission callback
*
* @return bool
*/
public function rest_permission_callback( WP_REST_Request $request ) {
$query_params = $request->get_query_params();
if ( isset( $query_params['bwf-nonce'] ) && $query_params['bwf-nonce'] === get_option( 'bwfan_unique_secret', '' ) ) {
return true;
}
return false;
}
}
BWFAN_API_Loader::register( 'BWFAN_API_Download_Export_File' );

View File

@@ -0,0 +1,81 @@
<?php
class BWFAN_Api_Get_Export_Action extends BWFAN_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::EDITABLE;
$this->route = '/export/action';
$this->request_args = array(
'type' => array(
'description' => __( 'Export type', 'wp-marketing-automations' ),
'type' => 'string',
),
'action' => array(
'description' => __( 'Export action', 'wp-marketing-automations' ),
'type' => 'string',
),
);
}
public function default_args_values() {
return array( 'type' => '' );
}
public function process_api_call() {
$this->response_code = 404;
/** if isset type param **/
$type = $this->get_sanitized_arg( 'type', 'text_field' );
$action = $this->get_sanitized_arg( 'action', 'text_field' );
$extra_data = ! empty( $this->args['extra_data'] ) ? $this->args['extra_data'] : [];
if ( $type === '' || $action === '' ) {
$response = __( 'Exporter mandatory options not passed', 'wp-marketing-automations' );
return $this->error_response( $response );
}
/** @var $exporter_registered */
$exporter_registered = BWFAN_Core()->exporter->get_exporters();
// check for export type registered
if ( ! isset( $exporter_registered[ $type ] ) ) {
$response = __( 'Exporter type is not found', 'wp-marketing-automations' );
return $this->error_response( $response );
}
$action_status = [
'status' => false,
];
/** Export action handler */
switch ( $action ) {
case 'start':
// add user data and start scheduler
$action_status = BWFAN_Core()->exporter->bwfan_start_export( $type, get_current_user_id(), $extra_data );
break;
case 'cancel':
// remove user data and unset scheduler
$action_status = BWFAN_Core()->exporter->bwfan_end_export( $type, get_current_user_id() );
break;
}
$this->response_code = 200;
return $this->success_response( $action_status );
}
}
BWFAN_API_Loader::register( 'BWFAN_Api_Get_Export_Action' );

View File

@@ -0,0 +1,84 @@
<?php
class BWFAN_Api_Get_Export_Status extends BWFAN_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 = '/export/status';
$this->request_args = array(
'type' => array(
'description' => __( 'Export status type', 'wp-marketing-automations' ),
'type' => 'string',
),
);
}
public function default_args_values() {
return array( 'type' => '' );
}
public function process_api_call() {
$this->response_code = 404;
/** if isset type param **/
$type = $this->get_sanitized_arg( 'type', 'text_field' );
if ( $type === '' ) {
$response = __( "Exporter type is mandatory", 'wp-marketing-automations' );
return $this->error_response( $response );
}
/** @var $exporter_registered */
$exporter_registered = BWFAN_Core()->exporter->get_exporters();
if ( ! isset( $exporter_registered[ $type ] ) ) {
$response = __( "Exporter type is not found", 'wp-marketing-automations' );
return $this->error_response( $response );
}
$status_data = [
'status' => 3,
'msg' => [
__( 'Unable to find the export for user', 'wp-marketing-automations' )
],
'percentage' => 0
];
$status = get_user_meta( get_current_user_id(), 'bwfan_single_export_status', true );
if ( isset( $status[ $type ] ) ) {
$status_data = $status[ $type ];
if ( isset( $status_data['status'] ) && $status_data['status'] === 1 ) {
$status_data['percentage'] = $this->get_percentage( $status_data['export_id'] );
}
}
$this->response_code = 200;
return $this->success_response( $status_data );
}
private function get_percentage( $export_id ) {
$db_export_row = \BWFAN_Model_Import_Export::get( $export_id );
if ( empty( $db_export_row ) || empty( $db_export_row['offset'] ) || empty( $db_export_row['count'] ) ) {
return 0;
}
return round( absint( $db_export_row['offset'] ) / absint( $db_export_row['count'] ) * 100, 2 );
}
}
BWFAN_API_Loader::register( 'BWFAN_Api_Get_Export_Status' );