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,47 @@
<?php
/**
* Class BWFAN_Pro_Compatibilities
* Loads all the compatibilities files we have in Autonami against plugins
*/
class BWFAN_Pro_Compatibilities {
public static function load_merge_tags_compatibilities() {
$compatibilities = [
'merge_tags/class-bwfan-pro-compatibility-handl-utm-grabber-data.php' => function_exists( 'bwfan_is_utm_grabber_active' ) && bwfan_is_utm_grabber_active(),
'merge_tags/class-bwfan-pro-compatibility-wc-advanced-shipment-tracking.php' => function_exists( 'wc_advanced_shipment_tracking' ) || class_exists( 'Ast_Pro' ),
'merge_tags/class-bwfan-pro-compatibility-wc-order-tracking.php' => bwfan_is_woocommerce_active() && function_exists( 'bwfan_wc_order_tracking_active' ) && bwfan_wc_order_tracking_active(),
'merge_tags/class-bwfan-pro-compatibility-wc-sequential-order-number.php' => class_exists( 'WC_Sequential_Order_Numbers_Pro_Loader' ) || class_exists( 'WC_Seq_Order_Number' ),
'merge_tags/class-bwfan-pro-compatibility-wc-services.php' => defined( 'WOOCOMMERCE_CONNECT_MINIMUM_WOOCOMMERCE_VERSION' ),
'merge_tags/class-bwfan-pro-compatibility-wc-shipment-tracking.php' => function_exists( 'wc_shipment_tracking' ),
'plugins/class-bwfan-pro-compatibility-translatepress.php' => class_exists( 'TRP_Translate_Press' ),
];
self::add_files( array_filter( $compatibilities ) );
}
/**
* Include valid compatibility files
*
* @param $paths
*
* @return void
*/
public static function add_files( $paths ) {
/** Compatibilities folder */
$dir = BWFAN_PRO_PLUGIN_DIR . '/compatibilities';
try {
foreach ( $paths as $file => $condition ) {
if ( ! file_exists( $dir . '/' . $file ) ) {
continue;
}
include_once $dir . '/' . $file;
}
} catch ( Exception|Error $e ) {
BWF_Logger::get_instance()->log( 'Error while loading compatibility files: ' . $e->getMessage(), 'compatibilities-load-error', 'fka-files-load-error' );
}
}
}
add_action( 'bwfan_merge_tags_loaded', array( 'BWFAN_Pro_Compatibilities', 'load_merge_tags_compatibilities' ), 999 );

View File

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

View File

