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,71 @@
<?php
if ( ! class_exists( 'BWFAN_Compatibility_With_Aelia_CS' ) ) {
class BWFAN_Compatibility_With_Aelia_CS {
public function __construct() {
add_filter( 'bwfan_ab_cart_total_base', [ $this, 'save_base_price_in_database' ] );
add_filter( 'bwfan_abandoned_cart_restore_link', [ $this, 'add_currency_parameter_in_url' ], 99, 2 );
}
public function save_base_price_in_database( $price ) {
$price = $this->get_price_in_currency( $price, get_option( 'woocommerce_currency' ), get_woocommerce_currency() );
return wc_format_decimal( $price, wc_get_price_decimals() );
}
/**
* Basic integration with WooCommerce Currency Switcher, developed by Aelia
* (http://aelia.co). This method can be used by any 3rd party plugin to
* return prices converted to the active currency.
*
* Need a consultation? Find us on Codeable: https://aelia.co/hire_us
*
* @param double price The source price.
* @param string to_currency The target currency. If empty, the active currency
* will be taken.
* @param string from_currency The source currency. If empty, WooCommerce base
* currency will be taken.
*
* @return double The price converted from source to destination currency.
* @author Aelia <support@aelia.co>
* @link https://aelia.co
*/
public function get_price_in_currency( $price, $to_currency = null, $from_currency = null ) {
// If source currency is not specified, take the shop's base currency as a default
if ( empty( $from_currency ) ) {
$from_currency = get_option( 'woocommerce_currency' );
}
// If target currency is not specified, take the active currency as a default.
// The Currency Switcher sets this currency automatically, based on the context. Other
// plugins can also override it, based on their own custom criteria, by implementing
// a filter for the "woocommerce_currency" hook.
//
// For example, a subscription plugin may decide that the active currency is the one
// taken from a previous subscription, because it's processing a renewal, and such
// renewal should keep the original prices, in the original currency.
if ( empty( $to_currency ) ) {
$to_currency = get_woocommerce_currency();
}
// Call the currency conversion filter. Using a filter allows for loose coupling. If the
// Aelia Currency Switcher is not installed, the filter call will return the original
// amount, without any conversion being performed. Your plugin won't even need to know if
// the multi-currency plugin is installed or active
return apply_filters( 'wc_aelia_cs_convert', $price, $from_currency, $to_currency );
}
public function add_currency_parameter_in_url( $url, $token ) {
global $wpdb;
$currency = $wpdb->get_var( $wpdb->prepare( "SELECT currency FROM {$wpdb->prefix}bwfan_abandonedcarts WHERE `token` = %s", $token ) ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$url = add_query_arg( array(
'aelia_cs_currency' => $currency,
), $url );
return $url;
}
}
new BWFAN_Compatibility_With_Aelia_CS();
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* WooFunnels Checkout
* https://wordpress.org/plugins/funnel-builder/
* https://funnelkit.com/wordpress-funnel-builder/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_Aero_Checkout' ) ) {
class BWFAN_Compatibility_With_Aero_Checkout {
public function __construct() {
add_filter( 'bwfan_get_global_settings', [ $this, 'disable_abandonment' ], 99 );
}
/**
* Disable cart abandonment tracking on checkout admin builder pages
*
* @param $global_settings
*
* @return mixed
*/
public function disable_abandonment( $global_settings ) {
if ( true === WFACP_Common::is_theme_builder() ) {
$global_settings['bwfan_ab_enable'] = 0;
}
return $global_settings;
}
}
new BWFAN_Compatibility_With_Aero_Checkout();
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Bonanza
* https://wordpress.org/plugins/bonanza-woocommerce-free-gifts-lite/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_Bonanza' ) ) {
class BWFAN_Compatibility_With_Bonanza {
public function __construct() {
add_filter( 'bwfan_exclude_cart_items_to_restore', [ $this, 'exclude_gifts' ], 99, 3 );
}
/**
* Excluding restoring gift products
*
* @param $bool
* @param $key
* @param $data
*
* @return bool|mixed
*/
public function exclude_gifts( $bool, $key, $data ) {
if ( isset( $data['xlwcfg_gift_id'] ) ) {
$bool = true;
}
return $bool;
}
}
new BWFAN_Compatibility_With_Bonanza();
}

View File

@@ -0,0 +1,96 @@
<?php
/**
* Handle UTM Grabber
* By Haktan Suren
* https://wordpress.org/plugins/handl-utm-grabber/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_Handle_UTM_Grabber' ) ) {
class BWFAN_Compatibility_With_Handle_UTM_Grabber {
public function __construct() {
add_filter( 'bwfan_ab_default_checkout_nice_names', array( $this, 'bwfan_set_handle_utm_field' ), 9, 1 );
add_action( 'bwfan_ab_handle_checkout_data_externally', array( $this, 'bwfan_set_handle_utm_cookie' ), 9, 1 );
/** additional data in case of handle_utm_grabber plugin is active for abandoned cart **/
add_filter( 'bwfan_ab_change_checkout_data_for_external_use', array( $this, 'bwfan_populate_utm_grabber_data_cart' ), 999, 1 );
}
/**
* Set handle_utm_grabber key in checkout field nice name
*
* @param $fields
*
* @return mixed
*/
public function bwfan_set_handle_utm_field( $fields ) {
$fields['handle_utm_grabber'] = __( 'Handle UTM Grabber', 'wp-marketing-automations' );
return $fields;
}
/**
* Set handle UTM data in cookies on cart restore
*
* @param $checkout_data
*/
public function bwfan_set_handle_utm_cookie( $checkout_data ) {
if ( ! isset( $checkout_data['fields']['handle_utm_grabber'] ) || empty( $checkout_data['fields']['handle_utm_grabber'] ) ) {
return;
}
$handle_utm_grabber = $checkout_data['fields']['handle_utm_grabber'];
$field_array = array( 'utm_source', 'utm_campaign', 'utm_term', 'utm_medium', 'utm_content' );
foreach ( $handle_utm_grabber as $utm_key => $value ) {
if ( ! in_array( $utm_key, $field_array, true ) ) {
continue;
}
$cookie_field = $handle_utm_grabber[ $utm_key ];
$domain = isset( $_SERVER["SERVER_NAME"] ) ? $_SERVER["SERVER_NAME"] : '';
if ( strtolower( substr( $domain, 0, 4 ) ) == 'www.' ) {
$domain = substr( $domain, 4 );
}
if ( substr( $domain, 0, 1 ) != '.' && $domain != "localhost" && $domain != "handl-sandbox" ) {
$domain = '.' . $domain;
}
setcookie( $utm_key, $cookie_field, time() + 60 * 60 * 24 * 30, '/', $domain );
}
}
/**
* passing grabber utm data to cart abandoned
*/
public function bwfan_populate_utm_grabber_data_cart( $data ) {
$utm_keys = [
'utm_campaign',
'utm_source',
'utm_term',
'utm_medium',
'utm_content',
'gclid',
'handl_original_ref',
'handl_device',
'handl_browser',
'handl_landing_page',
'handl_ip',
'handl_ref',
'handl_url',
];
$handle_utm_grabber_data = array();
foreach ( $utm_keys as $key ) {
if ( ! isset( $_COOKIE[ $key ] ) || empty( $_COOKIE[ $key ] ) ) {
continue;
}
$handle_utm_grabber_data[ $key ] = $_COOKIE[ $key ];
}
$data['handle_utm_grabber'] = $handle_utm_grabber_data;
return apply_filters( 'bwfan_external_handl_utm_grabber_data', $data );
}
}
new BWFAN_Compatibility_With_Handle_UTM_Grabber();
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* UTM Leads Tracker - XLPlugins
* https://wordpress.org/plugins/utm-leads-tracker-lite/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_UTM_Leads_Tracker' ) ) {
class BWFAN_Compatibility_With_UTM_Leads_Tracker {
public function __construct() {
add_filter( 'bwfan_ab_change_checkout_data_for_external_use', array( $this, 'bwfan_populate_utm_lead_data_cart' ), 99 );
add_action( 'bwfan_ab_handle_checkout_data_externally', array( $this, 'bwfan_set_utm_lead_cookie' ), 9 );
}
/**
* Set XL UTM data in cookies on cart restore
*
* @param $checkout_data
*/
public function bwfan_set_utm_lead_cookie( $checkout_data ) {
if ( ! isset( $checkout_data['xlutm_data'] ) || empty( $checkout_data['xlutm_data'] ) ) {
return;
}
$xlutm_data = $checkout_data['xlutm_data'];
$cookie_val = json_encode( $xlutm_data );
$secure = is_ssl();
setcookie( 'xlutm_params_utm', $cookie_val, time() + YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN, $secure, true );
}
/**
* Append UTM data from cookies to the cart
*
* @param $abandoned_data
*
* @return mixed
*/
public function bwfan_populate_utm_lead_data_cart( $abandoned_data ) {
if ( ! isset( $_COOKIE['xlutm_params_utm'] ) ) {
return $abandoned_data;
}
$abandoned_data['xlutm_data'] = json_decode( stripslashes( $_COOKIE['xlutm_params_utm'] ), true );
return $abandoned_data;
}
}
new BWFAN_Compatibility_With_UTM_Leads_Tracker();
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* Multi-currency for WooCommerce
* By VillaTheme
* https://wordpress.org/plugins/woo-multi-currency/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_WC_Multi_Currency_Villatheme' ) ) {
class BWFAN_Compatibility_With_WC_Multi_Currency_Villatheme {
public function __construct() {
add_filter( 'bwfan_ab_cart_total_base', [ $this, 'save_base_price_in_database' ] );
add_filter( 'bwfan_abandoned_cart_restore_link', [ $this, 'add_currency_parameter_in_url' ], 99, 2 );
}
/**
* Modify the cart total price
*
* @param $price
*
* @return float|string
*/
public function save_base_price_in_database( $price ) {
$setting = false;
if ( class_exists( 'WOOMULTI_CURRENCY_F_Data' ) ) {
$setting = new WOOMULTI_CURRENCY_F_Data();
}
if ( class_exists( 'WOOMULTI_CURRENCY_Data' ) ) {
$setting = new WOOMULTI_CURRENCY_Data();
}
if ( false === $setting ) {
return wc_format_decimal( $price, wc_get_price_decimals() );
}
$selected_currencies = $setting->get_list_currencies();
$current_currency = $setting->get_current_currency();
if ( isset( $selected_currencies[ $current_currency ] ) ) {
$price = $price / $selected_currencies[ $current_currency ]['rate'];
}
return wc_format_decimal( $price, wc_get_price_decimals() );
}
/**
* Append currency in the restore link
*
* @param $url
* @param $token
*
* @return string
*/
public function add_currency_parameter_in_url( $url, $token ) {
global $wpdb;
$currency = $wpdb->get_var( $wpdb->prepare( "SELECT `currency` FROM {$wpdb->prefix}bwfan_abandonedcarts WHERE `token` = %s", $token ) ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
if ( empty( $currency ) ) {
return $url;
}
$url = add_query_arg( array(
'wmc-currency' => $currency,
), $url );
return $url;
}
}
new BWFAN_Compatibility_With_WC_Multi_Currency_Villatheme();
}

