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,102 @@
<?php
class BWFCRM_Webhook_AmazonSES extends BWFCRM_Email_Webhook_Base {
private static $ins = null;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self;
}
return self::$ins;
}
public function __construct() {
$this->_name = "Amazon SES";
}
public function handle_webhook() {
if ( ! is_array( $this->_data ) || empty( $this->_data ) ) {
return;
}
$this->maybe_bounce_contact_email();
}
private function maybe_bounce_contact_email() {
$notificationType = isset( $this->_data['notificationType'] ) && ! empty( $this->_data['notificationType'] ) ? $this->_data['notificationType'] : '';
if ( empty( $notificationType ) ) {
$notificationType = isset( $this->_data['Type'] ) && ! empty( $this->_data['Type'] ) ? $this->_data['Type'] : '';
}
if ( empty( $notificationType ) ) {
BWFAN_Core()->logger->log( "Amazon SES no notification type found", 'crm_email_webhooks' );
return;
}
if ( $notificationType === 'SubscriptionConfirmation' ) {
wp_remote_get( $this->_data['SubscribeURL'] );
wp_send_json( [
'status' => 200,
'message' => 'success'
], 200 );
}
if ( $notificationType === 'Complaint' ) {
$complaint = isset( $this->_data['complaint'] ) && is_array( $this->_data['complaint'] ) ? $this->_data['complaint'] : [];
if ( empty( $complaint ) || ! isset( $complaint['complainedRecipients'] ) || ! is_array( $complaint['complainedRecipients'] ) ) {
return;
}
/** In case of complaint marking contact bounced */
foreach ( $complaint['complainedRecipients'] as $complainedRecipient ) {
$email = $this->extractEmail( $complainedRecipient['emailAddress'] );
$this->mark_contact_complaint( $email );
}
return;
}
if ( $notificationType === 'Bounce' ) {
$bounce = isset( $this->_data['bounce'] ) && is_array( $this->_data['bounce'] ) ? $this->_data['bounce'] : [];
if ( ! isset( $bounce['bounceType'] ) ) {
return;
}
$bounce_type = [ 'Undetermined', 'Permanent' ];
if ( in_array( $bounce['bounceType'], apply_filters( 'bwfan_amazonses_bounce_type', $bounce_type ), true ) ) {
foreach ( $bounce['bouncedRecipients'] as $bouncedRecipient ) {
$email = $this->extractEmail( $bouncedRecipient['emailAddress'] );
$this->mark_contact_bounce( $email );
}
return;
}
/** Soft bounce case */
foreach ( $bounce['bouncedRecipients'] as $bouncedRecipient ) {
$email = $this->extractEmail( $bouncedRecipient['emailAddress'] );
$this->mark_contact_soft_bounce( $email );
}
}
}
private function extractEmail( $from_email ) {
$bracket_pos = strpos( $from_email, '<' );
if ( false !== $bracket_pos ) {
$from_email = substr( $from_email, $bracket_pos + 1 );
$from_email = str_replace( '>', '', $from_email );
$from_email = trim( $from_email );
}
if ( is_email( $from_email ) ) {
return $from_email;
}
return false;
}
}
BWFCRM_Core()->email_webhooks->register( 'BWFCRM_Webhook_AmazonSES' );

View File

@@ -0,0 +1,70 @@
<?php
/**
* Elastic Email Bounce Handling Controller
*/
class BWFCRM_Webhook_ElasticEmail extends BWFCRM_Email_Webhook_Base {
private static $ins = null;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self;
}
return self::$ins;
}
public function __construct() {
$this->_name = "Elastic Email";
}
/**
* Email Bounce Service Handler
*
* @return void
*/
public function handle_webhook() {
if ( ! is_array( $this->_data ) || empty( $this->_data ) ) {
return;
}
$this->maybe_bounce_contact_email();
}
/**
* Mark contact bounced
*
* @return void
*/
private function maybe_bounce_contact_email() {
if ( ! is_array( $this->_data ) || ! isset( $this->_data['status'] ) || ! is_email( $this->_data['to'] ) ) {
return;
}
$valid_statuses = apply_filters( 'bwfan_elasticemail_bounce_statuses', array( 'complaint', 'error', 'soft', 'hard' ) );
$status = strtolower( $this->_data['status'] );
if ( ! in_array( $status, $valid_statuses, true ) ) {
return;
}
if ( 'complaint' === $status ) {
$this->mark_contact_complaint( $this->_data['to'] );
return;
}
if ( 'error' === $status ) {
$bounce_type = isset( $this->_data['bounce_type'] ) ? strtolower( $this->_data['bounce_type'] ) : 'soft';
if ( 'hard' === $bounce_type ) {
$this->mark_contact_bounce( $this->_data['to'] );
return;
}
if ( 'soft' === $bounce_type ) {
$this->mark_contact_soft_bounce( $this->_data['to'] );
}
}
}
}
BWFCRM_Core()->email_webhooks->register( 'BWFCRM_Webhook_ElasticEmail' );

View File

@@ -0,0 +1,52 @@
<?php
class BWFCRM_Webhook_Mailgun extends BWFCRM_Email_Webhook_Base {
private static $ins = null;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self;
}
return self::$ins;
}
public function __construct() {
$this->_name = "Mailgun";
}
public function handle_webhook() {
if ( ! is_array( $this->_data ) || empty( $this->_data ) ) {
return;
}
$this->maybe_bounce_contact_email();
}
private function maybe_bounce_contact_email() {
foreach ( $this->_data as $key => $datum ) {
if ( 'event-data' !== $key ) {
continue;
}
$valid_bounce_statuses = apply_filters( 'bwfan_mailgun_bounce_status', array( 'bounced', 'failed', 'complained', 'unsubscribed' ) );
if ( ! is_array( $datum ) || ! isset( $datum['event'] ) || ! in_array( $datum['event'], $valid_bounce_statuses, true ) || ! is_email( $datum['recipient'] ) ) {
continue;
}
$event_type = strtolower( $datum['event'] );
switch ( $event_type ) {
case 'bounced':
case 'failed':
$this->mark_contact_bounce( $datum['recipient'] );
break;
case 'complained':
$this->mark_contact_complaint( $datum['recipient'] );
break;
}
}
}
}
BWFCRM_Core()->email_webhooks->register( 'BWFCRM_Webhook_Mailgun' );

View File

@@ -0,0 +1,57 @@
<?php
class BWFCRM_Webhook_MailJet extends BWFCRM_Email_Webhook_Base {
private static $ins = null;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self;
}
return self::$ins;
}
public function __construct() {
$this->_name = "Mailjet";
}
public function handle_webhook() {
if ( ! is_array( $this->_data ) || empty( $this->_data ) ) {
return;
}
$this->maybe_bounce_contact_email();
}
private function maybe_bounce_contact_email() {
// Loop through the data if it's an array
foreach ( $this->_data as $datum ) {
// Ensure the necessary data is set and it's a valid email event
if ( ! is_array( $datum ) || ! isset( $datum[0] ) || ! isset( $datum[0]['event'] ) || ! isset( $datum[0]['email'] ) || ! is_email( $datum[0]['email'] ) ) {
continue;
}
$event = $datum[0]['event'];
$email = $datum[0]['email'];
$bounce_status = apply_filters( 'bwfan_mailjet_bounce_status', array( 'bounce', 'soft_bounce', 'complaint' ) );
if ( ! in_array( $event, $bounce_status, true ) ) {
continue;
}
switch ( strtolower( $event ) ) {
case 'bounce':
$this->mark_contact_bounce( $email );
break;
case 'soft_bounce':
$this->mark_contact_soft_bounce( $email );
break;
case 'complaint':
$this->mark_contact_complaint( $email );
break;
}
}
}
}
BWFCRM_Core()->email_webhooks->register( 'BWFCRM_Webhook_MailJet' );

