is_event_tickets_active() ) { add_action( 'admin_notices', [ $this, 'event_tickets_missing_notice' ] ); return; } // Load text domain load_plugin_textdomain( 'event-tickets-mail-in', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); // Include required files $this->includes(); // Initialize components $this->init_components(); } /** * Check if Event Tickets is active * * @return bool */ private function is_event_tickets_active() { return class_exists( 'Tribe__Tickets__Main' ) && class_exists( 'TEC\Tickets\Commerce\Module' ); } /** * Include required files */ private function includes() { require_once ET_MAIL_IN_PATH . 'src/Gateway.php'; require_once ET_MAIL_IN_PATH . 'src/Order.php'; require_once ET_MAIL_IN_PATH . 'src/Settings.php'; require_once ET_MAIL_IN_PATH . 'src/Provider.php'; require_once ET_MAIL_IN_PATH . 'src/Hooks.php'; } /** * Initialize components */ private function init_components() { // Register our provider with dependency injection container tribe_register_provider( ET_Mail_In_Payment\Provider::class ); } /** * Plugin activation */ public function activate() { // Check dependencies if ( ! $this->is_event_tickets_active() ) { deactivate_plugins( plugin_basename( __FILE__ ) ); wp_die( __( 'Event Tickets - Mail-In Payment Gateway requires Event Tickets to be installed and activated.', 'event-tickets-mail-in' ), __( 'Plugin Activation Error', 'event-tickets-mail-in' ), [ 'back_link' => true ] ); } // Set default options if they don't exist $this->set_default_options(); } /** * Plugin deactivation */ public function deactivate() { // Clean up if needed } /** * Get default payment instructions * * @return string */ private function get_default_instructions() { return __( 'Please mail your check to the address provided below. Your tickets will be reserved for 7 days while we wait for your payment to arrive. Include your order number on the check memo line.', 'event-tickets-mail-in' ); } /** * Set default options on activation */ private function set_default_options() { // Set default options if they don't exist if ( false === tribe_get_option( 'tickets-commerce-mail-in-enabled' ) ) { tribe_update_option( 'tickets-commerce-mail-in-enabled', true ); } if ( empty( tribe_get_option( 'tickets-commerce-mail-in-title' ) ) ) { tribe_update_option( 'tickets-commerce-mail-in-title', __( 'Mail-In Payment (Check)', 'event-tickets-mail-in' ) ); } if ( empty( tribe_get_option( 'tickets-commerce-mail-in-description' ) ) ) { tribe_update_option( 'tickets-commerce-mail-in-description', __( 'Pay by mailing a check to our address.', 'event-tickets-mail-in' ) ); } if ( empty( tribe_get_option( 'tickets-commerce-mail-in-instructions' ) ) ) { tribe_update_option( 'tickets-commerce-mail-in-instructions', $this->get_default_instructions() ); } // For testing purposes, set some default values if ( empty( tribe_get_option( 'tickets-commerce-mail-in-address' ) ) ) { tribe_update_option( 'tickets-commerce-mail-in-address', "123 Main Street\nAnytown, ST 12345\nUSA" ); } if ( empty( tribe_get_option( 'tickets-commerce-mail-in-payable-to' ) ) ) { tribe_update_option( 'tickets-commerce-mail-in-payable-to', "Your Organization Name" ); } } /** * Display admin notice when Event Tickets is missing */ public function event_tickets_missing_notice() { echo '

'; echo esc_html__( 'Event Tickets - Mail-In Payment Gateway requires Event Tickets to be installed and activated.', 'event-tickets-mail-in' ); echo '

'; } } // Initialize the plugin ET_Mail_In_Payment::instance();