diff --git a/alcastromol-function.php b/alcastromol-function.php
index b5c6e58..7a64633 100644
--- a/alcastromol-function.php
+++ b/alcastromol-function.php
@@ -87,7 +87,7 @@ function alcastromol_check_oxygen() {
if (alcastromol_get_oxygen_option() === '1' && !alcastromol_is_oxygen_installed()) {
add_action('admin_notices', function () {
echo '
-
Alcastromol Functions: Oxygen no está instalado. Tailwind v3 funciona de forma independiente. Puedes activar Oxygen más tarde desde Tailwind → Modo.
+
Alcastromol Functions: Oxygen no está instalado. Tailwind v3 funciona de forma independiente. Puedes activar Oxygen más tarde desde Centro de funciones → Tailwind v3.
';
});
}
@@ -170,6 +170,15 @@ register_activation_hook(__FILE__, 'alcastromol_setup_general_settings');
register_deactivation_hook(__FILE__, 'alcastromol_cleanup_options');
+/*
+|--------------------------------------------------------------------------
+| Centro de funciones
+|--------------------------------------------------------------------------
+*/
+
+alcastromol_require('functions/admin/modules-dashboard.php');
+alcastromol_require('functions/optimizer/optimizer.php');
+
/*
|--------------------------------------------------------------------------
| TailwindCSS
diff --git a/functions/admin/modules-dashboard.php b/functions/admin/modules-dashboard.php
new file mode 100644
index 0000000..1a9cda8
--- /dev/null
+++ b/functions/admin/modules-dashboard.php
@@ -0,0 +1,398 @@
+ '1',
+ 'cache' => '1',
+ 'optimizer' => '0',
+ ];
+
+}
+
+function alcastromol_get_modules() {
+
+ $saved = get_option('alcastromol_modules', []);
+
+ if (!is_array($saved)) {
+ $saved = [];
+ }
+
+ return array_merge(alcastromol_default_modules(), $saved);
+
+}
+
+function alcastromol_is_module_active($module) {
+
+ $modules = alcastromol_get_modules();
+
+ return isset($modules[$module]) && $modules[$module] === '1';
+
+}
+
+function alcastromol_module_icon($name) {
+
+ $icons = [
+ 'tailwind' => '',
+ 'cache' => '',
+ 'optimizer' => '',
+ ];
+
+ return isset($icons[$name]) ? $icons[$name] : '';
+
+}
+
+function alcastromol_get_module_cards() {
+
+ return [
+ 'tailwind' => [
+ 'title' => 'Tailwind v3',
+ 'desc' => 'Carga Tailwind CSS v3 en el sitio. En desarrollo usa el CDN y en producción el CSS compilado, con la configuración del tema.',
+ 'settings' => admin_url('admin.php?page=alcastromol-tailwind-mode'),
+ 'bg' => '#e8f3ff',
+ 'color' => '#3b82f6',
+ 'icon' => 'tailwind',
+ 'badge' => '',
+ 'locked' => false,
+ ],
+ 'cache' => [
+ 'title' => 'Cache de Tailwind',
+ 'desc' => 'Guarda el HTML del sitio para que Tailwind detecte las clases de páginas, entradas, productos, taxonomías y templates.',
+ 'settings' => admin_url('admin.php?page=tailwind-cache'),
+ 'bg' => '#f4e9ff',
+ 'color' => '#9333ea',
+ 'icon' => 'cache',
+ 'badge' => '',
+ 'locked' => false,
+ ],
+ 'optimizer' => [
+ 'title' => 'Optimizador de archivos',
+ 'desc' => 'Detecta los CSS y JS del sitio. Puedes retirar su URL, agrupar el CSS crítico y el no crítico, juntar el JS en el header, o marcar data-nowprocket y media print.',
+ 'settings' => admin_url('admin.php?page=alcastromol-optimizer'),
+ 'bg' => '#e7f8ef',
+ 'color' => '#16a34a',
+ 'icon' => 'optimizer',
+ 'badge' => '',
+ 'locked' => false,
+ ],
+ ];
+
+}
+
+add_action('admin_menu', function () {
+
+ add_menu_page(
+ 'Centro de funciones',
+ 'Centro de funciones',
+ 'manage_options',
+ 'alcastromol-functions',
+ 'alcastromol_functions_dashboard_page',
+ 'dashicons-screenoptions',
+ 58
+ );
+
+ add_submenu_page(
+ 'alcastromol-functions',
+ 'Centro de funciones',
+ 'Inicio',
+ 'manage_options',
+ 'alcastromol-functions',
+ 'alcastromol_functions_dashboard_page'
+ );
+
+}, 9);
+
+add_action('wp_ajax_alcastromol_toggle_module', function () {
+
+ if (!current_user_can('manage_options')) {
+ wp_send_json_error(['message' => 'No tienes permisos.'], 403);
+ }
+
+ check_ajax_referer('alcastromol_toggle_module', 'nonce');
+
+ $module = sanitize_key($_POST['module'] ?? '');
+ $active = ($_POST['active'] ?? '0') === '1' ? '1' : '0';
+ $allowed = ['tailwind', 'cache', 'optimizer'];
+
+ if (!in_array($module, $allowed, true)) {
+ wp_send_json_error(['message' => 'Esta función todavía no se puede activar.'], 400);
+ }
+
+ $modules = alcastromol_get_modules();
+ $modules[$module] = $active;
+
+ update_option('alcastromol_modules', $modules);
+
+ wp_send_json_success([
+ 'module' => $module,
+ 'active' => $active,
+ ]);
+
+});
+
+function alcastromol_functions_dashboard_page() {
+
+ if (!current_user_can('manage_options')) {
+ return;
+ }
+
+ $modules = alcastromol_get_modules();
+ $cards = alcastromol_get_module_cards();
+ $nonce = wp_create_nonce('alcastromol_toggle_module');
+
+ ?>
+
+
Centro de funciones
+
Activa las funciones del plugin y abre sus ajustes.