bp_nouveau_has_nav( array $args = array() )
Init the Navigation Loop and check it has items.
Description
Parameters
- $args
-
(Optional) Array of arguments.
- 'type'
(string) The type of Nav to get (primary or secondary) Default 'primary'. Required. - 'object'
(string) The object to get the nav for (eg: 'directory', 'group_manage', or any custom object). Default ''. Optional - 'user_has_access'
(bool) Used by the secondary member's & group's nav. Default true. Optional. - 'show_for_displayed_user'
(bool) Used by the primary member's nav. Default true. Optional.
Default value: array()
- 'type'
Return
(bool) True if the Nav contains items. False otherwise.
Source
File: bp-templates/bp-nouveau/includes/template-tags.php
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | function bp_nouveau_has_nav( $args = array () ) { $bp_nouveau = bp_nouveau(); $n = wp_parse_args( $args , array ( 'type' => 'primary' , 'object' => '' , 'user_has_access' => true, 'show_for_displayed_user' => true, ) ); if ( empty ( $n [ 'type' ] ) ) { return false; } $nav = array (); $bp_nouveau ->displayed_nav = '' ; $bp_nouveau ->object_nav = $n [ 'object' ]; if ( bp_is_directory() || 'directory' === $bp_nouveau ->object_nav ) { $bp_nouveau ->displayed_nav = 'directory' ; $nav = $bp_nouveau ->directory_nav->get_primary(); // So far it's only possible to build a Group nav when displaying it. } elseif ( bp_is_group() ) { $bp_nouveau ->displayed_nav = 'groups' ; $parent_slug = bp_get_current_group_slug(); $group_nav = buddypress()->groups->nav; if ( 'group_manage' === $bp_nouveau ->object_nav && bp_is_group_admin_page() ) { $parent_slug .= '_manage' ; } else if ( 'group_media' === $bp_nouveau ->object_nav && bp_is_group_media() ) { $parent_slug .= '_media' ; } else if ( 'group_members' === $bp_nouveau ->object_nav && bp_is_group_members() ) { $parent_slug .= '_members' ; /** * If it's not the Admin tabs, reorder the Group's nav according to the * customizer setting. */ } else { bp_nouveau_set_nav_item_order( $group_nav , bp_nouveau_get_appearance_settings( 'group_nav_order' ), $parent_slug ); } $nav = $group_nav ->get_secondary( array ( 'parent_slug' => $parent_slug , 'user_has_access' => (bool) $n [ 'user_has_access' ], ) ); // Build the nav for the displayed user } elseif ( bp_is_user() ) { $bp_nouveau ->displayed_nav = 'personal' ; $user_nav = buddypress()->members->nav; if ( 'secondary' === $n [ 'type' ] ) { $nav = $user_nav ->get_secondary( array ( 'parent_slug' => bp_current_component(), 'user_has_access' => (bool) $n [ 'user_has_access' ], ) ); } else { $args = array (); if ( true === (bool) $n [ 'show_for_displayed_user' ] && ! bp_is_my_profile() ) { $args = array ( 'show_for_displayed_user' => true ); } // Reorder the user's primary nav according to the customizer setting. bp_nouveau_set_nav_item_order( $user_nav , bp_nouveau_get_appearance_settings( 'user_nav_order' ) ); $nav = $user_nav ->get_primary( $args ); } } elseif ( ! empty ( $bp_nouveau ->object_nav ) ) { $bp_nouveau ->displayed_nav = $bp_nouveau ->object_nav; /** * Use the filter to use your specific Navigation. * Use the $n param to check for your custom object. * * @since BuddyPress 3.0.0 * * @param array $nav The list of item navigations generated by the BP_Core_Nav API. * @param array $n The arguments of the Navigation loop. */ $nav = apply_filters( 'bp_nouveau_get_nav' , $nav , $n ); } // The navigation can be empty. if ( $nav === false ) { $nav = array (); } $bp_nouveau ->sorted_nav = array_values ( $nav ); if ( 0 === count ( $bp_nouveau ->sorted_nav ) || ! $bp_nouveau ->displayed_nav ) { unset( $bp_nouveau ->sorted_nav, $bp_nouveau ->displayed_nav, $bp_nouveau ->object_nav ); return false; } $bp_nouveau ->current_nav_index = 0; return true; } |
Changelog
Version | Description |
---|---|
BuddyPress 3.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.