feat(wordpress): adiciona plugin wordpress (agents, skills, knowledge e metadados do projeto)
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
---
|
||||
name: branda-menu
|
||||
description: Organizacao do menu admin WordPress via Branda (branda-white-labeling) em seccoes Descomplicar standard. Computa Branda IDs a partir de slugs WP, constroi menu custom e guarda programaticamente via WP-CLI.
|
||||
layer: wiki
|
||||
---
|
||||
|
||||
# /branda-menu - Organizar Menu Admin WordPress
|
||||
|
||||
Skill para organizar o menu admin sidebar de qualquer site WordPress WiP usando o Branda (branda-white-labeling).
|
||||
|
||||
---
|
||||
|
||||
## Arquitectura Branda (Referencia Interna)
|
||||
|
||||
### Como o Branda gere menus
|
||||
|
||||
O Branda usa um modulo `admin/menu.php` que intercepta o render do menu admin WordPress e substitui pela configuracao custom.
|
||||
|
||||
**Options `wp_options` envolvidas:**
|
||||
|
||||
| Option | Funcao |
|
||||
|--------|--------|
|
||||
| `ultimatebranding_activated_modules` | Modulos activos (precisa ter `admin/menu.php`) |
|
||||
| `ub_custom_admin_menu` | Configuracao do menu custom por role |
|
||||
| `ub_saved_admin_menus` | Captura do menu nativo WP (so para UI Branda) |
|
||||
|
||||
### Algoritmo de ID (critico)
|
||||
|
||||
```php
|
||||
function branda_id($slug) {
|
||||
return "menu_item_" . substr(base_convert(md5($slug), 16, 32), 0, 12);
|
||||
}
|
||||
```
|
||||
|
||||
**Exemplo:** `index.php` -> `menu_item_42ho017e7jo0`
|
||||
|
||||
### Tipos de itens no menu
|
||||
|
||||
| Tipo | Campos chave | Uso |
|
||||
|------|-------------|-----|
|
||||
| **Section header** | `link_type: "none"`, `css_classes: "menu-highlight"` | Separador visual com titulo |
|
||||
| **Custom link** | `link_type: "custom"`, `custom_url: "..."` | Link manual |
|
||||
| **Native item** | `was_native: 1`, campos vazios | Item WP real |
|
||||
| **Hidden item** | `is_hidden: "1"`, `was_native: 1` | Item WP escondido |
|
||||
|
||||
### Mecanismo de merge (parse_args_deep)
|
||||
|
||||
Na renderizacao, o Branda faz merge do menu configurado com o menu WP real. **Regra critica:** Incluir **todos** os itens nativos no config (visiveis ou hidden). Se faltar algum, aparece na posicao default e quebra a organizacao.
|
||||
|
||||
---
|
||||
|
||||
## Seccoes Standard Descomplicar (9)
|
||||
|
||||
| # | Seccao | Dashicon | Conteudo tipico |
|
||||
|---|--------|----------|----------------|
|
||||
| 1 | **Suporte** | dashicons-admin-tools | Link Descomplicar |
|
||||
| 2 | **Admin** | dashicons-admin-generic | Painel, Utilizadores, Opcoes, Plugins, Ferramentas |
|
||||
| 3 | **Conteudo** | dashicons-admin-page | Paginas, CPTs, Artigos, Multimedia, ACF |
|
||||
| 4 | **Design** | dashicons-admin-appearance | Elementor, Modelos, Jeg Kit, Apresentacao |
|
||||
| 5 | **Marketing** | dashicons-megaphone | FluentCRM, Fluent Forms, Rank Math, WhatsApp |
|
||||
| 6 | **Idiomas** | dashicons-translation | Polylang/WPML, Loco Translate (se multilingue) |
|
||||
| 7 | **Performance** | dashicons-performance | WP Fastest Cache, WebP Express |
|
||||
| 8 | **Seguranca** | dashicons-shield | Wordfence, Complianz |
|
||||
| 9 | **WebMaster** | dashicons-admin-settings | Branda, Code Snippets, Activity Log |
|
||||
|
||||
---
|
||||
|
||||
## Procedimento
|
||||
|
||||
### Passo 1: Verificar pre-requisitos
|
||||
|
||||
```bash
|
||||
mcp__ssh-unified__ssh_execute server:"server" command:"wp plugin is-active branda-white-labeling --allow-root --path=/home/USER/SITE && echo ACTIVE || echo INACTIVE"
|
||||
|
||||
# Verificar modulo menu activo
|
||||
mcp__ssh-unified__ssh_execute server:"server" command:"wp eval '
|
||||
\$m = get_option(\"ultimatebranding_activated_modules\", array());
|
||||
echo isset(\$m[\"admin/menu.php\"]) ? \"MENU MODULE ACTIVE\" : \"MENU MODULE INACTIVE\";
|
||||
' --allow-root --path=/home/USER/SITE"
|
||||
```
|
||||
|
||||
Se modulo inactivo, activar:
|
||||
```bash
|
||||
mcp__ssh-unified__ssh_execute server:"server" command:"wp eval '
|
||||
\$m = get_option(\"ultimatebranding_activated_modules\", array());
|
||||
\$m[\"admin/menu.php\"] = \"yes\";
|
||||
update_option(\"ultimatebranding_activated_modules\", \$m);
|
||||
echo \"Activado\";
|
||||
' --allow-root --path=/home/USER/SITE"
|
||||
```
|
||||
|
||||
### Passo 2: Extrair menu nativo
|
||||
|
||||
**Opcao A (preferida): mu-plugin temporario** - criar mu-plugin que captura menu no proximo page load, depois ler a captura via `wp eval`.
|
||||
|
||||
**Opcao B (alternativa): Chrome DevTools** - navegar ao wp-admin e executar JS para listar itens.
|
||||
|
||||
### Passo 3: Mapear itens para seccoes
|
||||
|
||||
Com a lista de itens nativos, mapear cada um para a seccao correcta.
|
||||
|
||||
Mapeamento completo de slugs e IDs em: `references/mapeamento-slugs.md`
|
||||
|
||||
### Passo 4: Construir e guardar o menu
|
||||
|
||||
Script PHP template completo em: `references/script-template.md`
|
||||
|
||||
Executar com `wp eval-file` via SSH MCP.
|
||||
|
||||
### Passo 5: Verificar
|
||||
|
||||
```bash
|
||||
mcp__ssh-unified__ssh_execute server:"server" command:"wp eval '
|
||||
\$m = get_option(\"ub_custom_admin_menu\");
|
||||
\$items = \$m[\"administrator\"];
|
||||
echo \"Total: \" . count(\$items) . \"\n\";
|
||||
foreach (\$items as \$key => \$item) {
|
||||
\$hidden = !empty(\$item[\"is_hidden\"]) ? \" [HIDDEN]\" : \"\";
|
||||
\$type = !empty(\$item[\"was_native\"]) ? \"native\" : (!empty(\$item[\"link_type\"]) && \$item[\"link_type\"] == \"none\" ? \"header\" : \"custom\");
|
||||
\$title = !empty(\$item[\"title\"]) ? \$item[\"title\"] : \"(native)\";
|
||||
echo \"\$key => \$type: \$title\$hidden\n\";
|
||||
}
|
||||
' --allow-root --path=/home/USER/SITE"
|
||||
```
|
||||
|
||||
Verificar visualmente no browser.
|
||||
|
||||
### Passo 6: Limpar
|
||||
|
||||
```bash
|
||||
mcp__ssh-unified__ssh_execute server:"server" command:"rm -f /tmp/branda-menu-SITE.php"
|
||||
|
||||
mcp__ssh-unified__ssh_e
|
||||
@@ -0,0 +1,100 @@
|
||||
# Mapeamento de Slugs para Seccoes Branda
|
||||
|
||||
Referencia completa de mapeamento slug -> seccao e tabela de Branda IDs.
|
||||
|
||||
---
|
||||
|
||||
## Mapeamento Standard por Slug
|
||||
|
||||
```
|
||||
# Admin
|
||||
index.php -> Admin
|
||||
users.php -> Admin
|
||||
options-general.php -> Admin
|
||||
plugins.php -> Admin
|
||||
tools.php -> Admin
|
||||
|
||||
# Conteudo
|
||||
edit.php -> Conteudo (Artigos)
|
||||
edit.php?post_type=page -> Conteudo (Paginas)
|
||||
upload.php -> Conteudo (Multimedia)
|
||||
edit.php?post_type=acf-field-group -> Conteudo (ACF)
|
||||
edit.php?post_type=* -> Conteudo (CPTs)
|
||||
|
||||
# Design
|
||||
elementor-home -> Design (Elementor)
|
||||
edit.php?post_type=elementor_library -> Design (Modelos)
|
||||
jkit -> Design (Jeg Kit)
|
||||
themes.php -> Design (Apresentacao)
|
||||
|
||||
# Marketing
|
||||
fluentcrm-admin -> Marketing
|
||||
fluent_forms -> Marketing
|
||||
rank-math -> Marketing
|
||||
click-to-chat -> Marketing
|
||||
|
||||
# Idiomas (se multilingue)
|
||||
mlang -> Idiomas (Polylang)
|
||||
loco -> Idiomas (Loco Translate)
|
||||
|
||||
# Performance
|
||||
wpfastestcacheoptions -> Performance
|
||||
|
||||
# Seguranca
|
||||
Wordfence -> Seguranca
|
||||
complianz -> Seguranca
|
||||
|
||||
# WebMaster
|
||||
branding -> WebMaster (Branda)
|
||||
wpcode -> WebMaster (Code Snippets)
|
||||
|
||||
# Hidden
|
||||
separator1, separator2, separator-last -> Hidden
|
||||
edit-comments.php -> Hidden
|
||||
hello-elementor -> Hidden
|
||||
elementor -> Hidden (duplicado de elementor-home)
|
||||
```
|
||||
|
||||
**Itens que nao encaixam no standard:** Perguntar ao utilizador em que seccao colocar. Exemplos: WooCommerce, KiviCare, FareHarbor.
|
||||
|
||||
---
|
||||
|
||||
## IDs de Slugs Comuns (referencia rapida)
|
||||
|
||||
| Slug | Branda ID |
|
||||
|------|-----------|
|
||||
| `index.php` | `menu_item_42ho017e7jo0` |
|
||||
| `edit.php` | `menu_item_6lk5pbiakha0` |
|
||||
| `upload.php` | `menu_item_1jkdde99dfd0` |
|
||||
| `edit.php?post_type=page` | `menu_item_774p5endtlu0` |
|
||||
| `themes.php` | `menu_item_7jgmlsspgv60` |
|
||||
| `plugins.php` | `menu_item_5g2kqk93qi30` |
|
||||
| `users.php` | `menu_item_gajld83c8es0` |
|
||||
| `tools.php` | `menu_item_3t0no8pv5bfg` |
|
||||
| `options-general.php` | `menu_item_d1a8rsor9700` |
|
||||
| `edit-comments.php` | `menu_item_252pn6seih20` |
|
||||
| `separator1` | `menu_item_3u7nva84d1i0` |
|
||||
| `separator2` | `menu_item_6lm7mo14a4r0` |
|
||||
| `separator-last` | `menu_item_74g99t5jejn0` |
|
||||
| `elementor-home` | `menu_item_2kehh8g6nop0` |
|
||||
| `elementor` | `menu_item_27qkhd7iqao0` |
|
||||
| `edit.php?post_type=elementor_library` | `menu_item_3rubghs8krfg` |
|
||||
| `hello-elementor` | `menu_item_3q7v6ask7gpg` |
|
||||
| `fluentcrm-admin` | `menu_item_4a7t8bi9mt30` |
|
||||
| `fluent_forms` | `menu_item_ebai6etubd00` |
|
||||
| `rank-math` | `menu_item_148bl1t91os0` |
|
||||
| `click-to-chat` | `menu_item_1b65lubbpnd8` |
|
||||
| `Wordfence` | `menu_item_1077vi8mf9b0` |
|
||||
| `complianz` | `menu_item_5etmjgu9lnk0` |
|
||||
| `wpfastestcacheoptions` | `menu_item_4hqsn1kbum10` |
|
||||
| `branding` | `menu_item_7qde2b2f7670` |
|
||||
| `wpcode` | `menu_item_69igp9fj4tl0` |
|
||||
| `loco` | `menu_item_2c34vb7r1csg` |
|
||||
| `mlang` | `menu_item_24um676vv08g` |
|
||||
| `woocommerce` | Computar: `branda_id('woocommerce')` |
|
||||
| `edit.php?post_type=acf-field-group` | `menu_item_70ga2p32mc70` |
|
||||
|
||||
Para slugs nao listados, computar com:
|
||||
```bash
|
||||
wp eval 'echo "menu_item_" . substr(base_convert(md5("SLUG"), 16, 32), 0, 12);' --allow-root --path=/home/USER/SITE
|
||||
```
|
||||
@@ -0,0 +1,174 @@
|
||||
# Script Template Branda Menu Builder
|
||||
|
||||
Script PHP completo para construir e guardar menu Branda via WP-CLI.
|
||||
|
||||
---
|
||||
|
||||
## Template Base
|
||||
|
||||
```bash
|
||||
mcp__ssh-unified__ssh_execute server:"server" command:"cat > /tmp/branda-menu-SITE.php << 'PHPEOF'
|
||||
<?php
|
||||
/**
|
||||
* Branda menu builder for SITENAME
|
||||
* Generated by /branda-menu skill
|
||||
*/
|
||||
|
||||
function branda_id(\$slug) {
|
||||
return 'menu_item_' . substr(base_convert(md5(\$slug), 16, 32), 0, 12);
|
||||
}
|
||||
|
||||
function native_item(\$subs = array()) {
|
||||
return array(
|
||||
'title' => '', 'id_attribute' => '', 'css_classes' => '',
|
||||
'icon_svg' => '', 'icon_url' => '', 'icon_image_id' => '',
|
||||
'dashicon' => '', 'icon_type' => '', 'custom_url' => '',
|
||||
'link_type' => '', 'link_target' => '', 'is_invisible' => '',
|
||||
'is_hidden' => '', 'was_native' => 1, 'submenu' => \$subs
|
||||
);
|
||||
}
|
||||
|
||||
function hidden_item() {
|
||||
\$item = native_item();
|
||||
\$item['is_hidden'] = '1';
|
||||
return \$item;
|
||||
}
|
||||
|
||||
function section_header(\$title, \$dashicon) {
|
||||
return array(
|
||||
'icon_type' => 'dashicon', 'link_type' => 'none',
|
||||
'submenu' => array(), 'title' => \$title,
|
||||
'css_classes' => 'menu-highlight', 'dashicon' => \$dashicon
|
||||
);
|
||||
}
|
||||
|
||||
function custom_link(\$title, \$url, \$dashicon, \$target = '') {
|
||||
return array(
|
||||
'icon_type' => 'dashicon', 'link_type' => 'custom',
|
||||
'submenu' => array(), 'title' => \$title,
|
||||
'dashicon' => \$dashicon, 'link_target' => \$target,
|
||||
'custom_url' => \$url
|
||||
);
|
||||
}
|
||||
|
||||
// === BUILD MENU ===
|
||||
\$menu = array();
|
||||
|
||||
// 1. SUPORTE
|
||||
\$menu['menu_item_sec_suporte'] = section_header('Suporte', 'dashicons-admin-tools');
|
||||
\$menu['menu_item_desk_link'] = custom_link('Descomplicar', 'https://desk.descomplicar.pt/', 'dashicons-admin-comments', '_blank');
|
||||
|
||||
// 2. ADMIN
|
||||
\$menu['menu_item_sec_admin'] = section_header('Admin', 'dashicons-admin-generic');
|
||||
\$menu[branda_id('index.php')] = native_item();
|
||||
\$menu[branda_id('users.php')] = native_item();
|
||||
\$menu[branda_id('options-general.php')] = native_item();
|
||||
\$menu[branda_id('plugins.php')] = native_item();
|
||||
\$menu[branda_id('tools.php')] = native_item();
|
||||
|
||||
// 3. CONTEUDO
|
||||
\$menu['menu_item_sec_conteudo'] = section_header('Conteudo', 'dashicons-admin-page');
|
||||
\$menu[branda_id('edit.php?post_type=page')] = native_item();
|
||||
// [INSERIR CPTs DO PROJECTO AQUI]
|
||||
\$menu[branda_id('edit.php')] = native_item();
|
||||
\$menu[branda_id('upload.php')] = native_item();
|
||||
\$menu[branda_id('edit.php?post_type=acf-field-group')] = native_item();
|
||||
|
||||
// 4. DESIGN
|
||||
\$menu['menu_item_sec_design'] = section_header('Design', 'dashicons-admin-appearance');
|
||||
\$menu[branda_id('elementor-home')] = native_item();
|
||||
\$menu[branda_id('edit.php?post_type=elementor_library')] = native_item();
|
||||
// \$menu[branda_id('jkit')] = native_item(); // Se Jeg Kit activo
|
||||
\$menu[branda_id('themes.php')] = native_item();
|
||||
|
||||
// 5. MARKETING
|
||||
\$menu['menu_item_sec_marketing'] = section_header('Marketing', 'dashicons-megaphone');
|
||||
\$menu[branda_id('fluentcrm-admin')] = native_item();
|
||||
\$menu[branda_id('fluent_forms')] = native_item();
|
||||
\$menu[branda_id('rank-math')] = native_item();
|
||||
\$menu[branda_id('click-to-chat')] = native_item();
|
||||
|
||||
// 6. IDIOMAS (se multilingue)
|
||||
// \$menu['menu_item_sec_idiomas'] = section_header('Idiomas', 'dashicons-translation');
|
||||
// \$menu[branda_id('mlang')] = native_item();
|
||||
// \$menu[branda_id('loco')] = native_item();
|
||||
|
||||
// 7. PERFORMANCE
|
||||
\$menu['menu_item_sec_performance'] = section_header('Performance', 'dashicons-performance');
|
||||
\$menu[branda_id('wpfastestcacheoptions')] = native_item();
|
||||
|
||||
// 8. SEGURANCA
|
||||
\$menu['menu_item_sec_seguranca'] = section_header('Seguranca', 'dashicons-shield');
|
||||
\$menu[branda_id('Wordfence')] = native_item();
|
||||
\$menu[branda_id('complianz')] = native_item();
|
||||
|
||||
// 9. WEBMASTER
|
||||
\$menu['menu_item_sec_webmaster'] = section_header('WebMaster', 'dashicons-admin-settings');
|
||||
\$menu[branda_id('branding')] = native_item();
|
||||
\$menu[branda_id('wpcode')] = native_item();
|
||||
|
||||
// HIDDEN
|
||||
\$menu[branda_id('separator1')] = hidden_item();
|
||||
\$menu[branda_id('separator2')] = hidden_item();
|
||||
\$menu[branda_id('separator-last')] = hidden_item();
|
||||
\$menu[branda_id('edit-comments.php')] = hidden_item();
|
||||
\$menu[branda_id('hello-elementor')] = hidden_item();
|
||||
\$menu[branda_id('elementor')] = hidden_item();
|
||||
|
||||
// SAVE
|
||||
update_option('ub_custom_admin_menu', array('administrator' => \$menu));
|
||||
wp_cache_flush();
|
||||
|
||||
\$visible = count(array_filter(\$menu, function(\$i) { return empty(\$i['is_hidden']); }));
|
||||
\$hidden = count(\$menu) - \$visible;
|
||||
echo "Menu guardado: \$visible visiveis + \$hidden hidden = " . count(\$menu) . " total\n";
|
||||
PHPEOF
|
||||
echo 'Script criado'
|
||||
"
|
||||
|
||||
# Executar
|
||||
mcp__ssh-unified__ssh_execute server:"server" command:"wp eval-file /tmp/branda-menu-SITE.php --allow-root --path=/home/USER/SITE"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Adaptacoes por Tipo de Site
|
||||
|
||||
### Sites multilingue (Polylang/WPML)
|
||||
|
||||
Descomentar seccao Idiomas no script. Adicionar:
|
||||
```php
|
||||
$menu['menu_item_sec_idiomas'] = section_header('Idiomas', 'dashicons-translation');
|
||||
$menu[branda_id('mlang')] = native_item(); // Polylang
|
||||
$menu[branda_id('loco')] = native_item(); // Loco Translate
|
||||
```
|
||||
|
||||
### Sites WooCommerce
|
||||
|
||||
Adicionar seccao e-Commerce entre Marketing e Idiomas:
|
||||
```php
|
||||
$menu['menu_item_sec_ecommerce'] = section_header('e-Commerce', 'dashicons-cart');
|
||||
$menu[branda_id('woocommerce')] = native_item();
|
||||
```
|
||||
|
||||
### Sites Care (KiviCare)
|
||||
|
||||
Adicionar seccao Clinica entre Marketing e Idiomas:
|
||||
```php
|
||||
$menu['menu_item_sec_clinica'] = section_header('Clinica', 'dashicons-heart');
|
||||
$menu[branda_id('kivicare-...')] = native_item(); // Verificar slug exacto
|
||||
```
|
||||
|
||||
### CPTs customizados
|
||||
|
||||
Adicionar na seccao Conteudo, antes de Artigos:
|
||||
```php
|
||||
$menu[branda_id('edit.php?post_type=SLUG_CPT')] = native_item();
|
||||
```
|
||||
|
||||
### Itens desconhecidos
|
||||
|
||||
Se o menu nativo tiver itens que nao encaixam no mapeamento standard:
|
||||
1. Perguntar ao utilizador onde colocar
|
||||
2. Se plugin temporario/teste: adicionar ao Hidden
|
||||
3. Se plugin permanente: criar seccao propria ou adicionar a seccao existente
|
||||
Reference in New Issue
Block a user