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
<?php
defined( 'ABSPATH' ) || exit();
if ( ! class_exists( 'WC_Settings_API' ) ) {
return;
}
abstract class WC_Braintree_Settings_API extends WC_Settings_API {
use WC_Braintree_Settings_Trait;
protected $tab_title = '';
private $messages = array();
public function __construct() {
$this->init_form_fields();
$this->init_settings();
add_action( 'woocommerce_settings_checkout_' . $this->id, array( $this, 'output' ) );
add_filter( 'wc_braintree_admin_settings_tabs', array( $this, 'admin_settings_tabs' ) );
add_action( 'wc_braintree_localize_' . $this->id . '_settings', array( $this, 'get_admin_localized_params' ) );
}
public function output() {
global $current_section;
if ( count( $this->get_errors() ) > 0 ) {
$this->display_errors();
}
if ( count( $this->get_messages() ) > 0 ) {
$this->display_messages();
}
$this->admin_options();
}
public function admin_options() {
global $current_section;
$this->output_settings_nav();
printf( '<input type="hidden" id="wc_braintree_prefix" name="wc_braintree_prefix" value="%1$s"/>', $this->get_prefix() );
echo '<div class="wc-braintree-settings-container">';
parent::admin_options();
echo '</div>';
}
public function add_message( $message ) {
$this->messages[] = $message;
}
public function get_messages() {
return $this->messages;
}
public function display_messages() {
if ( $this->get_messages() ) {
echo '<div id="woocommerce_messages" class="updated notice is-dismissible">';
foreach ( $this->get_messages() as $error ) {
echo '<p>' . wp_kses_post( $error ) . '</p>';
}
echo '</div>';
}
}
public function enqueue_admin_scripts() {
}
}