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,107 @@
<?php
final class BWFAN_WC_Store_Credit_Decrease extends BWFAN_Action {
private static $ins = null;
protected function __construct() {
$this->action_name = __( 'Decrease Store Credit', 'wp-marketing-automations-pro' );
$this->action_desc = __( 'This action decreases store credit for user', 'wp-marketing-automations-pro' );
$this->action_priority = 5;
$this->support_v2 = true;
$this->support_v1 = false;
}
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function make_v2_data( $automation_data, $step_data ) {
$data_to_set = array();
$data_to_set['amount'] = BWFAN_Common::decode_merge_tags( $step_data['amount'] );
$email = ( isset( $automation_data['global']['email'] ) && is_email( $automation_data['global']['email'] ) ) ? $automation_data['global']['email'] : '';
$user = is_email( $email ) ? get_user_by( 'email', $email ) : '';
$data_to_set['user_id'] = $user instanceof WP_User ? $user->ID : 0;
$data_to_set['email'] = $email;
return $data_to_set;
}
public function process_v2() {
$credits_updated = $this->update_user_balance( $this->data );
if ( true === $credits_updated ) {
return $this->success_message( __( 'Store credits decreased.', 'wp-marketing-automations-pro' ) );
}
if ( is_wp_error( $credits_updated ) ) {
$this->error_response( $credits_updated->get_error_message() );
}
return $this->error_response( __( 'Some error occurred', 'wp-marketing-automations-pro' ) );
}
public function update_user_balance( $data ) {
if ( ! class_exists( 'ACFWF\Models\Objects\Store_Credit_Entry' ) ) {
return false;
}
if ( ! isset( $data['user_id'] ) || 0 === intval( $data['user_id'] ) ) {
return false;
}
if ( ! isset( $data['amount'] ) || 0 === floatval( $data['amount'] ) ) {
return false;
}
$store_credit_entry = new ACFWF\Models\Objects\Store_Credit_Entry();
$params = [
'amount' => floatval( $data['amount'] ),
'user_id' => $data['user_id'],
'type' => 'decrease',
'action' => 'admin_decrease',
];
foreach ( $params as $prop => $value ) {
$store_credit_entry->set_prop( $prop, $value );
}
$check = $store_credit_entry->save();
if ( $check ) {
return true;
}
return $check;
}
public function get_fields_schema() {
return [
[
"id" => 'amount',
"label" => __( 'Credit Amount', 'wp-marketing-automations-pro' ),
"type" => 'text',
"class" => 'bwfan-input-wrapper',
"required" => true,
],
];
}
public function get_desc_text( $data ) {
$data = json_decode( wp_json_encode( $data ), true );
if ( ! isset( $data['amount'] ) || empty( $data['amount'] ) ) {
return '';
}
return $data['amount'];
}
}
/**
* Register this action. Registering the action will make it eligible to see it on single automation screen in select actions dropdown.
*/
return 'BWFAN_WC_Store_Credit_Decrease';

View File

