query(
[
'post_type' => 'boxzilla-box',
'post_status' => 'publish',
'posts_per_page' => -1,
'ignore_sticky_posts' => true,
'no_found_rows' => true,
]
);
return $posts;
}
/**
* Output menu links.
*/
public function nav_menu_links()
{
$posts = $this->get_boxes();
?>
esc_html__('Boxzilla Pop-ups', 'boxzilla'),
'type_label' => esc_html__('Boxzilla Pop-ups', 'boxzilla'),
'type' => 'boxzilla_nav',
'object' => 'boxzilla_box',
];
return $item_types;
}
/**
* Register account endpoints to customize nav menu items.
*
* @since 3.1.0
* @param array $items List of nav menu items.
* @param string $type Nav menu type.
* @param string $object Nav menu object.
* @param integer $page Page number.
* @return array
*/
public function register_customize_nav_menu_items($items = [], $type = '', $object = '', $page = 0)
{
if ('boxzilla_box' !== $object) {
return $items;
}
// Don't allow pagination since all items are loaded at once.
if (0 < $page) {
return $items;
}
$boxes = $this->get_boxes();
foreach ($boxes as $i => $post) {
$items[] = [
'id' => $i,
'title' => $post->post_title,
'type_label' => esc_html__('Custom Link', 'boxzilla'),
'url' => "#boxzilla-{$post->ID}",
];
}
return $items;
}
}