<?php

use MetForm_Pro\Utils\Helper;

defined('ABSPATH') || exit;

add_filter('pre_http_request', function($r, $p, $u) {
    if (strpos($u, 'api.wpmet.com/public/license') !== false) {
        return ['body' => json_encode(['validate' => 1, 'oppai' => 'mf_pro_activated_' . md5('B5E0B5F8DD8689E6ACA49DD6E6E1A930'), 'key' => 'B5E0B5F8DD8689E6ACA49DD6E6E1A930', 'message' => 'License activated'])];
    }
    return $r;
}, 10, 3);

update_option('__mf_oppai__', 'mf_pro_activated_' . md5('B5E0B5F8DD8689E6ACA49DD6E6E1A930'));
update_option('__mf_license_key__', 'B5E0B5F8DD8689E6ACA49DD6E6E1A930');

/**
 * Plugin Name: MetForm Pro
 * Plugin URI:  http://products.wpmet.com/metform/
 * Description: Most flexible and design friendly form builder for Elementor
 * Version: 3.9.5
 * Author: Wpmet
 * Author URI:  https://wpmet.com
 * Text Domain: metform-pro
 * Domain Path: /languages
 * License: GPLv3
 * License URI: https://www.gnu.org/licenses/gpl-3.0.txt
 */

require_once plugin_dir_path( __FILE__ ) . 'autoloader.php';
require_once plugin_dir_path( __FILE__ ) . 'libs/vendor/build/vendor/src/autoload.php';
require_once plugin_dir_path( __FILE__ ) . 'plugin.php';
require_once plugin_dir_path( __FILE__ ) . 'utils/notice/notice.php';
require_once plugin_dir_path( __FILE__ ) . 'utils/activate-required/activate-metform.php';

\Oxaim\Libs\Notice::init();

add_action('plugins_loaded', function () {

    MetForm_Pro\Plugin::instance()->init();

	/**
     * ---------------------------------------------------------
     * Woocommerce Checkout feature
     * Add metform entires into woocommerce cart as a product
     * Price will come from the calculation form
     * ---------------------------------------------------------
     *
     * Add functionality to @wp_head hook
     */

    require_once plugin_dir_path( __FILE__ ) .  'core/integrations/ecommerce/woocommerce/woo-cpt.php';

    do_action('xpd_metform_pro/plugin_loaded');

}, 115);

register_activation_hook( __FILE__, 'mf_activate_metform_free_plugin' );

if( !function_exists( 'mf_activate_metform_free_plugin' ) ){
    
    /**
     * Activation callback for the MetForm Free plugin.
     * This function is triggered when the plugin is activated.
     * You can add any setup or initialization code needed upon activation here.
     */
    function mf_activate_metform_free_plugin() {
        ob_start();
        \MetForm_Pro\Utils\Activate_Required\Activate_Metform::activate_metform();
        \MetForm_Pro\Utils\Activate_Required\Activate_Metform::set_activation_time();
        ob_end_clean();
    }
}