<?php

/**
 * @wordpress-plugin
 * Plugin Name:       ConvertForce Popup Builder
 * Plugin URI:        https://convertforce.com/
 * Description:       A plugin for converting visitors to customers.
 * Version:           1.0.0
 * Author:            DotCamp
 * Author URI:        https://dotcamp.com/
 * License:           GPL-3.0+
 * License URI:       http://www.gnu.org/licenses/gpl-3.0.txt
 * Text Domain:       convertforce
 */

if (!defined('ABSPATH')) exit;

define('CONVERTFORCE_VERSION', '1.0.0');
define('CONVERTFORCE_FILE', __FILE__);
define('CONVERTFORCE_DIR', __DIR__);
define('CONVERTFORCE_URL', rtrim(plugin_dir_url(__FILE__), '/'));

require_once __DIR__ . '/vendor/autoload.php';


if (!function_exists('con_fs')) {
    function con_fs()
    {
        global $con_fs;

        if (!isset($con_fs)) {
            require_once __DIR__ . '/freemius/start.php';

            $con_fs = fs_dynamic_init([
                'id'               => '28285',
                'slug'             => 'convertforce-popup-builder',
                'type'             => 'plugin',
                'public_key'       => 'pk_879cb3417d6b586a0e19c42144d1d',
                'is_premium'       => false,
                'has_addons'       => true,
                'has_paid_plans'   => false,
                'is_org_compliant' => true,
                'menu'             => [
                    'slug'       => 'edit.php?post_type=convertforce-popup',
                    'first-path' => 'admin.php?page=convertforce',
                    'account'    => false,
                ],
            ]);
        }

        return $con_fs;
    }

    con_fs();
    do_action('con_fs_loaded');
}


register_activation_hook(__FILE__, function () {
    set_transient('convertforce_activation_redirect', true, 60);
});


add_action('init', [Convertforce\Convertforce::class, 'init']);
add_action('admin_init', [Convertforce\Convertforce::class, 'admin_init']);
add_action('admin_menu', [Convertforce\Admin\Menu::class, 'register']);
add_action('wp_footer', [Convertforce\Frontend\Frontend::class, 'render']);
add_action('save_post', [Convertforce\Core\Post::class, 'save_post'], 10, 3);
add_action('wp', [Convertforce\Frontend\Frontend::class, 'prepare_conversions']);