@@ -0,0 +1,172 @@
<?php
/**
* Plugin: https://wordpress.org/plugins/woo-advanced-shipment-tracking
* Class BWFAN_Handl_Utm_Grabber_Data
*/
class BWFAN_Handl_Utm_Grabber_Data extends Cart_Merge_Tag {
private static $instance = null;
public function __construct() {
$this->tag_name = 'handl_utm_grabber_data';
$this->tag_description = __( 'HandL UTM Grabber Data', 'wp-marketing-automations-pro' );
add_shortcode( 'bwfan_handl_utm_grabber_data', array( $this, 'parse_shortcode' ) );
}
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Show the html in popup for the merge tag.
*/
public function get_view() {
$handle_utm_fields = $this->get_view_data();
$this->get_back_button();
?>
<div class="bwfan_mtag_wrap">
<div class="bwfan_label">
<label for="" class="bwfan-label-title"><?php esc_html_e( 'Select Handl UTM Grabber', 'wp-marketing-automations-pro' ); ?></label>
</div>
<div class="bwfan_label_val">
<select id="" class="bwfan-input-wrapper bwfan_tag_select" name="data">
<?php
foreach ( $handle_utm_fields as $slug => $name ) {
echo '<option value="' . esc_attr__( $slug ) . '">' . esc_attr__( $name ) . '</option>';
}
?>
</select>
</div>
</div>
<?php
if ( $this->support_fallback ) {
$this->get_fallback();
}
$this->get_preview();
$this->get_copy_button();
}
public function get_view_data() {
$handler_merge_key = array(
'utm_campaign' => __( 'UTM Campaign', 'wp-marketing-automations-pro' ),
'utm_source' => __( 'UTM Source', 'wp-marketing-automations-pro' ),
'utm_term' => __( 'UTM Term', 'wp-marketing-automations-pro' ),
'utm_medium' => __( 'UTM Medium', 'wp-marketing-automations-pro' ),
'utm_content' => __( 'UTM Content', 'wp-marketing-automations-pro' ),
'gclid' => __( 'Gclid', 'wp-marketing-automations-pro' ),
'handl_original_ref' => __( 'Handl Original Reference', 'wp-marketing-automations-pro' ),
'handl_landing_page' => __( 'Handl Landing Page', 'wp-marketing-automations-pro' ),
'handl_ip' => __( 'Handl IP', 'wp-marketing-automations-pro' ),
'handl_ref' => __( 'Handl Reference', 'wp-marketing-automations-pro' ),
'handl_url' => __( 'Handl URL', 'wp-marketing-automations-pro' ),
);
return apply_filters( 'bwfan_external_handl_utm_grabber_key', $handler_merge_key );
}
/**
* Parse the merge tag and return its value.
*
* @param $attr
*
* @return mixed|string|void
*/
public function parse_shortcode( $attr ) {
if ( true === BWFAN_Merge_Tag_Loader::get_data( 'is_preview' ) ) {
return $this->get_dummy_preview();
}
$cart_details = BWFAN_Merge_Tag_Loader::get_data( 'cart_details' );
$checkout_data = isset( $cart_details['checkout_data'] ) ? $cart_details['checkout_data'] : '';
$key = ! isset( $attr['data'] ) ? 'utm_campaign' : $attr['data'];
/** getting the grabber data from checkout */
if ( ! empty( $checkout_data ) ) {
$field_value = '';
$checkout_data = json_decode( $checkout_data, true );
$field_value = '';
if ( isset( $checkout_data['handle_utm_grabber'][ $key ] ) ) {
$field_value = $checkout_data['handle_utm_grabber'][ $key ];
}
return $this->parse_shortcode_output( $field_value, $attr );
}
/** if order id available then get the details */
$order_id = $this->get_order_id();
if ( ! empty( $order_id ) ) {
$order = wc_get_order( $order_id );
if ( ! $order instanceof WC_Order ) {
return $this->parse_shortcode_output( '', $attr );
}
$field_value = $order->get_meta( $key );
return $this->parse_shortcode_output( $field_value, $attr );
}
return $this->parse_shortcode_output( '', $attr );
}
public function get_order_id() {
$order_id = absint( BWFAN_Merge_Tag_Loader::get_data( 'wc_order_id' ) );
$order_id = ( 0 === $order_id ) ? absint( BWFAN_Merge_Tag_Loader::get_data( 'order_id' ) ) : $order_id;
if ( 0 === $order_id ) {
$order = BWFAN_Merge_Tag_Loader::get_data( 'wc_order' );
$order_id = $order instanceof WC_Order ? absint( BWFAN_Woocommerce_Compatibility::get_order_id( $order ) ) : $order_id;
}
return $order_id;
}
/**
* Show dummy value of the current merge tag.
*
* @return string
*/
public function get_dummy_preview() {
return '';
}
/**
* Returns merge tag schema
*
* @return array[]
*/
public function get_setting_schema() {
$utm_data = $this->get_view_data();
$options = [];
foreach ( $utm_data as $utm_key => $data ) {
$options[] = [
'value' => $utm_key,
'label' => $data,
];
}
return [
[
'id' => 'data',
'type' => 'select',
'options' => $options,
'label' => __( 'Select UTM', 'wp-marketing-automations-pro' ),
"class" => 'bwfan-input-wrapper',
"required" => true,
'placeholder' => __( 'Select', 'wp-marketing-automations-pro' ),
"description" => ""
]
];
}
}
BWFAN_Merge_Tag_Loader::register( 'wc_ab_cart', 'BWFAN_Handl_Utm_Grabber_Data' );
BWFAN_Merge_Tag_Loader::register( 'wc_order', 'BWFAN_Handl_Utm_Grabber_Data' );

View File

@@ -0,0 +1,142 @@
<?php
/**
* Plugin: https://wordpress.org/plugins/woo-advanced-shipment-tracking
* Class BWFAN_WC_Advanced_Shipment_Tracking
*/
class BWFAN_WC_Advanced_Shipment_Tracking extends BWFAN_Merge_Tag {
private static $instance = null;
public function __construct() {
$this->tag_name = 'wc_adv_shipment';
$this->tag_description = __( 'WooCommerce Advanced Shipment Tracking details', 'wp-marketing-automations-pro' );
add_shortcode( 'bwfan_wc_advanced_shipment_tracking', array( $this, 'parse_shortcode' ) );
add_shortcode( 'bwfan_wc_adv_shipment', array( $this, 'parse_shortcode' ) );
}
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Show the html in popup for the merge tag.
*/
public function get_view() {
$tracking_fields = $this->get_view_data();
$this->get_back_button();
?>
<div class="bwfan_mtag_wrap">
<div class="bwfan_label">
<label for="" class="bwfan-label-title"><?php esc_html_e( 'Select Shipment Tracking Field', 'wp-marketing-automations-pro' ); ?></label>
</div>
<div class="bwfan_label_val">
<select id="" class="bwfan-input-wrapper bwfan_tag_select" name="data">
<?php
foreach ( $tracking_fields as $slug => $name ) {
echo '<option value="' . esc_attr__( $slug ) . '">' . esc_attr__( $name ) . '</option>';
}
?>
</select>
</div>
</div>
<?php
if ( $this->support_fallback ) {
$this->get_fallback();
}
$this->get_preview();
$this->get_copy_button();
}
public function get_view_data() {
return array(
'tracking_number' => __( 'Tracking Number', 'wp-marketing-automations-pro' ),
'formatted_tracking_provider' => __( 'Tracking Provider', 'wp-marketing-automations-pro' ),
'formatted_tracking_link' => __( 'Tracking Link', 'wp-marketing-automations-pro' ),
'date_shipped' => __( 'Date Shipped', 'wp-marketing-automations-pro' ),
);
}
/**
* Parse the merge tag and return its value.
*
* @param $attr
*
* @return mixed|string|void
*/
public function parse_shortcode( $attr ) {
if ( true === BWFAN_Merge_Tag_Loader::get_data( 'is_preview' ) ) {
return $this->get_dummy_preview();
}
$order_id = absint( BWFAN_Merge_Tag_Loader::get_data( 'wc_order_id' ) );
$order_id = empty( $order_id ) && ! empty( BWFAN_Merge_Tag_Loader::get_data( 'order_id' ) ) ? BWFAN_Merge_Tag_Loader::get_data( 'order_id' ) : $order_id;
if ( empty( $order_id ) ) {
return '';
}
$tracking_items = ast_get_tracking_items( $order_id );
if ( ! is_array( $tracking_items ) || 1 > count( $tracking_items ) ) {
return '';
}
/** If more than one shipments, then sort by date_shipped */
if ( count( $tracking_items ) > 1 ) {
usort( $tracking_items, function ( $item1, $item2 ) {
return absint( $item1['date_shipped'] ) <= absint( $item2['date_shipped'] );
} );
}
$item_key = ( isset( $attr['data'] ) && ! empty( $attr['data'] ) ) ? $attr['data'] : 'tracking_number';
$return_value = 'date_shipped' === $item_key ? date( 'm-d-Y', $tracking_items[0]['date_shipped'] ) : $tracking_items[0][ $item_key ];
return $this->parse_shortcode_output( $return_value, $attr );
}
/**
* Show dummy value of the current merge tag.
*
* @return string
*/
public function get_dummy_preview() {
return '123456789';
}
/**
* Return merge tag schema
*
* @return array[]
*/
public function get_setting_schema() {
$tracking_data = $this->get_view_data();
$options = [];
foreach ( $tracking_data as $track_key => $data ) {
$options[] = [
'value' => $track_key,
'label' => $data,
];
}
return [
[
'id' => 'data',
'type' => 'select',
'options' => $options,
'label' => __( 'Select Shipment Tracking Field', 'wp-marketing-automations-pro' ),
"class" => 'bwfan-input-wrapper',
"placeholder" => __( 'Select', 'wp-marketing-automations-pro' ),
"required" => false,
"description" => ""
],
];
}
}
/** checking for both WC Advanced Shipment Tracking Lite and Pro plugin */
BWFAN_Merge_Tag_Loader::register( 'wc_order', 'BWFAN_WC_Advanced_Shipment_Tracking' );