@@ -0,0 +1,107 @@
<?php
final class BWFAN_WC_Store_Credit_Increase extends BWFAN_Action {
private static $ins = null;
protected function __construct() {
$this->action_name = __( 'Increase Store Credit', 'wp-marketing-automations-pro' );
$this->action_desc = __( 'This action increases store credit for user', 'wp-marketing-automations-pro' );
$this->action_priority = 5;
$this->support_v2 = true;
$this->support_v1 = false;
}
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function make_v2_data( $automation_data, $step_data ) {
$data_to_set = array();
$data_to_set['amount'] = BWFAN_Common::decode_merge_tags( $step_data['amount'] );
$email = ( isset( $automation_data['global']['email'] ) && is_email( $automation_data['global']['email'] ) ) ? $automation_data['global']['email'] : '';
$user = is_email( $email ) ? get_user_by( 'email', $email ) : '';
$data_to_set['user_id'] = $user instanceof WP_User ? $user->ID : 0;
$data_to_set['email'] = $email;
return $data_to_set;
}
public function process_v2() {
$credits_updated = $this->update_user_balance( $this->data );
if ( true === $credits_updated ) {
return $this->success_message( __( 'Store credits increased.', 'wp-marketing-automations-pro' ) );
}
if ( is_wp_error( $credits_updated ) ) {
$this->error_response( $credits_updated->get_error_message() );
}
return $this->error_response( __( 'Some error occurred', 'wp-marketing-automations-pro' ) );
}
public function update_user_balance( $data ) {
if ( ! class_exists( 'ACFWF\Models\Objects\Store_Credit_Entry' ) ) {
return false;
}
if ( ! isset( $data['user_id'] ) || 0 === intval( $data['user_id'] ) ) {
return false;
}
if ( ! isset( $data['amount'] ) || 0 === floatval( $data['amount'] ) ) {
return false;
}
$store_credit_entry = new ACFWF\Models\Objects\Store_Credit_Entry();
$params = [
'amount' => floatval( $data['amount'] ),
'user_id' => $data['user_id'],
'type' => 'increase',
'action' => 'admin_increase',
];
foreach ( $params as $prop => $value ) {
$store_credit_entry->set_prop( $prop, $value );
}
$check = $store_credit_entry->save();
if ( $check ) {
return true;
}
return $check;
}
public function get_fields_schema() {
return [
[
"id" => 'amount',
"label" => __( 'Credit Amount', 'wp-marketing-automations-pro' ),
"type" => 'text',
"class" => 'bwfan-input-wrapper',
"required" => true,
],
];
}
public function get_desc_text( $data ) {
$data = json_decode( wp_json_encode( $data ), true );
if ( ! isset( $data['amount'] ) || empty( $data['amount'] ) ) {
return '';
}
return $data['amount'];
}
}
/**
* Register this action. Registering the action will make it eligible to see it on single automation screen in select actions dropdown.
*/
return 'BWFAN_WC_Store_Credit_Increase';

View File

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

View File

