<?php
/**
 * Plugin Name:       WPFAQBlock
 * Plugin URI:        https://www.wpfaqblock.com/
 * Description:       Simple FAQ and accordion plugin with easy to use Gutenberg blocks, shortcodes and widgets.
 * Version:           2.0.0
 * Requires at least: 6.1
 * Requires PHP:      7.4
 * Author:            Creative Werk Designs
 * Author URI:        https://creativewerkdesigns.com
 * License:           GPL-2.0-or-later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       wpfaqblock
 * Domain Path:       /languages
 *
 * @package WPFAQBlock
 */

// Prevent direct file access.
if (!defined('ABSPATH')) {
	exit;
}

// ──────────────────────────────────────────────
// Plugin Constants
// ──────────────────────────────────────────────

/** Plugin version. */
define('WPFAQBLOCK_VERSION', '2.0.0');

/** Absolute path to the plugin directory (with trailing slash). */
define('WPFAQBLOCK_DIR', plugin_dir_path(__FILE__));

/** Plugin URL (with trailing slash). */
define('WPFAQBLOCK_URL', plugins_url('/', __FILE__));

/** Plugin basename, e.g. wpfaqblock/wpfaqblock.php */
define('WPFAQBLOCK_BASENAME', plugin_basename(__FILE__));



// ──────────────────────────────────────────────
// Load core includes
// ──────────────────────────────────────────────

require_once WPFAQBLOCK_DIR . 'includes/class-wpfaqblock-loader.php';
require_once WPFAQBLOCK_DIR . 'includes/class-wpfaqblock-cpt.php';
require_once WPFAQBLOCK_DIR . 'includes/class-wpfaqblock-taxonomy.php';
require_once WPFAQBLOCK_DIR . 'includes/class-wpfaqblock-data.php';
require_once WPFAQBLOCK_DIR . 'includes/class-wpfaqblock-ajax.php';
require_once WPFAQBLOCK_DIR . 'includes/class-wpfaqblock-shortcode.php';
require_once WPFAQBLOCK_DIR . 'includes/class-wpfaqblock-block.php';
require_once WPFAQBLOCK_DIR . 'includes/class-wpfaqblock-settings.php';
require_once WPFAQBLOCK_DIR . 'includes/class-wpfaqblock-ai.php';
require_once WPFAQBLOCK_DIR . 'includes/class-wpfaqblock-admin.php';

// ──────────────────────────────────────────────
// Boot the plugin
// ──────────────────────────────────────────────

/**
 * Initialises the plugin by wiring up all registered hooks.
 *
 * Called on 'plugins_loaded' so all WordPress APIs are available.
 *
 * @since 2.0.0
 * @return void
 */
function wpfaqblock_init()
{
	$loader = new WPFAQBlock_Loader();
	$admin = new WPFAQBlock_Admin();
	$cpt = new WPFAQBlock_CPT();
	$taxonomy = new WPFAQBlock_Taxonomy();
	$ajax = new WPFAQBlock_Ajax();
	$shortcode = new WPFAQBlock_Shortcode();
	$block = new WPFAQBlock_Block();
	$settings = new WPFAQBlock_Settings();
	$ai = new WPFAQBlock_AI();

	// ── Data layer
	$loader->add_action('init', $cpt, 'register', 10, 0);
	$loader->add_action('init', $taxonomy, 'register', 11, 0);

	// ── AJAX
	$loader->add_action('init', $ajax, 'register_hooks', 12, 0);
	$loader->add_action('init', $ai, 'register', 12, 0);

	// ── Shortcode, Block + frontend assets
	$loader->add_action('init', $shortcode, 'register', 13, 0);
	$loader->add_action('init', $block, 'register', 13, 0);

	// ── Settings (uses its own admin_menu hook internally)
	$settings->register();

	// ── Admin ───────────────────────────────────
	$loader->add_action('admin_menu', $admin, 'register_menus');
	$loader->add_filter('post_row_actions', $admin, 'remove_view_action', 10, 2);



	$loader->run();
}
add_action('plugins_loaded', 'wpfaqblock_init');

