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,254 @@
<?php
namespace TVE\Dashboard\Automator;
use Thrive\Automator\Items\Action;
use Thrive_Dash_List_Manager;
use function Thrive\Automator\tap_logger;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Class Tag_User
*/
class Add_User extends Action {
private $autoresponder;
private $additional = array();
/**
* Get the action identifier
*
* @return string
*/
public static function get_id() {
return 'thrive/adduser';
}
/**
* Get the action name/label
*
* @return string
*/
public static function get_name() {
return 'Add user in autoresponder';
}
/**
* Get the action description
*
* @return string
*/
public static function get_description() {
return 'Add user to autoresponder';
}
/**
* Get the action logo
*
* @return string
*/
public static function get_image() {
return 'tap-add-user';
}
public static function get_app_id() {
return 'email';
}
public static function get_required_data_objects() {
return array( 'user_data', 'form_data', 'email_data' );
}
/**
* Array of action-field keys, required for the action to be setup
*
* @return array
*/
public static function get_required_action_fields() {
return array( 'autoresponder' => array( 'mailing_list' ) );
}
public function prepare_data( $data = array() ) {
if ( ! empty( $data['extra_data'] ) ) {
$data = $data['extra_data'];
}
$this->autoresponder = $data['autoresponder']['value'];
$this->build_subfield( $data['autoresponder']['subfield'] );
}
/**
* Init all subfields
*
* @param $data
*/
public function build_subfield( $data ) {
foreach ( $data as $key => $subfield ) {
if ( ! empty( $subfield['value'] ) ) {
$this->additional[ $key ] = $subfield['value'];
}
if ( ! empty( $subfield['subfield'] ) ) {
$this->build_subfield( $subfield['subfield'] );
}
}
}
public function do_action( $data ) {
$email = '';
global $automation_data;
$data_sets = Main::get_email_data_sets();
/**
* Try to get email for available data objects
*/
while ( ! empty( $data_sets ) && empty( $email ) ) {
$set = array_shift( $data_sets );
$data_object = $automation_data->get( $set );
if ( ! empty( $data_object ) && $data_object->can_provide_email() ) {
$email = $data_object->get_provided_email();
}
}
if ( empty( $email ) ) {
return false;
}
$api_load = array( 'email' => $email );
$apis = Thrive_Dash_List_Manager::get_available_apis( true );
if ( empty( $apis[ $this->autoresponder ] ) ) {
return false;
}
$api = $apis[ $this->autoresponder ];
if ( ! empty( $this->additional['tag_input'] ) && $api->has_tags() ) {
$tags = $this->additional['tag_input'];
if ( is_array( $tags ) ) {
$tags = implode( ', ', $tags );
}
$api_load[ $api->get_tags_key() ] = $tags;
}
if ( ! empty( $this->additional['tag_select'] ) && $api->has_tags() ) {
$tags = $this->additional['tag_select'];
$api_load[ $api->get_tags_key() ] = $tags;
}
if ( ! empty( $this->additional['optin'] ) && $api->has_optin() ) {
$api_load[ $api->get_optin_key() ] = $this->additional['optin'];
}
if ( ! empty( $this->additional['form_list'] ) && $api->has_forms() ) {
$api_load[ $api->get_forms_key() ] = $this->additional['form_list'];
}
$list_identifier = ! empty( $this->additional['mailing_list'] ) ? $this->additional['mailing_list'] : null;
if ( ! empty( $this->additional['api_fields'] ) ) {
$name = $this->get_specific_field_value( 'name' );
if ( ! empty( $name ) ) {
$api_load['name'] = $name;
}
$phone = $this->get_specific_field_value( 'phone' );
if ( ! empty( $phone ) ) {
$api_load['phone'] = $phone;
}
}
if ( ! empty( $this->additional['api_fields'] ) && $api->has_custom_fields() ) {
$api_load['automator_custom_fields'] = $api->build_automation_custom_fields( $this->additional );
}
return $api->add_subscriber( $list_identifier, $api_load );
}
public function get_specific_field_value( $field, $unset = true ) {
$key = array_search( $field, array_column( $this->additional['api_fields'], 'key' ) );
$value = false;
if ( $key !== false ) {
$value = $this->additional['api_fields'][ $key ]['value'];
if ( $unset ) {
array_splice( $this->additional['api_fields'], $key, 1 );
}
}
return $value;
}
/**
* For APIs with forms add it as required field
*
* @param $data
*
* @return array|string[][]|string[][][]
*/
public static function get_action_mapped_fields( $data ) {
$fields = static::get_required_action_fields();
if ( property_exists( $data, 'autoresponder' ) ) {
$api_instance = \Thrive_Dash_List_Manager::connection_instance( $data->autoresponder->value );
if ( $api_instance !== null && $api_instance->is_connected() ) {
$fields = $api_instance->get_automator_add_autoresponder_mapping_fields();
}
}
return $fields;
}
public static function get_subfields( $subfields, $current_value, $action_data ) {
$fields = parent::get_subfields( $subfields, $current_value, $action_data );
/**
* Remove required validation for tags
*/
if ( isset( $fields[ Tag_Input_Field::get_id() ] ) ) {
$fields[ Tag_Input_Field::get_id() ]['validators'] = array();
}
return $fields;
}
/**
* Match all trigger that provice user/form data
*
* @param $trigger
*
* @return bool
*/
public static function is_compatible_with_trigger( $provided_data_objects ) {
$action_data_keys = static::get_required_data_objects() ?: array();
return count( array_intersect( $action_data_keys, $provided_data_objects ) ) > 0;
}
public function can_run( $data ) {
$valid = true;
$available_data = array();
global $automation_data;
foreach ( Main::get_email_data_sets() as $key ) {
$data_set = $automation_data->get( $key );
if ( ! empty( $data_set ) && $data_set->can_provide_email() && ! empty( $data_set->get_provided_email() ) ) {
$available_data[] = $key;
}
}
if ( empty( $available_data ) ) {
$valid = false;
tap_logger( $this->aut_id )->register( [
'key' => static::get_id(),
'id' => 'data-not-provided-to-action',
'message' => 'Data object required by ' . static::class . ' action is not provided by trigger',
'class-label' => tap_logger( $this->aut_id )->get_nice_class_name( static::class ),
] );
}
return $valid;
}
}

