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,61 @@
<?php
namespace BWFCRM\Calls\Autonami;
use BWFCRM\Calls\Base;
/**
* Add lists call class
*/
class Add_To_Lists extends Base {
/**
* Add list to contact
*
* @param \BWFCRM_Contact $contact
* @param $data
*/
public function process_call( $contact, $data ) {
if ( ! is_array( $data ) || empty( $data ) ) {
return [
'skipped' => [],
'assigned' => []
];
}
$existing_lists = $contact->get_lists();
$contact->set_lists_v2( $data );
$new_lists = $contact->get_lists();
/** Check if any lists to add */
$assigned_ids = array_diff( $new_lists, $existing_lists );
if ( ! empty( $assigned_ids ) ) {
$contact->save();
}
$skipped_ids = array_diff( $data, $assigned_ids );
$all_ids = array_unique( array_merge( $assigned_ids, $skipped_ids ) );
$term_data = \BWFCRM_Term::get_terms( \BWFCRM_Term_Type::$LIST, $all_ids, '', 0, 0, OBJECT );
$term_map = [];
foreach ( $term_data as $term ) {
$term_map[ $term->get_id() ] = $term;
}
return [
'assigned' => array_map( function ( $id ) use ( $term_map ) {
return $term_map[ $id ] ?? null;
}, array_values( $assigned_ids ) ),
'skipped' => array_map( function ( $id ) use ( $term_map ) {
return $term_map[ $id ] ?? null;
}, array_values( $skipped_ids ) )
];
}
}
/**
* Register call
*/
BWFCRM_Core()->calls->register_call( 'add_to_lists', 'BWFCRM\Calls\Autonami\Add_To_Lists' );

View File

@@ -0,0 +1,63 @@
<?php
namespace BWFCRM\Calls\Autonami;
use BWFCRM\Calls\Base;
/**
* Add tags call class
*/
class Add_Tags extends Base {
/**
* Add tags to contact
*
* @param \BWFCRM_Contact $contact
* @param $data
*
* @return mixed
*/
public function process_call( $contact, $data ) {
if ( ! is_array( $data ) || empty( $data ) ) {
return [
'skipped' => [],
'assigned' => []
];
}
$existing_tags = $contact->get_tags();
$contact->set_tags_v2( $data );
$new_tags = $contact->get_tags();
/** Check if any tags to add */
$assigned_ids = array_diff( $new_tags, $existing_tags );
if ( ! empty( $assigned_ids ) ) {
$contact->save();
}
$skipped_ids = array_diff( $data, $assigned_ids );
$all_ids = array_unique( array_merge( $assigned_ids, $skipped_ids ) );
$term_data = \BWFCRM_Term::get_terms( \BWFCRM_Term_Type::$TAG, $all_ids, '', 0, 0, OBJECT );
$term_map = [];
foreach ( $term_data as $term ) {
$term_map[ $term->get_id() ] = $term;
}
return [
'assigned' => array_filter( array_map( function ( $id ) use ( $term_map ) {
return $term_map[ $id ] ?? null;
}, array_values( $assigned_ids ) ) ),
'skipped' => array_filter( array_map( function ( $id ) use ( $term_map ) {
return $term_map[ $id ] ?? null;
}, array_values( $skipped_ids ) ) )
];
}
}
/**
* Register call
*/
BWFCRM_Core()->calls->register_call( 'add_tags', 'BWFCRM\Calls\Autonami\Add_Tags' );

View File

@@ -0,0 +1,33 @@
<?php
namespace BWFCRM\Calls\Autonami;
use BWFCRM\Calls\Base;
/**
* Delete Contacts call class
*/
class Delete_Contacts extends Base {
/**
* @param \BWFCRM_Contact $contact
* @param $data
*
* @return bool
*/
public function process_call( $contact, $data ) {
$contact_id = $contact->contact->get_id();
// rechecking just to make sure if this function get invoked directly using namespace
if ( empty( $contact_id ) ) {
return false;
}
return \BWFCRM_Model_Contact::delete_contact( $contact_id );
}
}
/**
* Register call
*/
BWFCRM_Core()->calls->register_call( 'delete_contacts', 'BWFCRM\Calls\Autonami\Delete_Contacts' );

