1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 
	<?php
defined( 'ABSPATH' ) || exit();
use PaymentPlugins\WC_Braintree_Constants as Constants;
function wc_braintree_cart_checkout_template() {
    $gateways = array();
    foreach ( WC()->payment_gateways()->get_available_payment_gateways() as $gateway ) {
        if ( $gateway->supports( 'wc_braintree_cart_checkout' ) && $gateway->is_cart_checkout_enabled() ) {
            $gateways[ $gateway->id ] = $gateway;
        }
    }
    if ( count( apply_filters( 'wc_braintree_cart_payment_gateways', $gateways ) ) > 0 ) {
        wc_braintree_get_template(
            'cart/cart-fields.php',
            array(
                'gateways'   => $gateways,
                'priority'   => apply_filters( 'wc_braintree_cart_buttons_priority', 30 ),
                'cart_total' => WC()->cart->total,
            )
        );
    }
}
function wc_braintree_banner_checkout_template() {
    $gateways = array();
    foreach ( WC()->payment_gateways()->get_available_payment_gateways() as $id => $gateway ) {
        if ( $gateway->supports( 'wc_braintree_banner_checkout' ) && $gateway->banner_checkout_enabled() ) {
            $gateways[ $id ] = $gateway;
        }
    }
    if ( count( $gateways ) > 0 ) {
        wc_braintree_get_template( 'checkout/checkout-banner.php', array( 'gateways' => $gateways ) );
    }
}
function wc_braintree_show_product_checkout_gateways() {
}
function wc_braintree_deprecated_template_check( $template_name, $template_path, $located ) {
    if ( $template_path === braintree()->template_path() ) {
        $data = wc_braintree_get_file_data( $located, array( 'version' => 'version' ) );
        if ( $data && ! empty( $data['version'] ) ) {
            if ( version_compare( $data['version'], '3.0.0', '<' ) ) {
                _deprecated_file( $located, '3.0.0', braintree()->template_path() . $template_name, 'Please update your theme templates to use the new plugin files' );
            }
        }
    }
}
function wc_braintree_get_file_data( $filename, $headers ) {
    $file = fopen( $filename, 'r' );
    $data = fread( $file, 8192 );
    fclose( $file );
    
    foreach ( $headers as $key => $regex ) {
        if ( preg_match( '/[ \t\/*#@]' . preg_quote( $regex, '/' ) . '\s+([\w\.]+)/', $data, $match ) ) {
            $headers[ $key ] = $match[1];
        } else {
            $headers[ $key ] = '';
        }
    }
    return $headers;
}