View File

@@ -0,0 +1,99 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
namespace TVE\Dashboard\Automator;
use Thrive\Automator\Items\Action;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class Facebook_Event extends Action {
protected $event;
protected $standard_fields;
protected $custom_fields;
public static function get_id() {
return 'fb/standard_event';
}
public static function get_name() {
return __( 'Fire Facebook standard event', 'thrive-dash' );
}
public static function get_app_id() {
return Facebook_App::get_id();
}
public static function get_description() {
return __( 'Send a standard event to Facebook', 'thrive-dash' );
}
public static function get_image() {
return 'tap-facebook-logo';
}
public function prepare_data( $data = array() ) {
$this->event = $data[ Facebook_Event_Field::get_id() ]['value'];
$this->standard_fields = Main::extract_mapping( $data[ Facebook_Standard_Options_Field::get_id() ]['value'] );
$this->custom_fields = Main::extract_mapping( $data[ Facebook_Custom_Options_Field::get_id() ]['value'] );
}
public static function get_required_action_fields() {
return [
Facebook_Event_Field::get_id(),
Facebook_Standard_Options_Field::get_id(),
Facebook_Custom_Options_Field::get_id(),
];
}
public static function get_required_data_objects() {
return [];
}
public function do_action( $data ) {
/**
* @var \Thrive_Dash_Api_FacebookPixel $api_instance
*/
$api_instance = Facebook::get_api();
if ( $api_instance ) {
$user_fields = Facebook::extract_user_fields( $this->standard_fields );
$event_options = Facebook::extract_event_fields( $this->standard_fields );
$event_fields = [
'event_name' => $this->event,
];
if ( ! empty( $event_options ) ) {
$event_fields = array_merge( $event_fields, $event_options );
}
$event_fields['user_data'] = $api_instance->prepare_user_data( $user_fields );
$custom_data_details = array_diff( $this->standard_fields, $user_fields, $event_options );
$this->custom_fields = array_filter( $this->custom_fields );
if ( ! empty( $this->custom_fields ) ) {
$custom_data_details['custom_properties'] = $this->custom_fields;
}
if ( ! empty( $custom_data_details ) ) {
$event_fields['custom_data'] = $api_instance->prepare_custom_data( $custom_data_details );
}
$event = $api_instance->prepare_event_data( $event_fields );
$response = $api_instance->send_events( $event );
if ( $response['success'] !== true ) {
Facebook::log_error_request( $this->get_automation_id(), $response );
}
}
}
}

View File

