*/ class Wp_Stripe_Plaid_Public { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * The plugin settings. * * @since 1.0.0 * @access private * @var string $settings The current settings of this plugin. */ private $settings; /** * The plugin settings. * * @since 1.0.0 * @access private * @var string $user_message holds message(s) for user if they don't have Stripe or Plaid creds. */ private $user_message = array(); /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of the plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; $this->settings = get_option( 'stripe_plaid_settings' ); $this->has_creds(); add_shortcode( 'wp_stripe_plaid', array( $this, 'render_form' ) ); } /** * Register the stylesheets for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_styles() { wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wp-stripe-plaid-public.css', array(), $this->version, 'all' ); } /** * Register the JavaScript for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_scripts() { wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wp-stripe-plaid-public.js', array( 'jquery', 'stripe_plaid' ), $this->version, true ); wp_enqueue_script( 'stripe_plaid', 'https://cdn.plaid.com/link/v2/stable/link-initialize.js', array(), null, true ); wp_localize_script($this->plugin_name, 'ajax_object', array( 'ajax_url' => admin_url('admin-ajax.php'), 'ajax_nonce' => wp_create_nonce('stripe_plaid_nonce') ) ); } public function has_creds(){ // check for test creds if in test mode, otherwise live key if ( $this->settings['sp_environment'] === "test" ) { if ( !strlen( trim( $this->settings['stripe_test_api_key'] ) ) ) { $this->user_message[] = 'Missing Stripe test API Key'; } } else { if ( !strlen( trim( $this->settings['stripe_live_api_key'] ) ) ) { $this->user_message[] = 'Missing Stripe live API Key'; } } // Plaid keys if ( !strlen( trim( $this->settings['plaid_client_id'] ) ) ) { $this->user_message[] = 'Missing Plaid client ID'; } if ( !strlen( trim( $this->settings['plaid_secret'] ) ) ) { $this->user_message[] = 'Missing Plaid Secret'; } if ( !strlen( trim( $this->settings['plaid_public_key'] ) ) ) { $this->user_message[] = 'Missing Plaid public key'; } } public function render_form(){ if ( empty( $this->user_message ) ) { $env = ( $this->settings['sp_environment'] === 'live' ) ? 'production' : 'tartan'; ?>
user_message as $message ) { echo '- ' . $message . '