SLB: Notes – Admin: Navigation Objects: Pages: Properties

By Sol in Lab

Differentiating between WP and custom menus

  • When setting a menu (WP or custom) as parent of an admin UI object (e.g. submenu)
  • Currently: Wrapping WP menu ID in square brackets (e.g. [media])
    • - Extra work
    • + Simple to specify when creating menus


  1. Add “default” property to class definition
    • bool value (true/false)
    • Set by add_wp_page() method (so also set when using any add_[type]_page() methods (add_media_page(), etc.)
    • + Clear when defining and retrieving
    • If not WP Parent, add prefix to parent ID when building menus
      • ? Better to prefix from the start? Simpler?
    • - Cannot specify WP parent using add_page() method (must use add_wp_page())
      • + Might be better this way (clearer)
    • + Backwards compatible: If new WP menus are added, can always use add_wp_page() directly to specify parent if add_[type]_page() method is not available for new menu
  2. Custom menus are prefixed
    • When adding page, parent is slb_[name] in add_page() method
      • Example: add_page($page_id, 'slb_top', ...)
    • Look for prefix when building menus to determine if parent is a WP or custom menu
    • + Efficient: prefix already added to parent
    • - Must always remember to add prefix
      • + Though still better than always having to wrap WP menu names (e.g. [media])
    • + Can use add_page() for all pages (WP and custom children)
    • - Custom menus are not prefixed when created
      • Creates disconnect when adding menus