File: /var/www/kevin-demo/wp-content/plugins/wpforms-sendinblue/src/Plugin.php
<?php
namespace WPFormsSendinblue;
use stdClass;
use WPForms_Updater;
use WPFormsSendinblue\Api\Client;
use WPFormsSendinblue\Provider\Account;
use WPFormsSendinblue\Provider\Template;
use WPFormsSendinblue\Tasks\ProcessActionTask;
use WPForms\Providers\Providers;
/**
* Class Plugin that loads the whole plugin.
*
* @since 1.0.0
*/
class Plugin {
/**
* Provider slug.
*
* @since 1.0.0
*/
const SLUG = 'sendinblue';
/**
* Manage API accounts.
*
* @since 1.0.0
*
* @var Account
*/
private $account;
/**
* Get some addon templates.
*
* @since 1.0.0
*
* @var Template
*/
private $template;
/**
* Client for Sendinblue API.
*
* @since 1.0.0
*
* @var Client
*/
private $client;
/**
* Plugin constructor.
*
* @since 1.0.0
*/
private function __construct() {
$this->load_dependencies();
}
/**
* Load plugin dependencies.
*
* @since 1.0.0
*/
private function load_dependencies() {
$this->account = new Account();
$this->template = new Template();
$this->template->init();
$this->client = new Client();
( new ProcessActionTask() )->hooks();
Providers::get_instance()->register(
new Provider\Core()
);
}
/**
* Get property.
*
* @since 1.0.0
*
* @param string $property_name Property name.
*
* @return mixed
*/
public function get( $property_name ) {
return property_exists( $this, $property_name ) ? $this->{$property_name} : new stdClass();
}
/**
* Get a single instance of the addon.
*
* @since 1.0.0
*
* @return Plugin
*/
public static function get_instance() {
static $instance;
if ( ! $instance ) {
$instance = new self();
}
return $instance;
}
/**
* Flash a transient cache on provider data change.
*
* @since 1.0.0
* @deprecated 1.4.0
*/
public function flush_cache() {
_deprecated_function( __METHOD__, '1.4.0 of the WPForms Brevo addon.' );
// Call it when an account was added or disconnected.
if (
did_action( 'wp_ajax_wpforms_settings_provider_add_sendinblue' ) ||
did_action( 'wp_ajax_wpforms_settings_provider_disconnect_sendinblue' )
) {
delete_transient( 'wpforms_sendinblue_accounts' );
}
}
/**
* Load the addon updater.
*
* @since 1.0.0
* @deprecated 1.4.0
*
* @todo Remove with core 1.9.2
*
* @param string $key License key.
*/
public function updater( $key ) {
_deprecated_function( __METHOD__, '1.4.0 of the WPForms Brevo plugin' );
new WPForms_Updater(
[
'plugin_name' => 'WPForms Brevo',
'plugin_slug' => 'wpforms-sendinblue',
'plugin_path' => plugin_basename( WPFORMS_SENDINBLUE_FILE ),
'plugin_url' => trailingslashit( WPFORMS_SENDINBLUE_URL ),
'remote_url' => WPFORMS_UPDATER_API,
'version' => WPFORMS_SENDINBLUE_VERSION,
'key' => $key,
]
);
}
}