View File

@@ -0,0 +1,56 @@
<?php
class BWFCRM_Webhook_Pepipost extends BWFCRM_Email_Webhook_Base {
private static $ins = null;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self;
}
return self::$ins;
}
public function __construct() {
$this->_name = "Pepipost";
}
public function handle_webhook() {
if ( ! is_array( $this->_data ) || empty( $this->_data ) ) {
return;
}
$this->maybe_bounce_contact_email();
}
private function maybe_bounce_contact_email() {
foreach ( $this->_data as $datum ) {
if ( ! is_array( $datum ) || ! isset( $datum['EVENT'], $datum['EMAIL'] ) || ! is_email( $datum['EMAIL'] ) ) {
continue;
}
$valid_events = apply_filters( 'bwfan_pepipost_bounce_events', array( 'bounced', 'soft_bounced', 'complaint' ) );
$event = strtolower( $datum['EVENT'] );
if ( ! in_array( $event, $valid_events, true ) ) {
continue;
}
switch ( $event ) {
case 'bounced':
$this->mark_contact_bounce( $datum['EMAIL'] );
break;
case 'soft_bounced':
$this->mark_contact_soft_bounce( $datum['EMAIL'] );
break;
case 'complaint':
$this->mark_contact_complaint( $datum['EMAIL'] );
break;
}
}
}
}
BWFCRM_Core()->email_webhooks->register( 'BWFCRM_Webhook_Pepipost' );

View File

@@ -0,0 +1,68 @@
<?php
class BWFCRM_Webhook_Postmark extends BWFCRM_Email_Webhook_Base {
private static $ins = null;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self;
}
return self::$ins;
}
public function __construct() {
$this->_name = "Postmark";
}
public function handle_webhook() {
if ( ! is_array( $this->_data ) || empty( $this->_data ) ) {
return;
}
$this->maybe_bounce_contact_email();
}
private function maybe_bounce_contact_email() {
if ( ! is_array( $this->_data ) || ! isset( $this->_data['TypeCode'] ) || ! is_email( $this->_data['Email'] ) ) {
return;
}
/**
* checking for hard bounce
* https://postmarkapp.com/developer/api/bounce-api#bounce-types
*
* 1 - Hard bounce
* 100000 - Invalid email address
* 100006 - ISP block
* 100009 - DMARC Policy
*/
if ( in_array( intval( $this->_data['TypeCode'] ), [ 1, 100000, 100006, 100009 ], true ) ) {
$this->mark_contact_bounce( $this->_data['Email'] );
return;
}
/**
* checking for soft bounce
* 2 - Transient - Message delayed/Undeliverable
* 256 - DNS error
* 4096 - Soft bounce
*/
if ( in_array( intval( $this->_data['TypeCode'] ), [ 2, 256, 4096 ], true ) ) {
$this->mark_contact_soft_bounce( $this->_data['Email'] );
return;
}
/**
* checking for spam complaint
* 100001 - Spam complaint
*/
if ( in_array( intval( $this->_data['TypeCode'] ), [ 100001 ], true ) ) {
$this->mark_contact_complaint( $this->_data['Email'] );
}
}
}
BWFCRM_Core()->email_webhooks->register( 'BWFCRM_Webhook_Postmark' );

View File

@@ -0,0 +1,58 @@
<?php
class BWFCRM_Webhook_Sendgrid extends BWFCRM_Email_Webhook_Base {
private static $ins = null;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self;
}
return self::$ins;
}
public function __construct() {
$this->_name = "Sendgrid";
}
public function handle_webhook() {
if ( ! is_array( $this->_data ) || empty( $this->_data ) ) {
return;
}
$this->maybe_bounce_contact_email();
}
private function maybe_bounce_contact_email() {
// Apply filter to define valid events for bounce, soft bounce, and complaints
$valid_events = apply_filters( 'bwfan_sendgrid_bounce_events', array( 'bounce', 'deferred', 'dropped' ) );
// Loop through each data entry in the webhook
foreach ( $this->_data as $datum ) {
if ( ! is_array( $datum ) || ! isset( $datum['event'], $datum['email'] ) || ! is_email( $datum['email'] ) ) {
continue;
}
$event = strtolower( $datum['event'] );
if ( ! in_array( $event, $valid_events, true ) ) {
continue;
}
switch ( $event ) {
case 'bounce':
$this->mark_contact_bounce( $datum['email'] );
break;
case 'deferred':
$this->mark_contact_soft_bounce( $datum['email'] );
break;
case 'dropped':
case 'spamreport':
$this->mark_contact_complaint( $datum['email'] );
break;
}
}
}
}
BWFCRM_Core()->email_webhooks->register( 'BWFCRM_Webhook_Sendgrid' );

View File

@@ -0,0 +1,76 @@
<?php
/**
* Class BWFCRM_Webhook_Sendinblue
* This class tracks the bounced mail from sendinblue
*/
class BWFCRM_Webhook_Sendinblue extends BWFCRM_Email_Webhook_Base {
private static $ins = null;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self;
}
return self::$ins;
}
/*
* the name in the constructor is the name which will be shown in the dropdown in setting
*/
public function __construct() {
$this->_name = "Brevo (Formerly Sendinblue)";
}
/**
* this is the abstract function from the base class
* it needs to be define in child class
* it receives the data received from webhook set in sendinblue
*/
public function handle_webhook() {
if ( ! is_array( $this->_data ) || empty( $this->_data ) ) {
return;
}
$this->maybe_bounce_contact_email();
}
/**
* this function mark the email as bounce
*/
private function maybe_bounce_contact_email() {
if ( ! isset( $this->_data['event'], $this->_data['email'] ) || ! is_email( $this->_data['email'] ) ) {
return;
}
$valid_record_types = apply_filters( 'bwfan_sendinblue_bounce_recordtypes', array( 'hard_bounce', 'soft_bounce', 'complaint' ) );
$event = strtolower( $this->_data['event'] );
if ( ! in_array( $event, $valid_record_types, true ) ) {
return;
}
$handle_softbounce = apply_filters( 'bwfan_sendinblue_soft_bounce', 'yes' );
if ( 'soft_bounce' === $event && 'no' === $handle_softbounce ) {
return;
}
switch ( $event ) {
case 'hard_bounce':
$this->mark_contact_bounce( $this->_data['email'] );
break;
case 'soft_bounce':
$this->mark_contact_soft_bounce( $this->_data['email'] );
break;
case 'complaint':
case 'block':
$this->mark_contact_complaint( $this->_data['email'] );
break;
}
}
}
/**
* Registering the BWFCRM_Webhook_Sendinblue
* it will add the option of sendinblue in the dropdown in setting
*/
BWFCRM_Core()->email_webhooks->register( 'BWFCRM_Webhook_Sendinblue' );

View File

@@ -0,0 +1,38 @@
<?php
class BWFCRM_Webhook_Sparkpost extends BWFCRM_Email_Webhook_Base {
private static $ins = null;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self;
}
return self::$ins;
}
public function __construct() {
$this->_name = "Sparkpost";
}
public function handle_webhook() {
if ( ! is_array( $this->_data ) || empty( $this->_data ) ) {
return;
}
$this->maybe_bounce_contact_email();
}
private function maybe_bounce_contact_email() {
foreach ( $this->_data as $datum ) {
if ( ! is_array( $datum ) || ! isset( $datum['msys']['message_event']['type'] ) || 'bounce' !== $datum['msys']['message_event']['type'] || ! is_email( $datum['msys']['message_event']['rcpt_to'] ) ) {
continue;
}
$this->mark_contact_bounce( $datum['msys']['message_event']['rcpt_to'] );
break;
}
}
}
BWFCRM_Core()->email_webhooks->register( 'BWFCRM_Webhook_Sparkpost' );

View File

@@ -0,0 +1,3 @@
<?php
//silence is golden