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,63 @@
<?php
class BWFCRM_Api_Delete_Template 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 = '/template/(?P<template_id>[\\d]+)';
}
public function default_args_values() {
return array( 'template_id' => '' );
}
public function process_api_call() {
$template_id = $this->get_sanitized_arg( 'template_id', 'key' );
if ( empty( $template_id ) ) {
$this->response_code = 404;
$response = __( 'Template ID is mandatory', 'wp-marketing-automations-pro' );
return $this->error_response( $response );
}
/** if the provided id doesn't exists */
$already_exists = BWFAN_Model_Templates::bwfan_check_template_exists( 'ID', $template_id );
if ( ! $already_exists ) {
$this->response_code = 400;
$response = __( "Template doesn't exists with ID : ", 'wp-marketing-automations-pro' ) . $template_id;
return $this->error_response( $response );
}
$delete_template = BWFAN_Model_Templates::bwf_delete_template( $template_id );
if ( false === $delete_template ) {
$this->response_code = 404;
$response = __( 'Unable to delete the Template', 'wp-marketing-automations-pro' );
return $this->error_response( $response );
}
$this->response_code = 200;
$success_message = __( 'Template deleted', 'wp-marketing-automations-pro' );
return $this->success_response( [], $success_message );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Delete_Template' );

View File

@@ -0,0 +1,88 @@
<?php
class BWFCRM_API_Save_Template_Email_Content 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 = '/template/(?P<template_id>[\\d]+)/save-email-content';
$this->request_args = array(
'template_id' => array(
'description' => __( 'Template ID to update', 'wp-marketing-automations-pro' ),
'type' => 'integer',
),
);
}
public function default_args_values() {
$args = array(
'template' => '',
'data' => [],
);
return $args;
}
public function process_api_call() {
if ( isset( $this->args['content'] ) ) {
$content = BWFAN_Common::is_json( $this->args['content'] ) ? json_decode( $this->args['content'], true ) : [];
$this->args = wp_parse_args( $content, $this->args );
}
$template_id = $this->get_sanitized_arg( 'template_id' );
if ( empty( $template_id ) ) {
return $this->error_response( __( 'Invalid / Empty template ID provided', 'wp-marketing-automations-pro' ), null, 400 );
}
$template = $this->args['template'];
$data = $this->args['data'];
$subject = isset( $this->args['subject'] ) ? $this->args['subject'] : '';
$mode = $this->args['mode'];
$exists = BWFAN_Model_Templates::bwfan_check_template_exists( 'ID', $template_id );
if ( ! $exists ) {
$this->response_code = 400;
$response = __( 'Template does not exists with id : ', 'wp-marketing-automations-pro' ) . $template_id;
return $this->error_response( $response );
}
$create_time = current_time( 'mysql', 1 );
$template_data = [
'template' => $template,
'data' => BWFAN_Common::is_json( $data ) ? $data : wp_json_encode( $data ),
'mode' => ! empty( $mode ) ? intval($mode): 4,
'updated_at' => $create_time,
];
if ( ! empty( $subject ) ) {
$template_data[ 'subject' ] = $subject;
}
$result = BWFAN_Model_Templates::bwfan_update_template( $template_id, $template_data );
if ( ! $result ) {
$this->response_code = 500;
return $this->error_response( __( 'Unable to update template', 'wp-marketing-automations-pro' ) );
}
$response_data = BWFAN_Model_Templates::bwfan_get_template( $template_id );
if ( ! empty( $response_data['data'] ) ) {
$response_data['data'] = json_decode( $response_data['data'] );
}
return $this->success_response( $response_data, __( 'Template Updated Successfully', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_API_Save_Template_Email_Content' );

View File

@@ -0,0 +1,77 @@
<?php
/**
* Template Clone API file
*
* @package BWFCRM_API_Base
*/
/**
* Template Clone API class
*/
class BWFCRM_API_Clone_Template extends BWFCRM_API_Base {
/**
* BWFCRM_Core obj
*
* @var BWFCRM_Core
*/
public static $ins;
/**
* Return class instance
*/
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
/**
* Class constructor
*/
public function __construct() {
parent::__construct();
$this->method = WP_REST_Server::READABLE;
$this->route = '/template/(?P<template_id>[\\d]+)/clone';
$this->request_args = array(
'template_id' => array(
'description' => __( 'Template ID whose data to be cloned.', 'wp-marketing-automations-pro' ),
'type' => 'integer',
),
);
}
/**
* Default arg.
*/
public function default_args_values() {
return array(
'template_id' => 0,
);
}
/**
* API callback
*/
public function process_api_call() {
$template_id = $this->get_sanitized_arg( 'template_id', 'key' );
if ( intval( $template_id ) > 0 ) {
$template_data = BWFAN_Model_Templates::clone_template( $template_id );
$this->response_code = $template_data['status'];
if ( $template_data['status'] === 200 ) {
return $this->success_response( [], $template_data['message'] );
} else {
return $this->error_response( $template_data['message'] );
}
} else {
$this->response_code = 404;
return $this->error_response( __( 'Please provide a valid template id.', 'wp-marketing-automations-pro' ) );
}
}
}
BWFCRM_API_Loader::register( 'BWFCRM_API_Clone_Template' );

View File

@@ -0,0 +1,99 @@
<?php
class BWFCRM_Api_Create_Template 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 = '/template';
$this->response_code = 200;
}
public function default_args_values() {
$args = array(
'title' => '',
'subject' => '',
'template' => '',
'type' => '',
'mode' => '',
'data' => [],
);
return $args;
}
public function process_api_call() {
if ( isset( $this->args['content'] ) ) {
$content = BWFAN_Common::is_json( $this->args['content'] ) ? json_decode( $this->args['content'], true ) : [];
$this->args = wp_parse_args( $content, $this->args );
}
$title = $this->get_sanitized_arg( 'title', 'text_field', $this->args['title'] );
$subject = $this->get_sanitized_arg( 'subject', 'text_field', $this->args['subject'] );
$template = $this->args['template'];
$type = $this->get_sanitized_arg( 'type', 'text_field', $this->args['type'] );
$mode = $this->get_sanitized_arg( 'mode', 'text_field', $this->args['mode'] );
$escape_body = isset( $this->args['escape_body'] ) ? $this->get_sanitized_arg( 'escape_body', 'text_field', $this->args['escape_body'] ) : false;
$data = $this->args['data'];
if ( empty( $title ) ) {
$this->response_code = 400;
$response = __( 'Name is required', 'wp-marketing-automations-pro' );
return $this->error_response( $response );
}
if ( empty( $subject ) && ! $escape_body ) {
$this->response_code = 400;
$response = __( 'Subject is required', 'wp-marketing-automations-pro' );
return $this->error_response( $response );
}
if ( empty( $template ) && ! $escape_body ) {
$this->response_code = 400;
$response = __( 'Email body is required', 'wp-marketing-automations-pro' );
return $this->error_response( $response );
}
$already_exists = BWFAN_Model_Templates::bwfan_check_template_exists( 'title', $title );
if ( absint( $already_exists ) > 0 ) {
$title = "$title - $already_exists";
}
$create_time = current_time( 'mysql', 1 );
$template_data = [
'title' => $title,
'template' => $template,
'subject' => $subject,
'type' => intval( $type ) > 0 ? intval( $type ) : 1,
'mode' => intval( $mode ) > 0 ? intval( $mode ) : 5,
'canned' => 1,
'created_at' => $create_time,
'updated_at' => $create_time,
'data' => BWFAN_Common::is_json( $data ) ? $data : wp_json_encode( $data ),
];
$result = BWFAN_Model_Templates::bwfan_create_new_template( $template_data );
if ( empty( $result ) ) {
$this->response_code = 500;
return $this->error_response( __( 'Unable to create template', 'wp-marketing-automations-pro' ) );
}
return $this->success_response( [ 'id' => $result ], __( 'Template Saved Successfully', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Create_Template' );

View File

@@ -0,0 +1,32 @@
<?php
class BWFCRM_Api_Export_Single_Template 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 = '/templates/(?P<template_id>[\\d]+)/export/';
$this->response_code = 200;
}
public function process_api_call() {
$template_id = ( isset( $this->args['template_id'] ) && '' !== $this->args['template_id'] ) ? $this->args['template_id'] : 0;
$data = BWFCRM_Templates::get_json( $template_id );
$this->response_code = 200;
return $this->success_response( $data, __( 'Template exported', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Export_Single_Template' );

View File

@@ -0,0 +1,32 @@
<?php
class BWFCRM_Api_Export_Templates 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 = '/templates/export/';
$this->response_code = 200;
}
public function process_api_call() {
$ids = isset( $this->args['ids'] ) ? explode(',', $this->args['ids'] ) : [];
$data = BWFCRM_Templates::get_json( $ids );
$this->response_code = 200;
return $this->success_response( $data, __( 'Templates exported', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Export_Templates' );

View File

@@ -0,0 +1,51 @@
<?php
class BWFCRM_Api_Get_Template 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 = '/template/(?P<template_id>[\\d]+)';
$this->request_args = array(
'template_id' => array(
'description' => __( 'Template ID to retrieve', 'wp-marketing-automations-pro' ),
'type' => 'integer',
),
);
}
public function process_api_call() {
$template_id = $this->get_sanitized_arg( 'template_id' );
if ( empty( $template_id ) ) {
return $this->error_response( __( 'Invalid / Empty template ID provided', 'wp-marketing-automations-pro' ), null, 400 );
}
$template = BWFAN_Model_Templates::bwfan_get_template( $template_id );
if ( empty( $template ) ) {
return $this->error_response( __( 'Template not found with provided ID', 'wp-marketing-automations-pro' ), null, 400 );
}
if ( ! empty( $template['data'] ) ) {
$template['data'] = json_decode( $template['data'] );
}
$this->response_code = 200;
return $this->success_response( $template );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Get_Template' );

View File

@@ -0,0 +1,80 @@
<?php
class BWFCRM_Api_Get_Templates extends BWFCRM_API_Base {
public static $ins;
public $templates = array();
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 = '/templates';
$this->public_api = true;
$this->request_args = array(
'search' => array(
'description' => __( 'Search from name', 'wp-marketing-automations-pro' ),
'type' => 'string',
),
'ids' => array(
'description' => __( 'Search from template ids', 'wp-marketing-automations-pro' ),
'type' => 'string'
),
);
}
public function default_args_values() {
return array( 'ids' => '', 'search' => '' );
}
public function process_api_call() {
/** if isset search param then get the tag by name **/
$search = ! empty( $this->get_sanitized_arg( 'search', 'text_field' ) ) ? $this->get_sanitized_arg( 'search', 'text_field' ) : '';
$mode = ! empty( $this->get_sanitized_arg( 'mode', 'text_field' ) ) ? $this->get_sanitized_arg( 'mode', 'text_field' ) : '';
$template_ids = ! empty( $this->args['ids'] ) ? explode( ',', $this->args['ids'] ) : array();
$limit = ! empty( $this->get_sanitized_arg( 'limit', 'text_field' ) ) ? $this->get_sanitized_arg( 'limit', 'text_field' ) : 0;
$offset = ! empty( $this->get_sanitized_arg( 'offset', 'text_field' ) ) ? $this->get_sanitized_arg( 'offset', 'text_field' ) : 0;
$get_template = isset( $this->args['get_template'] ) ? $this->get_sanitized_arg( 'get_template', 'bool' ) : true;
$templates = BWFAN_Model_Templates::bwfan_get_templates( $offset, $limit, $search, $template_ids, $get_template, $mode );
if ( ! is_array( $templates ) ) {
$templates = array();
}
$templates = array_map( function ( $template ) {
if ( ! empty( $template['data'] ) ) {
$template['data'] = json_decode( $template['data'] );
}
if ( isset( $template['template'] ) ) {
unset( $template['template'] );
}
return $template;
}, $templates );
$this->total_count = BWFAN_Model_Templates::bwfan_get_templates_count( $search, $template_ids, $mode );
$this->response_code = 200;
return $this->success_response( $templates );
}
/**
* Return template total count
*
* @return int
*/
public function get_result_total_count() {
return $this->total_count;
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Get_Templates' );

View File

@@ -0,0 +1,51 @@
<?php
class BWFCRM_Api_Import_Templates 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 = '/templates/import/';
$this->response_code = 200;
}
public function process_api_call() {
$files = $this->args['files'];
$this->response_code = 404;
if ( empty( $files ) ) {
return $this->error_response( [], __( 'Import File missing.', 'wp-marketing-automations-pro' ) );
}
$file_data = file_get_contents( $files['files']['tmp_name'] );
$import_file_data = json_decode( $file_data, true );
if ( empty( $import_file_data ) && ! is_array( $import_file_data ) ) {
return $this->error_response( [], __( 'Import file data missing', 'wp-marketing-automations-pro' ) );
}
$template_id = BWFCRM_Templates::import( $import_file_data );
if ( empty( $template_id ) ) {
return $this->error_response( __( 'Invalid json file', 'wp-marketing-automations-pro' ) );
}
$this->response_code = 200;
return $this->success_response( [ 'template_id' => $template_id ], __( 'Templates imported', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Import_Templates' );

View File

@@ -0,0 +1,121 @@
<?php
class BWFCRM_Api_Update_Template 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 = '/template/(?P<template_id>[\\d]+)';
$this->request_args = array(
'template_id' => array(
'description' => __( 'Template ID to update', 'wp-marketing-automations-pro' ),
'type' => 'integer',
),
);
}
public function default_args_values() {
$args = array(
'title' => '',
'subject' => '',
'template' => '',
'type' => '',
'mode' => '',
'data' => [],
);
return $args;
}
public function process_api_call() {
if ( isset( $this->args['content'] ) ) {
$content = BWFAN_Common::is_json( $this->args['content'] ) ? json_decode( $this->args['content'], true ) : [];
$this->args = wp_parse_args( $content, $this->args );
}
$template_id = $this->get_sanitized_arg( 'template_id' );
if ( empty( $template_id ) ) {
return $this->error_response( __( 'Invalid / Empty template ID provided', 'wp-marketing-automations-pro' ), null, 400 );
}
$title = $this->get_sanitized_arg( 'title', 'text_field', $this->args['title'] );
$subject = $this->get_sanitized_arg( 'subject', 'text_field', $this->args['subject'] );
$onlytitle = isset( $this->args['onlytitle'] ) ? $this->get_sanitized_arg( 'onlytitle', 'text_field', $this->args['onlytitle'] ) : false;
$template = $this->args['template'];
$type = $this->get_sanitized_arg( 'type', 'text_field', $this->args['type'] );
$mode = $this->get_sanitized_arg( 'mode', 'text_field', $this->args['mode'] );
$data = $this->args['data'];
if ( empty( $title ) ) {
$this->response_code = 400;
$response = __( 'Oops Title not entered, enter title to save template', 'wp-marketing-automations-pro' );
return $this->error_response( $response );
}
if ( empty( $subject ) && ! $onlytitle ) {
$this->response_code = 400;
$response = __( 'Oops Subject not entered, enter subject to save template', 'wp-marketing-automations-pro' );
return $this->error_response( $response );
}
if ( empty( $template ) && ! $onlytitle ) {
$this->response_code = 400;
$response = __( 'Oops Template is empty, enter content to save template', 'wp-marketing-automations-pro' );
return $this->error_response( $response );
}
$exists = BWFAN_Model_Templates::bwfan_check_template_exists( 'ID', $template_id );
if ( ! $exists ) {
$this->response_code = 400;
$response = __( 'Template does not exists with id : ', 'wp-marketing-automations-pro' ) . $template_id;
return $this->error_response( $response );
}
$create_time = current_time( 'mysql', 1 );
if( $onlytitle ) {
$template_data = [
'title' => $title,
'updated_at' => $create_time,
];
} else {
$template_data = [
'title' => $title,
'template' => $template,
'subject' => $subject,
'type' => intval( $type ) > 0 ? intval( $type ) : 1,
'mode' => intval( $mode ) > 0 ? intval( $mode ) : 1,
'canned' => 1,
'updated_at' => $create_time,
'data' => BWFAN_Common::is_json( $data ) ? $data : wp_json_encode( $data ),
];
}
$result = BWFAN_Model_Templates::bwfan_update_template( $template_id, $template_data );
if ( ! $result ) {
$this->response_code = 500;
return $this->error_response( __( 'Unable to update template', 'wp-marketing-automations-pro' ) );
}
return $this->success_response( [], __( 'Template Updated', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_Api_Update_Template' );

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden