process_menu_item() public method

Fails for draft, orphaned menu items and those without an associated nav_menu or an invalid nav_menu term. If the post type or term object which the menu item represents doesn't exist then the menu item will not be imported (waits until the end of the import to retry again before discarding).
public process_menu_item ( array $item )
$item array Menu item details from WXR file
 public function process_menu_item($item)
 {
     $this->updateStats();
     parent::process_menu_item($item);
     // We need to step in to import custom meta assigned to a menu item because WP Importer won't do it for us
     // get the post (nav-menu-item) id
     $id = intval($item['post_id']);
     // check if it has been imported by WP Importer
     $id = empty($this->processed_menu_items[$id]) ? false : $this->processed_menu_items[$id];
     if ($id && is_array($item['postmeta'])) {
         // it seems it has, now cycle all metas to search ours
         foreach ($item['postmeta'] as $meta) {
             if ($meta['key'] === PE_THEME_META) {
                 // bingo, update the menu item meta
                 update_post_meta($id, PE_THEME_META, maybe_unserialize($meta['value']));
                 break;
             }
         }
     }
 }
Example #2
0
 public function process_menu_item($item)
 {
     $this->updateStats();
     parent::process_menu_item($item);
 }