View File

@@ -0,0 +1,161 @@
<?php
namespace BWFCRM\Calls\Autonami;
use BWFAN_Common;
use BWFAN_Model_Automations;
use BWFCRM\Calls\Base;
/**
* End Automation call class
*/
class End_Automation extends Base {
/**
* End Automation for contact
*
* @param $contact
* @param $data
*
* @return mixed
*/
public function process_call( $contact, $data ) {
/**
* End Automation for contact
*/
if ( empty( $data ) ) {
return array(
'status' => self::$RESPONSE_FAILED,
'message' => __( 'End Automation (Error): Invalid data', 'wp-marketing-automations-pro' ),
);
}
$automations = array();
$from = isset( $data['from'] ) ? $data['from'] : '';
$from_id = isset( $data['link_id'] ) ? $data['link_id'] : 0;
if ( empty( $from_id ) && isset( $data['bulk_action_id'] ) ) {
$from_id = isset( $data['bulk_action_id'] ) ? $data['bulk_action_id'] : 0;
unset( $data['bulk_action_id'] );
}
if ( isset( $data['from'] ) ) {
unset( $data['from'] );
}
if ( isset( $data['link_id'] ) ) {
unset( $data['link_id'] );
}
/** Form automation array */
foreach ( $data as $automation ) {
if ( empty( $automation['id'] ) ) {
continue;
}
/** Automation id */
$automation_id = absint( $automation['id'] );
/** Get Automation data */
$automation_data = BWFAN_Model_Automations::get( $automation_id );
/** if automation data not found */
if ( empty( $automation_data ) ) {
continue;
}
/** checking automation status before deleting tasks */
if ( isset( $automation_data['status'] ) && 2 === absint( $automation_data['status'] ) ) {
continue;
}
/** Set automation id */
$automations[] = $automation_id;
}
/** Contact email */
$email = $contact->contact->get_email();
/** Contact phone */
$phone = $contact->contact->get_phone();
$tasks = [];
/** Get task from email id */
if ( ! empty( $email ) && is_email( $email ) ) {
$email_tasks = BWFAN_Common::get_schedule_task_by_email( $automations, $email );
foreach ( $email_tasks as $etask ) {
if ( ! empty( $etask ) ) {
$tasks = array_merge( $tasks, $etask );
}
}
}
/** Get task from phone no */
if ( ! empty( $phone ) ) {
$phone_tasks = BWFAN_Common::get_schedule_task_by_phone( $automations, $phone );
foreach ( $phone_tasks as $ptask ) {
if ( ! empty( $ptask ) ) {
$tasks = array_merge( $tasks, $ptask );
}
}
}
/**Get Automation contact for v2 automation */
$automation_contact = \BWFAN_Model_Automation_Contact::get_multiple_automation_contact( $automations, $contact->get_id() );
/** If empty task skip action */
if ( ( ! is_array( $tasks ) || 0 === count( $tasks ) ) && ( ! is_array( $automation_contact ) || 0 === count( $automation_contact ) ) ) {
return array(
'status' => self::$RESPONSE_SKIPPED,
'message' => __( 'End Automation (Skipped): No Tasks Found', 'wp-marketing-automations-pro' ),
);
}
/** Form task id array */
$delete_tasks = array();
foreach ( $tasks as $task ) {
$delete_tasks[] = absint( $task['ID'] );
}
/** skip if delete task is empty */
if ( 0 === count( $delete_tasks ) && 0 === count( $automation_contact ) ) {
return array(
'status' => self::$RESPONSE_SKIPPED,
'message' => __( 'End Automation (Skipped): No Tasks Found', 'wp-marketing-automations-pro' ),
);
}
if ( count( $delete_tasks ) > 0 ) {
/** Delete tasks */
BWFAN_Core()->tasks->delete_tasks( $delete_tasks );
}
if ( count( $automation_contact ) > 0 ) {
/** End v2 automations */
foreach ( $automation_contact as $data ) {
/** Add automation ended from */
$type = 'Bulk Action' === $from ? \BWFAN_Automation_Controller::$BULK_ACTION_END : \BWFAN_Automation_Controller::$LINK_TRIGGER_END;
$reason = [
'type' => $type,
'data' => [
'id' => $from_id,
]
];
$data = \BWFAN_PRO_Common::set_automation_ended_reason( $reason, $data );
\BWFAN_Common::end_v2_automation( 0, $data );
/** Update status as success for any step trail where status was waiting */
\BWFAN_Model_Automation_Contact_Trail::update_all_step_trail_status_complete( $data['trail'] );
\BWFAN_Common::update_automation_contact_fields( $data['cid'], $data['aid'] );
}
}
return array(
'status' => self::$RESPONSE_SUCCESS,
'message' => __( 'End Automation (Tasks Deleted): ', 'wp-marketing-automations-pro' ) . implode( ',', $delete_tasks ),
);
}
}
/**
* Register call
*/
BWFCRM_Core()->calls->register_call( 'end_automation', 'BWFCRM\Calls\Autonami\End_Automation' );

View File

@@ -0,0 +1,28 @@
<?php
namespace BWFCRM\Calls\Autonami;
use BWFCRM\Calls\Base;
/**
* Remove lists call class
*/
class Remove_Lists extends Base {
/**
* Remove lists to contact
*
* @param \BWFCRM_Contact $contact
* @param $data
*
* @return mixed
*/
public function process_call( $contact, $data ) {
return $contact->remove_lists( $data );
}
}
/**
* Register call
*/
BWFCRM_Core()->calls->register_call( 'remove_lists', 'BWFCRM\Calls\Autonami\Remove_Lists' );

View File

@@ -0,0 +1,31 @@
<?php
namespace BWFCRM\Calls\Autonami;
use BWFCRM\Calls\Base;
/**
* Remove tags call class
*/
class Remove_Tags extends Base {
/**
* Remove tags to contact
*
* @param \BWFCRM_Contact $contact
* @param $data
*
* @return mixed
*/
public function process_call( $contact, $data ) {
$response = $contact->remove_tags( $data );
$contact->save();
return $response;
}
}
/**
* Register call
*/
BWFCRM_Core()->calls->register_call( 'remove_tags', 'BWFCRM\Calls\Autonami\Remove_Tags' );

View File

@@ -0,0 +1,25 @@
<?php
namespace BWFCRM\Calls\Autonami;
use BWFCRM\Calls\Base;
/**
* Subscribe Contacts call class
*/
class Subscribe_Contacts extends Base {
/**
* @param \BWFCRM_Contact $contact
*
* @return mixed
*/
public function process_call( $contact, $data ) {
return $contact->resubscribe();
}
}
/**
* Register call
*/
BWFCRM_Core()->calls->register_call( 'subscribe_contacts', 'BWFCRM\Calls\Autonami\Subscribe_Contacts' );

View File

@@ -0,0 +1,26 @@
<?php
namespace BWFCRM\Calls\Autonami;
use BWFCRM\Calls\Base;
/**
* Unsubscribe Contacts call class
*/
class Unsubscribe_Contacts extends Base {
/**
* @param \BWFCRM_Contact $contact
* @param $data
*
* @return mixed
*/
public function process_call( $contact, $data ) {
return $contact->unsubscribe();
}
}
/**
* Register call
*/
BWFCRM_Core()->calls->register_call( 'unsubscribe_contacts', 'BWFCRM\Calls\Autonami\Unsubscribe_Contacts' );

View File

@@ -0,0 +1,40 @@
<?php
namespace BWFCRM\Calls\Autonami;
use BWFCRM\Calls\Base;
/**
* Remove lists call class
*/
class Update_Fields extends Base {
/**
* Remove lists to contact
*
* @param \BWFCRM_Contact $contact
* @param $data
*
* @return mixed
*/
public function process_call( $contact, $data ) {
/** Handle status change */
if ( isset( $data['status'] ) ) {
if ( intval( $data['status'] ) === 3 ) {
/** unsubscribe contact */
$contact->unsubscribe( false );
unset( $data['status'] );
} else {
/** remove unsubscribe entry - maybe exists */
$contact->remove_unsubscribe_status();
}
}
return $contact->update_custom_fields( $data );
}
}
/**
* Register call
*/
BWFCRM_Core()->calls->register_call( 'update_fields', 'BWFCRM\Calls\Autonami\Update_Fields' );