View File

@@ -0,0 +1,147 @@
<?php
class BWFAN_WC_Order_Tracking extends BWFAN_Merge_Tag {
private static $instance = null;
public function __construct() {
$this->tag_name = 'wc_order_tracking';
$this->tag_description = __( 'WooCommerce order Tracking details', 'wp-marketing-automations-pro' );
add_shortcode( 'bwfan_wc_order_tracking', array( $this, 'parse_shortcode' ) );
$this->support_v1 = false;
}
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
public function get_view_data() {
return array(
'Items_name' => __( 'Tracking Item Name', 'wp-marketing-automations-pro' ),
'carrier_name' => __( 'Carrier Name', 'wp-marketing-automations-pro' ),
'tracking_number' => __( 'Tracking Number', 'wp-marketing-automations-pro' ),
'tracking_url_show' => __( 'Tracking Link', 'wp-marketing-automations-pro' ),
'order_tracking_formatted' => __( 'Formatted', 'wp-marketing-automations-pro' ),
);
}
public function parse_shortcode( $attr ) {
if ( true === BWFAN_Merge_Tag_Loader::get_data( 'is_preview' ) ) {
return $this->get_dummy_preview( $attr );
}
$order_id = absint( BWFAN_Merge_Tag_Loader::get_data( 'wc_order_id' ) );
$order_id = empty( $order_id ) && ! empty( BWFAN_Merge_Tag_Loader::get_data( 'order_id' ) ) ? BWFAN_Merge_Tag_Loader::get_data( 'order_id' ) : $order_id;
if ( empty( $order_id ) ) {
return '';
}
$tracking_data = self::get_tracking_data( $order_id );
if ( empty( $tracking_data ) ) {
return '';
}
$item_key = ( isset( $attr['data'] ) && ! empty( $attr['data'] ) ) ? $attr['data'] : 'tracking_number';
if ( 'order_tracking_formatted' === $item_key ) {
$return_value = $this->get_formatted_order_tracking( $tracking_data );
return $this->parse_shortcode_output( $return_value, $attr );
}
$return_value = 'Items_name' === $item_key ? implode( ', ', array_map( function ( $item ) {
return $item['item_name'];
}, $tracking_data ) ) : implode( ', ', array_column( $tracking_data, $item_key ) );
return $this->parse_shortcode_output( $return_value, $attr );
}
public function get_formatted_order_tracking( $tracking_items ) {
$formatted_order_tracking = array_map( function ( $item ) {
return "{$item['item_name']}\n{$item['carrier_name']} ({$item['tracking_number']})\n{$item['tracking_url_show']}";
}, $tracking_items );
return implode( ", \n", $formatted_order_tracking );
}
public function get_dummy_preview( $attr ) {
switch ( $attr['data'] ) {
case 'Items_name':
return 'Album, Belt';
case 'carrier_name':
return 'Carrier Name, Carrier Name 2';
case 'tracking_url_show':
return 'https://example.com, https://example2.com';
case 'order_tracking_formatted':
return "Item Name,\nCarrier Name (Tracking Code)\nhttps://example.com";
default:
return 'ABCD123, ABCDE1234';
}
}
public function get_setting_schema() {
$tracking_data = $this->get_view_data();
$options = [];
foreach ( $tracking_data as $track_key => $data ) {
$options[] = [
'value' => $track_key,
'label' => $data,
];
}
return [
[
'id' => 'data',
'type' => 'select',
'options' => $options,
'label' => __( 'Select order Tracking Field', 'wp-marketing-automations-pro' ),
'class' => 'bwfan-input-wrapper',
'placeholder' => __( 'Select', 'wp-marketing-automations-pro' ),
'required' => false,
'description' => ''
],
];
}
public static function get_tracking_data( $order_id ) {
$order = wc_get_order( $order_id );
if ( ! $order instanceof WC_Order || empty( $order->get_items() ) ) {
return [];
}
if ( class_exists( 'VI_WOOCOMMERCE_ORDERS_TRACKING_DATA' ) ) {
return VI_WOOCOMMERCE_ORDERS_TRACKING_DATA::get_tracking_numbers( $order_id );
}
$tracking_data = [];
foreach ( $order->get_items() as $item_id => $item ) {
$item_tracking_data = wc_get_order_item_meta( $item_id, '_vi_wot_order_item_tracking_data', true );
if ( empty( $item_tracking_data ) ) {
continue;
}
$item_tracking_data = json_decode( $item_tracking_data, true );
if ( empty( $item_tracking_data ) || ! is_array( $item_tracking_data ) ) {
continue;
}
foreach ( $item_tracking_data as $tracking ) {
// Check if tracking number already exists to prevent duplicates
if ( ! in_array( $tracking['tracking_number'], array_column( $tracking_data, 'tracking_number' ) ) ) {
$tracking_data[] = [
'tracking_number' => $tracking['tracking_number'] ?? '',
'carrier_name' => $tracking['carrier_name'] ?? '',
'item_name' => $item->get_name(),
'tracking_url_show' => str_replace( '{tracking_number}', $tracking['tracking_number'] ?? '', $tracking['carrier_url'] ?? '' ),
];
}
}
}
return $tracking_data;
}
}
BWFAN_Merge_Tag_Loader::register( 'wc_order', 'BWFAN_WC_Order_Tracking' );

View File

@@ -0,0 +1,64 @@
<?php
class BWFAN_WC_Sequential_Order_Number extends BWFAN_Merge_Tag {
private static $instance = null;
public function __construct() {
$this->tag_name = 'wc_seq_order_number';
$this->tag_description = __( 'WooCommerce Sequential Order Number', 'wp-marketing-automations-pro' );
add_shortcode( 'bwfan_wc_sequential_order_number', array( $this, 'parse_shortcode' ) );
add_shortcode( 'bwfan_wc_seq_order_number', array( $this, 'parse_shortcode' ) );
}
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Parse the merge tag and return its value.
*
* @param $attr
*
* @return mixed|string|void
*/
public function parse_shortcode( $attr ) {
if ( true === BWFAN_Merge_Tag_Loader::get_data( 'is_preview' ) ) {
return $this->get_dummy_preview();
}
$order = null;
$order_id = absint( BWFAN_Merge_Tag_Loader::get_data( 'wc_order_id' ) );
$order_id = 0 === $order_id ? absint( BWFAN_Merge_Tag_Loader::get_data( 'order_id' ) ) : $order_id;
if ( 0 === $order_id ) {
$order = BWFAN_Merge_Tag_Loader::get_data( 'wc_order' );
} else {
$order = wc_get_order( $order_id );
}
if ( ! $order instanceof WC_Order ) {
return '';
}
$order_number = $order->get_meta( '_order_number_formatted' );
$order_number = empty( $order_number ) ? $order->get_meta( '_order_number' ) : $order_number;
return $this->parse_shortcode_output( $order_number, $attr );
}
/**
* Show dummy value of the current merge tag.
*
* @return string
*/
public function get_dummy_preview() {
return 'WC-1234-2020';
}
}
BWFAN_Merge_Tag_Loader::register( 'wc_order', 'BWFAN_WC_Sequential_Order_Number' );

View File

@@ -0,0 +1,173 @@
<?php
class BWFAN_WC_Jetpack_Shipment extends BWFAN_Merge_Tag {
private static $instance = null;
public function __construct() {
$this->tag_name = 'wc_jetpack_shipment';
$this->tag_description = __( 'WooCommerce Services - Jetpack', 'wp-marketing-automations-pro' );
add_shortcode( 'bwfan_wc_jetpack_shipment', array( $this, 'parse_shortcode' ) );
}
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Show the html in popup for the merge tag.
*/
public function get_view() {
$tracking_fields = $this->get_view_data();
$this->get_back_button();
?>
<div class="bwfan_mtag_wrap">
<div class="bwfan_label">
<label for="" class="bwfan-label-title"><?php esc_html_e( 'Select Tracking Field', 'wp-marketing-automations-pro' ); ?></label>
</div>
<div class="bwfan_label_val">
<select id="" class="bwfan-input-wrapper bwfan_tag_select" name="data">
<?php
foreach ( $tracking_fields as $slug => $name ) {
echo '<option value="' . esc_attr__( $slug ) . '">' . esc_attr__( $name ) . '</option>';
}
?>
</select>
</div>
</div>
<?php
if ( $this->support_fallback ) {
$this->get_fallback();
}
$this->get_preview();
$this->get_copy_button();
}
public function get_view_data() {
return array(
'carrier_name_short' => __( 'Carrier Name - Short', 'wp-marketing-automations-pro' ),
'carrier_name_full' => __( 'Carrier Name - Full', 'wp-marketing-automations-pro' ),
'package_name' => __( 'Package Name', 'wp-marketing-automations-pro' ),
'tracking_number' => __( 'Tracking Number', 'wp-marketing-automations-pro' ),
'tracking_link' => __( 'Tracking Link', 'wp-marketing-automations-pro' ),
);
}
/**
* Parse the merge tag and return its value.
*
* @param $attr
*
* @return mixed|string|void
*/
public function parse_shortcode( $attr ) {
if ( true === BWFAN_Merge_Tag_Loader::get_data( 'is_preview' ) ) {
return $this->get_dummy_preview();
}
$order_id = absint( BWFAN_Merge_Tag_Loader::get_data( 'wc_order_id' ) );
$order_id = empty( $order_id ) && ! empty( BWFAN_Merge_Tag_Loader::get_data( 'order_id' ) ) ? BWFAN_Merge_Tag_Loader::get_data( 'order_id' ) : $order_id;
if ( empty( $order_id ) ) {
return '';
}
$order = wc_get_order( $order_id );
if ( ! $order instanceof WC_Order ) {
return '';
}
$tracking_items = $order->get_meta( 'wc_connect_labels' );
if ( ! is_array( $tracking_items ) || empty( $tracking_items ) ) {
$tracking_items = $order->get_meta( '_wc_shipment_tracking_items' );
}
if ( ! is_array( $tracking_items ) || empty( $tracking_items ) ) {
return '';
}
$item = $tracking_items[0];
$return_value = '';
$item_key = isset( $attr['data'] ) && ! empty( $attr['data'] ) ? $attr['data'] : 'tracking_number';
switch ( $item_key ) {
case 'carrier_name_short':
$return_value = isset( $item['tracking_provider'] ) ? strtoupper( $item['tracking_provider'] ) : ( isset( $item['custom_tracking_provider'] ) ? strtoupper( $item['custom_tracking_provider'] ) : '' );
break;
case 'carrier_name_full':
$return_value = isset( $item['custom_tracking_provider'] ) ? $item['custom_tracking_provider'] : '';
break;
case 'package_name':
$return_value = isset( $item['package_name'] ) ? $item['package_name'] : '';
break;
case 'tracking_number':
$return_value = isset( $item['tracking_number'] ) ? $item['tracking_number'] : '';
break;
case 'tracking_link':
$return_value = isset( $item['custom_tracking_link'] ) ? $item['custom_tracking_link'] : '';
break;
}
return $this->parse_shortcode_output( $return_value, $attr );
}
public function get_tracking_url( $carrier, $tracking_number ) {
$tracking_url = '';
switch ( $carrier ) {
case 'fedex':
$tracking_url = 'https://www.fedex.com/apps/fedextrack/?action=track&tracknumbers=' . $tracking_number;
break;
case 'usps':
$tracking_url = 'https://tools.usps.com/go/TrackConfirmAction.action?tLabels=' . $tracking_number;
break;
}
return $tracking_url;
}
/**
* Show dummy value of the current merge tag.
*
* @return string
*/
public function get_dummy_preview() {
return '123456789';
}
/**
* Return merge tag schema
*
* @return array[]
*/
public function get_setting_schema() {
$tracking_data = $this->get_view_data();
$options = [];
foreach ( $tracking_data as $track_key => $data ) {
$options[] = [
'value' => $track_key,
'label' => $data,
];
}
return [
[
'id' => 'data',
'type' => 'select',
'options' => $options,
'label' => __( 'Select Shipment Tracking Field', 'wp-marketing-automations-pro' ),
"class" => 'bwfan-input-wrapper',
"placeholder" => __( 'Select', 'wp-marketing-automations-pro' ),
"required" => false,
"description" => ""
],
];
}
}
BWFAN_Merge_Tag_Loader::register( 'wc_order', 'BWFAN_WC_Jetpack_Shipment' );

