whoami7 - Manager
:
/
home
/
analuakl
/
somethingsmushy.com
/
wp-content
/
plugins
/
wp-user-frontend
/
Lib
/
Gateway
/
Upload File:
files >> /home/analuakl/somethingsmushy.com/wp-content/plugins/wp-user-frontend/Lib/Gateway/Manager.php
<?php namespace WeDevs\Wpuf\Lib\Gateway; /** * Payment Gateway Manager * * Manages registration and initialization of payment gateways. * * @since WPUF_PRO_SINCE */ class Manager { /** * Registered gateway instances * * @var Abstract_Gateway[] */ private $gateways = []; /** * Constructor * * @since WPUF_PRO_SINCE */ public function __construct() { $this->init_gateways(); $this->setup_hooks(); } /** * Initialize all payment gateways * * @since WPUF_PRO_SINCE * * @return void */ private function init_gateways() { // Initialize core gateways $this->register_gateway( new Paypal_Gateway() ); $this->register_gateway( new Bank_Gateway() ); /** * Allow third-party plugins to register custom gateways * * @since WPUF_PRO_SINCE * * @param _Manager $manager Gateway manager instance */ do_action( 'wpuf_register_payment_gateways', $this ); } /** * Setup WordPress hooks * * @since WPUF_PRO_SINCE * * @return void */ private function setup_hooks() { add_filter( 'wpuf_payment_gateways', [ $this, 'get_registered_gateways' ], 5 ); } /** * Register a payment gateway * * @since WPUF_PRO_SINCE * * @param Abstract_Gateway $gateway Gateway instance * * @return bool True if registered successfully, false otherwise */ public function register_gateway( Abstract_Gateway $gateway ) { $gateway_id = $gateway->get_id(); if ( empty( $gateway_id ) ) { $this->log_error( 'Attempted to register gateway without ID' ); return false; } if ( isset( $this->gateways[ $gateway_id ] ) ) { $this->log_error( sprintf( 'Gateway "%s" is already registered', $gateway_id ) ); return false; } $this->gateways[ $gateway_id ] = $gateway; return true; } /** * Unregister a payment gateway * * @since WPUF_PRO_SINCE * * @param string $gateway_id Gateway ID * * @return bool True if unregistered successfully, false otherwise */ public function unregister_gateway( $gateway_id ) { if ( ! isset( $this->gateways[ $gateway_id ] ) ) { return false; } unset( $this->gateways[ $gateway_id ] ); return true; } /** * Get a specific gateway instance * * @since WPUF_PRO_SINCE * * @param string $gateway_id Gateway ID * * @return Abstract_Gateway|null Gateway instance or null if not found */ public function get_gateway( $gateway_id ) { return isset( $this->gateways[ $gateway_id ] ) ? $this->gateways[ $gateway_id ] : null; } /** * Get all registered gateways * * @since WPUF_PRO_SINCE * * @param array $gateways Existing gateways array (for filter compatibility) * * @return array Gateway configurations */ public function get_registered_gateways( $gateways = [] ) { $registered = []; foreach ( $this->gateways as $gateway_id => $gateway ) { $registered[ $gateway_id ] = $gateway->get_config(); } // Merge with any gateways added via the old filter system for backward compatibility return array_merge( $gateways, $registered ); } /** * Get all gateway instances * * @since WPUF_PRO_SINCE * * @return Abstract_Gateway[] */ public function get_gateway_instances() { return $this->gateways; } /** * Check if a gateway is registered * * @since WPUF_PRO_SINCE * * @param string $gateway_id Gateway ID * * @return bool */ public function is_gateway_registered( $gateway_id ) { return isset( $this->gateways[ $gateway_id ] ); } /** * Get gateway IDs * * @since WPUF_PRO_SINCE * * @return array */ public function get_gateway_ids() { return array_keys( $this->gateways ); } /** * Log error message * * @since WPUF_PRO_SINCE * * @param string $message Error message * * @return void */ private function log_error( $message ) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log( sprintf( '[WPUF Gateway Manager] %s', $message ) ); } } }
Copyright ©2021 || Defacer Indonesia