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,66 @@
<?php
class BWFCRM_API_Get_Transactional_Activity 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 = '/transactional-activity';
}
public function process_api_call() {
$search = $this->get_sanitized_arg( 'search', 'text_field' ) ?? '';
$limit = ! empty( $this->get_sanitized_arg( 'limit', 'text_field' ) ) ? $this->get_sanitized_arg( 'limit', 'text_field' ) : 25;
$offset = ! empty( $this->get_sanitized_arg( 'offset', 'text_field' ) ) ? $this->get_sanitized_arg( 'offset', 'text_field' ) : 0;
$activity_data = $this->get_trasnsactinal_activity( $search, $offset, $limit );
$this->response_code = 200;
$this->total_count = 0;
if ( empty( $activity_data[ 'activities' ] ) ) {
return $this->success_response( [],__( 'No transactional activity found', 'wp-marketing-automations-pro' ) );
}
$this->total_count = $activity_data[ 'total_count' ];
return $this->success_response( $activity_data[ 'activities' ], __( 'Transactional activity fetched successfully', 'wp-marketing-automations-pro' ) );
}
/**
* Get transactional activity
*
* @param string $search
* @param int $offset
* @param int $limit
*
* @return array
*/
public function get_trasnsactinal_activity( $search = '', $offset = 0, $limit = 25 ) {
$activity_data = [];
// Load all transactional mails
BWFCRM_Core()->transactional_mails->load_all_files();
// Get transactional activity list
$activity_data[ 'activities' ] = BWFCRM_Core()->transactional_mails->get_transactional_activity( $search, $offset, $limit );
// Get total count of transactional activity
$activity_data[ 'total_count' ] = BWFCRM_Core()->transactional_mails->get_transactional_activity( $search, $offset, $limit, [], [], true );
return $activity_data;
}
public function get_result_total_count() {
return $this->total_count;
}
}
BWFCRM_API_Loader::register( 'BWFCRM_API_Get_Transactional_Activity' );

View File