@@ -0,0 +1,84 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
namespace TVE\Dashboard\Automator;
use Thrive\Automator\Items\Action;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class Facebook_Event_Custom extends Action {
protected $event_name;
protected $custom_fields;
public static function get_id() {
return 'fb/custom_event';
}
public static function get_app_id() {
return Facebook_App::get_id();
}
public static function get_name() {
return __( 'Fire Facebook custom event', 'thrive-dash' );
}
public static function get_description() {
return __( 'Send a custom event to Facebook', 'thrive-dash' );
}
public static function get_image() {
return 'tap-facebook-logo';
}
public static function get_required_action_fields() {
return [
Facebook_Event_Name_Field::get_id(),
Facebook_Custom_Options_Field::get_id(),
];
}
public function prepare_data( $data = array() ) {
$this->event_name = $data[ Facebook_Event_Name_Field::get_id() ]['value'];
$this->custom_fields = Main::extract_mapping( $data[ Facebook_Custom_Options_Field::get_id() ]['value'] );
}
public static function get_required_data_objects() {
return [];
}
public function do_action( $data ) {
/**
* @var \Thrive_Dash_Api_FacebookPixel $api_instance
*/
$api_instance = Facebook::get_api();
if ( $api_instance ) {
$event_fields = [
'event_name' => $this->event_name,
];
$user_data = $api_instance->prepare_user_data();
$event_fields['user_data'] = $user_data;
$custom_properties = [];
if ( ! empty( $this->custom_fields ) ) {
$custom_properties['custom_properties'] = $this->custom_fields;
}
$event_fields['custom_data'] = $api_instance->prepare_custom_data( $custom_properties );
$event = $api_instance->prepare_event_data( $event_fields );
$response = $api_instance->send_events( $event );
if ( $response['success'] !== true ) {
Facebook::log_error_request( $this->get_automation_id(), $response );
}
}
}
}

View File

@@ -0,0 +1,118 @@
<?php
namespace TVE\Dashboard\Automator;
use Thrive\Automator\Items\Action;
use Thrive\Automator\Items\Action_Field;
use Thrive\Automator\Items\Connection_Test;
use Thrive\Automator\Items\Fields_Webhook;
use Thrive\Automator\Utils;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Class Slack_Send_Notification
*/
class Slack_Send_Notification extends Action {
protected $data;
/**
* Get the action identifier
*
* @return string
*/
public static function get_id() {
return 'slack/sendnotification';
}
/**
* Get the action name/label
*
* @return string
*/
public static function get_name() {
return __( 'Send notification', 'thrive-dash' );
}
/**
* Get the action description
*
* @return string
*/
public static function get_description() {
return __( 'Send a notification to a Slack channel', 'thrive-dash' );
}
/**
* Get the action logo
*
* @return string
*/
public static function get_image() {
return 'tap-slack-logo';
}
/**
* Get the name of app to which action belongs
*
* @return string
*/
public static function get_app_id() {
return Slack_App::get_id();
}
/**
* Array of action-field keys, required for the action to be setup
*
* @return array
*/
public static function get_required_action_fields() {
return [
Slack_Channel_Field::get_id(),
Slack_Message_Title_Field::get_id(),
Fields_Webhook::get_id(),
Slack_Test_Notification_Field::get_id(),
];
}
/**
* Get an array of keys with the required data-objects
*
* @return array
*/
public static function get_required_data_objects() {
return [];
}
public function do_action( $data = [] ) {
$channel = $this->get_automation_data_value( Slack_Channel_Field::get_id() );
$api_instance = \Thrive_Dash_List_Manager::connection_instance( 'slack' );
$response = false;
if ( $api_instance && $api_instance->is_connected() ) {
$args = array(
'fields' => $this->get_automation_data_value( 'fields_webhook', [] ),
'text' => $this->get_automation_data_value( Slack_Message_Title_Field::get_id() ),
);
$response = $api_instance->post_message( $channel, $args );
}
if ( empty( $response->ok ) ) {
$result = [
'status_code' => 400,
'message' => __( 'Request failed with error message', 'thrive-dash' ) . ': ' . $response->error
];
} else {
$result = [ 'status_code' => 200 ];
}
return $result;
}
public function prepare_data( $data = array() ) {
$this->data = $data;
}
}

View File