View File

@@ -0,0 +1,158 @@
<?php
class BWFAN_WC_Shipment_Tracking extends BWFAN_Merge_Tag {
private static $instance = null;
public function __construct() {
$this->tag_name = 'wc_shipment_tracking';
$this->tag_description = __( 'WooCommerce Shipment Tracking details', 'wp-marketing-automations-pro' );
add_shortcode( 'bwfan_wc_shipment_tracking', array( $this, 'parse_shortcode' ) );
}
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Show the html in popup for the merge tag.
*/
public function get_view() {
$tracking_fields = $this->get_view_data();
$this->get_back_button();
?>
<div class="bwfan_mtag_wrap">
<div class="bwfan_label">
<label for="" class="bwfan-label-title"><?php esc_html_e( 'Select Shipment Tracking Field', 'wp-marketing-automations-pro' ); ?></label>
</div>
<div class="bwfan_label_val">
<select id="" class="bwfan-input-wrapper bwfan_tag_select" name="data">
<?php
foreach ( $tracking_fields as $slug => $name ) {
echo '<option value="' . esc_attr__( $slug ) . '">' . esc_attr__( $name ) . '</option>';
}
?>
</select>
</div>
</div>
<?php
if ( $this->support_fallback ) {
$this->get_fallback();
}
$this->get_preview();
$this->get_copy_button();
}
public function get_view_data() {
return array(
'tracking_number' => __( 'Tracking Number', 'wp-marketing-automations-pro' ),
'formatted_tracking_provider' => __( 'Tracking Provider', 'wp-marketing-automations-pro' ),
'formatted_tracking_link' => __( 'Tracking Link', 'wp-marketing-automations-pro' ),
'date_shipped' => __( 'Date Shipped', 'wp-marketing-automations-pro' ),
'shipping_formatted' => __( 'Formatted', 'wp-marketing-automations-pro' ),
);
}
/**
* Parse the merge tag and return its value.
*
* @param $attr
*
* @return mixed|string|void
*/
public function parse_shortcode( $attr ) {
if ( true === BWFAN_Merge_Tag_Loader::get_data( 'is_preview' ) ) {
return $this->get_dummy_preview();
}
$order_id = absint( BWFAN_Merge_Tag_Loader::get_data( 'wc_order_id' ) );
$order_id = empty( $order_id ) && ! empty( BWFAN_Merge_Tag_Loader::get_data( 'order_id' ) ) ? BWFAN_Merge_Tag_Loader::get_data( 'order_id' ) : $order_id;
if ( empty( $order_id ) ) {
return '';
}
$tracking_items = wc_shipment_tracking()->actions->get_tracking_items( $order_id, true );
if ( count( $tracking_items ) < 1 ) {
return '';
}
$date_format = get_option( 'date_format', 'Y-m-d' );
$item_key = ( isset( $attr['data'] ) && ! empty( $attr['data'] ) ) ? $attr['data'] : 'tracking_number';
if ( 'shipping_formatted' === $item_key ) {
$return_value = $this->get_formatted_shipping( $tracking_items, $date_format );
return $this->parse_shortcode_output( $return_value, $attr );
}
$return_value = 'date_shipped' === $item_key ? implode( ', ', array_map( function ( $item ) use ( $date_format ) {
return date( $date_format, $item['date_shipped'] );
}, $tracking_items ) ) : implode( ', ', array_column( $tracking_items, $item_key ) );
return $this->parse_shortcode_output( $return_value, $attr );
}
/**
* Format shipping information.
*
* @param array $tracking_items Tracking items array.
*
* @return string Formatted shipping information.
*/
public function get_formatted_shipping( $tracking_items, $date_format ) {
$formatted_shipping = array_map( function ( $item ) use ( $date_format ) {
$output = "{$item['formatted_tracking_provider']} ({$item['tracking_number']})";
$output .= "\n{$item['formatted_tracking_link']}";
$output .= "\n" . date( $date_format, $item['date_shipped'] );
return $output;
}, $tracking_items );
return implode( "\n\n", $formatted_shipping );
}
/**
* Show dummy value of the current merge tag.
*
* @return string
*/
public function get_dummy_preview() {
return '123456789';
}
/**
* Return merge tag schema
*
* @return array[]
*/
public function get_setting_schema() {
$tracking_data = $this->get_view_data();
$options = [];
foreach ( $tracking_data as $track_key => $data ) {
$options[] = [
'value' => $track_key,
'label' => $data,
];
}
return [
[
'id' => 'data',
'type' => 'select',
'options' => $options,
'label' => __( 'Select Shipment Tracking Field', 'wp-marketing-automations-pro' ),
"class" => 'bwfan-input-wrapper',
"placeholder" => __( 'Select', 'wp-marketing-automations-pro' ),
"required" => false,
"description" => ""
],
];
}
}
BWFAN_Merge_Tag_Loader::register( 'wc_order', 'BWFAN_WC_Shipment_Tracking' );

View File

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

View File

@@ -0,0 +1,28 @@
<?php
/**
* Plugin: https://wordpress.org/plugins/translatepress-multilingual/
* Class BWFAN_Pro_Compatibility_TranslatePress
*/
class BWFAN_Pro_Compatibility_TranslatePress {
private static $instance = null;
public function __construct() {
add_action( 'bwfan_before_executing_broadcast', [ $this, 'unhook_wp_mail_filter' ] );
}
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
public function unhook_wp_mail_filter() {
BWFAN_PRO_Common::remove_actions( 'wp_mail', 'TRP_Translation_Render', 'wp_mail_filter' );
}
}
BWFAN_Pro_Compatibility_TranslatePress::get_instance();

View File

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