query(
array(
'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();
?>
__( 'Boxzilla Pop-ups', 'boxzilla' ),
'type_label' => __( '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 = array(), $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[] = array(
'id' => $i,
'title' => $post->post_title,
'type_label' => __( 'Custom Link', 'boxzilla' ),
'url' => sprintf( '#boxzilla-%d', $post->ID ),
);
}
return $items;
}
}