@@ -0,0 +1,193 @@
<?php
namespace TVE\Dashboard\Automator;
use Thrive\Automator\Items\Action;
use Thrive_Dash_List_Manager;
use function Thrive\Automator\tap_logger;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Class Tag_User
*/
class Tag_User extends Action {
private $autoresponder;
private $tags;
private $additional = array();
/**
* Get the action identifier
*
* @return string
*/
public static function get_id() {
return 'thrive/taguser';
}
/**
* Get the action name/label
*
* @return string
*/
public static function get_name() {
return 'Tag user in autoresponder';
}
/**
* Get the action description
*
* @return string
*/
public static function get_description() {
return 'Apply {num_items} tags to user in autoresponder';
}
/**
* Get the action logo
*
* @return string
*/
public static function get_image() {
return 'tap-tag-user';
}
public static function get_app_id() {
return 'email';
}
public static function get_required_data_objects() {
return array( 'user_data', 'form_data', 'email_data' );
}
/**
* Array of action-field keys, required for the action to be setup
*
* @return array
*/
public static function get_required_action_fields() {
return array( 'autoresponder' => 'tag_input' );
}
/**
* For APIs with forms add it as required field
*
* @param $data
*
* @return array|string[][]|string[][][]
*/
public static function get_action_mapped_fields( $data ) {
$fields = static::get_required_action_fields();
if ( property_exists( $data, 'autoresponder' ) ) {
$api_instance = \Thrive_Dash_List_Manager::connection_instance( $data->autoresponder->value );
if ( $api_instance !== null && $api_instance->is_connected() ) {
$fields = $api_instance->get_automator_tag_autoresponder_mapping_fields();
}
}
return $fields;
}
public function prepare_data( $data = array() ) {
if ( ! empty( $data['extra_data'] ) ) {
$data = $data['extra_data'];
}
foreach ( $data['autoresponder']['subfield'] as $key => $subfield ) {
$this->additional[ $key ] = $subfield['value'];
}
$this->autoresponder = $data['autoresponder']['value'];
if ( ! empty( $data['tag_input']['value'] ) ) {
$this->tags = $data['tag_input']['value'];
}//tags were moved as subfields of autoresponder
elseif ( ! empty( $this->additional['tag_input'] ) ) {
$this->tags = $this->additional['tag_input'];
} elseif ( ! empty( $this->additional['tag_select'] ) ) {
$this->tags = $this->additional['tag_select'];
}
}
public function do_action( $data ) {
$email = '';
$data_sets = Main::get_email_data_sets();
global $automation_data;
while ( ! empty( $data_sets ) && empty( $email ) ) {
$set = array_shift( $data_sets );
$data_object = $automation_data->get( $set );
if ( ! empty( $data_object ) && $data_object->can_provide_email() ) {
$email = $data_object->get_provided_email();
}
}
if ( empty( $email ) ) {
return false;
}
$apis = Thrive_Dash_List_Manager::get_available_apis( true );
$api = $apis[ $this->autoresponder ];
if ( empty( $api ) ) {
return false;
}
$extra = [];
$tags_value = $this->tags;
if ( is_array( $tags_value ) ) {
$tags_value = implode( ', ', $tags_value );
}
if ( ! empty( $this->additional['mailing_list'] ) ) {
$extra['list_identifier'] = $this->additional['mailing_list'];
}
$api->update_tags( $email, $tags_value, $extra );
}
/**
* Match all trigger that provice user/form data
*
* @param $trigger
*
* @return bool
*/
public static function is_compatible_with_trigger( $provided_data_objects ) {
$action_data_keys = static::get_required_data_objects() ?: array();
return count( array_intersect( $action_data_keys, $provided_data_objects ) ) > 0;
}
public function can_run( $data ) {
$valid = true;
$available_data = array();
global $automation_data;
foreach ( Main::get_email_data_sets() as $key ) {
if ( ! empty( $automation_data->get( $key ) ) ) {
$available_data[] = $key;
}
}
if ( empty( $available_data ) ) {
$valid = false;
tap_logger( $this->aut_id )->register( [
'key' => static::get_id(),
'id' => 'data-not-provided-to-action',
'message' => 'Data object required by ' . static::class . ' action is not provided by trigger',
'class-label' => tap_logger( $this->aut_id )->get_nice_class_name( static::class ),
] );
}
return $valid;
}
}

View File

