Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Setup Navigation
- * @since 0.1
- * @version 1.3
- */
- public function setup_nav() {
- global $bp;
- $user_id = bp_displayed_user_id();
- // User is excluded
- if ( $this->core->exclude_user( $user_id ) ) return;
- // If visibility is not set for visitors
- if ( ! is_user_logged_in() && ! $this->buddypress['visibility']['history'] ) return;
- // Admins always see the token history
- if ( ! $this->core->can_edit_plugin() && $this->buddypress['history_location'] != 'top' ) return;
- // Show admins
- if ( $this->core->can_edit_plugin() )
- $show = true;
- else
- $show = $this->buddypress['visibility']['history'];
- // Top Level Nav Item
- $top_name = bp_word_or_name(
- $this->buddypress['history_menu_title']['me'],
- $this->buddypress['history_menu_title']['others'], false, false );
- bp_core_new_nav_item( array(
- 'name' => $this->core->template_tags_general( $top_name ),
- 'slug' => 'mycred-history',
- 'parent_url' => $bp->displayed_user->domain,
- 'default_subnav_slug' => 'mycred-history',
- 'screen_function' => array( $this, 'my_history' ),
- 'show_for_displayed_user' => $show,
- 'position' => $this->buddypress['history_menu_pos']
- ) );
- // Date Sorting
- $date_sorting = apply_filters( 'mycred_sort_by_time', array(
- '' => __( 'All', 'mycred' ),
- 'today' => __( 'Today', 'mycred' ),
- 'yesterday' => __( 'Yesterday', 'mycred' ),
- 'thisweek' => __( 'This Week', 'mycred' ),
- 'thismonth' => __( 'This Month', 'mycred' )
- ) );
- // "All" is default
- bp_core_new_subnav_item( array(
- 'name' => __( 'All', 'mycred' ),
- 'slug' => 'mycred-history',
- 'parent_url' => $bp->displayed_user->domain . $this->buddypress['history_url'] . '/',
- 'parent_slug' => 'mycred-history',
- 'screen_function' => array( $this, 'my_history' )
- ) );
- // Loop though and add each filter option as a sub menu item
- if ( !empty( $date_sorting ) ) {
- foreach ( $date_sorting as $sorting_id => $sorting_name ) {
- if ( empty( $sorting_id ) ) continue;
- bp_core_new_subnav_item( array(
- 'name' => $sorting_name,
- 'slug' => $sorting_id,
- 'parent_url' => $bp->displayed_user->domain . $this->buddypress['history_url'] . '/',
- 'parent_slug' => 'mycred-history',
- 'screen_function' => array( $this, 'my_history' )
- ) );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement