<?php
/**
 * Conditionals.php
 *
 * @since      1.0.0
 * @author     alfiopiccione <alfio.piccione@gmail.com>

 * @license    http://opensource.org/licenses/gpl-2.0.php GPL v2
 *
 * Copyright (C) 2025 alfiopiccione <alfio.piccione@gmail.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

namespace WcElectronInvoice\Functions;

if (! defined('ABSPATH')) {
    exit; // Exit if accessed directly.
}

/**
 * Is WpMl active
 *
 * @return bool If the class SitePress exists and the theme support WpMl.
 * @since 1.0.0
 *
 */
function isWpmlActive()
{
    return class_exists('SitePress');
}

/**
 * Is WooCommerce active
 *
 * @return bool If the function WC exists.
 * @since 1.0.0
 *
 */
function isWooCommerceActive()
{
    return function_exists('WC');
}

/**
 * Is Cozmoslabs Paid Member Subscriptions Pro active
 *
 * @return bool if the class PMS_Handle_Included_Addons exists.
 * @since 5.5.4
 *
 */
function isCozmoslabsPaidMemberSubscriptionsActive()
{
    return class_exists('Paid_Member_Subscriptions') || class_exists('PMS_Handle_Included_Addons');
}

/**
 * Is Stranger Studios Paid Memberships Pro active
 *
 * @return bool
 * @since 6.1.6
 *
 */
function isPaidMembershipsProActive()
{
	return defined( 'PMPRO_VERSION' );
}

/**
 * Have an active Provider
 *
 * @return bool
 */
function haveAnActiveProvider()
{
    $ordersProviderQuery = \WcElectronInvoice\Providers\OrderQuery::instance();
    $providers = $ordersProviderQuery->get_providers();

    return is_array($providers) && ! empty($providers) && count($providers) > 0;
}