@@ -0,0 +1,42 @@
<?php
class BWFCRM_API_Get_Transactional_Mail 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 = '/transactional-mail/(?P<type>[a-zA-Z_-]+)';
}
public function process_api_call() {
$type = $this->get_sanitized_arg( 'type' );
if ( empty( $type ) ) {
return $this->error_response( __( 'Empty transactional mail type', 'wp-marketing-automations-pro' ), null, 400 );
}
$lang = $this->args['lang'] ?? '';
$this->response_code = 200;
// @todo add lite data if pro not found || pro version is old
if ( ! isset( BWFCRM_Core()->transactional_mails ) ) {
return $this->success_response( [] );
}
$mail_class = BWFCRM_Core()->transactional_mails;
$template_data = $mail_class->get_transactional_mail_by_slug( $type, $lang );
if( ! $template_data ) {
return $this->error_response( __( 'Invalid transactional mail type', 'wp-marketing-automations-pro' ), null, 404 );
}
return $this->success_response( $template_data );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_API_Get_Transactional_Mail' );

View File

@@ -0,0 +1,71 @@
<?php
class BWFCRM_API_Get_Transactional_Mails 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 = '/transactional-mails';
$this->lists = array();
}
public function process_api_call() {
$this->response_code = 200;
if ( ! isset( BWFCRM_Core()->transactional_mails ) ) {
return $this->success_response( [] );
}
$mail_obj = BWFCRM_Core()->transactional_mails;
$mail_obj->load_all_files();
$mail_data = $mail_obj->get_registered_transactional_mails();
if ( empty( $mail_data ) ) {
return $this->success_response( [], __( 'No transactional mails found', 'wp-marketing-automations-pro' ) );
}
$final_data = [];
foreach ( $mail_data as $mail ) {
if ( empty( $mail['template_data'] ) ) {
$final_data[] = $mail;
continue;
}
$template_id = 0;
if ( empty( $lang ) && ! empty( $mail['template_data']['template_id'] ) ) {
$template_id = $mail['template_data']['template_id'];
} else if ( ! empty( $lang ) && ! empty( $mail['template_data']['lang'][ $lang ] ) ) {
$template_id = $mail['template_data']['lang'][ $lang ];
}
if ( empty( $template_id ) ) {
$final_data[] = $mail;
continue;
}
$template_data = BWFAN_Model_Templates::bwfan_get_template( $template_id, 0 );
if ( isset( $template_data['data'] ) ) {
$template_data_data = json_decode( $template_data['data'], true );
$other_recipient = ! empty( $template_data_data['other_recipients'] ) ? $template_data_data['other_recipients'] : '';
if ( ! empty( $other_recipient ) ) {
$mail['other_recipient'] = $other_recipient;
}
}
$final_data[] = $mail;
}
return $this->success_response( $final_data, __( 'Transactional mails fetched successfully', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_API_Get_Transactional_Mails' );

View File

@@ -0,0 +1,99 @@
<?php
/**
* Class BWFCRM_API_Get_Transactional_Preview
*/
class BWFCRM_API_Get_Transactional_Preview extends BWFCRM_API_Base {
public static $ins;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
/**
* BWFCRM_API_Get_Transactional_Preview constructor.
*/
public function __construct() {
parent::__construct();
$this->method = WP_REST_Server::READABLE;
$this->route = '/transactional-mail/(?P<type>[a-zA-Z_-]+)/preview';
}
/**
* Process API call
*
* @return array|WP_Error
*/
public function process_api_call() {
$type = $this->get_sanitized_arg( 'type' );
if ( empty( $type ) ) {
return $this->error_response( __( 'Empty transactional mail type', 'wp-marketing-automations-pro' ), null, 400 );
}
$lang = $this->args['lang'] ?? '';
$this->response_code = 200;
// Check if transactional mails are loaded
if ( ! isset( BWFCRM_Core()->transactional_mails ) ) {
return $this->success_response( [] );
}
// Initialize transactional mails class
$mail_class = BWFCRM_Core()->transactional_mails;
// Get transactional mail data by slug
$template_data = $mail_class->get_transactional_mail_by_slug( $type, $lang );
// Check if transactional mail not found
if ( empty( $template_data ) ) {
return $this->error_response( __( 'Transactional mail not found', 'wp-marketing-automations-pro' ), null, 404 );
}
// Get template content
$content = $template_data['template'];
if( method_exists( 'BWFAN_Common', 'bwfan_before_send_mail' ) ){
BWFAN_Common::bwfan_before_send_mail( 'block' );
}
// Set data for merge tags
BWFAN_Merge_Tag_Loader::set_data( [ 'is_preview' => true ] );
// Correct shortcode string for email body
$body = method_exists( 'BWFAN_Common', 'correct_shortcode_string' ) ? BWFAN_Common::correct_shortcode_string( $content, 'block' ) : $content;
// Decode merge tags
$body = BWFAN_Common::decode_merge_tags( $body );
// Update links in email body
$body = BWFAN_Common::bwfan_correct_protocol_url( $body );
// Get final email body
$body = BWFCRM_Core()->conversation->apply_template_by_type( $body, 'block', '' );
$this->response_code = 200;
// Return success response
return $this->success_response( [
'body' => $body,
'data' => [
'subject' => ! empty( $template_data['subject'] ) ? $template_data['subject'] : __( 'Test Subject', 'wp-marketing-automations-pro' ),
'preheader' => ! empty( $template_data['data']['preheader'] ) ? $template_data['data']['preheader']: '',
'utmEnabled' => ! empty( $template_data['data']['utmEnabled'] ) && boolval( $template_data['data']['utmEnabled'] ),
'utmDetails' => ! empty( $template_data['data']['utm'] ) ? $template_data['data']['utm'] : [],
'overRideSenderInfo' => true,
'overRideInfo' => [
'from_name' => ! empty( $template_data['data']['from_name'] ) ? $template_data['data']['from_name'] : '',
'from_email' => ! empty( $template_data['data']['from_email'] ) ? $template_data['data']['from_email'] : '',
'reply_to' => ! empty( $template_data['data']['reply_to_email'] ) ? $template_data['data']['reply_to_email'] : '',
]
],
] );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_API_Get_Transactional_Preview' );

View File

@@ -0,0 +1,44 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Class BWFCRM_API_Resend_Transactional_Email
*/
class BWFCRM_API_Resend_Transactional_Email 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 = '/transactional-mail/(?P<eid>[\\d]+)/resend';
}
public function process_api_call() {
$eid = $this->get_sanitized_arg( 'eid' );
if ( empty( $eid ) ) {
return $this->error_response( __( 'Invalid or empty engagement id.', 'wp-marketing-automations-pro' ), null, 400 );
}
$status = BWFCRM_Core()->transactional_mails->resend_conversation_to_contact( $eid );
if ( ! $status ) {
$this->response_code = 500;
return $this->error_response( __( 'Unable to send transactional mail', 'wp-marketing-automations-pro' ) );
}
return $this->success_response( [], __( 'Transactional mail sent successfully', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_API_Resend_Transactional_Email' );

View File

@@ -0,0 +1,96 @@
<?php
class BWFCRM_API_Save_Transactional_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 = '/transactional-mail/(?P<type>[a-zA-Z_-]+)/save-email-content';
}
public function process_api_call() {
$type = $this->get_sanitized_arg( 'type' );
if ( empty( $type ) ) {
return $this->error_response( __( 'Invalid or empty transactional mail type', 'wp-marketing-automations-pro' ), null, 400 );
}
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 );
}
$lang = $this->args['lang'] ?? '';
$subject = $this->get_sanitized_arg( 'subject', 'text_field', $this->args['subject'] );
$template = isset( $this->args['template'] ) ? $this->args['template'] : '';
$data = isset($this->args['data']) ? $this->args['data'] : [];
if ( ! empty( $lang ) ) {
$data['lang'] = $lang;
}
$this->response_code = 200;
if ( ! isset( BWFCRM_Core()->transactional_mails ) ) {
return $this->success_response( [] );
}
$mail_class = BWFCRM_Core()->transactional_mails;
$template_data = $mail_class->get_transactional_mail_by_slug( $type, $lang );
if ( empty( $template_data ) ) {
$this->response_code = 404;
return $this->error_response( __( 'Transactional mail not found', 'wp-marketing-automations-pro' ) );
}
$template_id = $template_data['ID'];
//check if the template_id exists in other engagement
//if exists create a new transactional mail template with the updated content
//else update the existing transactional mail template with the updated content
$engagement_exists = BWFAN_Model_Engagement_Tracking::get_engagements_by_tid( $template_id, true );
// Update the template
$create_time = current_time( 'mysql', 1 );
if ( intval( $engagement_exists ) > 0 ) {
// new template data
$template_data = [
'title' => $type,
'template' => $template,
'subject' => $subject,
'type' => 1,
'mode' => 7,
'canned' => 0,
'updated_at' => $create_time,
'created_at' => $create_time,
'data' => BWFAN_Common::is_json( $data ) ? $data : wp_json_encode( $data ),
];
$template_id = BWFAN_Model_Templates::bwfan_create_new_template( $template_data );
$result = BWFCRM_Core()->transactional_mails->update_option_template_id( $type, $template_id, $lang );
} else {
$template_data = [
'template' => $template,
'data' => BWFAN_Common::is_json( $data ) ? $data : wp_json_encode( $data ),
'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 transactional mail', 'wp-marketing-automations-pro' ) );
}
return $this->success_response( [], __( 'Transactional mail updated successfully', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_API_Save_Transactional_Email_Content' );

View File

@@ -0,0 +1,46 @@
<?php
class BWFCRM_API_Update_Transactional_Mail_Status 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 = '/transactional-mail/(?P<type>[a-zA-Z_-]+)/status';
}
public function process_api_call() {
$type = $this->get_sanitized_arg( 'type' ); // Transactional mail type or 'all' for all transactional mails
if ( empty( $type ) ) {
return $this->error_response( __( 'Invalid or empty transactional mail type', 'wp-marketing-automations-pro' ), null, 400 );
}
$status = $this->get_sanitized_arg( 'status', 'bool' );
$this->response_code = 200;
if ( ! isset( BWFCRM_Core()->transactional_mails ) ) {
return $this->error_response( __( 'Unable to find transactional mail', 'wp-marketing-automations-pro' ), null, 400 );
}
/** @var $mail_class BWFCRM_Transactional_Mail_Loader */
$mail_class = BWFCRM_Core()->transactional_mails;
$result = $mail_class->update_transactional_mail_status( $type, $status );
if ( ! $result ) {
return $this->error_response( __( 'Unable to update transactional mail status', 'wp-marketing-automations-pro' ), null, 400 );
}
return $this->success_response( [], __( 'Transactional mail status updated', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_API_Update_Transactional_Mail_Status' );

View File

@@ -0,0 +1,87 @@
<?php
class BWFCRM_API_Update_Transactional_Mail 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 = '/transactional-mail/(?P<type>[a-zA-Z_-]+)';
}
public function process_api_call() {
$type = $this->get_sanitized_arg( 'type' );
if ( empty( $type ) ) {
return $this->error_response( __( 'Invalid or empty transactional mail type', 'wp-marketing-automations-pro' ), null, 400 );
}
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 );
}
$lang = $this->args['lang'] ?? '';
$subject = $this->get_sanitized_arg( 'subject', 'text_field', $this->args['subject'] );
$template = isset( $this->args['template'] ) ? $this->args['template'] : '';
$data = isset($this->args['data']) ? $this->args['data'] : [];
$this->response_code = 200;
if ( ! isset( BWFCRM_Core()->transactional_mails ) ) {
return $this->success_response( [] );
}
$template_data = BWFCRM_Core()->transactional_mails->get_transactional_mail_by_slug( $type, $lang );
$template_id = $template_data['ID'];
// Implementing the logic to update the transactional mail content
//check if the template_id exists in other engagement
//if exists create a new transactional mail template with the updated content
//else update the existing transactional mail template with the updated content
$engagement_exists = BWFAN_Model_Engagement_Tracking::get_engagements_by_tid( $template_id, true );
// Update the template
$create_time = current_time( 'mysql', 1 );
if ( ! empty( $lang ) ) {
$data['lang'] = $lang;
}
// new template data
$template_data = [
'title' => $type,
'template' => $template,
'subject' => $subject,
'type' => 1,
'mode' => 7,
'canned' => 0,
'updated_at' => $create_time,
'data' => BWFAN_Common::is_json( $data ) ? $data : wp_json_encode( $data ),
];
if ( intval( $engagement_exists ) > 0 ) {
$template_data[ 'created_at' ] = $create_time;
$template_id = BWFAN_Model_Templates::bwfan_create_new_template( $template_data );
$result = BWFCRM_Core()->transactional_mails->update_option_template_id( $type, $template_id, $lang );
} else {
$result = BWFAN_Model_Templates::bwfan_update_template( $template_id, $template_data );
}
if ( ! $result ) {
$this->response_code = 500;
return $this->error_response( __( 'Unable to update transactional mail', 'wp-marketing-automations-pro' ) );
}
return $this->success_response( [], __( 'Transactional mail updated', 'wp-marketing-automations-pro' ) );
}
}
BWFCRM_API_Loader::register( 'BWFCRM_API_Update_Transactional_Mail' );