<?php



/*
 * Copyright (c) 2012-2022, Squirrly.
 * The copyrights to the software code in this file are licensed under the (revised) BSD open source license.

 * Plugin Name: Product Perfect Feed
 * Plugin URI: https://wordpress.org/plugins/squirrly-seo/
 * Description: Product Perfect Feed
 * Author: Squirrly
 * Author URI: https://plugin.squirrly.co
 * Version: 1.0.2
 * License: GPLv2 or later
 * License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * Text Domain: Product Perfect Feed
 * Domain Path: /languages
 */


         
    if (!defined('PROD_PERF')) {}
    /* SET THE CURRENT VERSION ABOVE AND BELOW */
    define('PROD_PERF', '1.0.2');

    // Call config files
    try {
            include_once dirname(__FILE__) . '/config/config.php';
            include_once dirname(__FILE__) . '/debug/index.php';
           
       
            include_once _PROD_CLASSES_DIR_ . 'ObjController.php';

            // Load helpers
            PROD_Classes_ObjController::getClass('PROD_Classes_Helpers_Tools');
            PROD_Classes_ObjController::getClass('PROD_Classes_Helpers_Sanitize');

            // Load the Front and Block controller
            PROD_Classes_ObjController::getClass('PROD_Classes_FrontController'); 
            // include_once _PROD_MODEL_DIR_ . 'JSONDataModel.php';

            include_once _PROD_CLASSES_DIR_ . 'ActionController.php';
            if (defined('DOING_AJAX') && DOING_AJAX) {
                $actionController = new PROD_Classes_ActionController();
                add_action('init', function () use ($actionController) {
                    $actionController->getActions();
                });
            } else {
                $actionController = new PROD_Classes_ActionController();
                $actionController->getActions();
            }

            add_action('init', function () {
                $settingsController = PROD_Classes_ObjController::getClass('PROD_Controllers_Settings');
                add_action('prod_ai_optimize_products', [$settingsController, 'prod_ai_optimize_products_callback']);
                add_action('wp_ajax_prod_check_optimization_complete', [$settingsController, 'prod_check_optimization_complete_callback']);
            });
            
            require_once(plugin_dir_path(__FILE__) . '/update.php');

            if (PROD_Classes_Helpers_Tools::isBackedAdmin()) {
                //if (class_exists('WooCommerce')) { 
                    PROD_Classes_ObjController::getClass('PROD_Classes_FrontController')->runAdmin();
                //}
                register_activation_hook(__FILE__, array(PROD_Classes_ObjController::getClass('PROD_Classes_Helpers_Tools'), 'prod_activate'));

                if(PROD_Classes_Helpers_Tools::getOption('deleteDataCheck')=='true'){
                    register_deactivation_hook(__FILE__, array(PROD_Classes_ObjController::getClass('PROD_Classes_Helpers_Tools'),'PROD_deactivate'));
                }
                    
            } 
            //register_uninstall_hook(__FILE__,PROD_Classes_ObjController::getClass('PROD_Classes_Helpers_Tools')->PROD_deactivate());           

        } catch (Exception $e) {
        };
    
       