View File

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

View File

@@ -0,0 +1,78 @@
<?php
/**
* Class BWFAN_Compatibilities
* Loads all the compatibilities files we have in Autonami against plugins
*/
class BWFAN_Compatibilities {
/**
* Load all compatibilities if valid
*
* @return void
*/
public static function load_all_compatibilities() {
$compatibilities = [
// checkout
'checkout/class-bwfan-compatibility-with-aelia-cs.php' => class_exists( 'Aelia\WC\CurrencySwitcher\WC_Aelia_CurrencySwitcher' ),
'checkout/class-bwfan-compatibility-with-aerocheckout.php' => ( class_exists( 'WFACP_Common' ) && method_exists( 'WFACP_Common', 'is_theme_builder' ) ),
'checkout/class-bwfan-compatibility-with-bonanza.php' => class_exists( 'XLWCFG_Core' ),
'checkout/class-bwfan-compatibility-with-handle-utm-grabber.php' => ( function_exists( 'bwfan_is_utm_grabber_active' ) && bwfan_is_utm_grabber_active() ),
'checkout/class-bwfan-compatibility-with-utm-leads-tracker.php' => class_exists( 'Xlutm_Core' ),
'checkout/class-bwfan-compatibility-with-wc-multi-currency-villatheme.php' => ( defined( 'WOOMULTI_CURRENCY_VERSION' ) || defined( 'WOOMULTI_CURRENCY_F_VERSION' ) ),
// email
'email/class-bwfan-compatibility-with-elastic-email-sender.php' => class_exists( 'eemail' ),
'email/class-bwfan-compatibility-with-wp-ses.php' => isset( $GLOBALS['wposes_meta'] ),
'email/class-bwfan-compatibility-with-wp-smtp.php' => defined( 'WPMS_PLUGIN_VER' ),
//plugins
'plugins/class-bwfan-compatibility-with-mailpoet.php' => class_exists( 'MailPoet\Config\Initializer' ),
'plugins/class-bwfan-compatibility-with-uni-cpo.php' => defined( 'UNI_CPO_PLUGIN_FILE' ),
'plugins/class-bwfan-compatibility-with-wc-preorder.php' => class_exists( 'WC_Pre_Orders' ),
'plugins/class-bwfan-compatibility-with-wc-product-bundle.php' => class_exists( 'WC_Bundles' ),
'plugins/class-bwfan-compatibility-with-weglot.php' => function_exists( 'bwfan_is_weglot_active' ) && bwfan_is_weglot_active(),
'plugins/class-bwfan-compatibility-with-wpml.php' => defined( 'ICL_SITEPRESS_VERSION' ),
'plugins/class-bwfan-compatibility-woocommerce.php' => function_exists( 'bwfan_is_woocommerce_active' ) && bwfan_is_woocommerce_active(),
'plugins/class-bwfan-wc-product-addon.php' => defined( 'PEWC_PLUGIN_VERSION' ),
'plugins/class-bwfan-compatibility-with-gtranslate.php' => function_exists( 'bwfan_is_gtranslate_active' ) && bwfan_is_gtranslate_active(),
//rest
'rest/class-bwfan-compability-with-permatters.php' => defined( 'PERFMATTERS_VERSION' ),
'rest/class-bwfan-compatibilities-with-force-login.php' => function_exists( 'v_forcelogin_rest_access' ),
'rest/class-bwfan-compatibilities-with-logged-in-only.php' => function_exists( 'logged_in_only_rest_api' ),
'rest/class-bwfan-compatibilities-with-password-protected.php' => class_exists( 'Password_Protected' ),
'rest/class-bwfan-compatibility-with-breeze-cache.php' => defined( 'BREEZE_VERSION' ),
'rest/class-bwfan-compatibility-with-clearfy.php' => class_exists( 'Clearfy_Plugin' ),
'rest/class-bwfan-compatibility-with-sg-cache.php' => function_exists( 'sg_cachepress_purge_cache' ),
'rest/class-bwfan-compatibility-with-wp-rest-authenticate.php' => function_exists( 'mo_api_auth_activate_miniorange_api_authentication' ),
'rest/class-bwfan-compatibility-with-wp-rocket.php' => function_exists( 'rocket_clean_home' ),
'rest/class-bwfan-compatibility-with-image-optimisation.php' => defined( 'IMAGE_OPTIMIZATION_VERSION' ),
'rest/class-bwfan-compatibility-with-atom-stock-manager.php' => defined( 'ATUM_VERSION' ),
'rest/class-bwfan-compatibility-with-security-by-cleantalk.php' => defined( 'SPBC_VERSION' ),
// other files
'class-bwfan-compatibility-with-wp-oauth.php' => ( defined( 'WPOAUTH_VERSION' ) && class_exists( 'WO_SERVER' ) ),
];
self::add_files( array_filter( $compatibilities ) );
}
/**
* Include valid compatibility files
*
* @param array $paths
*/
public static function add_files( $paths ) {
/** Compatibilities folder */
$dir = plugin_dir_path( BWFAN_PLUGIN_FILE ) . 'compatibilities';
try {
foreach ( $paths as $file => $condition ) {
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( 'plugins_loaded', array( 'BWFAN_Compatibilities', 'load_all_compatibilities' ), 999 );

View File

@@ -0,0 +1,30 @@
<?php
/**
* WP OAuth Server
* https://wordpress.org/plugins/oauth2-provider/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_WP_Oauth' ) ) {
class BWFAN_Compatibility_With_WP_Oauth {
public function __construct() {
add_filter( 'rest_jsonp_enabled', array( $this, 'bwfan_allow_rest_apis_with_wp_oauth' ) );
}
/**
* @param $status
*
* @return mixed
*/
public function bwfan_allow_rest_apis_with_wp_oauth( $status ) {
$rest_route = $GLOBALS['wp']->query_vars['rest_route'];
if ( strpos( $rest_route, 'autonami' ) !== false || strpos( $rest_route, 'woofunnel' ) !== false ) {
BWFAN_Common::remove_actions( 'rest_authentication_errors', 'WO_Server', 'wpoauth_block_unauthenticated_rest_requests' );
}
return $status;
}
}
new BWFAN_Compatibility_With_WP_Oauth();
}

View File

@@ -0,0 +1,46 @@
<?php
/**
* Elastic Email Sender
* https://wordpress.org/plugins/elastic-email-sender/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_Elastic_Email' ) ) {
class BWFAN_Compatibility_With_Elastic_Email {
public function __construct() {
add_action( 'bwfan_before_send_email', array( $this, 'remove_elastic_email_settings' ) );
}
/**
* Disable elastic email settings
*
* @return void
*/
public static function remove_elastic_email_settings( $data ) {
/** Set mime type by default text/html **/
if ( 'texthtml' === get_option( 'ee_mimetype' ) ) {
return;
}
add_filter( 'pre_option_ee_mimetype', function ( $value ) {
return 'texthtml';
}, PHP_INT_MAX );
/** Set From email **/
add_filter( 'pre_option_ee_config_from_name', function ( $return ) use ( $data ) {
$from_email = isset( $data['senders_email'] ) ? $data['senders_email'] : $data['from_email'];
return ! empty( $from_email ) ? $from_email : $return;
}, PHP_INT_MAX );
/** Set From email **/
add_filter( 'pre_option_ee_config_from_email', function ( $return ) use ( $data ) {
$from_name = isset( $data['senders_name'] ) ? $data['senders_name'] : $data['from_name'];
return ! empty( $from_name ) ? $from_name : $return;
}, PHP_INT_MAX );
}
}
new BWFAN_Compatibility_With_Elastic_Email();
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* WP Offload SES
* https://wordpress.org/plugins/wp-ses/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_WP_SES' ) ) {
class BWFAN_Compatibility_With_WP_SES {
public function __construct() {
add_action( 'bwfan_before_send_email', array( $this, 'disable_open_click_tracking' ) );
}
/**
* Disable open click tracking to improve performance
*/
public static function disable_open_click_tracking( $data ) {
/** WP Offload SES option settings */
$wp_ses_settings = get_option( 'wposes_settings' );
if ( empty( $wp_ses_settings ) || ! is_array( $wp_ses_settings ) ) {
return;
}
add_filter( 'pre_option_wposes_settings', function ( $value_return ) use ( $wp_ses_settings ) {
$wp_ses_settings['enable-click-tracking'] = '0';
$wp_ses_settings['enable-open-tracking'] = '0';
return $wp_ses_settings;
}, PHP_INT_MAX );
}
}
new BWFAN_Compatibility_With_WP_SES();
}

