Something like this should do it:
switch ( $item[ 'type' ] ) {
case 'post_type':
$post = get_post( $item['object_id'] );
$menu_item = array(
'id' => abs( $item['ID'] ),
'order' => (int) $item['menu_order'],
'parent' => abs( $item['menu_item_parent'] ),
'title' => $item['title'],
'url' => $item['url'],
'attr' => $item['attr_title'],
'target' => $item['target'],
'classes' => implode( ' ', $item['classes'] ),
'xfn' => $item['xfn'],
'description' => $item['description'],
'object_id' => abs( $item['object_id'] ),
'object' => $item['object'],
'object_slug' => $post !== null ? $post->post_name : '',
'type' => $item['type'],
'type_label' => $item['type_label'],
);
break;
default:
$menu_item = array(
'id' => abs( $item['ID'] ),
'order' => (int) $item['menu_order'],
'parent' => abs( $item['menu_item_parent'] ),
'title' => $item['title'],
'url' => $item['url'],
'attr' => $item['attr_title'],
'target' => $item['target'],
'classes' => implode( ' ', $item['classes'] ),
'xfn' => $item['xfn'],
'description' => $item['description'],
'object_id' => abs( $item['object_id'] ),
'object' => $item['object'],
'object_slug' => null,
'type' => $item['type'],
'type_label' => $item['type_label'],
);
break;
}
-
This reply was modified 4 years, 2 months ago by jaroat.