<?php
/**
 * FluentC Manager Class.
 *
 * @package FluentCPlugin
 */


namespace FluentC;

use FluentC\Utils\Language;
use FluentC\Models\FluentC_Links_Model;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
class FluentC_Manager {
    public $links_model;

	protected $fluentc_languages;
	public function __construct() {
        $this->links_model = new FluentC_Links_Model();
		$this->fluentc_languages = new Language();
		add_action( 'init', array( $this, 'init_hooks' ), 99 );
	}

	/**
	 * Register hooks to replace Polylang functionality
	 */
	public function init_hooks() {
		add_filter( 'locale', array( $this, 'set_locale' ) );
	}

	/**
	 * Set locale function to replace Polylang functionality
	 */
	public function set_locale( $locale ) {
		// Always return the original locale unchanged
		// FluentC should never modify WordPress locale
		return $locale;
	}

	/**
	 * Check if FluentC is active
	 */
	public function is_fluentc_active() {
		$has_api_key = !empty(get_option('fluentc_api_key'));
		if ($has_api_key) {
			return true; 
		}
		else {
			return false; 
		}
		
	}

	/**
	 * Get the locale for FluentC
	 */
	public function get_fluentc_locale() {
		
		return $this->fluentc_languages->fluentc_site_language();
	}
}