View File

@@ -0,0 +1,22 @@
<?php
/**
* WP Mail SMTP
* https://wordpress.org/plugins/wp-mail-smtp/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_WP_SMTP' ) ) {
class BWFAN_Compatibility_With_WP_SMTP {
/**
* checking for smart routing/Backup connection enabled
*
* @return bool
*/
public static function has_multiple_connections() {
if ( ! class_exists( 'WPMailSMTP\Options' ) ) {
return false;
}
return ( WPMailSMTP\Options::init()->get( 'smart_routing', 'enabled' ) || WPMailSMTP\Options::init()->get( 'backup_connection', 'connection_id' ) );
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,268 @@
<?php
/**
* WordPress gTranslate Plugin Compatibility
* https://gtranslate.io/
*
* @package BWFAN
* @since 1.0.0
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_GTRANSLATE' ) ) {
/**
* Class BWFAN_Compatibility_With_GTRANSLATE
*
* Handles compatibility with the GTranslate WordPress plugin
*/
class BWFAN_Compatibility_With_GTRANSLATE {
/**
* Constructor
*/
public function __construct() {
add_filter( 'bwfan_enable_language_settings', array( $this, 'bwfan_add_gtranslate_language_settings' ) );
}
/**
* Get GTranslate language code from various sources
*
* @return string Language code
*/
public static function get_gtranslate_language() {
// Check if googtrans cookie is set
if ( isset( $_COOKIE['googtrans'] ) ) {
$googtrans = bwf_clean( $_COOKIE['googtrans'] );
$googtrans = explode( '/', $googtrans );
return is_array( $googtrans ) ? end( $googtrans ) : '';
}
// Check if HTTP_X_GT_LANG header is set
if ( isset( $_SERVER['HTTP_X_GT_LANG'] ) && ! empty( $_SERVER['HTTP_X_GT_LANG'] ) ) {
return bwf_clean( $_SERVER['HTTP_X_GT_LANG'] );
}
// Check domain mapping if HTTP_HOST is set
if ( isset( $_SERVER['HTTP_HOST'] ) && ! empty( $_SERVER['HTTP_HOST'] ) ) {
$current_domain = bwf_clean( $_SERVER['HTTP_HOST'] );
$gtranslate = get_option( 'GTranslate' );
$domain = wp_parse_url( home_url(), PHP_URL_HOST );
if ( $current_domain === $domain ) {
return isset( $gtranslate['default_language'] ) ? $gtranslate['default_language'] : 'en';
}
if ( isset( $gtranslate['custom_domains'] ) && ! empty( $gtranslate['custom_domains'] ) ) {
$custom_domains_data = $gtranslate['custom_domains_data'];
if ( is_string( $custom_domains_data ) && ! empty( $custom_domains_data ) ) {
$decoded_data = json_decode( stripslashes( $custom_domains_data ), true );
if ( is_array( $decoded_data ) ) {
$custom_domains_data = $decoded_data;
}
}
if ( is_array( $custom_domains_data ) && ! empty( $custom_domains_data ) ) {
$found_lang = array_search( $current_domain, $custom_domains_data, true );
if ( ! empty( $found_lang ) ) {
return $found_lang;
}
}
}
if ( isset( $gtranslate['enterprise_version'] ) && $gtranslate['enterprise_version'] ) {
$parts = explode( '.', $current_domain );
if ( count( $parts ) > 2 && ! empty( $parts[0] ) ) {
$potential_lang = trim( $parts[0] );
// Validate potential language code format
if ( ! empty( $potential_lang ) && preg_match( '/^[a-z]{2}(-[A-Z]{2})?$/', $potential_lang ) ) {
// Check if the subdomain is a valid language code
$enabled_languages = [];
if ( isset( $gtranslate['fincl_langs'] ) && ! empty( $gtranslate['fincl_langs'] ) ) {
$enabled_languages = $gtranslate['fincl_langs'];
} elseif ( isset( $gtranslate['incl_langs'] ) && ! empty( $gtranslate['incl_langs'] ) ) {
$enabled_languages = $gtranslate['incl_langs'];
}
if ( ! empty( $enabled_languages ) && in_array( $potential_lang, $enabled_languages, true ) ) {
return $potential_lang;
}
}
}
}
}
return '';
}
/**
* Add GTranslate languages to FunnelKit Automation language settings
*
* @param array $settings Existing language settings array
*
* @return array Modified settings array with GTranslate languages added
*/
public function bwfan_add_gtranslate_language_settings( $settings ) {
// Ensure settings is an array
if ( ! is_array( $settings ) ) {
$settings = [];
}
$gtranslate_options = get_option( 'GTranslate' );
if ( empty( $gtranslate_options ) || ! isset( $gtranslate_options['incl_langs'] ) || ! is_array( $gtranslate_options['incl_langs'] ) ) {
return $settings;
}
$gtranslate_language_codes = $gtranslate_options['incl_langs'];
$gtranslate_languages = [];
foreach ( $gtranslate_language_codes as $code ) {
if ( ! empty( $code ) && is_string( $code ) ) {
$gtranslate_languages[ $code ] = $this->get_language_display_name( $code );
}
}
if ( ! empty( $gtranslate_languages ) ) {
$settings['lang_options'] = array_merge( isset( $settings['lang_options'] ) ? $settings['lang_options'] : [], $gtranslate_languages );
$settings['enable_lang'] = 1;
}
return $settings;
}
/**
* Convert a URL to its language-specific domain equivalent
*
* @param string $url Original URL to be translated
* @param string $lang Language code to translate the URL to
*
* @return string URL with the appropriate language-specific domain or path
*/
public static function get_translated_domain_url( $url, $lang ) {
// Validate input parameters
if ( empty( $url ) || empty( $lang ) || ! is_string( $url ) || ! is_string( $lang ) ) {
return $url;
}
$gtranslate_settings = get_option( 'GTranslate' );
if ( empty( $gtranslate_settings ) || ! is_array( $gtranslate_settings ) ) {
return $url;
}
// Parse the URL
$url_parts = wp_parse_url( $url );
if ( false === $url_parts || ! isset( $url_parts['host'] ) ) {
return $url;
}
$base_domain = $url_parts['host'];
$scheme = isset( $url_parts['scheme'] ) ? $url_parts['scheme'] : 'https';
$path = isset( $url_parts['path'] ) ? $url_parts['path'] : '';
$query = isset( $url_parts['query'] ) ? '?' . $url_parts['query'] : '';
$fragment = isset( $url_parts['fragment'] ) ? '#' . $url_parts['fragment'] : '';
// Determine URL structure based on GTranslate version
$url_structure = 'none';
if ( isset( $gtranslate_settings['pro_version'] ) && ! empty( $gtranslate_settings['pro_version'] ) ) {
$url_structure = 'sub_directory';
} elseif ( isset( $gtranslate_settings['enterprise_version'] ) && ! empty( $gtranslate_settings['enterprise_version'] ) ) {
$url_structure = 'sub_domain';
}
// Handle custom domains first (highest priority)
if ( isset( $gtranslate_settings['custom_domains'] ) && ! empty( $gtranslate_settings['custom_domains'] ) ) {
$custom_domains_data = $gtranslate_settings['custom_domains_data'];
if ( is_string( $custom_domains_data ) && ! empty( $custom_domains_data ) ) {
$decoded_data = json_decode( stripslashes( $custom_domains_data ), true );
if ( is_array( $decoded_data ) ) {
$custom_domains_data = $decoded_data;
}
}
// Check if language exists in custom domains data
if ( is_array( $custom_domains_data ) && ! empty( $custom_domains_data ) && isset( $custom_domains_data[ $lang ] ) && ! empty( $custom_domains_data[ $lang ] ) ) {
$new_domain = $custom_domains_data[ $lang ];
$url = $scheme . '://' . $new_domain . $path . $query . $fragment;
}
}
// Handle URL structure based on version
if ( 'sub_domain' === $url_structure ) {
// Enterprise version: lang.domain.com/path
$url = $scheme . '://' . $lang . '.' . $base_domain . $path . $query . $fragment;
} elseif ( 'sub_directory' === $url_structure ) {
// Pro version: domain.com/lang/path
$url = $scheme . '://' . $base_domain . '/' . $lang . $path . $query . $fragment;
}
return $url;
}
/**
* Get language display name using WordPress built-in functions
*
* @param string $lang_code Language code
*
* @return string Language display name
*/
private function get_language_display_name( $lang_code ) {
// Validate input - ensure it's a non-empty string
if ( ! is_string( $lang_code ) || empty( trim( $lang_code ) ) ) {
// Return a safe default for invalid input
return 'UNKNOWN';
}
// Try PHP native function first (PHP 8.1+) - faster and more reliable
if ( function_exists( 'locale_get_display_language' ) ) {
$display_name = locale_get_display_language( $lang_code, 'en' );
if ( ! empty( $display_name ) && $display_name !== $lang_code ) {
return $display_name;
}
}
// Fallback to WordPress method for older PHP versions or edge cases
$translations = $this->wp_get_available_translations();
$wp_lang_code = str_replace( '-', '_', $lang_code );
if ( isset( $translations[ $wp_lang_code ]['native_name'] ) ) {
return $translations[ $wp_lang_code ]['native_name'];
}
// Also try the original format in case it matches
if ( isset( $translations[ $lang_code ]['native_name'] ) ) {
return $translations[ $lang_code ]['native_name'];
}
if ( strlen( $lang_code ) === 2 && strpos( $lang_code, '_' ) === false && strpos( $lang_code, '-' ) === false ) {
$with_country = $lang_code . '_' . strtoupper( $lang_code );
if ( isset( $translations[ $with_country ]['native_name'] ) ) {
return $translations[ $with_country ]['native_name'];
}
}
// return uppercase language code if translation not found
return strtoupper( $lang_code );
}
/**
* Wrap wp_get_available_translations
*
* @return array Available translations array
*/
private function wp_get_available_translations() {
if ( ! function_exists( 'wp_get_available_translations' ) ) {
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
}
// WordPress may fail silently or return an empty array if offline, and will cache the result otherwise.
$translations = wp_get_available_translations();
// Ensure we return an array even if the function fails
return is_array( $translations ) ? $translations : [];
}
}
new BWFAN_Compatibility_With_GTRANSLATE();
}