@@ -0,0 +1,111 @@
<?php
namespace TVE\Dashboard\Automator;
use Thrive\Automator\Items\Action;
use function wc_get_order;
use function wc_get_product;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Class Woo_Add_Product_To_Order
*/
class Woo_Add_Product_To_Order extends Action {
private $products;
/**
* Get the action identifier
*
* @return string
*/
public static function get_id() {
return 'woo/producttoorder';
}
/**
* Get the action name/label
*
* @return string
*/
public static function get_name() {
return 'Add WooCommerce product to order';
}
/**
* Get the action description
*
* @return string
*/
public static function get_description() {
return 'Add a WooCommerce product to an existing order';
}
/**
* Get the action logo
*
* @return string
*/
public static function get_image() {
return 'woo-add-product-to-order';
}
/**
* Get the name of app to which action belongs
*
* @return string
*/
public static function get_app_id() {
return Woo_App::get_id();
}
/**
* Array of action-field keys, required for the action to be setup
*
* @return array
*/
public static function get_required_action_fields() {
return array( 'woo_products' );
}
/**
* Get an array of keys with the required data-objects
*
* @return array
*/
public static function get_required_data_objects() {
return array( 'woo_order_data' );
}
public function prepare_data( $data = array() ) {
if ( ! empty( $data['extra_data'] ) ) {
$data = $data['extra_data'];
}
$this->products = $data['woo_products']['value'];
}
public function do_action( $data ) {
global $automation_data;
$order_data = $automation_data->get( 'woo_order_data' );
if ( empty( $order_data ) ) {
return false;
}
$order = wc_get_order( $order_data->get_value( Woo_Order_Id::get_id() ) );
if ( empty( $order ) ) {
return false;
}
foreach ( $this->products as $product_id ) {
$product = wc_get_product( $product_id );
if ( $product ) {
$order->add_product( $product );
}
}
}
}

View File

@@ -0,0 +1,105 @@
<?php
namespace TVE\Dashboard\Automator;
use Thrive\Automator\Items\Action;
use function wc_get_order;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Class Woo_Order_Status_Update
*/
class Woo_Order_Status_Update extends Action {
private $status;
/**
* Get the action identifier
*
* @return string
*/
public static function get_id() {
return 'woo/orderstatus';
}
/**
* Get the action name/label
*
* @return string
*/
public static function get_name() {
return 'Update WooCommerce order status';
}
/**
* Get the action description
*
* @return string
*/
public static function get_description() {
return 'Change the status of a WooCommerce order';
}
/**
* Get the action logo
*
* @return string
*/
public static function get_image() {
return 'woo-update-order-status';
}
/**
* Get the name of app to which action belongs
*
* @return string
*/
public static function get_app_id() {
return Woo_App::get_id();
}
/**
* Array of action-field keys, required for the action to be setup
*
* @return array
*/
public static function get_required_action_fields() {
return array( 'woo_order_status' );
}
/**
* Get an array of keys with the required data-objects
*
* @return array
*/
public static function get_required_data_objects() {
return array( 'woo_order_data' );
}
public function prepare_data( $data = array() ) {
if ( ! empty( $data['extra_data'] ) ) {
$data = $data['extra_data'];
}
$this->status = $data['woo_order_status']['value'];
}
public function do_action( $data ) {
global $automation_data;
$order_data = $automation_data->get( 'woo_order_data' );
if ( empty( $order_data ) ) {
return false;
}
$order = wc_get_order( $order_data->get_value( Woo_Order_Id::get_id() ) );
if ( empty( $order ) ) {
return false;
}
$order->update_status( $this->status, '', true );
}
}

View File

@@ -0,0 +1,94 @@
<?php
namespace TVE\Dashboard\Automator;
use Thrive\Automator\Items\Action;
use function wc_create_refund;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Class Woo_Refund_Order
*/
class Woo_Refund_Order extends Action {
/**
* Get the action identifier
*
* @return string
*/
public static function get_id() {
return 'woo/refundorder';
}
/**
* Get the action name/label
*
* @return string
*/
public static function get_name() {
return 'Refund WooCommerce order';
}
/**
* Get the action description
*
* @return string
*/
public static function get_description() {
return 'Refund the WooCommerce order';
}
/**
* Get the action logo
*
* @return string
*/
public static function get_image() {
return 'woo-refund-order';
}
/**
* Get the name of app to which action belongs
*
* @return string
*/
public static function get_app_id() {
return Woo_App::get_id();
}
/**
* Array of action-field keys, required for the action to be setup
*
* @return array
*/
public static function get_required_action_fields() {
return array();
}
/**
* Get an array of keys with the required data-objects
*
* @return array
*/
public static function get_required_data_objects() {
return array( 'woo_order_data' );
}
public function do_action( $data ) {
global $automation_data;
$order_data = $automation_data->get( 'woo_order_data' );
if ( empty( $order_data ) ) {
return false;
}
$order = wc_get_order( $order_data->get_value( Woo_Order_Id::get_id() ) );
if ( empty( $order ) ) {
return false;
}
wc_create_refund( array( 'order_id' => $order_data->get_value( Woo_Order_Id::get_id() ) ) );
}
}