HEX
Server: LiteSpeed
System: Linux premium283.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User: citaqlmd (746)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/citaqlmd/listing.lmskreators.com/wp-content/plugins/texty/includes/Gateways.php
<?php

namespace Texty;

use Texty\Gateways\GatewayInterface;
use WP_Error;

/**
 * Manager Class
 */
class Gateways {

    /**
     * Send the message from the active gateway
     *
     * @param string $to      The TO phone number
     * @param string $message The message to send
     *
     * @return bool|WP_Error
     */
    public function send( $to, $message ) {
        $gateway = $this->active_gateway();

        if ( $gateway instanceof GatewayInterface ) {
            return $gateway->send( $to, $message );
        }

        return false;
    }

    /**
     * Get the active gateway
     *
     * @return Gateways\GatewayInterface|false
     */
    public function active_gateway() {
        $gateways  = $this->all();
        $gateway   = texty()->settings()->gateway();

        if ( $gateway && array_key_exists( $gateway, $gateways ) ) {
            return new $gateways[ $gateway ]();
        }

        return false;
    }

    /**
     * Get all the available gateways
     *
     * @return array
     */
    public function all() {
        $gateways = [
            'twilio'     => __NAMESPACE__ . '\Gateways\Twilio',
            'vonage'     => __NAMESPACE__ . '\Gateways\Vonage',
            'clickatell' => __NAMESPACE__ . '\Gateways\Clickatell',
            'plivo'      => __NAMESPACE__ . '\Gateways\Plivo',
        ];

        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
            $gateways['fake'] = __NAMESPACE__ . '\Gateways\Fake';
        }

        return apply_filters( 'texty_available_gateways', $gateways );
    }
}