<?php
/**
 * Plugin Name: Pop3D Charts – 2D/3D Data Visualizer
 * Description: Create interactive 2D and 3D charts in the WordPress Block Editor.
 * Version: 1.7.0
 * Author: Daily Ape
 * Text Domain: pop3d-charts
 * Domain Path: /languages
 * License: GPLv2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Requires at least: 6.7
 * Requires PHP: 7.4
 */

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

/**
 * Plugin-Anker-Konstanten. MÜSSEN hier stehen (nicht in includes/constants.php),
 * damit __FILE__ auf die Plugin-Hauptdatei zeigt — sonst registrieren Block-/Asset-
 * Pfade falsch (z.B. plugin_dir_path(includes/…) landet in .../includes/).
 */
if (!defined('CE_PD_VERSION')) {
    $ce_pd_header = get_file_data(__FILE__, ['Version' => 'Version']);
    define('CE_PD_VERSION', !empty($ce_pd_header['Version']) ? $ce_pd_header['Version'] : '0.0.0');
    unset($ce_pd_header);
}
if (!defined('CE_PD_DIR')) define('CE_PD_DIR', plugin_dir_path(__FILE__));
if (!defined('CE_PD_URL')) define('CE_PD_URL', plugin_dir_url(__FILE__));

/**
 * Bootstrap: lädt die Plugin-Teile aus includes/ in fester Reihenfolge.
 *
 * Reihenfolge ist wichtig, weil spätere Module auf Konstanten/Helper früherer zugreifen:
 *   constants      – ce_pd_asset_url/_ver/_bust/contrast (CE_PD_VERSION/DIR/URL werden oben gesetzt)
 *   assets         – Loader-Filter, Block-Registrierung, Textdomain, block_type_metadata
 *   sanitize       – Input-Sanitisierung + Label-Resolver (werden von render genutzt)
 *   render         – SSR: aria-label + ce_pd_render_block + has_block
 *   importmap      – window.__CE_PD_*-Globals (wp_enqueue_script / Inline) für Frontend/Editor
 *   editor-assets  – Script-Module-Registrierung + editor-Data-Filter (Icons/XLSX/i18n)
 */
require_once __DIR__ . '/includes/constants.php';
require_once __DIR__ . '/includes/assets.php';
require_once __DIR__ . '/includes/sanitize.php';
require_once __DIR__ . '/includes/render.php';
require_once __DIR__ . '/includes/importmap.php';
require_once __DIR__ . '/includes/editor-assets.php';

/**
 * Trigger für Add-on-Plugins, nach dem letzten require_once.
 */
add_action(
    'plugins_loaded',
    static function () {
        do_action('ce_pd_plugin_loaded');
    },
    20
);