View File

@@ -0,0 +1,17 @@
<?php
/**
* MailPoet emails and newsletters in WordPress
* https://wordpress.org/plugins/mailpoet/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_MailPoet' ) ) {
class BWFAN_Compatibility_With_MailPoet {
public function __construct() {
if ( ! empty( WooFunnels_AS_DS::$unique ) || true === BWFAN_Common::$change_data_strore ) {
BWFAN_Common::remove_actions( 'init', 'MailPoet\Config\Initializer', 'initialize' );
}
}
}
new BWFAN_Compatibility_With_MailPoet();
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* Uni CPO Plugin Compatibility
* https://wordpress.org/plugins/uni-woo-custom-product-options/
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
if ( ! class_exists( 'BWFAN_Compatibility_With_Uni_Cpo' ) ) {
class BWFAN_Compatibility_With_Uni_Cpo {
public function __construct() {
add_filter( 'bwfan_abandoned_modify_cart_item_data', [ $this, 'bwfan_uni_cpo_item_data' ] );
}
/**
* @param $item_data
*
* @return mixed
*/
public function bwfan_uni_cpo_item_data( $item_data ) {
if ( ! isset( $item_data['_cpo_data'] ) ) {
return $item_data;
}
$cpo_data = $item_data['_cpo_data'];
unset( $item_data['_cpo_data'] );
$item_data['cpo_data'] = $cpo_data;
return $item_data;
}
}
new BWFAN_Compatibility_With_Uni_Cpo();
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* WooCommerce Pre-Orders
* https://woocommerce.com/products/woocommerce-pre-orders/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_WC_PreOrders' ) ) {
class BWFAN_Compatibility_With_WC_PreOrders {
public function __construct() {
add_filter( 'woocommerce_order_is_paid_statuses', array( $this, 'append_order_status' ) );
}
/**
* passing wc-pre-order status as paid order
*
* @param $status
*
* @return mixed
*/
public function append_order_status( $status ) {
$status[] = 'wc-pre-ordered';
return $status;
}
}
new BWFAN_Compatibility_With_WC_PreOrders();
}

View File

@@ -0,0 +1,46 @@
<?php
/**
* WC Product Bundle
* https://woocommerce.com/products/product-bundles/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_WC_Product_Bundle' ) ) {
class BWFAN_Compatibility_With_WC_Product_Bundle {
public function __construct() {
add_filter( 'bwfan_abandoned_cart_items_visibility', array( $this, 'bwfan_modify_abandoned_cart_items' ), 10, 1 );
}
/**
* @return bool
*/
public function bwfan_modify_abandoned_cart_items( $cart ) {
foreach ( $cart as $cart_item_key => $item ) {
if ( ! function_exists( 'wc_pb_maybe_is_bundled_cart_item' ) || ! wc_pb_maybe_is_bundled_cart_item( $item ) ) {
continue;
}
$bundled_item_id = $item['bundled_item_id'];
if ( empty( $bundled_item_id ) ) {
continue;
}
$bundled_item_data = new WC_Bundled_Item_Data( $bundled_item_id );
if ( ! $bundled_item_data instanceof WC_Bundled_Item_Data ) {
continue;
}
$bundled_cart_visibility = $bundled_item_data->get_meta( 'cart_visibility' );
if ( 'hidden' !== $bundled_cart_visibility ) {
continue;
}
unset( $cart[ $cart_item_key ] );
}
return $cart;
}
}
new BWFAN_Compatibility_With_WC_Product_Bundle();
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* Weglot Translate Translate your WordPress website and go multilingual
* https://weglot.com/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_Weglot' ) ) {
class BWFAN_Compatibility_With_Weglot {
public function __construct() {
if ( false === strpos( $_SERVER['REQUEST_URI'], BWFAN_API_NAMESPACE . '/automation/' ) ) {
return;
}
/** Disable weglot translation on automation page */
add_filter( 'weglot_active_translation_before_process', '__return_false' );
}
}
new BWFAN_Compatibility_With_Weglot();
}

View File

@@ -0,0 +1,97 @@
<?php
/**
* WordPress Multilingual Plugin
* https://wpml.org/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_WPML' ) ) {
class BWFAN_Compatibility_With_WPML {
public function __construct() {
add_action( 'bwfan_email_setup_locale', [ $this, 'translate_email_body' ] );
}
/**
* setup locale for email with translation plugins
*
* @param $lang
*/
public function translate_email_body( $lang ) {
if ( empty( $lang ) ) {
return;
}
global $woocommerce_wpml;
if ( ! class_exists( 'woocommerce_wpml' ) || ! $woocommerce_wpml instanceof woocommerce_wpml ) {
return;
}
$woocommerce_wpml->emails->change_email_language( $lang );
}
/**
* Get translated term IDs dynamically based on the context
*
* @param array $term_ids The original term IDs
* @param string $taxonomy_name The taxonomy name
* @param array $automation_data Automation context data
*
* @return array An array of translated term IDs
*/
public static function get_translated_term_ids( $term_ids, $taxonomy_name, $automation_data = [] ) {
if ( empty( $term_ids ) ) {
return $term_ids;
}
$language_code = self::detect_language_from_sources( $automation_data );
if ( empty( $language_code ) ) {
return $term_ids;
}
$all_translated_ids = [];
foreach ( $term_ids as $term_id ) {
$all_translated_ids[] = $term_id;
$translated_id = apply_filters( 'wpml_object_id', $term_id, $taxonomy_name, false, $language_code );
if ( $translated_id ) {
$all_translated_ids[] = $translated_id;
}
}
$ids = array_unique( $all_translated_ids );
sort( $ids );
return $ids;
}
/**
* Detect language from various possible sources
*
* @param $automation_data
*
* @return array|mixed|string
*/
private static function detect_language_from_sources( $automation_data ) {
if ( isset( $automation_data['global']['language'] ) ) {
return $automation_data['global']['language'];
}
global $sitepress;
$default_language = $sitepress->get_default_language();
$sitepress->get_current_language();
if ( ! isset( $automation_data['global']['order_id'] ) ) {
return $default_language;
}
$order = $automation_data['global']['order_id'];
$order = wc_get_order( $order );
if ( ! $order instanceof WC_Order ) {
return $default_language;
}
$order_language = $order->get_meta( 'wpml_language' );
return ! empty( $order_language ) ? $order_language : $default_language;
}
}
new BWFAN_Compatibility_With_WPML();
}

View File

