Skip to content

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

@eduayala

Description

@eduayala

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).
  9. Expand the newly added menu item.
  10. 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

Screenshot 2

Screenshot 2024-09-18 at 16-03-46 Menus ‹ MIT Technology Review — WordPress

Screenshot 3

Screenshot 2024-09-18 at 15-52-22 Menus ‹ MIT Technology Review — WordPress

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions