alleyinteractive / alleyinteractive/wordpress-fieldmanager

Fields not appearing for newly added Menu Item (appearing after saving)

Aperta
#879 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
PHP
Stelle
563
Fork
99
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### Description of the bug

Context for Menu Item (`class-fieldmanager-context-menuitem.php`) is not working properly. I would expect to see the fields when a new Menu Item is added to a Menu in Appearance -> Menus without the need to save the menu to refresh the page, but instead I need to save the menu, reloading the page and only then the fields appears for the newly added Menu Item.

### Steps To Reproduce

### Requirements:
1. WordPress and FieldManager 1.6.1 installed.
2. Add Menus support to the theme `add_theme_support( 'menus' );`.
3. Add a menu with some menu items inside.
4. Add the code below to your functions.php file to add some fields to Menu Item.

```
add_action( 'fm_nav_menu', 'fm_expanded_menu_fields' );

function fm_expanded_menu_fields() {
$fm = new Fieldmanager_Group( array(
'name' => 'contact_information',
'children' => array(
'name' => new Fieldmanager_Textfield( 'Name' ),
'phone' => new Fieldmanager_Textfield( 'Phone Number' ),
'website' => new Fieldmanager_Link( 'Website' ),
),
) );
$fm->add_nav_menu_fields();
}
```

### Steps:
1. Go to Appearance -> Menus.
2. Select the menu you've created.
3. Expand any existing menu item.
4. Check that fields are visible. (See Screenshot 1)
5. Add a new item to the menu a Custom Link for this example.
6. Expand the newly added menu item.
7. Check that fields are not visible. (See Screenshot 2)
8. Save the menu (the page will reload).
10. Expand the newly added menu item.
11. Check that fields are visible. (See Screenshot 3)

### Additional Information

### Screenshot 1
![Screenshot 2024-09-18 at 16-02-46 Menus ‹ MIT Technology Review — WordPress](https://github.com/user-attachments/assets/05a7107e-b4cd-47e7-8b88-630438acf339)

### Screenshot 2
![Screenshot 2024-09-18 at 16-03-46 Menus ‹ MIT Technology Review — WordPress](https://github.com/user-attachments/assets/b5a1ef40-2bd2-498e-8d07-9154e6494713)

### Screenshot 3
![Screenshot 2024-09-18 at 15-52-22 Menus ‹ MIT Technology Review — WordPress](https://github.com/user-attachments/assets/15974880-15a0-4954-8911-80002ec897ae)

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.