← back to flintfromthebasement__pmpro-mailerlite

Function bodies 1 total

All specs Real LLM only Function bodies
PMPro_MailerLite_API class · php · L13-L356 (344 LOC)
classes/class-pmpro-mailerlite-api.php
class PMPro_MailerLite_API {

	/**
	 * Singleton instance.
	 *
	 * @var PMPro_MailerLite_API|null
	 */
	private static $instance = null;

	/**
	 * API base URL.
	 *
	 * @var string
	 */
	private $api_url = 'https://connect.mailerlite.com/api';

	/**
	 * API key.
	 *
	 * @var string
	 */
	private $api_key = '';

	/**
	 * Whether the API is connected and ready.
	 *
	 * @var bool
	 */
	private $connected = false;

	/**
	 * Cached groups.
	 *
	 * @var array|null
	 */
	private $groups_cache = null;

	/**
	 * Cached custom fields.
	 *
	 * @var array|null
	 */
	private $fields_cache = null;

	/**
	 * Get singleton instance.
	 *
	 * @return PMPro_MailerLite_API|null
	 */
	public static function get_instance() {
		if ( null === self::$instance ) {
			self::$instance = new self();
		}
		return self::$instance;
	}

	/**
	 * Constructor. Loads stored API key.
	 */
	private function __construct() {
		$options = get_option( 'pmproml_options', array() );
		if ( ! empty( $options['api_key'] ) ) {
			$