<?php
/**
 * Plugin Name:       Advanced Block Controls - ABC
 * Description:       The most powerful block styling & customization toolkit for Gutenberg
 * Requires at least: 6.4.3
 * Requires PHP:      7.4.3
 * Version:           2.1.0
 * Author:            wptali
 * License:           GPL-2.0-or-later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       advanced-block-controls
 */

namespace AdvancedBlockControls;

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

// Define plugin version for easy access.
define('ABCON_VERSION', '2.1.0');

// Define paths for easy includes.
define('ABCON_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('ABCON_PLUGIN_URL', plugin_dir_url(__FILE__));
define('ABCON_FILE', __FILE__);


// Classes
require_once plugin_dir_path(__FILE__) . 'classes/ABCPlugin.php';
require_once plugin_dir_path(__FILE__) . 'classes/AttributesManager.php';
require_once plugin_dir_path(__FILE__) . 'classes/MenuManager.php';
require_once plugin_dir_path(__FILE__) . 'classes/CssManager.php';
require_once plugin_dir_path(__FILE__) . 'classes/AssetsManager.php';
require_once plugin_dir_path(__FILE__) . 'classes/RegistrationManager.php';
require_once plugin_dir_path(__FILE__) . 'classes/RestApiController.php';
require_once plugin_dir_path(__FILE__) . 'classes/Utils.php';
require_once plugin_dir_path(__FILE__) . 'classes/Upgrader.php';

$abcPlugin = new ABCPlugin();


add_filter('gettext', function($translated_text, $text, $domain) {
    if ($text === 'Hello, World!' && $domain === 'advanced-block-controls') {
        error_log("Original: $text, Translated: $translated_text");
    }
    return $translated_text;
}, 10, 3);


// Add action when plugin is loaded for the pro version to load
do_action( 'abcon_free_plugin_loaded' );


// Upon activation, redirect to the Welcome page.
register_activation_hook(__FILE__, function () {
    add_option('abcon_activation_redirect', true);
});

add_action('admin_init', function () {
    if (get_option('abcon_activation_redirect')) {
        delete_option('abcon_activation_redirect');
        wp_safe_redirect(admin_url('admin.php?page=advanced-block-controls-settings'));
        exit;
    }
});