<?php
/**
 * Plugin Name:       Auranet Page and Theme Builder
 * Plugin URI:        https://www.auranet.com.br/aura-builder/
 * Description:       Visual page and theme builder by Auranet. Edit pages, headers and footers with a free, fully functional visual editor.
 * Version:           1.2.37
 * Requires at least: 6.4
 * Requires PHP:      8.1
 * Author:            Auranet
 * Author URI:        https://www.auranet.com.br/
 * License:           GPL-2.0-or-later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       auranet-page-theme-builder
 * Domain Path:       /languages
 *
 * @package AuraBuilder
 */

declare(strict_types=1);

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

define( 'AURA_BUILDER_VERSION', '1.2.37' );
define( 'AURA_BUILDER_FILE', __FILE__ );
define( 'AURA_BUILDER_PATH', plugin_dir_path( __FILE__ ) );
define( 'AURA_BUILDER_URL', plugin_dir_url( __FILE__ ) );
/** Unique meta keys (aptb_ = Auranet Page Theme Builder). */
define( 'AURA_BUILDER_META_DOC', '_aptb_document' );
define( 'AURA_BUILDER_META_ON', '_aptb_enabled' );
/** Legacy meta (pre-1.0.2) — read fallback in DocumentRepository. */
define( 'AURA_BUILDER_META_DOC_LEGACY', '_aura_builder_document' );
define( 'AURA_BUILDER_META_ON_LEGACY', '_aura_builder_enabled' );
/** Brand assets (logo.png + resized variants in assets/images/). */
define( 'AURA_BUILDER_LOGO_URL', AURA_BUILDER_URL . 'assets/images/logo.png' );
define( 'AURA_BUILDER_LOGO_64_URL', AURA_BUILDER_URL . 'assets/images/logo-64.png' );
define( 'AURA_BUILDER_LOGO_32_URL', AURA_BUILDER_URL . 'assets/images/logo-32.png' );

require_once AURA_BUILDER_PATH . 'src/Autoloader.php';
\AuraBuilder\Autoloader::register( AURA_BUILDER_PATH . 'src/', 'AuraBuilder\\' );

register_activation_hook(
	__FILE__,
	static function (): void {
		$role = get_role( 'administrator' );
		if ( $role ) {
			$role->add_cap( 'edit_aura_builder' );
		}
		flush_rewrite_rules();
	}
);

register_deactivation_hook(
	__FILE__,
	static function (): void {
		flush_rewrite_rules();
	}
);

add_action(
	'plugins_loaded',
	static function (): void {
		// WordPress.org loads translations automatically (WP 4.6+). No load_plugin_textdomain().
		\AuraBuilder\Plugin::instance()->boot();
	},
	1
);