@@ -0,0 +1,34 @@
<?php
final class BWFAN_ADV_Coupons_Integration extends BWFAN_Integration {
private static $instance = null;
/**
* BWFAN_ADV_Coupons_Integration constructor.
*/
private function __construct() {
$this->action_dir = __DIR__;
$this->nice_name = __( 'Advanced Coupons', 'wp-marketing-automations-pro' );
$this->group_name = __( 'WooCommerce', 'wp-marketing-automations-pro' );
$this->group_slug = 'wc';
$this->priority = 35;
}
/**
* Ensures only one instance of the class is loaded or can be loaded.
*
* @return BWFAN_ADV_Coupons_Integration|null
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
}
if ( bwfan_is_woocommerce_active() && bwfan_is_advanced_coupon_for_woocommerce_active() ) {
BWFAN_Load_Integrations::register( 'BWFAN_ADV_Coupons_Integration' );
}

View File

@@ -0,0 +1,66 @@
<?php
class BWFAN_ADV_Coupon_Source extends BWFAN_Source {
private static $instance = null;
public function __construct() {
$this->event_dir = __DIR__;
$this->nice_name = __( 'Advanced Coupons', 'wp-marketing-automations-pro' );
$this->group_name = __( 'WooCommerce', 'wp-marketing-automations-pro' );
$this->group_slug = 'wc';
$this->priority = 100;
}
/**
* Ensures only one instance of the class is loaded or can be loaded.
*
* @return BWFAN_ADV_Coupon_Source|null
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
*
* @param $user_id
*
* @return int|mixed
*/
public static function fetch_user_total_credit( $user_id ) {
if ( empty( $user_id ) ) {
return 0;
}
$credits = self::get_user_credits( $user_id );
return ! empty( $credits ) && isset( $credits['increase'] ) ? $credits['increase'] : 0;
}
/**
* Get user credits
*
* @param $user_id
*
* @return array|false|null
*/
public static function get_user_credits( $user_id ) {
global $wpdb;
$query = $wpdb->prepare( "SELECT SUM(`entry_amount`) AS `amount`, `entry_type` FROM {$wpdb->prefix}acfw_store_credits WHERE `user_id` = %d GROUP BY `entry_type`", $user_id );
$result = $wpdb->get_results( $query, ARRAY_A ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
return ! empty( $result ) ? array_column( $result, 'amount', 'entry_type' ) : [];
}
}
/**
* Register this as a source.
*/
if ( bwfan_is_woocommerce_active() && bwfan_is_advanced_coupon_for_woocommerce_active() ) {
BWFAN_Load_Sources::register( 'BWFAN_ADV_Coupon_Source' );
}

View File

@@ -0,0 +1,138 @@
<?php
#[AllowDynamicProperties]
final class BWFAN_ADV_Lifetime_Credit_Limit_Exceed extends BWFAN_Event {
private static $instance = null;
public $total_credit = null;
public $user_id = null;
public $email = null;
private $type = null;
private function __construct() {
$this->optgroup_label = esc_html__( 'Advanced Coupons', 'wp-marketing-automations-pro' );
$this->event_name = esc_html__( 'Lifetime Store Credit Reached', 'wp-marketing-automations-pro' );
$this->event_desc = esc_html__( 'This event will run if life time store credits crossed specific amount ', 'wp-marketing-automations-pro' );
$this->event_merge_tag_groups = array( 'bwf_contact', 'wc_order' );
$this->event_rule_groups = array(
'wc_order',
'aerocheckout',
'bwf_contact_segments',
'bwf_contact',
'bwf_contact_fields',
'bwf_contact_user',
'bwf_contact_wc',
'bwf_contact_geo',
'bwf_engagement',
'bwf_broadcast',
'store_credit',
);
$this->support_lang = true;
$this->v2 = true;
$this->support_v1 = false;
}
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
public function load_hooks() {
add_action( 'acfw_create_store_credit_entry', [ $this, 'process' ] );
}
public function process( $entry ) {
if ( isset( $entry['type'] ) && 'decrease' === $entry['type'] ) {
return;
}
if ( ! isset( $entry['user_id'] ) || 0 === intval( $entry['user_id'] ) ) {
return;
}
$data = $this->get_default_data();
$data['user_id'] = intval( $entry['user_id'] );
$data['amount'] = floatval( $entry['amount'] );
$data['type'] = $entry['type'];
$this->send_async_call( $data );
}
public function get_event_data() {
$data_to_send['global']['amount'] = $this->total_credit;
$data_to_send['global']['user_id'] = $this->user_id;
$data_to_send['global']['type'] = $this->type;
return $data_to_send;
}
/**
* validate v2 event settings
* @return bool
*/
public function validate_v2_event_settings( $automation_data ) {
$credits = BWFAN_ADV_Coupon_Source::get_user_credits( $automation_data['user_id'] );
$total_credit = ! empty( $credits ) && isset( $credits['increase'] ) ? $credits['increase'] : 0;
return ( floatval( $automation_data['event_meta']['bwfan_limit_amount'] ) < floatval( $total_credit ) );
}
/**
* Capture the async data for the current event.
*
* @return array|bool
*/
public function capture_v2_data( $automation_data ) {
$user = get_user_by( 'id', $automation_data['user_id'] );
if ( ! $user instanceof WP_User ) {
return $automation_data;
}
$this->user_id = BWFAN_Common::$events_async_data['user_id'];
$this->type = BWFAN_Common::$events_async_data['type'];
$credits = BWFAN_ADV_Coupon_Source::get_user_credits( $this->user_id );
$this->total_credit = ! empty( $credits ) && isset( $credits['increase'] ) ? $credits['increase'] : 0;
$this->email = $user->user_email;
$automation_data['amount'] = $this->total_credit;
$automation_data['user_id'] = $this->user_id;
$automation_data['type'] = $this->type;
$automation_data['email'] = $this->email;
$automation_data['first_name'] = $user->first_name;
$automation_data['last_name'] = $user->last_name;
return $automation_data;
}
/**
* v2 Method: Get fields schema
*
* @return array[][]
*/
public function get_fields_schema() {
return [
[
'id' => 'bwfan_limit_amount',
'type' => 'text',
'label' => __( 'Amount', 'wp-marketing-automations-pro' ),
"class" => 'bwfan-input-wrapper',
"placeholder" => __( 'Amount', 'wp-marketing-automations-pro' ),
"required" => true,
"errorMsg" => __( 'Enter amount.', 'wp-marketing-automations-pro' ),
"description" => ""
],
];
}
}
/**
* Register this event to a source.
* This will show the current event in dropdown in single automation screen.
*/
if ( bwfan_is_woocommerce_active() && bwfan_is_advanced_coupon_for_woocommerce_active() ) {
return 'BWFAN_ADV_Lifetime_Credit_Limit_Exceed';
}

View File

@@ -0,0 +1,147 @@
<?php
#[AllowDynamicProperties]
final class BWFAN_ADV_Coupons_Store_credits_update extends BWFAN_Event {
private static $instance = null;
public $total_credit = null;
public $user_id = null;
public $email = null;
private $credit_type = [];
private function __construct() {
$this->optgroup_label = esc_html__( 'Advanced Coupons', 'wp-marketing-automations-pro' );
$this->event_name = esc_html__( 'Store Credits Updated', 'wp-marketing-automations-pro' );
$this->event_desc = esc_html__( 'This event will run if store credit is updated ', 'wp-marketing-automations-pro' );
$this->event_merge_tag_groups = array( 'bwf_contact', 'wc_order' );
$this->event_rule_groups = array(
'wc_order',
'aerocheckout',
'bwf_contact_segments',
'bwf_contact',
'bwf_contact_fields',
'bwf_contact_user',
'bwf_contact_wc',
'bwf_contact_geo',
'bwf_engagement',
'bwf_broadcast',
'store_credit',
);
$this->priority = 100;
$this->optgroup_priority = 25;
$this->support_lang = true;
$this->credit_type = [
'both' => __( 'Both', 'wp-marketing-automations-pro' ),
'increase' => __( 'Increase', 'wp-marketing-automations-pro' ),
'decrease' => __( 'Decrease', 'wp-marketing-automations-pro' ),
];
$this->v2 = true;
$this->support_v1 = false;
}
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
public function load_hooks() {
add_action( 'acfw_store_credits_total_changed', [ $this, 'process' ], 10, 1 );
}
public function process( $entry ) {
$data = $this->get_default_data();
$data['amount'] = $entry->get_prop( 'amount' );
$data['user_id'] = $entry->get_prop( 'user_id' );
$data['credit_type'] = $entry->get_prop( 'type' );
$this->send_async_call( $data );
}
public function get_event_data() {
$data_to_send['global']['amount'] = $this->total_credit;
$data_to_send['global']['user_id'] = $this->user_id;
$data_to_send['global']['credit_type'] = $this->credit_type;
return $data_to_send;
}
/**
* validate v2 event settings
* @return bool
*/
public function validate_v2_event_settings( $automation_data ) {
if ( 'both' === $automation_data['event_meta']['bwfan_credit_type'] || $automation_data['credit_type'] === $automation_data['event_meta']['bwfan_credit_type'] ) {
return true;
}
return false;
}
/**
* Capture the async data for the current event.
* @return array|bool
*/
public function capture_v2_data( $automation_data ) {
$this->user_id = BWFAN_Common::$events_async_data['user_id'];
$user = get_user_by( 'id', $this->user_id );
if ( ! $user instanceof WP_User ) {
return $automation_data;
}
$this->credit_type = BWFAN_Common::$events_async_data['credit_type'];
$credits = BWFAN_ADV_Coupon_Source::get_user_credits( $this->user_id );
$this->total_credit = ! empty( $credits ) && isset( $credits['increase'] ) ? $credits['increase'] : 0;
$this->email = $user->user_email;
$automation_data['amount'] = $this->total_credit;
$automation_data['user_id'] = $this->user_id;
$automation_data['credit_type'] = $this->credit_type;
$automation_data['email'] = $this->email;
$automation_data['first_name'] = $user->first_name;
$automation_data['last_name'] = $user->last_name;
return $automation_data;
}
/**
* v2 Method: Get fields schema
* @return array[][]
*/
public function get_fields_schema() {
$credit_type = BWFAN_Common::prepared_field_options( $this->credit_type );
return [
[
'id' => 'bwfan_credit_type',
'type' => 'wp_select',
'options' => $credit_type,
'label' => __( 'Credit Type', 'wp-marketing-automations-pro' ),
"class" => 'bwfan-input-wrapper',
"placeholder" => 'Select',
"required" => true,
"errorMsg" => __( "Select Store Credit.", 'wp-marketing-automations-pro' ),
"description" => ""
],
];
}
/** set default values */
public function get_default_values() {
return [
'bwfan_credit_type' => 'both',
];
}
}
/**
* Register this event to a source.
* This will show the current event in dropdown in single automation screen.
*/
if ( bwfan_is_woocommerce_active() && bwfan_is_advanced_coupon_for_woocommerce_active() ) {
return 'BWFAN_ADV_Coupons_Store_credits_update';
}

View File

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

View File

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