<?php

/**
 * The plugin bootstrap file
 *
 * This file is read by WordPress to generate the plugin information in the plugin
 * admin area. This file also includes all of the dependencies used by the plugin,
 * registers the activation and deactivation functions, and defines a function
 * that starts the plugin.
 *
 * @link              https://webkrafterz.com/
 * @since             1.0.0
 * @package           polylai
 *
 * @wordpress-plugin
 * Plugin Name: AI Translator for Polylang
 * Plugin URI:        https://www.wp-polylai.com
 * Requires PHP:      7.4
 * Requires at least: 6.0
 * Description:       Translate your Polylang posts with AI
 * Version:           1.5.4
 * Author:            Webkrafterz
 * Author URI:        https://webkrafterz.com/
 * License:           GPL-2.0+
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * Text Domain:       ai-translator-for-polylang
 * Domain Path:       /languages
 */
require_once __DIR__ . '/vendor/autoload.php';
/**
 * Currently plugin version.
 * Start at version 1.0.0 and use SemVer - https://semver.org
 * Rename this for your plugin and update it as you release new versions.
 */
define( 'POLYLAI_VERSION', '1.5.3' );
define( 'POLYLAI_WS_URL', 'https://api.wp-polylai.com/api/v1' );
// define('POLYLAI_WS_URL', 'http://localhost:8000/api/v1');
define( "POLYLAI_TD", "ai-translator-for-polylang" );
define( "POLYLAI_TRANSLATING_KEY", "polylai_translating" );
define( "POLYLAI_STATUS", "polylai_status" );
define( "POLYLAI_LOCAL_READY", "polylai_local_ready" );
define( "POLYLAI_SERVICE", "polylai_service" );
define( "POLYLAI_PROCESSING", "polylai_processing" );
define( "POLYLAI_CLOUD_GUID", "polylai_cloud_guid" );
define( "POLYLAI_CLOUD_TRANSIENT", "polylai_cloud_transient" );
define( "POLYLAI_SOURCE_ID", "polylai_source_id" );
define( "POLYLAI_POST_TYPE", "polylai-translation" );
/**
 * The code that runs during plugin activation.
 * This action is documented in includes/class-polylai-translator-activator.php
 */
function polylai_activate() {
    require_once plugin_dir_path( __FILE__ ) . 'includes/class-polylai-translator-activator.php';
    polylai_Activator::activate();
}

/**
 * The code that runs during plugin deactivation.
 * This action is documented in includes/class-polylai-translator-deactivator.php
 */
function polylai_deactivate() {
    require_once plugin_dir_path( __FILE__ ) . 'includes/class-polylai-translator-deactivator.php';
    polylai_Deactivator::deactivate();
}

register_activation_hook( __FILE__, 'polylai_activate' );
register_deactivation_hook( __FILE__, 'polylai_deactivate' );
/**
 * The core plugin class that is used to define internationalization,
 * admin-specific hooks, and public-facing site hooks.
 */
require plugin_dir_path( __FILE__ ) . 'includes/class-polylai-translator.php';
/**
 * Begins execution of the plugin.
 *
 * Since everything within the plugin is registered via hooks,
 * then kicking off the plugin from this point in the file does
 * not affect the page life cycle.
 *
 * @since    1.0.0
 */
function polylai_run() {
    $plugin = new polylai();
    $plugin->run();
}

if ( !function_exists( 'polylai_fs' ) ) {
    // Create a helper function for easy SDK access.
    function polylai_fs() {
        global $polylai_fs;
        if ( !isset( $polylai_fs ) ) {
            // Include Freemius SDK.
            // SDK is auto-loaded through composer
            $polylai_fs = fs_dynamic_init( array(
                'id'               => '15708',
                'slug'             => 'ai-translator-for-polylang',
                'premium_slug'     => 'polylai-translator-premium',
                'type'             => 'plugin',
                'public_key'       => 'pk_fe7dde2a72823221dcac1d8dea75f',
                'is_premium'       => false,
                'has_addons'       => false,
                'has_paid_plans'   => true,
                'menu'             => array(
                    'slug'       => 'polylai',
                    'first-path' => 'admin.php?page=polylai-tutorial',
                ),
                'is_live'          => true,
                'is_org_compliant' => true,
            ) );
        }
        return $polylai_fs;
    }

    // Init Freemius.
    polylai_fs();
    // Signal that SDK was initiated.
    do_action( 'polylai_fs_loaded' );
}
polylai_run();