@@ -0,0 +1,757 @@
<?php
/**
* WooCommerce Plugin Compatibility
*
* This source file is subject to the GNU General Public License v3.0
* that is bundled with this package in the file license.txt.
* It is also available through the world-wide-web at this URL:
* http://www.gnu.org/licenses/gpl-3.0.html
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@skyverge.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade the plugin to newer
* versions in the future. If you wish to customize the plugin for your
* needs please refer to http://www.skyverge.com
*
* @author SkyVerge
* @copyright Copyright (c) 2013, SkyVerge, Inc.
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
if ( ! class_exists( 'BWFAN_Woocommerce_Compatibility' ) ) :
/**
* WooCommerce Compatibility Utility Class
*
* The unfortunate purpose of this class is to provide a single point of
* compatibility functions for dealing with supporting multiple versions
* of WooCommerce.
*
* The recommended procedure is to rename this file/class, replacing "my plugin"
* with the particular plugin name, so as to avoid clashes between plugins.
* Over time we expect to remove methods from this class, using the current
* ones directly, as support for older versions of WooCommerce is dropped.
*
* Current Compatibility: 2.0.x - 2.1
*
* @version 1.0
*/
class BWFAN_Woocommerce_Compatibility {
/**
* Compatibility function for outputting a woocommerce attribute label
*
* @param string $label the label to display
*
* @return string the label to display
* @since 1.0
*
*/
public static function wc_attribute_label( $label ) {
if ( self::is_wc_version_gte_2_1() ) {
return wc_attribute_label( $label );
}
}
/**
* @param $name
*
* @return string
*/
public static function wc_attribute_taxonomy_name( $name ) {
if ( self::is_wc_version_gte_2_1() ) {
return wc_attribute_taxonomy_name( $name );
}
}
/**
* @return array
*/
public static function wc_get_attribute_taxonomies() {
if ( self::is_wc_version_gte_2_1() ) {
return wc_get_attribute_taxonomies();
}
}
/**
* @return string
*/
public static function wc_placeholder_img_src() {
if ( self::is_wc_version_gte_2_1() ) {
return wc_placeholder_img_src();
}
}
/**
* @param WC_Product $product
*
* @return string
*/
public static function woocommerce_get_formatted_product_name( $product ) {
if ( self::is_wc_version_gte_2_1() ) {
return $product->get_formatted_name();
}
}
/**
* @param $order
* @param $item
*
* @return bool|string|void|WC_Product
*/
public static function get_product_from_item( $order, $item ) {
if ( ! $item instanceof WC_Order_Item_Product ) {
return '';
}
if ( self::is_wc_version_gte_3_0() ) {
return $item->get_product();
}
}
/**
* @param WC_Product $product
*
* @return mixed|string|void
*/
public static function get_short_description( $product ) {
if ( false === $product ) {
return '';
}
if ( self::is_wc_version_gte_3_0() ) {
return apply_filters( 'woocommerce_short_description', $product->get_short_description() );
}
}
/**
* @param WC_Order $order
* @param WC_Order_Item $item
*
* @return mixed
*/
public static function get_productname_from_item( $order, $item ) {
if ( self::is_wc_version_gte_3_0() ) {
return $item->get_name();
}
}
/**
* @param WC_Order $order
* @param WC_Order_Item $item
*
* @return mixed
*/
public static function get_qty_from_item( $order, $item ) {
if ( self::is_wc_version_gte_3_0() ) {
return $item->get_quantity();
}
}
/**
* @param WC_Order $order
* @param $item
*
* @return string|void
*/
public static function get_display_item_meta( $order, $item ) {
if ( self::is_wc_version_gte_3_0() ) {
return wc_display_item_meta( $item );
}
}
/**
* @param WC_Order $order
* @param $item
*
* @return string|void
*/
public static function get_display_item_downloads( $order, $item ) {
if ( self::is_wc_version_gte_3_0() ) {
return wc_display_item_downloads( $item );
}
}
/**
* @param WC_Product $product
*
* @return mixed|string
*/
public static function get_purchase_note( $product ) {
if ( self::is_wc_version_gte_3_0() ) {
return $product ? $product->get_purchase_note() : '';
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_payment_gateway_from_order( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_payment_method();
}
}
/**
* @param WC_Order $order
* @param WC_Order_Item $item
*
* @return mixed
*/
public static function get_item_subtotal( $order, $item ) {
if ( self::is_wc_version_gte_3_0() ) {
return $item->get_subtotal();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_shipping_country_from_order( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_shipping_country();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_billing_country_from_order( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_billing_country();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_billing_email( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_billing_email();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_order_id( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_id();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_order_billing_1( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_billing_address_1();
}
}
/**
* @param WC_Order $order
* @param $key
*
* @return mixed
*/
public static function get_order_data( $order, $key ) {
if ( ! $order instanceof WC_Order ) {
return '';
}
if ( method_exists( $order, 'get_' . $key ) ) {
return call_user_func( array( $order, 'get_' . $key ) );
}
if ( method_exists( $order, 'get' . $key ) ) {
return call_user_func( array( $order, 'get' . $key ) );
}
$data = $order->get_meta( $key );
if ( ! empty( $data ) ) {
return $data;
}
return $order->get_meta( '_' . $key );
}
/**
* get order meta: currently done via get_post_meta, will change later to WC func
*
* @param $order_id
* @param $key
*
* @return mixed
*/
public static function get_order_meta( $order_id, $key ) {
$order = wc_get_order( $order_id );
if ( ! $order instanceof WC_Order ) {
return '';
}
return $order->get_meta( $key );
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_billing_first_name( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_billing_first_name();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_billing_last_name( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_billing_last_name();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_order_status( $order ) {
$status = $order->get_status();
if ( strpos( $status, 'wc-' ) === false ) {
return 'wc-' . $status;
} else {
return $status;
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_order_billing_2( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_billing_address_2();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_order_shipping_1( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_shipping_address_1();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_order_shipping_total( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_shipping_total();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_order_shipping_2( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_shipping_address_2();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_order_billing_city( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_billing_city();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_order_billing_state( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_billing_state();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_order_billing_postcode( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_billing_postcode();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_order_shipping_city( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_shipping_city();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_order_shipping_state( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_shipping_state();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_order_shipping_postcode( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_shipping_postcode();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_order_date( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_date_created();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_payment_method( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_payment_method_title();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_customer_ip_address( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_customer_ip_address();
}
}
/**
* @param WC_Order $order
*
* @return mixed
*/
public static function get_customer_note( $order ) {
if ( self::is_wc_version_gte_3_0() ) {
return $order->get_customer_note();
}
}
/**
* Compatibility function to add and store a notice
*
* @param string $message The text to display in the notice.
* @param string $notice_type The singular name of the notice type - either error, success or notice. [optional]
*
* @since 1.0
*
*/
public static function wc_add_notice( $message, $notice_type = 'success' ) {
if ( self::is_wc_version_gte_2_1() ) {
wc_add_notice( $message, $notice_type );
}
}
/**
* Prints messages and errors which are stored in the session, then clears them.
*
* @since 1.0
*/
public static function wc_print_notices() {
if ( self::is_wc_version_gte_2_1() ) {
wc_print_notices();
}
}
/**
* Compatibility function to queue some JavaScript code to be output in the footer.
*
* @param string $code javascript
*
* @since 1.0
*
*/
public static function wc_enqueue_js( $code ) {
if ( self::is_wc_version_gte_2_1() ) {
wc_enqueue_js( $code );
}
}
/**
* Sets WooCommerce messages
*
* @since 1.0
*/
public static function set_messages() {
global $woocommerce;
if ( false === self::is_wc_version_gte_2_1() ) {
$woocommerce->set_messages();
}
}
/**
* Returns a new instance of the woocommerce logger
*
* @return object logger
* @since 1.0
*/
public static function new_wc_logger() {
if ( self::is_wc_version_gte_2_1() ) {
return new WC_Logger();
}
}
/**
* Format decimal numbers ready for DB storage
*
* Sanitize, remove locale formatting, and optionally round + trim off zeros
*
* @param float|string $number Expects either a float or a string with a decimal separator only (no thousands)
* @param mixed $dp number of decimal points to use, blank to use woocommerce_price_num_decimals, or false to avoid all rounding.
* @param boolean $trim_zeros from end of string
*
* @return string
* @since 1.0
*
*/
public static function wc_format_decimal( $number, $dp = false, $trim_zeros = false ) {
if ( self::is_wc_version_gte_2_1() ) {
return wc_format_decimal( $number, $dp, $trim_zeros );
}
}
/**
* Get the count of notices added, either for all notices (default) or for one particular notice type specified
* by $notice_type.
*
* @param string $notice_type The name of the notice type - either error, success or notice. [optional]
*
* @return int the notice count
* @since 1.0
*
*/
public static function wc_notice_count( $notice_type = '' ) {
if ( self::is_wc_version_gte_2_1() ) {
return wc_notice_count( $notice_type );
}
}
/**
* Compatibility function to use the new WC_Admin_Meta_Boxes class for the save_errors() function
*
* @since 1.0-1
*/
public static function save_errors() {
if ( self::is_wc_version_gte_2_1() ) {
WC_Admin_Meta_Boxes::save_errors();
}
}
/**
* Compatibility function to get the version of the currently installed WooCommerce
*
* @return string woocommerce version number or null
* @since 1.0
*/
public static function get_wc_version() {
// WOOCOMMERCE_VERSION is now WC_VERSION, though WOOCOMMERCE_VERSION is still available for backwards compatibility, we'll disregard it on 2.1+
if ( defined( 'WC_VERSION' ) && WC_VERSION ) {
return WC_VERSION;
}
if ( defined( 'WOOCOMMERCE_VERSION' ) && WOOCOMMERCE_VERSION ) {
return WOOCOMMERCE_VERSION;
}
return null;
}
/**
* Returns the WooCommerce instance
*
* @return WooCommerce woocommerce instance
* @since 1.0
*/
public static function WC() {
if ( self::is_wc_version_gte_2_1() ) {
return WC();
}
}
/**
* Returns true if the WooCommerce plugin is loaded
*
* @return boolean true if WooCommerce is loaded
* @since 1.0
*/
public static function is_wc_loaded() {
if ( self::is_wc_version_gte_2_1() ) {
return class_exists( 'WooCommerce' );
}
}
/**
* Returns true if the installed version of WooCommerce is 2.1 or greater
*
* @return boolean true if the installed version of WooCommerce is 2.1 or greater
* @since 1.0
*/
public static function is_wc_version_gte_2_1() {
// can't use gte 2.1 at the moment because 2.1-BETA < 2.1
return self::is_wc_version_gt( '2.0.20' );
}
/**
* Returns true if the installed version of WooCommerce is 2.6 or greater
*
* @return boolean true if the installed version of WooCommerce is 2.1 or greater
* @since 1.0
*/
public static function is_wc_version_gte_3_0() {
return version_compare( self::get_wc_version(), '3.0.0', 'ge' );
}
/**
* Returns true if the installed version of WooCommerce is greater than $version
*
* @param string $version the version to compare
*
* @return boolean true if the installed version of WooCommerce is > $version
* @since 1.0
*
*/
public static function is_wc_version_gt( $version ) {
return self::get_wc_version() && version_compare( self::get_wc_version(), $version, '>' );
}
/**
* @param $item
* @param $key
*
* @return mixed
*/
public static function get_item_data( $item, $key ) {
if ( ! $item instanceof WC_Order ) {
return '';
}
if ( method_exists( $item, 'get_' . $key ) ) {
return call_user_func( array( $item, 'get_' . $key ) );
}
return $item->get_meta( $key );
}
public static function get_product_variation_length( $obj ) {
if ( self::is_wc_version_gte_3_0() ) {
$length = $obj->get_length() ? $obj->get_length() : '';
}
return $length;
}
public static function get_product_variation_width( $obj ) {
if ( self::is_wc_version_gte_3_0() ) {
$width = $obj->get_width() ? $obj->get_width() : '';
}
return $width;
}
public static function get_product_variation_height( $obj ) {
if ( self::is_wc_version_gte_3_0() ) {
$height = $obj->get_height() ? $obj->get_height() : '';
}
return $height;
}
public static function get_product_variation_weight( $obj ) {
if ( self::is_wc_version_gte_3_0() ) {
$weight = $obj->get_weight() ? $obj->get_weight() : '';
}
return $weight;
}
/**
* @param WC_Product $product
*
* @return mixed
*/
public static function get_parent_id( $product ) {
if ( self::is_wc_version_gte_3_0() ) {
return $product->get_parent_id();
}
}
/**
* @param WC_Product $product
*
* @return mixed
*/
static function is_variation( $product ) {
return $product->is_type( [ 'variation', 'subscription_variation' ] );
}
}
endif; // Class exists check

View File

@@ -0,0 +1,32 @@
<?php
/**
* WooCommerce Product Add-Ons Compatibility
* https://wpml.org/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_WC_Product_Addon' ) ) {
class BWFAN_Compatibility_With_WC_Product_Addon {
public function __construct() {
add_filter( 'bwfan_abandoned_modify_cart_item_data', [ $this, 'abandoned_modify_cart_item_data' ], 10, 1 );
}
/**
* Modify cart item data for abandoned carts.
*
* @param array $item_data Cart item data.
*
* @return array Modified cart item data.
*/
public function abandoned_modify_cart_item_data( $item_data ) {
if ( defined( 'PEWC_PLUGIN_VERSION' ) && isset( $item_data['product_extras'] ) ) {
remove_filter( 'woocommerce_add_cart_item_data', 'pewc_add_cart_item_data' );
}
return $item_data;
}
}
new BWFAN_Compatibility_With_WC_Product_Addon();
}

View File

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

View File

@@ -0,0 +1,37 @@
<?php
/**
* Perfmatters
* https://perfmatters.io/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_Perfmatters' ) ) {
class BWFAN_Compatibility_With_Perfmatters {
public function __construct() {
add_filter( 'rest_jsonp_enabled', array( $this, 'bwfan_allow_rest_apis_with_perfmatters' ), 100 );
}
/**
* Allow Autonami and WooFunnels endpoints in rest calls
*
* @param $status
*
* @return mixed
*/
public function bwfan_allow_rest_apis_with_perfmatters( $status ) {
if ( ! is_array( $GLOBALS['wp']->query_vars ) || ! isset( $GLOBALS['wp']->query_vars['rest_route'] ) ) {
return $status;
}
$rest_route = $GLOBALS['wp']->query_vars['rest_route'];
if ( strpos( $rest_route, 'autonami' ) !== false || strpos( $rest_route, 'woofunnel' ) !== false ) {
remove_filter( 'rest_authentication_errors', 'perfmatters_rest_authentication_errors', 20 );
}
return $status;
}
}
new BWFAN_Compatibility_With_Perfmatters();
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Force Login
* https://wordpress.org/plugins/wp-force-login/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_Force_Login' ) ) {
class BWFAN_Compatibility_With_Force_Login {
public function __construct() {
add_filter( 'rest_jsonp_enabled', array( $this, 'bwfan_allow_rest_apis_with_force_login' ), 100 );
}
/**
* Allow Autonami and WooFunnels endpoints in rest calls
*
* @param $status
*
* @return mixed
*/
public function bwfan_allow_rest_apis_with_force_login( $status ) {
$rest_route = $GLOBALS['wp']->query_vars['rest_route'];
if ( false !== strpos( $rest_route, 'autonami' ) || false !== strpos( $rest_route, 'woofunnel' ) || false !== strpos( $rest_route, 'funnelkit' ) ) {
remove_filter( 'rest_authentication_errors', 'v_forcelogin_rest_access', 99 );
}
return $status;
}
}
new BWFAN_Compatibility_With_Force_Login();
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Logged-in-only
* https://wordpress.org/plugins/wp-logged-in-only/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_Logged_In_Only' ) ) {
class BWFAN_Compatibility_With_Logged_In_Only {
public function __construct() {
add_filter( 'rest_jsonp_enabled', array( $this, 'bwfan_allow_rest_apis' ), 100 );
}
/**
* Allow Autonami and WooFunnels endpoints in rest calls
*
* @param $status
*
* @return mixed
*/
public function bwfan_allow_rest_apis( $status ) {
$rest_route = $GLOBALS['wp']->query_vars['rest_route'];
if ( false !== strpos( $rest_route, 'autonami' ) || false !== strpos( $rest_route, 'woofunnel' ) || false !== strpos( $rest_route, 'funnelkit' ) ) {
remove_filter( 'rest_authentication_errors', 'logged_in_only_rest_api' );
}
return $status;
}
}
new BWFAN_Compatibility_With_Logged_In_Only();
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Password Protected
* https://wordpress.org/plugins/password-protected/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_Password_Protected' ) ) {
class BWFAN_Compatibility_With_Password_Protected {
public function __construct() {
add_filter( 'password_protected_is_active', array( $this, 'bwfan_allow_rest_api_password_protected' ), 100 );
}
/**
* Allow Autonami and WooFunnels endpoints in rest calls
*
* @param $status
*
* @return false|mixed
*/
public function bwfan_allow_rest_api_password_protected( $status ) {
$rest_route = isset( $GLOBALS['wp']->query_vars['rest_route'] ) ? $GLOBALS['wp']->query_vars['rest_route'] : '';
if ( empty( $rest_route ) ) {
return $status;
}
if ( strpos( $rest_route, 'autonami' ) !== false || strpos( $rest_route, 'woofunnel' ) !== false ) {
return false;
}
return $status;
}
}
new BWFAN_Compatibility_With_Password_Protected();
}

View File

@@ -0,0 +1,40 @@
<?php
/**
* ATUM WooCommerce Inventory Management and Stock Tracking
* By Stock Management Labs
* https://wordpress.org/plugins/atum-stock-manager-for-woocommerce/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_Atom_Stock_Manager' ) ) {
class BWFAN_Compatibility_With_Atom_Stock_Manager {
public function __construct() {
add_action( 'action_scheduler_failed_action', [ $this, 'unhook_atom_stock_manager' ], 9, 2 );
}
/**
* Remove atom stock manager hook
*
* @param $action_id
* @param $timeout
*
* @return void
*/
public function unhook_atom_stock_manager( $action_id, $timeout ) {
$rest_route = filter_input( INPUT_GET, 'rest_route' );
if ( empty( $rest_route ) ) {
$rest_route = $_SERVER['REQUEST_URI'] ?? '';
}
if ( empty( $rest_route ) ) {
return;
}
$rest_route = bwf_clean( $rest_route );
if ( false !== strpos( $rest_route, '/woofunnels/v1/worker' ) || false !== strpos( $rest_route, '/autonami/v2/worker' ) || false !== strpos( $rest_route, '/autonami/v1/worker' ) ) {
BWFAN_Common::remove_actions( 'action_scheduler_failed_action', 'Atum\Api\AtumApi', 'maybe_retry_full_export_action' );
}
}
}
new BWFAN_Compatibility_With_Atom_Stock_Manager();
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* Breeze
*
* https://wordpress.org/plugins/breeze/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_Breeze_Cache' ) ) {
class BWFAN_Compatibility_With_Breeze_Cache {
public function __construct() {
add_filter( 'option_breeze_advanced_settings', array( $this, 'exclude_autonami_endpoint_urls' ), 999 );
}
/**
* Exclude Autonami endpoints from cache
*
* @param $options
*
* @return mixed
*/
public function exclude_autonami_endpoint_urls( $options ) {
$new_urls = [ site_url( 'wp-json/' . BWFAN_API_NAMESPACE . '/*' ), site_url( 'wp-json/woofunnels/*' ), site_url( 'wp-json/funnelkit-automations/*' ) ];
$excluded_urls = isset( $options['breeze-exclude-urls'] ) && is_array( $options['breeze-exclude-urls'] ) ? $options['breeze-exclude-urls'] : [];
$excluded_urls = array_unique( array_merge( $new_urls, $excluded_urls ) );
sort( $excluded_urls );
$options['breeze-exclude-urls'] = $excluded_urls;
return $options;
}
}
new BWFAN_Compatibility_With_Breeze_Cache();
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* Clearfy Pro
* https://wpshop.ru/plugins/clearfy
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_Clearfy' ) ) {
class BWFAN_Compatibility_With_Clearfy {
public function __construct() {
add_filter( 'clearfy_rest_api_white_list', array( $this, 'bwfan_whitelist_autonami_endpoints' ), 10, 1 );
}
/** white list autonami endpoints in clearfy pro plugin
*
* @param $white_list
*
* @return mixed
*/
public function bwfan_whitelist_autonami_endpoints( $white_list ) {
$white_list[] = 'woofunnels';
$white_list[] = 'woofunnels-admin';
$white_list[] = BWFAN_API_NAMESPACE;
$white_list[] = 'autonami-webhook';
$white_list[] = 'woofunnels-analytics';
$white_list[] = 'autonami';
$white_list[] = 'funnelkit-automations';
return $white_list;
}
}
new BWFAN_Compatibility_With_Clearfy();
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Image Optimizer Optimize Images and Convert to WebP or AVIF
* By Elementor
* https://wordpress.org/plugins/image-optimization/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_Image_Optimization' ) ) {
class BWFAN_Compatibility_With_Image_Optimization {
public function __construct() {
add_action( 'action_scheduler_init', [ $this, 'remove_image_optimization_hook' ], 9 );
}
/**
* Remove image optimisation hook
*
* @return void
*/
public function remove_image_optimization_hook() {
$rest_route = filter_input( INPUT_GET, 'rest_route' );
if ( empty( $rest_route ) ) {
$rest_route = $_SERVER['REQUEST_URI'] ?? '';
}
if ( empty( $rest_route ) ) {
return;
}
$rest_route = bwf_clean( $rest_route );
if ( false !== strpos( $rest_route, '/woofunnels/v1/worker' ) || false !== strpos( $rest_route, '/autonami/v2/worker' ) || false !== strpos( $rest_route, '/autonami/v1/worker' ) ) {
BWFAN_Common::remove_actions( 'action_scheduler_init', 'ImageOptimization\Modules\Optimization\Components\Actions_Cleanup', 'schedule_cleanup' );
}
}
}
new BWFAN_Compatibility_With_Image_Optimization();
}

View File

@@ -0,0 +1,61 @@
<?php
/**
* Security & Malware scan by CleanTalk
* https://wordpress.org/plugins/security-malware-firewall/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_Security_By_CleanTalk' ) ) {
class BWFAN_Compatibility_With_Security_By_CleanTalk {
public function __construct() {
add_filter( 'rest_jsonp_enabled', array( $this, 'bwfan_allow_rest_apis_with_force_login' ), 100 );
}
/**
* Allow FKA and FB endpoints in the rest calls
*
* @param $status
*
* @return mixed
*/
public function bwfan_allow_rest_apis_with_force_login( $status ) {
global $spbc;
if ( empty( $spbc ) || ( ! $spbc instanceof CleantalkSP\SpbctWP\State ) || empty( $spbc->settings['wp__disable_rest_api_for_non_authenticated'] ) ) {
return $status;
}
try {
$rest_route = $_GET['rest_route'] ?? '';
$rest_route = empty( $rest_route ) ? $_SERVER['REQUEST_URI'] : $rest_route;
if ( empty( $rest_route ) ) {
return $status;
}
if ( false === strpos( $rest_route, 'autonami' ) && false === strpos( $rest_route, 'woofunnel' ) && false === strpos( $rest_route, 'funnelkit' ) ) {
return $status;
}
$auth_errors_hooks = BWFAN_Common::get_list_of_attach_actions( 'rest_authentication_errors' );
if ( ! is_array( $auth_errors_hooks ) || count( $auth_errors_hooks ) == 0 ) {
return $status;
}
global $wp_filter;
foreach ( $auth_errors_hooks as $value ) {
if ( ! isset( $value['function_path'] ) ) {
continue;
}
if ( false !== strpos( $value['function_path'], '/security-malware-firewall' ) && isset( $wp_filter['rest_authentication_errors']->callbacks[ $value['priority'] ][ $value['index'] ] ) ) {
unset( $wp_filter['rest_authentication_errors']->callbacks[ $value['priority'] ][ $value['index'] ] );
}
}
} catch ( Error|Exception $e ) {
return $status;
}
return $status;
}
}
new BWFAN_Compatibility_With_Security_By_CleanTalk();
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* SiteGround Optimizer
*
* https://wordpress.org/plugins/sg-cachepress/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_SG_Cache' ) ) {
class BWFAN_Compatibility_With_SG_Cache {
public function __construct() {
/** Exclude FK endpoints from cache */
add_filter( 'option_siteground_optimizer_excluded_urls', array( $this, 'exclude_endpoints' ), PHP_INT_MAX );
add_filter( 'default_option_siteground_optimizer_excluded_urls', array( $this, 'exclude_endpoints' ), PHP_INT_MAX );
}
/**
* Exclude endpoints from SiteGround cache
*
* @param $value
*
* @return array|mixed
*/
public function exclude_endpoints( $value ) {
$value = BWFAN_Common::make_array( $value );
$value[] = "/wp-json/" . BWFAN_API_NAMESPACE . "/*";
$value[] = "/wp-json/woofunnels/*";
$value[] = "/wp-json/funnelkit-automations/*";
return BWFAN_Common::unique( $value );
}
}
new BWFAN_Compatibility_With_SG_Cache();
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* WordPress REST API Authentication
* By miniOrange
* https://wordpress.org/plugins/wp-rest-api-authentication/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_WP_Rest_Authenticate' ) ) {
class BWFAN_Compatibility_With_WP_Rest_Authenticate {
public function __construct() {
add_filter( 'dra_allow_rest_api', [ $this, 'bwfan_allow_rest_apis' ] );
}
/**
* Allow Autonami and WooFunnels endpoints in rest calls
*
* @return bool
*/
public function bwfan_allow_rest_apis() {
$rest_route = $GLOBALS['wp']->query_vars['rest_route'];
if ( false !== strpos( $rest_route, 'autonami' ) || false !== strpos( $rest_route, 'woofunnel' ) || false !== strpos( $rest_route, 'funnelkit' ) ) {
return true;
}
return false;
}
}
new BWFAN_Compatibility_With_WP_Rest_Authenticate();
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* Wp-Rocket
*
* https://wp-rocket.me/
*/
if ( ! class_exists( 'BWFAN_Compatibility_With_Wp_Rocket' ) ) {
class BWFAN_Compatibility_With_Wp_Rocket {
public function __construct() {
add_filter( 'rocket_cache_reject_uri', array( $this, 'exclude_autonami_endpoint_option' ), 100 );
}
/**
* Exclude Autonami and WooFunnels endpoints from wp-rocket cache
*
* @param $uris
*
* @return mixed
*/
public function exclude_autonami_endpoint_option( $uris ) {
$uris[] = "/wp-json/" . BWFAN_API_NAMESPACE . "/*";
$uris[] = "/wp-json/woofunnels/*";
$uris[] = "/wp-json/funnelkit-automations/*";
return $uris;
}
}
new BWFAN_Compatibility_With_Wp_Rocket();
}

View File

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